Add shader for texture handling

This commit is contained in:
2024-07-04 16:57:30 +02:00
parent 471786d18e
commit 6cb776587a
4 changed files with 256 additions and 183 deletions

View File

@@ -8,6 +8,7 @@ layout(location = 3) in vec3 biTangent;
layout(location = 4) in vec3 textureCoordinates;
layout(location = 5) in vec4 color;
layout(location = 0) out vec4 outColor;
layout(location = 1) out vec2 fragTextureCoordinates;
layout(set = 0, binding = 0) uniform NodeData
{
@@ -22,8 +23,9 @@ void main()
{
vec3 light = normalize(vec3(1));
vec4 worldPos = node.world * vec4(position, 1.0);
vec3 worldNormal = normalize(transpose(inverse(mat3(node.world))) * normal);
float brightness = max(0.0, dot(worldNormal, light));
outColor = vec4(clamp(color.rgb * (0.5 + brightness / 2), 0, 1), 1);
vec3 worldNormal = normalize(transpose(inverse(mat3(node.world))) * normal);
float brightness = max(0.0, dot(worldNormal, light));
outColor = vec4(clamp(color.rgb * (0.5 + brightness / 2), 0, 1), 1);
gl_Position = normalize(cam.viewProjection * worldPos);
fragTextureCoordinates = textureCoordinates.xy;
}