62 lines
1.1 KiB
GLSL
62 lines
1.1 KiB
GLSL
layout (location = 0) out vec3 outNormal;
|
|
layout (location = 1) out vec4 outColor;
|
|
layout (location = 2) out vec4 outSpecular;
|
|
|
|
uniform float materialNs;
|
|
uniform int objectId;
|
|
|
|
#ifdef ALPHA_MASK
|
|
uniform sampler2D alphaMask;
|
|
#endif
|
|
|
|
#ifdef DIFFUSE_TEXTURE
|
|
uniform sampler2D diffuseTexture;
|
|
#else
|
|
uniform vec3 materialKd;
|
|
#endif
|
|
|
|
#ifdef SPECULAR_TEXTURE
|
|
uniform sampler2D specularTexture;
|
|
#else
|
|
uniform vec3 materialKs;
|
|
#endif
|
|
|
|
#ifdef NORMAL_MAP
|
|
uniform sampler2D normalMap;
|
|
|
|
in mat3 tangentSpace;
|
|
#else
|
|
in vec3 varNormal;
|
|
#endif
|
|
|
|
in vec2 varTexCoord;
|
|
|
|
void main()
|
|
{
|
|
#ifdef ALPHA_MASK
|
|
if(texture(alphaMask, varTexCoord).r < 0.5)
|
|
discard;
|
|
#endif
|
|
|
|
#ifdef NORMAL_MAP
|
|
vec3 varNormal = texture(normalMap, varTexCoord).xyz * tangentSpace;
|
|
#endif
|
|
outNormal = normalize(varNormal);
|
|
|
|
#ifdef DIFFUSE_TEXTURE
|
|
outColor.rgb = texture(diffuseTexture, varTexCoord).rgb;
|
|
#else
|
|
outColor.rgb = materialKd;
|
|
#endif
|
|
|
|
outColor.a = materialNs;
|
|
|
|
#ifdef SPECULAR_TEXTURE
|
|
outSpecular.rgb = texture(specularTexture, varTexCoord).rgb;
|
|
#else
|
|
outSpecular.rgb = materialKs;
|
|
#endif
|
|
|
|
outSpecular.a = objectId;
|
|
}
|