45 lines
No EOL
1.1 KiB
GLSL
45 lines
No EOL
1.1 KiB
GLSL
#version 450
|
|
|
|
const int MAX_TEXTURES = 512;
|
|
|
|
layout(location = 0) in vec4 inPos;
|
|
layout(location = 1) in vec3 inNormal;
|
|
layout(location = 2) in vec3 inTangent;
|
|
layout(location = 3) in vec3 inBitangent;
|
|
layout(location = 4) in vec2 inTextCoords;
|
|
|
|
layout(location = 0) out vec4 outAlbedo;
|
|
|
|
struct Material{
|
|
vec4 diffuseColor;
|
|
uint hasTexture;
|
|
uint textureIdx;
|
|
uint hasNormalMap;
|
|
uint normalMapIdx;
|
|
uint hasRoughMap;
|
|
uint roughMapIdx;
|
|
float roughnessFactor;
|
|
float metallicFactor;
|
|
};
|
|
|
|
layout(set = 2, binding = 0) readonly buffer MaterialUniform{
|
|
Material materials[];
|
|
} matUniform;
|
|
|
|
layout(set = 3, binding = 0) uniform sampler2D textSampler[MAX_TEXTURES];
|
|
|
|
layout(push_constant) uniform pc{
|
|
layout(offset = 64) uint materialIdx;
|
|
} push_constants;
|
|
|
|
void main()
|
|
{
|
|
Material material = matUniform.materials[push_constants.materialIdx];
|
|
if(material.hasTexture == 1){
|
|
vec4 texColor = texture(textSampler[material.textureIdx],inTextCoords);
|
|
if(texColor.a < 0.05 || texColor.a >= 0.9){discard;}
|
|
outAlbedo = texColor;
|
|
} else{
|
|
outAlbedo = material.diffuseColor;
|
|
}
|
|
} |