diff options
author | mano-wii <germano.costa@ig.com.br> | 2018-11-19 13:58:29 +0300 |
---|---|---|
committer | mano-wii <germano.costa@ig.com.br> | 2018-11-19 14:05:22 +0300 |
commit | 6647e2c71e9a50791c2f7550fcdf4c4c75c701f6 (patch) | |
tree | 85f9004a79f4125e78e45c7e2d9805dd8b40cc68 | |
parent | 80499bcc52947cde946cd6c64e8ddb694e598286 (diff) |
EEVEE: Cleanup: default_world_frag.glsl
-rw-r--r-- | source/blender/draw/engines/eevee/shaders/default_world_frag.glsl | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/source/blender/draw/engines/eevee/shaders/default_world_frag.glsl b/source/blender/draw/engines/eevee/shaders/default_world_frag.glsl index 19c23fbfa39..126f2d9610a 100644 --- a/source/blender/draw/engines/eevee/shaders/default_world_frag.glsl +++ b/source/blender/draw/engines/eevee/shaders/default_world_frag.glsl @@ -15,13 +15,13 @@ in vec3 viewPosition; #define M_PI 3.14159265358979323846 -void background_transform_to_world(vec3 viewvec, out vec3 worldvec) +vec3 background_transform_to_world(vec3 viewvec) { vec4 v = (ProjectionMatrix[3][3] == 0.0) ? vec4(viewvec, 1.0) : vec4(0.0, 0.0, 1.0, 1.0); vec4 co_homogenous = (ProjectionMatrixInverse * v); vec4 co = vec4(co_homogenous.xyz / co_homogenous.w, 0.0); - worldvec = (ViewMatrixInverse * co).xyz; + return (ViewMatrixInverse * co).xyz; } float hypot(float x, float y) @@ -29,7 +29,7 @@ float hypot(float x, float y) return sqrt(x * x + y * y); } -void node_tex_environment_equirectangular(vec3 co, sampler2D ima, out vec4 color) +vec4 node_tex_environment_equirectangular(vec3 co, sampler2D ima) { vec3 nco = normalize(co); float u = -atan(nco.y, nco.x) / (2.0 * M_PI) + 0.5; @@ -44,20 +44,19 @@ void node_tex_environment_equirectangular(vec3 co, sampler2D ima, out vec4 color /* This is caused by texture filtering, since uv don't have smooth derivatives * at u = 0 or 2PI, hardware filtering is using the smallest mipmap for certain * texels. So we force the highest mipmap and don't do anisotropic filtering. */ - color = textureLod(ima, vec2(u, v), 0.0); + return textureLod(ima, vec2(u, v), 0.0); } #endif void main() { + vec3 background_color; #ifdef LOOKDEV - vec3 worldvec; - vec4 background_color; - background_transform_to_world(viewPosition, worldvec); - node_tex_environment_equirectangular(StudioLightMatrix * worldvec, image, background_color); - background_color.rgb = mix(color, background_color.rgb, studioLightBackground); + vec3 worldvec = background_transform_to_world(viewPosition); + background_color = node_tex_environment_equirectangular(StudioLightMatrix * worldvec, image).rgb; + background_color = mix(color, background_color, studioLightBackground); #else - vec3 background_color = color; + background_color = color; #endif - FragColor = vec4(clamp(background_color.rgb, vec3(0.0), vec3(1e10)), backgroundAlpha); + FragColor = vec4(clamp(background_color, vec3(0.0), vec3(1e10)), backgroundAlpha); } |