PDA

View Full Version : texture2D vs textureLOD



heinz85
01-20-2012, 06:38 AM
Hello Everybody.
Can anybody explain me in short what is the difference between texture2D and textureLod, and when one should be preferred over the other?

Thanks,
Heinrich

V-man
01-20-2012, 06:54 AM
According to
http://www.opengl.org/registry/doc/GLSLangSpec.Full.1.40.05.pdf

texture2D has been deprecated in favor of texture. However, if you are targeting GLSL 1.10 , you can still use texture2D.

texture2D is used in the fragment shader.
textureLod is used in the vertex shader since the derivatives are not computed. There are no derivatives because a vertex is just a point. You need to select the mipmap yourself.


Some texture functions (non-“Lod” and non-“Grad” versions) may require implicit derivatives. Implicit
derivatives are undefined within non-uniform control flow and for vertex shader texture fetches.

heinz85
01-20-2012, 10:13 AM
Ok, and what is mipmap? (if this question is too stupid fell free not to answer...).

Alfonse Reinheart
01-20-2012, 12:48 PM
Please read the Texture article on the OpenGL Wiki (http://www.opengl.org/wiki/Texture).