# Precomputed atmospheric scattering

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

## Recommended Posts

Hello! I'm trying to integrate method for rendering sky and aerial perspective from Precomputed Atmospheric Scattering Paper (by Eric Bruneton and Fabrice Neyret) I tried to adopt code they provided to compute aerial perspective for non-ideally spherical ground (so i dont implement light shafts). Everything seems okey except pixels near horizon: this appears when camera is very close to parts of landscape that are not lit or when sun is low... For nonspherical ground i rewrited some code for computing inscattering. Originally it was:
//inscattered light along ray x+tv, when sun in direction s (=S[L]|x)
float3 inscatter_simple(inout float3 x, float3 v, float3 s, out float r, out float mu)
{
float3 result;
r = length(x);
mu = dot(x, v) / r; /// u with tail
//float d = -r * mu - sqrt(r * r * (mu * mu - 1.0) + Rg * Rg);
float nu = dot(v, s); // greek v
float muS = dot(x, s) / r;

float phaseR = phaseFunctionR(nu);
float phaseM = phaseFunctionM(nu);
float4 inscatter = max(texture4D(inscatterSampler, r, mu, muS, nu), 0.0);
result = max(inscatter.xyz * phaseR + getMie(inscatter) * phaseM, 0.0);
return result * ISun;
}


And i just added substraction of light inscattered from point x0 to infinity:
//inscattered light along ray x+tv, when sun in direction s (=S[L]|x)
float3 inscatter_simple(inout float3 x, float3 v, float3 s, out float r, out float mu)
{
float3 result;
r = length(x);
mu = dot(x, v) / r; /// u with tail
//float d = -r * mu - sqrt(r * r * (mu * mu - 1.0) + Rg * Rg);
float nu = dot(v, s); // greek v
float muS = dot(x, s) / r;

float phaseR = phaseFunctionR(nu);
float phaseM = phaseFunctionM(nu);
float4 inscatter = max(texture4D(inscatterSampler, r, mu, muS, nu), 0.0);
result = max(inscatter.xyz * phaseR + getMie(inscatter) * phaseM, 0.0);
return result * ISun;
}

float3 fullGroundInscatter(in float3 x,in float3 v,in float3 s,in float3 x0,out float r,out float mu)
{
float3 result = inscatter_simple(x,v,s,r,mu);
float r_x = r;
float mu_x = mu;
float3 i2 = inscatter_simple(x0,v,s,r,mu);
result -= transmittance(r_x,mu_x,v,x0)*i2;
r = r_x;
mu = mu_x;
return result;
}


Anyone got the same issue? Help please... Trying to defeat this bug for a week now T_T Thanks for attention and sorry for my bad English [Edited by - msomeone on January 10, 2009 11:28:34 AM]

up?

##### Share on other sites
I just started implementing this yesterday. In the next day or so I will work on it some more and can try to help. When you say the pixels near the horizon, are you are talking about the red on the terrain in the first image? It is difficult to see what you mean in the 2nd image.

##### Share on other sites
Yeah, Leafteaner, im talking about red line on first image... on second image there is noise at bottom of image, some strange noisy lines... Im wondering could all this happen beacause i`m using planar ground and hacking Eric's code with
eye vector like this: float3 eye = camera_position.xyz + float3(0,0,EARTH_RADIUS);
and landscape vertex positions: float3 x = vertex.pos.xyz + float3(0,0,EARTH_RADIUS);
(smth near North Pole :D)

Leafteaner, how's your progress? And are you reusing Eric Bruneton's shaders code? or writing from scratch?

##### Share on other sites
I've been porting over some of his code using the paper for help, since his code is OpenGL and I use D3D10 it was slow at first. My first guess would be to try adding to the y component instead of z, float3(0,EARTH_RADIUS,0). So that shader you modified to try to work with irregular terrain since his code was for spherical only?

##### Share on other sites
His code was for flat spherical terrain only. to remove T(x,x0)*S|xs term from inscattering value. In his app he also uses z-axis up... so float3(0,R,0) won't help, but thanks for advice :) how's your porting progress? ) waiting for it so much

##### Share on other sites
Up? I dont believe that no one had tried to implement Eric Bruneton's and Fabrice Neyret's algorithm o_O It's the best GPU algo for simulating multiple scattering, nobody even tried out it on non flat-spherical landscapes?

er... up?

##### Share on other sites
Okey guys... I recently analyzed Eric's paper, demo and videos closely. And you know what? He got the same bug when viewer looks at horizon near any mountain (sun is close to horizon) on all screenshots in the paper, on all videos. Of course no bugs in his demo source code - terrain there is just simple sphere. In his article he talks about angular precision and how the problem was solved, there are two screenshots - with linear parametrization and with smart non-linear parametrization (figure 3 in paper)... the funniest thing is that when you zoom greatly in right part of fig3(which is demonstrating solved angular precision problem :-D ) you will notice the same bug, but line just one pixel in height :) of course its not a big deal on a small image... now try to run your implementation (or his code integrated in any rendering engine) of this model at res 1024x768 for exmpl and look what happens during sunsets and sunrises as I did - you will see angular precision problem clearly (just about 50-80 pixels in height artefact near horizon)... It's okey, every model has bugs and limitations. Every one interested in modeling atmosphere appreciates Eric's contribution, so do i. But why they publish paper without noting there in "Limitations" that they have another one limitation?! They just write that they solved it! AMAZING! You go write thankfull letter to Eric's and Neyret's for sharing freely that work, and then you go to integrate their model. Haha and then you try to fix bug, you noticed during two or more weeks, thinking that's your fault, writing a tons of e-mail to INRIA, Eric, Fabrice, waiting for reply and still trying to fix it yourself. And for what? Just to notice some weeks later that that's not your fault?
Nah, i still don't get how it's possible to publish article hiding some limitations from publicity, why not just say about them?

[Edited by - msomeone on January 23, 2009 1:28:10 PM]

##### Share on other sites
Quote:
 Original post by msomeoneOkey guys... I recently analyzed Eric's paper, demo and videos closely. And you know what? He got the same bug when viewer looks at horizon near any mountain (sun is close to horizon) on all screenshots in the paper, on all videos. Of course no bugs in his demo source code - terrain there is just simple sphere.

the noise comes from the computation of the transparency of the atmosphere with the "transmittance" texture. It can be fixed by using an analytic approximation of the optical depth. The small discontinuity at the horizon can be fixed by interpolating between two values computed just above and below the horizon. I've uploaded a new version of the demo with a 10km high conic mountain at the north pole, and with the previous fixes (see the "#ifdef FIX").

See http://www-evasion.imag.fr/Membres/Eric.Bruneton/PrecomputedAtmosphericScattering2.zip and http://www-evasion.imag.fr/Membres/Eric.Bruneton/PrecomputedAtmosphericScattering2.jpg

Quote:
 fault, writing a tons of e-mail to INRIA, Eric, Fabrice, waiting for reply and still trying to fix it yourself. And for what? Just to notice some weeks later

sorry, I haven't received any email about these problems. Otherwise I could have given you the above solutions earlier

Eric

1. 1
2. 2
Rutin
19
3. 3
khawk
18
4. 4
5. 5
A4L
11

• 12
• 16
• 26
• 10
• 44
• ### Forum Statistics

• Total Topics
633767
• Total Posts
3013739
×