#### Archived

This topic is now archived and is closed to further replies.

This topic is 5639 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

hey all, I''m working on implimenting PSM, and all my projections are off slightly. Not to mention, I''m not getting any shadow map result itself. from my understanding, this is the process: 1. Our transformation from world space to post perspective space is the matrix T=P*MV where P= our camera''s Perspective matrix MV= our camera''s ModelView matrix Thus T maps a visible scene point in world space to the unit cube [-1,1] in R3. IE transformation by T puts stuff in "post-perspective" space 2.We then have to transform our light pos & light dir by T to put it in Post-perspective space. 3.We load T into our current modelview matrix in order to transform all other points relative to this transformation 4.Then, set up our shadow map as normal, using gluLookAt(loc.x, loc.y,loc.z,dir.x, dir.y, dir.z,0.f,1.f,0.f); 5.Once the shadow Map is updated, restore Modelview matrix Via glLoadIdentity();translate via camera.LookAt(); I know there''s some more conceptual stuff in there, however, i was trying to just get the basic method working. Below is the math i''m using.

float T[16];
//we want to get the mvp for what is ultimatly going to be the camera

g_Camera.Update();
g_Camera.Look();

//Get our model view matrix

glGetFloatv(GL_MODELVIEW_MATRIX, mv);

//push our model view, so we can use it later

glMatrixMode(GL_PROJECTION);
glPushMatrix();

//multiply our current p with mv: p*mv

glMultMatrixf(mv);

//get the result of p*mv

glGetFloatv(GL_PROJECTION_MATRIX, T);

glPopMatrix();
glMatrixMode(GL_MODELVIEW);

//Transform our light position by T

l->loc.x=T[0]*l->loc.x + T[1]*l->loc.y + T[2]*l->loc.z; //T[3]

l->loc.y=T[4]*l->loc.x + T[5]*l->loc.y + T[6]*l->loc.z; //T[7]

l->loc.z=T[8]*l->loc.x + T[9]*l->loc.y + T[11]*l->loc.z; //T[12]

l->loc.z*=-1.f;

//also, transform our dir by T

l->dir.x=T[0]*l->dir.x + T[1]*l->dir.y + T[2]*l->dir.z; //T[3]

l->dir.y=T[4]*l->dir.x + T[5]*l->dir.y + T[6]*l->dir.z; //T[7]

l->dir.z=T[8]*l->dir.x + T[9]*l->dir.y + T[11]*l->dir.z; //T[12]

l->dir.z*=-1.f;

//setup view from our light

gluLookAt(loc.x, loc.y,	loc.z,
dir.x, dir.y, dir.z,
0.f,0.f,1.f);
//render scene, copy to SM image


Firstly, Do i have the concept correct? or am i completly lost? Secondly, am i doing something wrong with my math? thanks ~Main == Colt "MainRoach" McAnlis Programmer www.badheat.com/sinewave

1. 1
2. 2
3. 3
4. 4
5. 5
Rutin
11

• 12
• 19
• 10
• 14
• 10
• ### Forum Statistics

• Total Topics
632665
• Total Posts
3007710
• ### Who's Online (See full list)

There are no registered users currently online

×