# Rendering Outdoor Light Scattering in Real Time Paper

This topic is 2786 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Is there anywhere with an implementation of this that I could look at? I've seen the source code in the RenderMonkey examples, but it seems to use an optimized technique using pre baked textures rather than the functions discussed in the paper, and is also in ASM. This code also doesnt seem to be able to produce blue skys.

##### Share on other sites
This is the paper I was talking about. I tried implementing it, (just with the Rayleigh term so far), but seem to be getting incorrect results.

The sun always appears overly bright and I cant seem to remove the hard circular shape. Also, I seem to get black patches where the angle between the sun and th epoint on the skydome is more than 90 degrees.

Here is my pixel shader code

float4 PShader( PS iPS ) : SV_TARGET{	float3 Br = float3( 0.07, 0.009, 0.0001 );	//position sun somewhere on hemisphere 	float3 SunPos = 100*normalize(float3( 0, 0.6, -1));	//float T = gFrame.Time;	//float3 SunPos = 100*normalize(float3( 0, sin(T), cos(T)));	float3 SunDir = normalize( -SunPos );	// Sun Intensity	float3 ESun = float3( 1.0f, 1.0f, 1.0f );		float3 EyeToPoint = iPS.PosW - gFrame.EyePosW.xyz;	float s = length(EyeToPoint);	EyeToPoint /= s;		// Is hemisphere point the sun	float DistancePointToSun = abs(length( SunPos - iPS.PosW ));	float3 L0 = DistancePointToSun < 5.0f ? ESun : 0.0f; 		// Absorbtion/extinction	float3 Fex = exp( -(Br)*s );	// angle between [eye to point vector] and sun direction	float theta = dot(SunDir, EyeToPoint);	// Rayleigh phase	float3 RayPhase = (3.0 / (16.0*3.14159)) * ( 1 + (theta * theta)) * Br;	// In scattering	float3 Lin = ( RayPhase / Br ) * ESun * ( float3(1.0f,1.0f,1.0f) - Fex );	float3 Out = L0*Fex + Lin;	return float4( Out, 1);}

[Edited by - hick18 on December 10, 2010 10:08:32 AM]

##### Share on other sites
I have an implementation here and there are also implementations in somewhere on ATI's site and Graphics Programming Methods.

##### Share on other sites
check out the link above to

http://filougk.blogspot.com/search/label/Sky%20Rendering

That is one of the best examples that I have seen on the topic. . .

##### Share on other sites
In my code I test to see if the current rendered point of the skydome is within the suns projection on the hemisphere, and if so have its L0 as 1.0f, else its just space and set it to 0.0f. Is this correct?

Secondly, looking at your source code, you seem to adjust the Br and Bm RGB vectors depending on where the sun is. Is this how you're getting the horizon to change to orange/red at sunset? They dont seem to mention this in the paper. I got the impression that Br and Bm were constants

There is a lot of computation in your calculateScatteringConstants() and ComputeAttenuation() functions. Where does all this come from? I did not see it mentioned in the paper.

Also, I couldnt find that ATI demo, but I found the book. Is the example on the CD in ASM?

##### Share on other sites
Most of the code as I remember is taken from the source of the ati light scattering demo. There are a lot of magic numbers/fudge factors/etc in the code that aren't mentioned in the paper or the slides. It's been a couple of years since I've looked at it, but I'll have a look tonight and the slides and update this post.

I can't comment on the code from Graphics Programming Methods, but Natty said that the article in that book is the most up to date and should have hlsl code. The ati source did as well (I'll try to find this too, as it looks like ati doesn't have it readily accessible anymore.).

Edit:
Pm sent.

[Edited by - glaeken on December 8, 2010 12:13:26 AM]

1. 1
2. 2
3. 3
Rutin
19
4. 4
5. 5

• 10
• 14
• 30
• 13
• 11
• ### Forum Statistics

• Total Topics
631785
• Total Posts
3002348
×