35 lines
No EOL
843 B
GLSL
35 lines
No EOL
843 B
GLSL
#version 450
|
|
|
|
const int MAX_TEXTURES = 500;
|
|
|
|
layout(location = 0) in vec2 inTextCoords;
|
|
layout(location = 0) out vec4 outAlbedo;
|
|
|
|
struct Material{
|
|
vec4 diffuseColor;
|
|
uint hasTexture;
|
|
uint textureIdx;
|
|
uint padding[2];
|
|
};
|
|
|
|
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.1){discard;}
|
|
outAlbedo = texColor;
|
|
} else{
|
|
outAlbedo = material.diffuseColor;
|
|
}
|
|
} |