diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2014-09-02 13:34:07 +0400 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2014-09-02 13:41:50 +0400 |
commit | bf0f3a04ccb927ec01a9059e56b0ac4fb80870a0 (patch) | |
tree | cb3664dc77cf76cdc28858731a354beab9723993 /source/blender/gpu/shaders | |
parent | 8230ea4858dd6361c057b208d7a31e3d58135079 (diff) |
Fix second part of T41068 -- reflection mapping was wrong
Few things:
- reflect() takes arguments in this order: N, I, it was swapped
in the previous code for some reason.
- Normal and view vectors are to be normalized. For the view
vector we're now using shade_view() in order to deal with the
ortho camera. However, Cycles does not support ortho camera
for reflection, but this is easy to do in a separate commit.
- Reflection vector is to be in the world space. Kudos to
Antony Riakiotakis for figuring this out!
Diffstat (limited to 'source/blender/gpu/shaders')
-rw-r--r-- | source/blender/gpu/shaders/gpu_shader_material.glsl | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/source/blender/gpu/shaders/gpu_shader_material.glsl b/source/blender/gpu/shaders/gpu_shader_material.glsl index 3866ec2b8ae..a60421a5b29 100644 --- a/source/blender/gpu/shaders/gpu_shader_material.glsl +++ b/source/blender/gpu/shaders/gpu_shader_material.glsl @@ -2323,8 +2323,11 @@ void node_tex_coord(vec3 I, vec3 N, mat4 viewinvmat, mat4 obinvmat, object = (obinvmat*(viewinvmat*vec4(I, 1.0))).xyz; camera = I; window = gl_FragCoord.xyz; - reflection = reflect(N, I); + vec3 shade_I; + shade_view(I, shade_I); + vec3 view_reflection = reflect(shade_I, normalize(N)); + reflection = (viewinvmat*vec4(view_reflection, 0.0)).xyz; } /* textures */ |