Hello!
I implemented the god rays algorith presented in GPU gems but I have a few questions, here the link of the article (http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html).
How could I remove the rays when I'm not facing the sun? As the effect is being aplied if the sun is behind the view it gives weird results.
Right now, I'm checking the projected z value and if it is less than 0, I just dont perform the effect, this works OK but the change is really abrupt.
As I'm aplying the god rays to the sun, to get the sun in NDC space I'm doing the following math:
glm::vec3 sunEyePos = mCamera.GetPosition() + (mSunDirection);
glm::vec4 sunProj = mCamera.Projection * mCamera.View * glm::vec4(sunEyePos, 1.0f);
sunProj /= sunProj.w;
sunProj = (sunProj + 1.0f) * 0.5f;
I'm a bit worried on how do I get the sun pos, the idea is to get a global light source , is that ok?
Thanks!