Projective Texturing

Started by
-1 comments, last by LShad 21 years, 7 months ago
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.

This topic is closed to new replies.

Advertisement