Jump to content
  • Advertisement
Sign in to follow this  
MrWereWolf

Rendering projected textures with vertex program.

This topic is 4948 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

In my app I use a vertex program, but this excludes projected textures, which I need anyway. Partially I figured out how does this equation work, I use DP4 temp.x, fx , in_pos; DP4 temp.y, fy , in_pos; DP4 temp.w, fz , in_pos; where fx,fy,fz is the projection matrix and temp goes out to result.texcoord, but however the texture is always centered at (0,0), and I would like it to be centered at the middle of the texture (0.5,0.5). Anyone did this before? //Mr.WereWolf//

Share this post


Link to post
Share on other sites
Advertisement
There's a quick chapter about projective texture mapping with range correction in a vertex shader (probably what you want) in my water article. Scroll down to "A word on projective texturing".

Anyway, the trick is to use a complete 4x4 projective matrix, and encode the (0.5, 0.5, 0) translation into it. Then, a simple sequence of 3 or 4 DP4's will create the desired effect. Don't forget to use a projective texture lookup in the fragment shader, though, otherwise the homogeneous q component will be ignored.

Share this post


Link to post
Share on other sites
Quote:
Original post by Yann L
There's a quick chapter about projective texture mapping with range correction in a vertex shader (probably what you want) in my water article. Scroll down to "A word on projective texturing".

Anyway, the trick is to use a complete 4x4 projective matrix, and encode the (0.5, 0.5, 0) translation into it. Then, a simple sequence of 3 or 4 DP4's will create the desired effect. Don't forget to use a projective texture lookup in the fragment shader, though, otherwise the homogeneous q component will be ignored.


Sorry if I am jumping in on this thread but I would like to clear up YannL posting for my own clarification...

So if I setup the projective matrix in a texture unit with all the necessary math done to the matrix including the translation and scaling and call that data in the VP and then I can do the 3 or 4 DP4 commands and send that data out as texcoords into the FP and use TXP to sample the shadowmap or whatever texture unit that has the incoming texture coordinates, that should be all I need to do if I am understanding you correctly? BTW will I need the ARB_fragment_program_shadow extension for this? Thanks

Share this post


Link to post
Share on other sites
Quote:
Original post by MARS_999
So if I setup the projective matrix in a texture unit with all the necessary math done to the matrix including the translation and scaling and call that data in the VP and then I can do the 3 or 4 DP4 commands and send that data out as texcoords into the FP and use TXP to sample the shadowmap or whatever texture unit that has the incoming texture coordinates, that should be all I need to do if I am understanding you correctly?

Exactly.

Quote:

BTW will I need the ARB_fragment_program_shadow extension for this?

No, you don't. Keep in mind, that vertex programs are independent of fragment programs. So, you can very well compute projective texture coordinates in your VP, and just have a simple TXP in your fragment program.

ARB_fragment_program_shadow adds three new texture targets, that encapsulate the depth comparison operation (which is usually defined by ARB_shadow) in a way that makes it more elegant and consistent with the programmable fragment pipeline paradigm.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!