Bit by Bit


Update:
Very good tutorial and example of shadow mapping on the ios or android really any device.
here: http://fabiensanglard.net/shadowmapping/index.php
A good guide to keep your head on straight when constructing it. And I agree with him. I have no idea why people go to all the effort of transforming out of camera spaces inverse and the like when you can map directly to the rendered frame buffer object through the light projection and view matrices… anyway this method is much faster.

Getting much better =)

With Spinning light…


Now to get it in the game and test out the edges I expect I will blend the edges by clearing the viewport in full rez then render to a subset….back to work!

Is how you program systems.. and the bit I am on right now is getting the shadows into the correct space… I am transforming the vertex position back into the light cameras view space to get the sample points for the depth map render. Somewhere in that mess I have a mistake and it could be in my scene graph. I am close however and when I am done with this I really do not see anymore difficult code chunks left. This required some additional functionality added across the scene graph but overall again I am very pleased with the robust nature of this scene graph =)..Hopefully I will be back into eye candy and game talk soon this stuff can wear on you.

Here is where I left it last night. As you can see the map is not mapping properly to the eye space and the camera eye space. Something that should be simple is turning out to be elusive =)

And there is the error… those values there should map into the light and the colors should be at the edges or close really.. hmm very strange…

WOW found it…. sheesh stupid.. the magical W component of the bias matrix I had set to 0.5 not 1.0… NICE!

So for a quick explanation of how Shadow mapping works. It is actually much easier then Shadow Volumes. First you create a render texture and use a camera to render from the light to the target into that render buffer only drawing to the Depth map (front face culling helps in artifacts!). Then take the Frame Buffer Object and use it when you render the object and for the “shadow” part of the shader simply transform the untransformed point BACK into the light cameras space EXACTLY as you did when you rendered it into the FBO. This will place the puppy back into the map you rendered and a reference point for how far away it was from the light. With some Magic W action check the difference of the two and see what is in front. I need to optimize this shader someday as it is the work horse in the game but that is for later for now I need to finish up this shadow mapping fun =). A BIG tip when working on this is to line up the camera and the light cam and then attempt everything that way you can narrow down the variables. =)

Advertisements

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


%d bloggers like this: