[英]GLSL fragment shader struct out
i have a problem with my GLSL shader. 我的GLSL着色器有问题。 When i want to compile the fragment shader part, i get the following error: 当我要编译片段着色器部分时,出现以下错误:
0:24: error(#181) Cannot be used with a structure: out
error(#273) 1 compilation errors. No code generated
So the problem lies around my out variable, i assume. 因此,问题就在于我的out变量。 Here is my fragment shader: 这是我的片段着色器:
#version 410
uniform mat4 gWVP;
uniform mat4 gWorld;
uniform sampler2D gColorMap;
in VSOutput
{
vec3 WorldSpacePos;
vec2 TexCoord;
vec3 Normal;
} FSin;
struct FSOutput
{
vec3 WorldSpacePos;
vec3 Diffuse;
vec3 Normal;
vec3 TexCoord;
};
out FSOutput FSOut;
void main()
{
FSOut.WorldSpacePos = FSin.WorldSpacePos;
FSOut.Diffuse = texture(gColorMap, FSin.TexCoord).xyz;
FSOut.Normal = normalize(FSin.Normal);
FSOut.TexCoord = vec3(FSin.TexCoord, 0.0);
}
As i know it should be possible to output structs in OpenGL 4.0+, shouldn't it? 据我所知,应该可以在OpenGL 4.0+中输出结构,不是吗? So I dont get the error, is it a driver problem or something like that? 所以我没有得到错误,是驱动程序问题还是类似的问题? I'm running on a Radeon HD 6950 with 13.4 drivers. 我在具有13.4驱动程序的Radeon HD 6950上运行。
As i know it should be possible to output structs in OpenGL 4.0+, shouldn't it? 据我所知,应该可以在OpenGL 4.0+中输出结构,不是吗?
No, it shouldn't. 不,不应该。
The GLSL specification is quite clear on this: vertex shader inputs and fragment shader outputs cannot be structs. GLSL规范对此很明确:顶点着色器输入和片段着色器输出不能是结构。 From the GLSL 4.4 specification, section 4.3.6: 根据GLSL 4.4规范的第4.3.6节:
Fragment outputs can only be float, single-precision floating-point vectors, signed or unsigned integers or integer vectors, or arrays of any these. 片段输出只能是浮点数,单精度浮点向量,有符号或无符号整数或整数向量或任何这些的数组。 It is a compile-time error to declare any double-precision type, matrix, or structure as an output. 将任何双精度类型,矩阵或结构声明为输出是编译时错误。
They also can't be aggregated into interface blocks , in case you're wondering. 如果您想知道的话,也不能将它们聚合到接口块中。 They must be loose variables. 它们必须是宽松的变量。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.