diff --git a/source/blender/gpu/intern/gpu_material.c b/source/blender/gpu/intern/gpu_material.c index 39252c13d607..ef781c7f2648 100644 --- a/source/blender/gpu/intern/gpu_material.c +++ b/source/blender/gpu/intern/gpu_material.c @@ -1362,7 +1362,7 @@ static void do_material_tex(GPUShadeInput *shi) GPU_cube_map(tex->ima, &tex->iuser, false), shi->view, shi->vn, GPU_select_uniform(&mtex->lodbias, GPU_DYNAMIC_TEX_LODBIAS, NULL, ma), GPU_builtin(GPU_INVERSE_VIEW_MATRIX), - GPU_builtin(GPU_VIEW_MATRIX), &tin, &trgb); + &tin, &trgb); } rgbnor = TEX_RGB; diff --git a/source/blender/gpu/shaders/gpu_shader_material.glsl b/source/blender/gpu/shaders/gpu_shader_material.glsl index 8b906d635ebf..69cae56b87ec 100644 --- a/source/blender/gpu/shaders/gpu_shader_material.glsl +++ b/source/blender/gpu/shaders/gpu_shader_material.glsl @@ -1331,10 +1331,10 @@ void mtex_cube_map(vec3 co, samplerCube ima, float lodbias, out float value, out value = 1.0; } -void mtex_cube_map_refl(samplerCube ima, vec3 vp, vec3 vn, float lodbias, mat4 viewmatrixinverse, mat4 viewmatrix, out float value, out vec4 color) +void mtex_cube_map_refl(samplerCube ima, vec3 vp, vec3 vn, float lodbias, mat4 viewmatrixinverse, out float value, out vec4 color) { vec3 viewdirection = vec3(viewmatrixinverse * vec4(vp, 0.0)); - vec3 normaldirection = normalize(vec3(vec4(vn, 0.0) * viewmatrix)); + vec3 normaldirection = normalize(viewmatrixinverse * vec4(vn, 0.0)).xyz; vec3 reflecteddirection = reflect(viewdirection, normaldirection); color = textureCube(ima, reflecteddirection, lodbias); value = 1.0;