[Bf-blender-cvs] [29da019cb35] master: EEVEE: Fix sky zenith bug

Szymon Ulatowski noreply at git.blender.org
Mon Jul 13 16:25:16 CEST 2020


Commit: 29da019cb3532524f336ecd2c33c837dce6a3ef3
Author: Szymon Ulatowski
Date:   Mon Jul 13 17:02:19 2020 +0200
Branches: master
https://developer.blender.org/rB29da019cb3532524f336ecd2c33c837dce6a3ef3

EEVEE: Fix sky zenith bug

Careless use of acos() in spherical coordinates transformation was
deteriorating the precision near zenith (and nadir) and producing
glitchy pixels (best seen in longer focal lengths).

Reviewed By: fclem

Differential Revision: https://developer.blender.org/D8266

===================================================================

M	source/blender/gpu/shaders/material/gpu_shader_material_tex_sky.glsl

===================================================================

diff --git a/source/blender/gpu/shaders/material/gpu_shader_material_tex_sky.glsl b/source/blender/gpu/shaders/material/gpu_shader_material_tex_sky.glsl
index b2f6147b629..b6aad5904ff 100644
--- a/source/blender/gpu/shaders/material/gpu_shader_material_tex_sky.glsl
+++ b/source/blender/gpu/shaders/material/gpu_shader_material_tex_sky.glsl
@@ -14,7 +14,7 @@ float sky_angle_between(float thetav, float phiv, float theta, float phi)
 
 vec3 sky_spherical_coordinates(vec3 dir)
 {
-  return vec3(acos(dir.z), atan(dir.x, dir.y), 0);
+  return vec3(M_PI_2 - atan(dir.z, length(dir.xy)), atan(dir.x, dir.y), 0);
 }
 
 /* Preetham */



More information about the Bf-blender-cvs mailing list