Archived

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

Projective Texturing

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi everybody, I have a problem using projective texturing in D3D as the title of this post says. Id like to create a spotlight effect, projecting a light onto my polys using multitexturing. The multitexturing part is not the problem though, the texture matrix is my problem. Ive set the texture coordindex to tci camera space position, and also the transform state flag to projected | count3, moreover I use of course clamp texture adressing mode. I should also set a texture matrix using D3DTS_TEXTURE1 (as I use texture stage 1 for the spotlight). The problem as I mentionned is this matrix. From the documents I read, it says I should bring back the camera space to world space, then to spotlight space then apply a spotlight projection, and scale it by a matrix in order to bring the texture coords to 0..1. The problem is I dont really know how to perform these operations, Ive tried to take the invert view matrix and multiply it by my spotlight projection considering my spotlight matrix is identity, and then scale it... but this doesnt seem to work at all. I see flaws on my wall, thats all I see. If I dont set any matrix, I see the spotlight moving and another problem here (which is not my major problem of course), when I walk backward, the distance between the camera and the wall being greater and greater, I see my spotlight circle becoming smaller (it is normal in this case as the texture coordinates dont change), but i begin to see a CROSS being created at the four borders of the spotlight texture (a square). This cross forming a ''+'' gets bigger and takes all my wall when im really far. This is just to ask u if u ever encountered this problem. Again this is not the reason of my post. So I would appreciate any help, as Im really stuck here. Thanks a lot in advance, Seb.

Share this post


Link to post
Share on other sites