🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

How to get the texture coverage?

Started by
3 comments, last by Tommato 2 years, 7 months ago

Hi All

How can I get a size of current fragment in GLSL 3.3 shader? In other words, what is a size (in UV coordinates) of area covered by currently shaded pixel?

Thx

Advertisement

Im not 100% sure about your question but I think this resource can help you: http://www.opengl-tutorial.org/beginners-tutorials/tutorial-5-a-textured-cube/​

You'll want to use dFdx and dFdy. They tell you how much a value changes when moving to a neighboring pixel in the X or Y direction, which you can use to estimate the pixel's footprint in UV space. Incidentally this is exactly what GPUs do to automatically compute mip levels and anisotropic filtering.

MJP said:
You'll want to use dFdx and dFdy.

Clear, thank you

This topic is closed to new replies.

Advertisement