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!
This commit is contained in:
Sergey Sharybin
2014-09-02 15:34:07 +06:00
parent 8230ea4858
commit bf0f3a04cc

View File

@@ -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 */