- vec3 in_transmittance = texture(transmittance_lookup, vec2(sqrt(height/atmosphere_thickness), light_z)).rgb;
- vec3 in_luminance = (ev.rayleigh_scatter*p_rayleigh+ev.mie_scatter*p_mie)*step_size;
- if(i==n_steps && ground_t>0.0)
- in_luminance += ground_albedo*light_z/PI;
- path_luminance += transmittance*in_transmittance*in_luminance;
+ float in_ground_t = ray_sphere_intersect(pos, light_dir, planet_center, planet_radius);
+ if(in_ground_t<0.0)
+ {
+ vec3 in_transmittance = texture(transmittance_lookup, vec2(sqrt(height/atmosphere_thickness), light_z)).rgb;
+ vec3 in_luminance = (ev.rayleigh_scatter*p_rayleigh+ev.mie_scatter*p_mie)*step_size;
+ if(i==n_steps && ground_t>0.0 && light_z>0.0)
+ in_luminance += ground_albedo*light_z/PI;
+ path_luminance += transmittance*in_transmittance*in_luminance;
+ }