简体   繁体   English

函数texture()采用什么参数?

[英]what parameters does the function texture() takes?

float texture(gsampler2DArrayShadow sampler, vec4 P, [float bias]);

Look at this function in OpenGL ES (shader lang). 在OpenGL ES(shader lang)中查看此函数。 I do not understand the difference between gsampler2DArrayShadow and sampler2DArrayShadow . 我不明白gsampler2DArrayShadowsampler2DArrayShadow之间的区别。 Can you explain this? 你能解释一下吗? I read that 'g' can mean nothing or i or u. 我读到'g'可能意味着什么,或者我或你。 But what then is this type? 但那么这种类型呢?

Also, Does '[float bias]' mean that we have 2 functions: with this parameter and without? 另外,'[float bias]'是否意味着我们有2个函数:使用此参数而没有?

Anytime you see a variable type in GLSL prefixed with g in a function prototype, that is a shorthand convention that means there is an overload for every type of data. 每当你看到前缀在GLSL可变型g在函数原型,即,这意味着存在用于每种类型的数据的过载的速记约定。 A function that accepts gvec , for instance, means it has an overload for ivec , uvec , vec , dvec , bvec and so on. 例如,接受gvec的函数意味着它具有ivecuvecvecdvecbvec等的过载。

Desktop GLSL has support for integer samplers in addition to fixed-/floating-point so you will see a lot of functions defined using gsampler... instead of sampler... , that means the function has isampler... and usampler... overloads in addition to the more traditional variety. 桌面GLSL除了固定/浮点外还支持整数采样器,因此您将看到使用gsampler...而不是sampler...定义的许多函数,这意味着该函数具有isampler...usampler...除了较传统的各种重载。


As for [float bias] , that is used to control mipmap LOD bias. 至于[float bias] ,用于控制mipmap LOD偏差。 When you do not supply a value to that parameter, GL computes the bias itself. 如果不为该参数提供值,则GL会计算偏差本身。

Interestingly because of the way mipmap LODs are computed, only the fragment shader variety of the texture lookups support automatic mipmap selection (it has to do with the per-fragment derivative calculation). 有趣的是,由于mipmap LOD的计算方式,只有纹理查找的片段着色器多种支持自动mipmap选择(它与每片段衍生计算有关)。 To use mipmapping in the vertex shader, you have to explicitly select the LOD with textureLod (...) or supply your own partial derivative using textureGrad (...) . 要在顶点着色器中使用textureLod (...) ,您必须使用textureLod (...)显式选择LOD或使用textureGrad (...)提供您自己的偏导数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM