opengl 着色器中预先定义的变量 (GLSLLang spec4.3 chapter 7)

VS:


in int  gl_VertexID;

in int gl_InstanceID;

out gl_PerVertex {

  vec4 gl_Position;

  float gl_PointSize;

  float gl_ClipDistance[];

};

FS/PS:


vec4 gl_FragCoord;

bool gl_FrontFacing;

flaot gl_ClipDistance[];

vec2 gl_PointCoord;

int gl_PrimitiveID;

itn gl_SampleID;

vec2 gl_SamplePosition;

int gl_SampleMaskIn[];

int gl_Layer;

int gl_ViewportIndex;

out float gl_FragDepth;

out int gl_SampleMask[];


CS:


// work group dimensions

in uvec3 gl_NumWorkGroups;

const uvec3 gl_WorkGroupSize;

// work group and invocation IDs

in uvec3 gl_WorkGroupID;

in uvec3 gl_LocalInvocationID;

// derived variables

in uvec3 gl_GlobalInvocationID;

in uint gl_LocalInvocationIndex;


GS:


in gl_PerVertex {

vec4 gl_Position;

float gl_PointSize;

float gl_ClipDistance[];

} gl_in[];

in int gl_PrimitiveIDIn;

in int gl_InvocationID;

out gl_PerVertex {

vec4 gl_Position;

float gl_PointSize;

float gl_ClipDistance[];

};

out int gl_PrimitiveID;

out int gl_Layer;

out int gl_ViewportIndex;

TCS:


in gl_PerVertex {

vec4 gl_Position;

float gl_PointSize;

float gl_ClipDistance[];

} gl_in[gl_MaxPatchVertices];

in int gl_PatchVerticesIn;

in int gl_PrimitiveID;

in int gl_InvocationID;

out gl_PerVertex {

vec4 gl_Position;

float gl_PointSize;

float gl_ClipDistance[];

} gl_out[];

patch out float gl_TessLevelOuter[4];

patch out float gl_TessLevelInner[2];

TES:


in gl_PerVertex {

vec4 gl_Position;

float gl_PointSize;

float gl_ClipDistance[];

} gl_in[gl_MaxPatchVertices];

in int gl_PatchVerticesIn;

in int gl_PrimitiveID;

in vec3 gl_TessCoord;

patch in float gl_TessLevelOuter[4];

patch in float gl_TessLevelInner[2];

out gl_PerVertex {

vec4 gl_Position;

float gl_PointSize;

float gl_ClipDistance[];

};

对于兼容模式,各shader的输入和输出有所不一样。

兼容模式的VS输入:


in vec4 gl_Color;

in vec4 gl_SecondaryColor;

in vec4 gl_Normal;

in vec4 gl_Vertex;

in vec4 gl_MultiTexCoord0;

in vec4 gl_MultiTexCoord1;

in vec4 gl_MultiTexCoord2;

in vec4 gl_MultiTexCoord3;

in vec4 gl_MultiTexCoord4;

in vec4 gl_MultiTexCoord5;

in vec4 gl_MultiTexCoord6;

in vec4 gl_MultiTexCoord7;

in float gl_FogCoord;


output除非兼容模式列出的以外,还可以有:


out gl_PerVertex {

// part of the gl_PerVertex block described in 7.1

// in addition to other gl_PerVertex members…

vec4 gl_ClipVertex;

vec4 gl_FrontColor;

vec4 gl_BackColor;

vec4 gl_FrontSecondaryColor;

vec4 gl_BackSecondaryColor;

vec4 gl_TexCoord[];

float gl_FogFragCoord;

};


因为有了上面的output, 在TCS, TES , GS的input也可以为上面的声明。

对于兼容模式的PS,其输入可以为:


in gl_PerFragment {

in float gl_FogFragCoord;

in vec4 gl_TexCoord[];

in vec4 gl_Color;

in vec4 gl_SecondaryColor;

};


输出为:


out vec4 gl_FragColor;

out vec4 gl_FragData[gl_MaxDrawBuffers];

更多的预定义变量可以查阅手册。其中没有列出的是预定义的uniform 变量。



本文地址: http://www.bagualu.net/wordpress/archives/2576 转载请注明




发表评论

电子邮件地址不会被公开。 必填项已用*标注