2022-09-19 00:00:07 +08:00
|
|
|
#version 450
|
|
|
|
#extension GL_ARB_separate_shader_objects : enable
|
|
|
|
#extension GL_ARB_shading_language_420pack : enable
|
2022-09-27 19:18:45 +08:00
|
|
|
#extension GL_EXT_nonuniform_qualifier : require
|
2022-09-19 00:00:07 +08:00
|
|
|
|
2022-09-28 20:33:29 +08:00
|
|
|
struct MatPropData
|
|
|
|
{
|
|
|
|
vec4 color;
|
|
|
|
int textureIndex;
|
|
|
|
float alpha;
|
|
|
|
vec3 beta;
|
|
|
|
};
|
|
|
|
|
2022-09-19 00:00:07 +08:00
|
|
|
layout(location = 0) in struct
|
|
|
|
{
|
2022-10-30 00:25:49 +08:00
|
|
|
vec4 vertPos; // location 0
|
|
|
|
vec2 uv; // location = 1
|
|
|
|
vec4 normal; // location = 2
|
2022-09-19 00:00:07 +08:00
|
|
|
|
|
|
|
} In;
|
|
|
|
|
2022-09-28 18:03:46 +08:00
|
|
|
// material stuff
|
2022-10-30 00:25:49 +08:00
|
|
|
layout(location = 3) flat in struct
|
2022-09-19 00:00:07 +08:00
|
|
|
{
|
2022-09-28 18:03:46 +08:00
|
|
|
int materialIndex;
|
2022-10-14 11:52:15 +08:00
|
|
|
uint eid;
|
2022-10-26 02:14:43 +08:00
|
|
|
uint lightLayerIndex;
|
2022-09-28 18:03:46 +08:00
|
|
|
} In2;
|
2022-09-19 00:00:07 +08:00
|
|
|
|
2022-09-28 20:33:29 +08:00
|
|
|
layout (set = 0, binding = 1) uniform sampler2D textures[]; // for textures (global)
|
2022-10-30 00:25:49 +08:00
|
|
|
layout (std430, set = 3, binding = 0) buffer MaterialProperties // For materials
|
2022-09-27 21:06:14 +08:00
|
|
|
{
|
|
|
|
MatPropData data[];
|
|
|
|
} MatProp;
|
|
|
|
|
2022-10-30 00:25:49 +08:00
|
|
|
layout(location = 0) out vec4 position;
|
2022-10-13 16:57:08 +08:00
|
|
|
layout(location = 1) out uint outEntityID;
|
2022-10-26 02:14:43 +08:00
|
|
|
layout(location = 2) out uint lightLayerIndices;
|
2022-10-30 00:25:49 +08:00
|
|
|
layout(location = 3) out vec4 normals;
|
|
|
|
layout(location = 4) out vec4 albedo;
|
2022-09-19 00:00:07 +08:00
|
|
|
|
|
|
|
void main()
|
|
|
|
{
|
2022-10-30 00:25:49 +08:00
|
|
|
position = In.vertPos;
|
|
|
|
normals = In.normal;
|
2022-11-02 21:31:27 +08:00
|
|
|
albedo = texture(textures[nonuniformEXT(MatProp.data[In2.materialIndex].textureIndex)], In.uv);
|
2022-09-19 00:00:07 +08:00
|
|
|
|
2022-10-14 11:52:15 +08:00
|
|
|
outEntityID = In2.eid;
|
2022-10-26 02:14:43 +08:00
|
|
|
lightLayerIndices = In2.lightLayerIndex;
|
2022-09-19 00:00:07 +08:00
|
|
|
}
|