Jump to content

  • Log In with Google      Sign In   
  • Create Account

Interested in a FREE copy of HTML5 game maker Construct 2?

We'll be giving away three Personal Edition licences in next Tuesday's GDNet Direct email newsletter!

Sign up from the right-hand sidebar on our homepage and read Tuesday's newsletter for details!


We're also offering banner ads on our site from just $5! 1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


ShadowMapping matrices - scaling issue


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
No replies to this topic

#1 akuda.org   Members   -  Reputation: 119

Like
0Likes
Like

Posted 18 September 2012 - 02:52 PM

Hi,

I am implementing shadow mapping for my university homework, unfortunately on top of a very primitive rendering engine.

Fortunately though, the output of the engine is rather simple: renderer receives a list of meshes + their modelview matrix, with no hierarchy or anything. Just setup projection, push & load modelview, draw, pop modelview. The rendering itself is a bit complex (skeletal animation, skinning, shaders etc), but that's not the issue.

I was successful in creating depth texture, as described here http://fabiensanglard.net/shadowmapping/index.php , using gluLookAt etc. I know it looks good, since I visualize it. I have Light's modelview and projection matrices saved.

The engine provides following matrices:
1) for camera (that itself moves around the scene) I can get both it's location matices (wolrdToLocal and localToWorld) and it's "view" matrix (the one that it receives from "lookAt" method).
2) for objects, I receive a localToWorld matrix (which was sufficient for rendering), and I can get worldToLocal as well.
3) for light source, I have it's worldToLocal, localToWorld, projection and "view" matrix (the one from gluLookAt)

drawing (now) looks like this:
1) I set up PROJECTION via gluPerspective
2) I load camera's worldToLocal*view as MODELVIEW

for each mesh (in MODELVIEW mode):
1) I pushMatrix();
2) multiply by it's localToWorld;
3) draw;
4) popMatrix;


What is the recipe for texture matrix I need to set as shadowmap's texture matrix, so I can use it in step 3 (drawing) in fragment shaders?

I got some minor success with trying textureMatrix = bias * lightModelView * lightProjection, where
1) lightModelView = result of gluLookAt using world coordinates for light origin and directon
2) lightProjection = result of gluPerspective.
but it works only to some models, namely those with worldToLocal = ID. If model is even only scaled, the shadow is places wrong (scale > 1, shadow is too big and too far from 0,0,0, and scale < 1, shadow is too small and to close to 0,0,0).

Can someone help me out? I am dying trying all combinations here, and tutorial I used does some weird stuff with a basic translation, while the engine implements way more operations, and I cannot rewrite that.

Best Regards
Andrzej Skalski

Sponsor:



Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS