Jump to content
  • Advertisement
Sign in to follow this  
XDarkAngelX

problems with Projective Texturing

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

I am trying to do Projective Texturing like it is explained in http://developer.nvi...advanced-topics but the problem is I can't get it to work right as it doens't map the texutre coordinates correctly

so my main pooblems is that in the article they gave a equation with [sqrt] = const * light frusum (projection) matrix * light view (lookat) martix * modeling matrix * [x0y0z0w0] but I am not sure I understand it
(for clearer view of the equation look in the article at 9.3 projective texturing equation - 9-2 The sequence of Transformations for Projective Texturing)

light frusum (projection) - this matrix should be the matrix I will get from D3DXMatrixPerspectiveFovLH while using values correct to the projective light ?
light view (lookat) - this matrix shoud be like the view martrix of a camera that is positioned and oriented the same as the projective light ?
modeling matrix - this one I really not sure is this the world matrix of the projective light or the world matrix of the object having this texture projected at him ?
[x0y0z0w0] - really didn't understand what this should mean ...


Share this post


Link to post
Share on other sites
Advertisement
[color="#1C2837"]
light frusum (projection) - this matrix should be the matrix I will get from D3DXMatrixPerspectiveFovLH while using values correct to the projective light ?[/quote]
Correct. It might look something like this: [font="Consolas, Courier, monospace"]D3DXMatrixPerspectiveLH( &Light.ProjMatrix, Camera.mFOV, mAspectRatio, Camera.mNearPlane, Camera.mFarPlane );[/font]

[color="#1C2837"]
light view (lookat) - this matrix shoud be like the view martrix of a camera that is positioned and oriented the same as the projective light ?[/quote]
[color="#1C2837"]Correct. It might look something like this: [font="Consolas, Courier, monospace"]D3DXMatrixLookAtLH( &Light.ViewMatrix, &Light.Position, ORIGIN, D3DXVECTOR3( 0.0f, 1.0f, 0.0f ) );[/font]
[font="Consolas, Courier, monospace"] [/font]
[color="#1C2837"]
modeling matrix - this one I really not sure is this the world matrix of the projective light or the world matrix of the object having this texture projected at him ?[/quote]
This matrix should be the world matrix of each object that the texture is being projected on.

[color="#1c2837"]
[x0y0z0w0] - really didn't understand what this should mean ...[/quote]
[color="#1c2837"]This is supposed to be your vertex's position (local space) in homogeneous coordinates. This will transform the final outcome of these operations into a D3DXVECTOR4 rather than a D3DXMATRIX.
[color="#1c2837"]
[color="#1c2837"]
[color="#1c2837"]The final outcome of these matrix operations are going to be 4D Texture Coordinates in NDC Space which the X & Y coordinates range from [-1, 1], and the z coordinate ranges from [0, 1]. The X & Y coordinates are in screen space, and the Z coordinate is the depth of the object commonly used in shadow mapping (how far the object/pixel is from the light). Since you're ultimately going to want to sample a texture using these coordinates, you'll want the X&Y values in the range [0, 1] (texture space) rather than [-1, 1] (screen space). That's why they have the matrix applied at the end with all of the 1/2's. Another option for converting the coordinates into texture space (rather than the const matrix multiplication) is like this:

[size="4"]normalized_device_coordinates.x = +0.5f * normalized_device_coordinates.x + 0.5f;
[size="4"][color="#1c2837"][color="#000000"]normalized_device_coordinates[color="#000000"].y = -0.5f * [color="#000000"]normalized_device_coordinates[color="#000000"].y + 0.5f;

[color="#1c2837"]So at the end of it all, sample your texture with the S&T terms in the finally calculated matrix

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!