Jump to content
  • Advertisement
Sign in to follow this  
schupf

O'Neil Atmospheric Scattering

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello! In O'Neils CPU Atmospheric Scattering Code is one thing I dont understand. He calcualtes the optical depth for a path through the atmosphere from P_a to P_b by solving this integral: The coordinate system for the Points P_a, P_b and the line between the 2 Points (the blue line) looks like this: http://www.infoboard.org/screenshots/system.png Ok, and this is the code how O'Neil solves this integral:
double height = EPSILON + planetaryRadius + x; // x between 0 and 80 000
D3DXVECTOR3 pos(0, height, 0);

double distance = ... // distance = length of the blue line (the path)
					
double sampleLength = distance / samples; // Length of a sampling interval (in real meter)
			
double scaledLength = sampleLength * scale;  // Normalized length of a sampling interval. scale = 1 / 80000. 

D3DXVECTOR3 sampleRay = ray * sampleLength;
pos += sampleRay * 0.5f;  // pos is the sampling point used in the loop			       
double opticalDepth_R = 0;
// Iterate through the samples to sum up the optical 
// depth for the distance the ray travels through the atmosphere
for(int i=0; i< samples; i++) {
   double height = D3DXVec3Length(&pos); 
   double samplePointAltitude = (height - planetaryRadius) * scale; 
				
   opticalDepth_R += exp(-samplePointAltitude / 0.1);
   pos += sampleRay;
}
opticalDepth_R *= scaledLength;  

So actually all he does is go through some sample points on the line, evaluate exp(-h/H0) and at the end multiply the sum with the scaledLength of one sampleInterval. But there are 2 things I dont understand: 1) He doesnt use the true height and doesnt divide by 8000 (1/10 of the atmosphere height). Instead he scales the height in [0,1] and divides it by 1/10. Is this the same? 2) My main question: why does he multiply the sum by scaledLength? Since he goes along the real path I would expect to multiply it by sampleLength. Is this his because of some strengh line integral parameterization? Thanks for help!

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!