SHADE_Y3/Assets/Shaders/UI_FS.glsl

48 lines
1.0 KiB
Plaintext
Raw Normal View History

2022-11-18 22:03:21 +08:00
#version 450
#extension GL_ARB_separate_shader_objects : enable
#extension GL_ARB_shading_language_420pack : enable
#extension GL_EXT_nonuniform_qualifier : require
struct MatPropData
{
int textureIndex;
float alpha;
};
layout(location = 0) in struct
{
vec4 vertPos; // location 0
vec2 uv; // location = 1
vec4 normal; // location = 2
} In;
// material stuff
layout(location = 3) flat in struct
{
int materialIndex;
uint eid;
uint lightLayerIndex;
} In2;
layout (set = 0, binding = 1) uniform sampler2D textures[]; // for textures (global)
2022-12-28 20:47:20 +08:00
layout (std430, set = 2, binding = 0) buffer MaterialProperties // For materials
2022-11-18 22:03:21 +08:00
{
MatPropData data[];
} MatProp;
2023-01-31 15:17:40 +08:00
layout(location = 0) out vec4 fragColor;
2022-11-18 22:03:21 +08:00
layout(location = 1) out uint outEntityID;
void main()
{
2023-01-31 15:17:40 +08:00
fragColor = texture(textures[nonuniformEXT(MatProp.data[In2.materialIndex].textureIndex)], In.uv);
if (fragColor.a < 0.01f)
{
discard;
}
fragColor.a = MatProp.data[In2.materialIndex].alpha;
2023-02-21 19:31:50 +08:00
// fragColor.a = 1.0f;
2022-11-18 22:03:21 +08:00
outEntityID = In2.eid;
}