Color变量设置片段颜色
fragment shader:
#version 330
in vec4 Color; //! 由vertex shader 传入
out vec4 FragColor;
void main()
{
FragColor = Color;
}
vertex shader:
#version 330
layout (location=0) in vec3 Position;
uniform mat4 gWorld;
out vec4 Color; //! 传出Color 变量
void main()
{
gl_Position = gWorld*vec4(Position, 1.0);
Color = vec4(clamp(Position, 0.0, 1.0), 1.0); //! use the built-in clamp() to make sure the color value do not go outside of the 0.0-1.0 range.
}
浙公网安备 33010602011771号