Saturday, 16 January 2010

Dynamic Cube Mapping in XNA - Part 2

okay guys. Here goes...

I thought I would save everyone some hassle and deliver you the WHOLE code needed to create Dynamic Environment Maps. The code produces a result as below:




The FX file used is a simple Reflection.fx effect. The secret is the manipulation of the 6 reflections rendered to RenderTargetCube.faces.

Cubemaps are generated from inside the virtual cube, so looking at these images from the outside of the cube-mesh creates unwanted results, as the UV's and normals are flipped.

It is just like turning your socks inside out !


XNA3.1 PROJECT DOWNLOAD

The regenerated cube-maps will work with any shader.

It would also be very easy to use these 'corrected' maps and blur/filter them to create ambience maps with very little overheads.

Included in the archive are various other shaders that you are free to use.

An XboxPC controller is required to rotate the scene objects. L_Stick for orbiters and R_Stick for the BMW car.

Enjoy!

Any questions?