• Advertisement

Archived

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

How to align a texture with the screen in HLSL?

This topic is 5070 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’m trying to understand how to align a texture with the screen in HLSL. I was trying to make a reflection effect in HLSL. I saw this done in Render Monkey and I tried to follow that example but there is one thing I don’t get. I flip the world through the mirror plane and render it to a texture. Then I want to apply the texture to the mirror. It doesn’t make sense to use the UV coordinates of the mirror. So I have to create UV coordinates for each vertex of the mirror passed to the Shader using only the vertex position. Of what I saw in the example it goes: float4 sPos = mul(view_proj_matrix, float4(Pos.xzy,1)); Out.Pos = sPos; Out.Tex.u = 0.5 * (sPos.z + sPos.x)/sPos.z; Out.Tex.v = 0.5 * (sPos.z - sPos.y)/sPos.z; I just can’t make out why the last two lines are correct. Any Ideas? Has some one done this maybe in a different way?

Share this post


Link to post
Share on other sites
Advertisement

  • Advertisement