Matrix for shadow mapping

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
Brainsaw
Posts: 1252
Joined: Wed Jan 07, 2004 12:57 pm
Location: Bavaria

Matrix for shadow mapping

Post by Brainsaw »

Hello,

I want to improve my own shader (see "Code Snippets" forum), but due to my lack of mathematical skills I don't make any progress at the moment.

I want to create an orthogonal matrix for my camera which starts at a given point (at the "near" value of the active camera) and ends at another specific point ("far" value of the camera), but I have no idea how I can calculate that.

My idea is to get the distance between those points from the perspective of the shadow camera, i.e. the width and height will vary. Does anyone know how to proceed there?

Thanks in advance
Image
Dustbin::Games on the web: https://www.dustbin-online.de/
CuteAlien
Admin
Posts: 10041
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Matrix for shadow mapping

Post by CuteAlien »

I'm probably missing something. But Irrlicht matrix has the function buildProjectionMatrixOrthoLH which allows you to set the near and far plane and width/height. The world-view transformation is the same as for other cameras.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Brainsaw
Posts: 1252
Joined: Wed Jan 07, 2004 12:57 pm
Location: Bavaria

Re: Matrix for shadow mapping

Post by Brainsaw »

What I am struggling with is to limit my shadow maps so that they start exactly at the near values of the player's camera's view frustum and don't go too far. In my test application I have added a scene node which shows the view frustum (from the light's perspective), and once I pitch the camera up or down the shadow covers more than necessary, i.e. it doesn't start with the active camera but behind it.

I tried a little this afternoon but didn't get anywhere, at the moment I think my shadows are ok the way they are
Image
Dustbin::Games on the web: https://www.dustbin-online.de/
CuteAlien
Admin
Posts: 10041
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Matrix for shadow mapping

Post by CuteAlien »

Ah yes - covering exactly how much you need is a bit tricky. But having a bit more won't hurt much.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Post Reply