Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Shader TextureLod parameter value?

Tags:

opengl

glsl

What value does the LOD parameter take for texturelod? The spec I found doesn't mention it at all. Is it a percentage or an index value with a percent. If the later is the case, is there a way to get the number of mipmaps the texture has so that I would be able to use a percentage?

like image 352
user3901459 Avatar asked Dec 16 '15 08:12

user3901459


People also ask

What is textureLod?

textureLod performs a texture lookup at coordinate P from the texture bound to sampler with an explicit level-of-detail as specified in lod .

What is sampler in shader?

Shader stages: A sampler is a set of GLSL variable types. Variables of one of the sampler types must be uniforms or as function parameters. Each sampler in a program represents a single texture of a particular texture type. The type of the sampler corresponds to the type of the texture that can be used by that sampler.

What is gl_FragColor?

gl_FragColor is the principal variable that your fragment shader is designed to change. If your code does not assign a value to it then it is left undefined for the rest of the pipeline. gl_FragData is an array of data that can be used by the rest of the pipeline.

What is a sampler 2d?

A sampler2D is used to do lookup in a standard texture image; a samplerCube is used to do lookup in a cubemap texture (Subsection 5.3. 4). The value of a sampler variable is a reference to a texture unit. The value tells which texture unit is invoked when the sampler variable is used to do texture lookup.


1 Answers

The LOD parameter specifies the mipmap level, rounded to the nearest whole number. Remember that OpenGL specifies mipmap levels, such that 0 is the largest, with increasing numbers going smaller.

However, the LOD specified here will always be relative to the current GL_TEXTURE_BASE_LEVEL of the texture. So if you use textureLod(..., 0), and the base level is set to mipmap 2, then you will select from mipmap level 2. You also cannot select mipmaps outside of the GL_TEXTURE_MAX_LEVEL range; the system will automatically clamp the specified parameter appropriately.

like image 110
Nicol Bolas Avatar answered Nov 15 '22 08:11

Nicol Bolas