diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2017-06-02 22:52:40 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2017-06-03 01:54:01 +0300 |
commit | 433bb91a378fb1053b345f37eac958ff682fbdb7 (patch) | |
tree | d199d9f9da1125b048385190229f0727032dfc36 /source/blender/draw | |
parent | bc984fd09bad889d54ffc78f0337ee7f15f68531 (diff) |
Eevee: fix bad eye vector and get rid of two uniform
Diffstat (limited to 'source/blender/draw')
-rw-r--r-- | source/blender/draw/engines/eevee/shaders/lit_surface_frag.glsl | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/source/blender/draw/engines/eevee/shaders/lit_surface_frag.glsl b/source/blender/draw/engines/eevee/shaders/lit_surface_frag.glsl index 953b087bcd7..1461b04a41c 100644 --- a/source/blender/draw/engines/eevee/shaders/lit_surface_frag.glsl +++ b/source/blender/draw/engines/eevee/shaders/lit_surface_frag.glsl @@ -1,8 +1,7 @@ uniform int light_count; -uniform vec3 cameraPos; -uniform vec3 eye; uniform mat4 ProjectionMatrix; +uniform mat4 ViewMatrixInverse; uniform sampler2D probeFiltered; uniform float lodMax; @@ -35,6 +34,9 @@ in vec3 worldNormal; in vec3 viewNormal; #endif +#define cameraForward normalize(ViewMatrixInverse[2].xyz) +#define cameraPos ViewMatrixInverse[3].xyz + /* type */ #define POINT 0.0 #define SUN 1.0 @@ -138,7 +140,7 @@ void light_visibility(LightData ld, ShadingData sd, out float vis) ShadowCascadeData smd = shadows_cascade_data[int(shid)]; /* Finding Cascade index */ - vec4 z = vec4(-dot(cameraPos - worldPosition, normalize(eye))); + vec4 z = vec4(-dot(cameraPos - worldPosition, cameraForward)); vec4 comp = step(z, smd.split_distances); float cascade = dot(comp, comp); mat4 shadowmat; @@ -195,7 +197,7 @@ vec3 eevee_surface_lit(vec3 world_normal, vec3 albedo, vec3 f0, float roughness, sd.N = normalize(world_normal); sd.V = (ProjectionMatrix[3][3] == 0.0) /* if perspective */ ? normalize(cameraPos - worldPosition) - : normalize(eye); + : cameraForward; sd.W = worldPosition; vec3 radiance = vec3(0.0); |