Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

My goal is to create accurate reflections, sampled from a dynamic cubemap, for specific 3d objects (mostly lights) in XNA 4.0.

To sample the cubemap I compute the 3d reflection vector in a classic way:

    half3 ReflectionVec = reflect(-directionToCamera, Normal.rgb);

I then use the vector to get the actual reflected color:

    half3 ReflectionCol = texCUBElod(ReflectionSampler, float4(ReflectionVec, 0));

The cubemap I am sampling from is a RenderTarget with 6 flat faces.

So my question is, given the 3d world position of an arbitrary 3d object, how can I make sure that I get accurate reflections of this object, when I re-render the cubemap. Should I build the ViewProjection matrix in a specific way? Or is there any other approach?

share|improve this question

The incident light that is reflected will usually be true to the original object, unless it is itself reflected, bent, or otherwise altered light. The accuracy of the reflection is relative to the properties of the reflective material, and the geometry.

This link provides more reading for this wonderful topic.

Ideally, your cube map would be generated from the same projection you would want to see the geometry normally. Though this could be something fun to play around with.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.