37 lines
1.0 KiB
GLSL
37 lines
1.0 KiB
GLSL
// XC_BUILTIN_FORWARD_LIT_OPENGL_PS
|
|
#version 430
|
|
layout(binding = 1) uniform sampler2D uBaseColorTexture;
|
|
|
|
layout(std140, binding = 1) uniform PerObjectConstants {
|
|
mat4 gProjectionMatrix;
|
|
mat4 gViewMatrix;
|
|
mat4 gModelMatrix;
|
|
mat4 gNormalMatrix;
|
|
vec4 gMainLightDirectionAndIntensity;
|
|
vec4 gMainLightColorAndFlags;
|
|
};
|
|
|
|
layout(std140, binding = 2) uniform MaterialConstants {
|
|
vec4 gBaseColorFactor;
|
|
};
|
|
|
|
in vec3 vNormalWS;
|
|
in vec2 vTexCoord;
|
|
|
|
layout(location = 0) out vec4 fragColor;
|
|
|
|
void main() {
|
|
vec4 baseColor = texture(uBaseColorTexture, vTexCoord) * gBaseColorFactor;
|
|
if (gMainLightColorAndFlags.w < 0.5) {
|
|
fragColor = baseColor;
|
|
return;
|
|
}
|
|
|
|
vec3 normalWS = normalize(vNormalWS);
|
|
vec3 directionToLightWS = normalize(gMainLightDirectionAndIntensity.xyz);
|
|
float diffuse = max(dot(normalWS, directionToLightWS), 0.0);
|
|
vec3 lighting = vec3(0.28) +
|
|
gMainLightColorAndFlags.rgb * (diffuse * gMainLightDirectionAndIntensity.w);
|
|
fragColor = vec4(baseColor.rgb * lighting, baseColor.a);
|
|
}
|