2023-04-07 06:17:37 +00:00
|
|
|
#version 330 core
|
|
|
|
|
2023-04-17 03:09:24 +00:00
|
|
|
in VS_OUT {
|
2024-01-30 23:24:01 +00:00
|
|
|
float flogz;
|
2023-04-17 03:09:24 +00:00
|
|
|
vec2 texcoord;
|
|
|
|
vec3 vertex_normal;
|
|
|
|
} fs_in;
|
2023-04-07 06:17:37 +00:00
|
|
|
|
|
|
|
uniform sampler2D color_tex;
|
|
|
|
|
|
|
|
// gbuffer_pack.glsl
|
|
|
|
void gbuffer_pack(vec3 normal, vec3 base_color, float metallic, float roughness,
|
|
|
|
float occlusion, vec3 emissive, uint mat_id);
|
|
|
|
// color.glsl
|
|
|
|
vec3 eotf_inverse_sRGB(vec3 srgb);
|
2024-01-30 23:24:01 +00:00
|
|
|
// logarithmic_depth.glsl
|
|
|
|
float logdepth_encode(float z);
|
2023-04-07 06:17:37 +00:00
|
|
|
|
|
|
|
void main()
|
|
|
|
{
|
2023-04-17 03:09:24 +00:00
|
|
|
vec4 texel = texture(color_tex, fs_in.texcoord);
|
2023-04-07 06:17:37 +00:00
|
|
|
if (texel.a < 0.5)
|
|
|
|
discard;
|
|
|
|
|
|
|
|
vec3 color = eotf_inverse_sRGB(texel.rgb);
|
|
|
|
|
2023-04-17 03:09:24 +00:00
|
|
|
vec3 N = normalize(fs_in.vertex_normal);
|
|
|
|
|
|
|
|
gbuffer_pack(N, color, 0.0, 0.9, 1.0, vec3(0.0), 3u);
|
2024-01-30 23:24:01 +00:00
|
|
|
gl_FragDepth = logdepth_encode(fs_in.flogz);
|
2023-04-07 06:17:37 +00:00
|
|
|
}
|