Altitude of Ray Marching Point for Optical Depth Integration in Atmospheric Rendering
Optical depth is an integration of outscattering of a ray, which is at a given altitude h_0 whose direction is deviated from the vertical direction of angle theta. The integration is done by sampling the ray whose starting point is p_0 and end point p_1, which is the intersection of the ray with the outer atmosphere, i.e. sky dome. For every sampling point p_i, the altitude needs to be estimated. That is the topic of this article.
Assume the coordinate is dominated by the starting point p_0, we can set up the initial coordinate system by having p_0 placed right above the earth. So the coordinate of p_0 is (0, r + h_0). For any sampling point p_i, the coordinate is p_0 + i * ray_marching_interval * ray_direction, which would produce (x, y). With (x, y) the altitude of p_i is sqrt(x*x + y*y) – r.
Note that the domain of the altitude in the context is [0, 1]. So the earth radius needs to be scaled according to the ratio of the earth radius upon atmospheric thickness. According to the Simulating the Colors of the Sky blog, the ratio is 6360/(6420-6360) = 106. So the earth radius used in this context is 106 * 1.0 = 106, where 1.0 is the maximum value of the domain of altitude.