2023-08-06 08:48:11 -04:00
|
|
|
// SPDX-FileCopyrightText: 2023 Joshua Goins <josh@redstrate.com>
|
|
|
|
// SPDX-License-Identifier: CC0-1.0
|
|
|
|
|
2022-04-12 00:54:11 -04:00
|
|
|
#version 450
|
|
|
|
|
2022-04-12 09:11:31 -04:00
|
|
|
layout(location = 0) in vec3 inNormal;
|
|
|
|
layout(location = 1) in vec3 inFragPos;
|
2022-08-11 17:53:56 -04:00
|
|
|
layout(location = 2) in vec2 inUV;
|
2022-04-12 09:11:31 -04:00
|
|
|
|
2022-04-12 00:54:11 -04:00
|
|
|
layout(location = 0) out vec4 outColor;
|
|
|
|
|
2023-04-09 15:26:27 -04:00
|
|
|
layout(binding = 3) uniform sampler2D diffuseTexture;
|
|
|
|
layout(binding = 4) uniform sampler2D normalTexture;
|
|
|
|
layout(binding = 5) uniform sampler2D specularTexture;
|
|
|
|
layout(binding = 6) uniform sampler2D multiTexture;
|
|
|
|
|
|
|
|
layout(std430, push_constant) uniform PushConstant {
|
|
|
|
mat4 vp, model;
|
|
|
|
int boneOffset;
|
|
|
|
int type;
|
|
|
|
};
|
2022-08-11 17:53:56 -04:00
|
|
|
|
2022-04-12 00:54:11 -04:00
|
|
|
void main() {
|
2022-04-12 09:11:31 -04:00
|
|
|
const vec3 lightPos = vec3(3);
|
|
|
|
|
2024-02-02 14:37:58 -05:00
|
|
|
vec3 diffuse;
|
|
|
|
if (textureSize(diffuseTexture, 0).x == 1) {
|
|
|
|
diffuse = vec3(1);
|
|
|
|
} else {
|
|
|
|
diffuse = texture(diffuseTexture, inUV).rgb;
|
|
|
|
}
|
2023-04-09 15:26:27 -04:00
|
|
|
if(type == 1) {
|
|
|
|
const float skinInfluence = texture(specularTexture, inUV).r;
|
|
|
|
vec3 skinColor = vec3(250 / 255.0, 199 / 255.0, 166 / 255.0);
|
|
|
|
|
|
|
|
diffuse = mix(texture(diffuseTexture, inUV).rgb, skinColor, 1.0);
|
|
|
|
}
|
|
|
|
|
2022-04-12 09:11:31 -04:00
|
|
|
vec3 norm = normalize(inNormal);
|
|
|
|
vec3 lightDir = normalize(lightPos - inFragPos);
|
|
|
|
|
|
|
|
float diff = max(dot(norm, lightDir), 0.0);
|
|
|
|
|
2023-04-09 15:26:27 -04:00
|
|
|
outColor = vec4(diffuse * diff, 1.0);
|
2022-04-12 00:54:11 -04:00
|
|
|
}
|