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:
authorBrecht Van Lommel <brechtvanlommel@gmail.com>2016-02-07 16:45:39 +0300
committerBrecht Van Lommel <brechtvanlommel@gmail.com>2016-02-07 16:45:39 +0300
commit72dd1ba3fe67206680ef3540b681d944e8bb4872 (patch)
tree6e4a2fe9be3ee265422faf1ce49c3155b64b62cf /source/blender/gpu
parentbd0223b8fefe1bf21f9cd2b444256775b5540227 (diff)
Fix T47349: incorrect Cycles fresnel and layer weight with GLSL materials.
Patch by Ralf Hölzemer.
Diffstat (limited to 'source/blender/gpu')
-rw-r--r--source/blender/gpu/shaders/gpu_shader_material.glsl12
1 files changed, 7 insertions, 5 deletions
diff --git a/source/blender/gpu/shaders/gpu_shader_material.glsl b/source/blender/gpu/shaders/gpu_shader_material.glsl
index 51d4706d91e..3682f7e0625 100644
--- a/source/blender/gpu/shaders/gpu_shader_material.glsl
+++ b/source/blender/gpu/shaders/gpu_shader_material.glsl
@@ -2413,27 +2413,29 @@ void node_add_shader(vec4 shader1, vec4 shader2, out vec4 shader)
/* fresnel */
-void node_fresnel(float ior, vec3 N, vec3 I, out float result)
+void node_fresnel(float ior, vec3 N, vec3 I, mat4 toworld, out float result)
{
/* handle perspective/orthographic */
vec3 I_view = (gl_ProjectionMatrix[3][3] == 0.0)? normalize(I): vec3(0.0, 0.0, -1.0);
+ vec3 normal = (toworld*vec4(N, 0.0)).xyz;
float eta = max(ior, 0.00001);
- result = fresnel_dielectric(I_view, N, (gl_FrontFacing)? eta: 1.0/eta);
+ result = fresnel_dielectric(I_view, normal, (gl_FrontFacing)? eta: 1.0/eta);
}
/* layer_weight */
-void node_layer_weight(float blend, vec3 N, vec3 I, out float fresnel, out float facing)
+void node_layer_weight(float blend, vec3 N, vec3 I, mat4 toworld, out float fresnel, out float facing)
{
/* fresnel */
float eta = max(1.0 - blend, 0.00001);
vec3 I_view = (gl_ProjectionMatrix[3][3] == 0.0)? normalize(I): vec3(0.0, 0.0, -1.0);
+ vec3 normal = (toworld*vec4(N, 0.0)).xyz;
- fresnel = fresnel_dielectric(I_view, N, (gl_FrontFacing)? 1.0/eta : eta );
+ fresnel = fresnel_dielectric(I_view, normal, (gl_FrontFacing)? 1.0/eta : eta );
/* facing */
- facing = abs(dot(I_view, N));
+ facing = abs(dot(I_view, normal));
if(blend != 0.5) {
blend = clamp(blend, 0.0, 0.99999);
blend = (blend < 0.5)? 2.0*blend: 0.5/(1.0 - blend);