Tuesday 3 January 2012

Shadows and learning to read

So my first attempt at implementing the shadow mapping example was a mess.

I figured I would add all of the shadow creation code straight to the base3Dobject as that held all the lighting information.

Then I would call the draw shadow method on the player object only and I should get a shadow.

Well, mostly right but the shadow mapping uses something called a RenderTarget2D.

Not really sure exactly what it is but I think it is what is used to draw the shadows.

You set the render target as the item you want to cast shadows then pass this render target to other objects so they know where to draw the shadows.

What I had originally done was to define this render target object in everyone of my objects so they were all casting shadows only on themselves.

All I needed to do set this render target as a scene variable and pass it to my objects and now I have my shadow working the way I want.

The lighting is a bit basic at the moment as everything is lit very uniformly. This is because there is only one light source processed. For now I'm happy enough and I'll look into multi pass lighting later on.

I've added some textures to my objects in 3D max just to make it look a bit nicer.

Things are starting to shape up, I have the basics of a game.

No comments:

Post a Comment