Skip to main content
GameDev.net gamedev.net
🔒 Locked

reverse y coordinates texture for refraction/reflection

Started by arkerone Aug 3, 2012 at 3:49 PM 1 replies 1k views
Original Post
arkerone
arkerone
Hello,

i have a question, i found a tutorial to implement water in directx http://rastertek.com/dx11tut29.html and in shader to compute the textures coordinates of refraction and reflection, the y coordinates is reversed. Why?

[source lang="cpp"]
// Calculate the projected reflection texture coordinates.
reflectTexCoord.x = input.reflectionPosition.x / input.reflectionPosition.w / 2.0f + 0.5f;
reflectTexCoord.y = -input.reflectionPosition.y / input.reflectionPosition.w / 2.0f + 0.5f;

// Calculate the projected refraction texture coordinates.
refractTexCoord.x = input.refractionPosition.x / input.refractionPosition.w / 2.0f + 0.5f;
refractTexCoord.y = -input.refractionPosition.y / input.refractionPosition.w / 2.0f + 0.5f;[/source]

thx!
Quat
Quat
Because in NDC space +y is "up" and in texture space "+y" goes "down".
-----Quat
arkerone
arkerone
Ok thank you happy.png

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.