Advertisement

Precomputed Atmospheric scattering

Started by May 09, 2019 04:00 PM
3 comments, last by Bongseok 5 years, 2 months ago

Hello~ 

I'm implementing Bruneton's precomputed atmospheric scattering and I having trouble understanding this line in inscatterS.glsl

float sx = v.x == 0.0 ? 0.0 : (nu - muS * mu) / v.x;

sx is sun direction's x component. but I don't know why

Does anyone know why '(nu - muS * mu) / v.x' is sun direction?

Thanks

ref: https://ebruneton.github.io/precomputed_atmospheric_scattering/

Is this the reference or the older version? I couldn't find that shader file to start chasing uniforms.

edit: Ah, yes. check the link above. there is an improved version with better comments. But at a glance, I'd say it's not. It's the setup to compute the single scattering components. (or the perturbation)

Advertisement

Hi GoliathForge 

Thank you for your reply

I have checked improved version. but I have still difficulty understanding.


// Compute unit direction vectors for the zenith, the view direction omega and
// and the sun direction omega_s, such that the cosine of the view-zenith
// angle is mu, the cosine of the sun-zenith angle is mu_s, and the cosine of
// the view-sun angle is nu. The goal is to simplify computations below.
vec3 zenith_direction = vec3(0.0, 0.0, 1.0);
vec3 omega = vec3(sqrt(1.0 - mu * mu), 0.0, mu);
Number sun_dir_x = omega.x == 0.0 ? 0.0 : (nu - mu * mu_s) / omega.x;
Number sun_dir_y = sqrt(max(1.0 - sun_dir_x * sun_dir_x - mu_s * mu_s, 0.0));
vec3 omega_s = vec3(sun_dir_x, sun_dir_y, mu_s);

comments just explain what is mu, mu_s and nu. I already know these variables mean

I'm curious how equation compute sun direction's x. it may be simple math but it's hard for me

Hello~

I finally found out Why '(nu - muS * mu) / v.x' is sun direction

It's Spherical trigonometry.

this article helped me a lot.

https://en.wikipedia.org/wiki/Spherical_trigonometry#Derivation_of_the_cosine_rule

This topic is closed to new replies.

Advertisement