# Reflection/environment mapping

I'm implementing reflection/environment mapping using a cubemap. I have it working for the most part but when I move my camera around, I see the same area reflected on the object. I am calculating the eye vector and normal vector in view space similar to OpenGL Shading Language 3rd Edition example (p.311, Section 10.4).

Why does the reflection stay as if it is from the same view?

Which space should I be doing my calculations?

How render looks:

Snippets of HLSL code

normal = mul( (float3x3)mvMatrix, input.normal );
normal = normalize(normal);
viewPos = mul( mvMatrix, float4(input.pos, 1) );


viewPos.w = 0;
V = normalize(viewPos);
normal.w = 0;
normal = normalize(normal);

float4 reflectVec = normalize(reflect(V, normal));
float4 reflectColor = tex.Sample(samLinear, reflectVec.xyz );

• What exactly is the question here ? – Raxvan Jan 28 '15 at 10:04
• Shouldn't viewPos be position3D-cameraPosition? And I hope mvMatrix is the world matrix? – János Turánszki Jan 28 '15 at 11:03
• @Raxvan, why isn't the reflection direction changing as I move around the object? – Plato Jan 28 '15 at 16:23
• @JánosTuránszki its in eye space, so its pos-eye, but eye = 0. mvMatrix includes world matrix (it is identity) – Plato Jan 28 '15 at 16:25