diff options
author | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2014-06-04 21:35:56 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2014-06-04 21:42:47 +0400 |
commit | 9b3efa912a24de57aa58f5dd62291c5654504d8c (patch) | |
tree | 294e21a5f60240ada491954a6ff0c26f0246a81a /source/blender | |
parent | ec97cb87f63f19303352cf5ac9bdca52f13377be (diff) |
Fix T40478: wrong cycles fresnel with GLSL materials in the viewport.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/gpu/shaders/gpu_shader_material.glsl | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/source/blender/gpu/shaders/gpu_shader_material.glsl b/source/blender/gpu/shaders/gpu_shader_material.glsl index 44119d4a913..5c7872a8b3a 100644 --- a/source/blender/gpu/shaders/gpu_shader_material.glsl +++ b/source/blender/gpu/shaders/gpu_shader_material.glsl @@ -2197,8 +2197,11 @@ void node_add_shader(vec4 shader1, vec4 shader2, out vec4 shader) void node_fresnel(float ior, vec3 N, vec3 I, out float result) { + /* handle perspective/orthographic */ + vec3 I_view = (gl_ProjectionMatrix[3][3] == 0.0)? normalize(I): vec3(0.0, 0.0, -1.0); + float eta = max(ior, 0.00001); - result = fresnel_dielectric(normalize(I), N, (gl_FrontFacing)? eta: 1.0/eta); + result = fresnel_dielectric(I_view, N, (gl_FrontFacing)? eta: 1.0/eta); } /* layer_weight */ @@ -2248,10 +2251,14 @@ void node_geometry(vec3 I, vec3 N, mat4 toworld, out float backfacing) { position = (toworld*vec4(I, 1.0)).xyz; - normal = N; + normal = (toworld*vec4(N, 0.0)).xyz; tangent = vec3(0.0); - true_normal = N; - incoming = I; + true_normal = normal; + + /* handle perspective/orthographic */ + vec3 I_view = (gl_ProjectionMatrix[3][3] == 0.0)? normalize(I): vec3(0.0, 0.0, -1.0); + incoming = -(toworld*vec4(I_view, 0.0)).xyz; + parametric = vec3(0.0); backfacing = (gl_FrontFacing)? 0.0: 1.0; } |