2023-02-27 05:42:54 +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;
|
|
|
|
float sliderThreshold;
|
2023-03-30 15:16:18 +08:00
|
|
|
float borderThickness;
|
2023-02-27 05:42:54 +08:00
|
|
|
vec4 sliderStartColor;
|
|
|
|
vec4 sliderEndColor;
|
|
|
|
vec4 sliderBarColor;
|
|
|
|
};
|
|
|
|
|
|
|
|
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)
|
|
|
|
layout (std430, set = 2, binding = 0) buffer MaterialProperties // For materials
|
|
|
|
{
|
|
|
|
MatPropData data[];
|
|
|
|
} MatProp;
|
|
|
|
|
|
|
|
layout(location = 0) out vec4 fragColor;
|
|
|
|
layout(location = 1) out uint outEntityID;
|
|
|
|
|
|
|
|
void main()
|
|
|
|
{
|
|
|
|
//fragColor = texture(textures[nonuniformEXT(MatProp.data[In2.materialIndex].textureIndex)], In.uv);
|
2023-02-27 09:59:58 +08:00
|
|
|
|
2023-03-30 15:16:18 +08:00
|
|
|
|
|
|
|
|
2023-02-27 05:42:54 +08:00
|
|
|
if (In.uv.x > MatProp.data[In2.materialIndex].sliderThreshold)
|
|
|
|
fragColor = MatProp.data[In2.materialIndex].sliderBarColor;
|
|
|
|
else
|
|
|
|
fragColor = (1.0f - In.uv.x) * MatProp.data[In2.materialIndex].sliderStartColor + In.uv.x * MatProp.data[In2.materialIndex].sliderEndColor;
|
|
|
|
//fragColor = texture(textures[nonuniformEXT(MatProp.data[In2.materialIndex].textureIndex)], In.uv);
|
2023-02-27 09:59:58 +08:00
|
|
|
if (fragColor.a < 0.01f)
|
|
|
|
{
|
|
|
|
discard;
|
|
|
|
}
|
2023-02-27 05:42:54 +08:00
|
|
|
|
|
|
|
fragColor.a = MatProp.data[In2.materialIndex].alpha;
|
|
|
|
|
|
|
|
// fragColor.a = 1.0f;
|
|
|
|
outEntityID = In2.eid;
|
|
|
|
}
|