Jump to content
  • Advertisement
Bongseok

DX11 Precomputed Atmospheric scattering

Recommended Posts

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

Share this post


Link to post
Share on other sites
Advertisement
Posted (edited)

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)

Edited by GoliathForge

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Advertisement
×

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!