From 5fe200ad7f4f5328d4263f934e2c41c8a2343fc0 Mon Sep 17 00:00:00 2001 From: Jonathas Costa Date: Wed, 13 Dec 2017 14:53:57 -0500 Subject: [PATCH] Fixed squared texture noise on surface' planets when seeing from far away. --- ext/ghoul | 2 +- modules/atmosphere/shaders/atmosphere_deferred_fs.glsl | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/ext/ghoul b/ext/ghoul index 7463fe3cc0..e5ef9ee61e 160000 --- a/ext/ghoul +++ b/ext/ghoul @@ -1 +1 @@ -Subproject commit 7463fe3cc005565e64e50dd13c1d50e45fcf6c2e +Subproject commit e5ef9ee61e5523ccf08655e941400fedd48541f4 diff --git a/modules/atmosphere/shaders/atmosphere_deferred_fs.glsl b/modules/atmosphere/shaders/atmosphere_deferred_fs.glsl index 969bf2b89b..2f6e1241b8 100644 --- a/modules/atmosphere/shaders/atmosphere_deferred_fs.glsl +++ b/modules/atmosphere/shaders/atmosphere_deferred_fs.glsl @@ -366,6 +366,7 @@ vec3 inscatterRadiance(inout vec3 x, inout float t, inout float irradianceFactor irradianceFactor = 1.0; } else { attenuation = analyticTransmittance(r, mu, t); + //attenuation = transmittance(r, mu, t); } // cos(PI-thetaH) = dist/r @@ -500,7 +501,7 @@ vec3 groundColor(const vec3 x, const float t, const vec3 v, const vec3 s, const //groundRadiance = groundReflectance.rgb * RLStar; // Specular reflection from sun on oceans and rivers - if ((waterReflectance > 0.1) && (dotNS > -0.2f)/*(muSun > 0.0)*/) { + if ((waterReflectance > 0.1) && /*(dotNS > -0.2f)*/(muSun > 0.0)) { vec3 h = normalize(s - v); // Fresnell Schlick's approximation float fresnel = 0.02f + 0.98f * pow(1.0f - dot(-v, h), 5.0f); @@ -647,6 +648,13 @@ void main() { //double pixelDepth = distance(cameraPositionInObject.xyz, fragObjectCoords.xyz); double pixelDepth = length(cameraPositionInObject.xyz - fragObjectCoords.xyz); + // JCC (12/13/2017): TRick to remove floating error in texture. + // We see a squared noise on planet's surface when seeing the planet + // from far away. + if (length(cameraPositionInObject.xyz) > 1e8) { + pixelDepth += 1000000.0; + } + // All calculations are done in Km: pixelDepth *= 0.001; fragObjectCoords.xyz *= 0.001;