paysages3d/src/render/opengl/shaders/skybox.frag

20 lines
798 B
GLSL
Raw Normal View History

2013-12-21 22:48:54 +00:00
void main(void)
{
float yoffset = GROUND_OFFSET - waterHeight;
2013-12-22 00:17:57 +00:00
vec3 camera = vec3(cameraLocation.x, max(cameraLocation.y + yoffset, 0.0), cameraLocation.z);
vec3 location = vec3(unprojected.x, max(unprojected.y + yoffset, 0.0), unprojected.z);
vec3 x = vec3(0.0, Rg + camera.y * WORLD_SCALING, 0.0);
vec3 v = normalize(location - camera);
2013-12-21 22:48:54 +00:00
vec3 s = normalize(sunDirection * SUN_DISTANCE_SCALED - x);
float r = length(x);
float mu = dot(x, v) / r;
float t = -r * mu - sqrt(r * r * (mu * mu - 1.0) + Rg * Rg);
vec4 sunTransmittance = _sunTransmittance(v, s, r, mu, sunRadius);
vec3 attenuation;
vec3 inscattering = _getInscatterColor(x, t, v, s, r, mu, attenuation);
2013-12-24 14:00:32 +00:00
gl_FragColor = applyToneMapping(sunTransmittance + vec4(inscattering, 0.0));
2013-12-21 22:48:54 +00:00
}