mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-13 15:31:17 -06:00
Fix atmosphere floating point issue
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
// ============================
|
||||
|
||||
Reference in New Issue
Block a user