XNA 4.0 parallax occlusion mapping

The XNACommunity Codeplex site, run by a group of hobbyist Spanish game developers, has a huge collection of programs and code examples that you can use freely for your own projects. However, most of them have not been updated for XNA 4.0. I was mostly interested in the Parallax Occulsion Mapping sample, and decided to see if I could update the code.

Parallax Mapping is a more complex way to make textures pop out, and it differs from normal and bump mapping that it actually projects the texture’s details in three dimensions, as opposed to just changing the lighting from the normals.

The original sample included a particle generator, which added a bit of flair to the scene. I could not get this working because the PointSprite object has been deprecated in XNA 4.0 and there’s no easy equivalent for it. The best I could to is make the generator produce black lines :-/ Its particle system was a bit complex to just simply change from point sprites to billboarded quads, so I just decided to omit this altogether since it’s not relevant to the real purpose of the sample.

Aside from trying to get the particles working, porting the program was a breeze. Just a few tweaks were needed in the effect files, and removing unneeded rendering functions and replacing others. Pressing the space bar lets you switch between no mapping, normal mapping, and parallax mapping. Use WASD/arrow keys to move around.

You can download the updated sample here, or check out the source at GitHub. It is ready to work with your XNA 4.0 projects. Please drop a line if you found it helpful!


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s