[Bf-blender-cvs] [9b3efa9] master: Fix T40478: wrong cycles fresnel with GLSL materials in the viewport.
Brecht Van Lommel
noreply at git.blender.org
Wed Jun 4 19:42:53 CEST 2014
Commit: 9b3efa912a24de57aa58f5dd62291c5654504d8c
Author: Brecht Van Lommel
Date: Wed Jun 4 19:35:56 2014 +0200
https://developer.blender.org/rB9b3efa912a24de57aa58f5dd62291c5654504d8c
Fix T40478: wrong cycles fresnel with GLSL materials in the viewport.
===================================================================
M source/blender/gpu/shaders/gpu_shader_material.glsl
===================================================================
diff --git a/source/blender/gpu/shaders/gpu_shader_material.glsl b/source/blender/gpu/shaders/gpu_shader_material.glsl
index 44119d4..5c7872a 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;
}
More information about the Bf-blender-cvs
mailing list