很长一段时间以来我都有这个问题,我无法运行一个简单的多样本示例..
layout(location = POSITION) in vec2 Position;
layout(location = TEXCOORD) in vec2 Texcoord;
out vert
{
vec2 Texcoord;
} Vert;
void main()
{
Vert.Texcoord = Texcoord;
gl_Position = MVP * vec4(Position, 0.0, 1.0);
}
in vert
{
vec2 Texcoord;
} Vert;
layout(location = FRAG_COLOR, index = 0) out vec4 Color;
void main()
{
Color = texture(Diffuse, interpolateAtSample(Vert.Texcoord, gl_SampleID));
}
当我运行它时,我收到以下错误:
着色器状态无效:0(20):错误 C5229:interpolateAtSample 的参数 1 必须没有组件选择
什么?我了解规格说:
Built-in interpolation functions are available to compute an interpolated value of a fragment shader input variable at a shader-specified (x,y) location. A separate (x,y) location may be used for each invocation of the built-in function, and those locations may differ from the default (x,y) location used to produce the default value of the input. float interpolateAtCentroid(float interpolant); vec2 interpolateAtCentroid(vec2 interpolant); vec3 interpolateAtCentroid(vec3 interpolant); vec4 interpolateAtCentroid(vec4 interpolant); float interpolateAtSample(float interpolant, int sample); vec2 interpolateAtSample(vec2 interpolant, int sample); vec3 interpolateAtSample(vec3 interpolant, int sample); vec4 interpolateAtSample(vec4 interpolant, int sample); float interpolateAtOffset(float interpolant, vec2 offset); vec2 interpolateAtOffset(vec2 interpolant, vec2 offset); vec3 interpolateAtOffset(vec3 interpolant, vec2 offset); vec4 interpolateAtOffset(vec4 interpolant, vec2 offset); The function interpolateAtCentroid() will return the value of the input varying <interpolant> sampled at a location inside the both the pixel and the primitive being processed. The value obtained would be the same value assigned to the input variable if declared with the "centroid" qualifier. The function interpolateAtSample() will return the value of the input varying <interpolant> at the location of the sample numbered <sample>. If multisample buffers are not available, the input varying will be evaluated at the center of the pixel. If the sample number given by <sample> does not exist, the position used to interpolate the input varying is undefined. The function interpolateAtOffset() will return the value of the input varying <interpolant> sampled at an offset from the center of the pixel specified by <offset>. The two floating-point components of <offset> give the offset in pixels in the x and y directions, respectively. An offset of (0,0) identifies the center of the pixel. The range and granularity of offsets supported by this function is implementation-dependent. For all of the interpolation functions, <interpolant> must be an input variable or an element of an input variable declared as an array. Component selection operators (e.g., ".xy") may not be used when specifying <interpolant>. If <interpolant> is declared with a "flat" or "centroid" qualifier, the qualifier will have no effect on the interpolated value. If <interpolant> is declared with the "noperspective" qualifier, the interpolated value will be computed without perspective correction.
但我仍然不明白为什么。插值没有组件选择,它是来自 vs 中绑定顶点属性的输入变量。或者它是否解释了.Texcoord
具有Vert.Texcoord
组件选择运算符?
但是,在另一个示例中,我也遇到了相同的错误interpolateAtOffset
。
怎么了?我的意思是,我想gl_SampleID
在给定的偏移量处插值,我不知道该函数还能如何使用..