Help with Shadowmaps and shaders

Hi All !

So i’ve got a question about shadow maps.

I’ve done work with these before and tried to port some of my old shader code to TD.

Something is not working :slight_smile:.

In order to render a shadow using shadow mapping the technique is as follows:

  1. render the depth of the scene from the point of view of the light source.
  2. render the scene from the point of view of the camera
  3. during this part - take each rendered pixel and transform it’s original xyz into the above “light perspective”
  4. using this resulting xyz look up the depth map.
  5. if the current depth value is less than that in the depth map draw the pixel lit - otherwise it is in shadow

I’m using my own shaders to create a shadow map - this may eventually evolve into a shadow cube map for point lights found in the scene - or to do soft shadows.

From what i understand “uShadowMapMatrix0” is a matrix provided by TD that will transform a current gl_Vertex into the light space (for the first light - in my case the only light) …

I’ve tried all this and there is still some weird transform happening …

Then i placed a camera in the same spot as the point light. In theory this should render a completely shadow free scene - not so … help !!! :slight_smile:

I’m attaching a toe of what i’m talking about.

Thank you in advance!

A
testMyShadow.toe (15.1 KB)

Hey, the information for shadow mapping gets filled in if you use the Shadow Map parameter in the light. Put your depth map in that parameter, that those uniforms will be filled in for you.

I know you are creating your own custom shader here, so this may be a moot point, but take a look at the Rendering Shadows tip in the Touch Tips section of the wiki. It shows you how to use the shadow parameters in TouchDesigner.