Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClément Foucault <foucault.clem@gmail.com>2018-11-08 15:16:06 +0300
committerClément Foucault <foucault.clem@gmail.com>2018-11-08 21:20:40 +0300
commit9d12a5aa9e20c33c49bd86e956d0b3d5fbf6fd46 (patch)
treefd18dfc5c3f9955ddb7eb39819c5e2721f527694 /source/blender/gpu/shaders
parent1250ace641814098ed8e6715f6e69c5cbd46f8dd (diff)
Eevee: Fix geometry node for environments and support true_normal
Also minor cleanup for the Bump node.
Diffstat (limited to 'source/blender/gpu/shaders')
-rw-r--r--source/blender/gpu/shaders/gpu_shader_material.glsl43
1 files changed, 29 insertions, 14 deletions
diff --git a/source/blender/gpu/shaders/gpu_shader_material.glsl b/source/blender/gpu/shaders/gpu_shader_material.glsl
index 0817a0311d4..24115dbd9c4 100644
--- a/source/blender/gpu/shaders/gpu_shader_material.glsl
+++ b/source/blender/gpu/shaders/gpu_shader_material.glsl
@@ -1759,23 +1759,37 @@ void node_geometry(
out vec3 true_normal, out vec3 incoming, out vec3 parametric,
out float backfacing, out float pointiness)
{
+ /* handle perspective/orthographic */
+ vec3 I_view = (ProjectionMatrix[3][3] == 0.0) ? normalize(I) : vec3(0.0, 0.0, -1.0);
+ incoming = -(toworld * vec4(I_view, 0.0)).xyz;
+
+#if defined(WORLD_BACKGROUND) || defined(PROBE_CAPTURE)
+ position = -incoming;
+ true_normal = normal = incoming;
+ tangent = parametric = vec3(0.0);
+ vec3(0.0);
+ backfacing = 0.0;
+ pointiness = 0.0;
+#else
+
position = worldPosition;
-#ifndef VOLUMETRICS
+# ifndef VOLUMETRICS
normal = normalize(worldNormal);
-#else
+
+ vec3 B = dFdx(worldPosition);
+ vec3 T = dFdy(worldPosition);
+ true_normal = normalize(cross(B, T));
+# else
normal = (toworld * vec4(N, 0.0)).xyz;
-#endif
+ true_normal = normal;
+# endif
tangent_orco_z(orco, orco);
node_tangent(N, orco, objmat, toworld, tangent);
- true_normal = normal;
-
- /* handle perspective/orthographic */
- vec3 I_view = (ProjectionMatrix[3][3] == 0.0) ? normalize(I) : vec3(0.0, 0.0, -1.0);
- incoming = -(toworld * vec4(I_view, 0.0)).xyz;
parametric = vec3(barycentric, 0.0);
backfacing = (gl_FrontFacing) ? 0.0 : 1.0;
pointiness = 0.5;
+#endif
}
void generated_texco(vec3 I, vec3 attr_orco, out vec3 generated)
@@ -2930,9 +2944,9 @@ void node_normal_map(vec4 tangent, vec3 normal, vec3 texnormal, out vec3 outnorm
void node_bump(float strength, float dist, float height, vec3 N, vec3 surf_pos, float invert, out vec3 result)
{
- if (invert != 0.0) {
- dist *= -1.0;
- }
+ N = mat3(ViewMatrix) * normalize(N);
+ dist *= invert;
+
vec3 dPdx = dFdx(surf_pos);
vec3 dPdy = dFdy(surf_pos);
@@ -2942,7 +2956,6 @@ void node_bump(float strength, float dist, float height, vec3 N, vec3 surf_pos,
/* Compute surface gradient and determinant. */
float det = dot(dPdx, Rx);
- float absdet = abs(det);
float dHdx = dFdx(height);
float dHdy = dFdy(height);
@@ -2950,8 +2963,10 @@ void node_bump(float strength, float dist, float height, vec3 N, vec3 surf_pos,
strength = max(strength, 0.0);
- result = normalize(absdet * N - dist * sign(det) * surfgrad);
- result = normalize(strength * result + (1.0 - strength) * N);
+ result = normalize(abs(det) * N - dist * sign(det) * surfgrad);
+ result = normalize(mix(N, result, strength));
+
+ result = mat3(ViewMatrixInverse) * result;
}
void node_bevel(float radius, vec3 N, out vec3 result)