2026-07-17 15:30:29 +01:00
|
|
|
//*PIXEL*
|
|
|
|
|
#version 460 core
|
|
|
|
|
|
|
|
|
|
#extension GL_ARB_bindless_texture : require
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
uint INVALID_HYDRA_ID = 4294967295;
|
|
|
|
|
|
|
|
|
|
struct MaterialStore
|
|
|
|
|
{
|
|
|
|
|
vec4 diffuse_colour;
|
|
|
|
|
vec4 matalic_rough;
|
|
|
|
|
uint diffuse_texture_id;
|
|
|
|
|
uint metallic_rough_texture_id;
|
|
|
|
|
uint normal_texture_id;
|
|
|
|
|
uint padding[1];
|
|
|
|
|
};
|
|
|
|
|
|
2026-08-03 22:34:52 +01:00
|
|
|
layout(binding = 2, std430) readonly buffer material_buffer
|
2026-07-17 15:30:29 +01:00
|
|
|
{
|
|
|
|
|
MaterialStore materials[1000];
|
|
|
|
|
};
|
|
|
|
|
|
2026-08-03 22:34:52 +01:00
|
|
|
layout( std430, binding = 3) readonly buffer texture_buffer {
|
2026-07-17 15:30:29 +01:00
|
|
|
uvec2 textures[1000];
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
layout (location=0) in VS_OUT
|
|
|
|
|
{
|
|
|
|
|
vec2 vsUV;
|
|
|
|
|
vec4 vsWorldPos;
|
|
|
|
|
vec3 vsNormal;
|
|
|
|
|
vec3 vsBiTangent;
|
|
|
|
|
vec3 vsTangent;
|
|
|
|
|
mat3 vsTBN;
|
|
|
|
|
flat uint vsChunkID;
|
|
|
|
|
flat uint vsMaterialID;
|
|
|
|
|
}vs_out;
|
|
|
|
|
|
|
|
|
|
layout (location=0) out vec4 diffuse_out;
|
|
|
|
|
layout (location=1) out vec4 metalic_rough_out;
|
|
|
|
|
layout (location=2) out vec4 normal_out;
|
|
|
|
|
layout (location=3) out vec4 position_out;
|
|
|
|
|
|
|
|
|
|
void main()
|
|
|
|
|
{
|
|
|
|
|
MaterialStore mat = materials[vs_out.vsMaterialID];
|
|
|
|
|
vec4 diffuse_val = mat.diffuse_colour;
|
|
|
|
|
vec4 mat_rough_val =mat.matalic_rough;
|
|
|
|
|
vec3 normal_val = vs_out.vsNormal;
|
|
|
|
|
|
|
|
|
|
if(mat.diffuse_texture_id != INVALID_HYDRA_ID)
|
|
|
|
|
{
|
|
|
|
|
uvec2 diffuse_handle = textures[mat.diffuse_texture_id];
|
|
|
|
|
diffuse_val = diffuse_val * texture(sampler2D(diffuse_handle), vs_out.vsUV.xy);
|
|
|
|
|
}
|
|
|
|
|
if(mat.metallic_rough_texture_id != INVALID_HYDRA_ID)
|
|
|
|
|
{
|
|
|
|
|
uvec2 metal_rough_handle = textures[mat.metallic_rough_texture_id];
|
|
|
|
|
mat_rough_val = texture(sampler2D(metal_rough_handle), vs_out.vsUV.xy);
|
|
|
|
|
}
|
|
|
|
|
if(mat.normal_texture_id != INVALID_HYDRA_ID)
|
|
|
|
|
{
|
|
|
|
|
uvec2 normal_handle = textures[mat.normal_texture_id];
|
|
|
|
|
normal_val = texture(sampler2D(normal_handle), vs_out.vsUV.xy).xyz;
|
|
|
|
|
normal_val = (normal_val * 2.0) - 1.0;
|
|
|
|
|
normal_val = normalize(vs_out.vsTBN * normal_val);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(diffuse_val[3] <= 0.4)
|
|
|
|
|
{
|
|
|
|
|
discard;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
diffuse_out = diffuse_val;
|
|
|
|
|
metalic_rough_out = mat_rough_val;
|
|
|
|
|
normal_out = vec4(normal_val,1);
|
|
|
|
|
position_out = vs_out.vsWorldPos;
|
|
|
|
|
}
|