spooky-game/assets/shaders/model-default-fragment.glsl

35 lines
1.0 KiB
GLSL

#version 450
layout (location = 0) in vec3 vertexWorldSpacePosition;
layout (location = 1) in vec3 vertexViewSpacePosition;
layout (location = 2) in vec2 vertexTexCoords;
layout (location = 3) in vec3 vertexViewSpaceNormal;
layout (location = 0) out vec4 fragAlbedo;
layout (location = 1) out vec4 fragWorldSpacePosition;
layout (location = 2) out vec4 fragViewSpacePosition;
layout (location = 3) out vec4 fragViewSpaceNormal;
layout (binding = 0) uniform sampler2D albedoTextureID;
uniform vec3 albedoColor;
void main()
{
// Texturing
vec2 flipped_texcoord = vec2(vertexTexCoords.x, 1.0 - vertexTexCoords.y);
vec4 texelColor = texture(albedoTextureID, flipped_texcoord);
// Discard fragment if transparent
if (texelColor.a < 0.5f)
{
discard;
}
// Final color
fragAlbedo = vec4(texelColor.rgb*albedoColor, texelColor.a);
fragWorldSpacePosition = vec4(vertexWorldSpacePosition, 1);
fragViewSpacePosition = vec4(vertexViewSpacePosition, 1);
fragViewSpaceNormal = vec4(vertexViewSpaceNormal, 1);
}