<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
Hi all!<br>
<br>
I'm still working on my shadow technique for OpenGL 3 shaders.<br>
I only partially manage setting the matrix for the light camera
creating the shadowMap.<br>
<br>
What I do:<br>
<span style=" color:#c0c0c0;"> </span><span style=" color:#800080;">
osg</span>::<span style=" color:#800080;">Vec3</span><span
style=" color:#c0c0c0;"> </span>lightPositionVS<span style="
color:#c0c0c0;"> </span>=<span style=" color:#c0c0c0;"> </span><span
style=" color:#800000;">mainCamera</span>->getViewMatrix()<span
style=" color:#c0c0c0;"> </span>*<span style=" color:#c0c0c0;"> </span><span
style=" color:#800000;">lightPosition</span>;
<pre style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">
</pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;"> </span><span style=" color:#800080;">osg</span>::<span style=" color:#800080;">Vec3</span><span style=" color:#c0c0c0;"> </span>eye;</pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;"> </span><span style=" color:#800080;">osg</span>::<span style=" color:#800080;">Vec3</span><span style=" color:#c0c0c0;"> </span>center;</pre>
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;"> </span><span style=" color:#800080;">osg</span>::<span style=" color:#800080;">Vec3</span><span style=" color:#c0c0c0;"> </span>up;</pre>
<span style=" color:#c0c0c0;"> </span><span style="
color:#800000;">mainCamera</span>->getViewMatrixAsLookAt(eye,<span
style=" color:#c0c0c0;"> </span>center,<span style="
color:#c0c0c0;"> </span>up,<span style=" color:#c0c0c0;"> </span><span
style=" color:#800000;">view</span>->getDistance());
<pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#c0c0c0;"> </span><span style=" color:#800000;">shadowDepthCamera</span>->setViewMatrixAsLookAt(center,<span style=" color:#c0c0c0;"> </span>center+lightPositionVS,<span style=" color:#c0c0c0;"> </span>up);</pre>
<pre style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">
That works quite fine except it doesn't honor the manipulations which are
usually done by the model matrix (scaling / translation).
So I guess I should do something like that:
<span style=" color:#800080;"> osg</span>::<span style=" color:#800080;">Vec3</span><span style=" color:#c0c0c0;"> </span>lightPositionVS<span style=" color:#c0c0c0;"> </span>=<span style=" color:#c0c0c0;"> </span><span style=" color:#800000;">???->getModelMatrix() * mainCamera</span>->getViewMatrix()<span style=" color:#c0c0c0;"> </span>*<span style=" color:#c0c0c0;"> </span><span style=" color:#800000;">lightPosition</span>;
I have references to the view and to the mainCamera.
I found out that the model matrix is held by the cameraManipulator.
Unfortunately I couldn't find and way to get the manipulator from the references I have.
Any other things I have to care about?
Or is there any other approach in setting up the shadowDepthCamera?
Any idea?
Thanks
- Werner -
</pre>
</body>
</html>