Fix atmosphere floating point issue

This commit is contained in:
Emil Axelsson
2018-04-04 16:58:24 +02:00
parent 402cd19fb8
commit ab93e2ca4d
2 changed files with 7 additions and 0 deletions

View File

@@ -258,6 +258,9 @@ void AtmosphereDeferredcaster::preRaycast(const RenderData& renderData,
program.setUniform("eyeToModel",
glm::mat4(eyeToModel));
float viewScaling = renderData.camera.scaling();
program.setUniform("viewScaling", viewScaling);
glm::mat4 invProjection =
glm::inverse(renderData.camera.projectionMatrix());
program.setUniform("inverseProjection", invProjection);

View File

@@ -77,6 +77,7 @@ uniform int cullAtmosphere;
uniform float backgroundConstant;
uniform bool firstPaint;
uniform float atmExposure;
uniform float viewScaling;
uniform sampler2D irradianceTexture;
uniform sampler3D inscatterTexture;
@@ -253,6 +254,9 @@ void dCalculateRayRenderableGlobe(in int mssaSample, out dRay ray) {
vec4 eyeSpaceCoords = inverseProjection * vec4(clipCoords);
eyeSpaceCoords.w = 1.0;
// Scale the vector to avoid floating point inaccuracy.
eyeSpaceCoords.xyz *= viewScaling * 1000000.0;
dvec4 objectCoords = eyeToModel * eyeSpaceCoords;
// ============================