Understanding how texCUBE works and writing cubemaps properly into a cube rendertarget

Posted by cubrman on Game Development See other posts from Game Development or by cubrman
Published on 2014-05-01T12:00:05Z Indexed on 2014/05/31 16:07 UTC
Read the original article Hit count: 251

Filed under:
|
|

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?

© Game Development or respective owner

Related posts about XNA

Related posts about reflection