我现在有这个问题,因为很长一段时间,我无法得到一个简单的多重采样示例...
This是原始代码,this是vs和this fs,为方便起见,我在这里报告:
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:参数1表示 interpolateAtSample必须没有组件选择
什么?我理解specs说:
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.
但我仍然不明白为什么。插值没有组件选择,它是一个来自绑定顶点属性的输入变量。
或者它是否解释.Texcoord
Vert.Texcoord
有组件选择运算符?
但是,我在interpolateAtOffset
上的另一个示例中也遇到了同样的错误。
有什么问题?我的意思是,我想在给定的偏移处插入gl_SampleID
,我不知道该函数应该如何使用..