2023-04-07 06:17:37 +00:00
|
|
|
#version 330 core
|
|
|
|
|
2023-04-17 03:09:24 +00:00
|
|
|
in VS_OUT {
|
|
|
|
vec2 texcoord;
|
|
|
|
vec3 vertex_normal;
|
|
|
|
vec3 view_vector;
|
|
|
|
} fs_in;
|
2023-04-07 06:17:37 +00:00
|
|
|
|
|
|
|
uniform sampler2D color_tex;
|
2023-04-17 03:09:24 +00:00
|
|
|
|
2023-04-07 06:17:37 +00:00
|
|
|
uniform int normalmap_enabled;
|
|
|
|
uniform float normalmap_tiling;
|
2023-04-23 19:24:56 +00:00
|
|
|
uniform float metallic;
|
|
|
|
uniform float roughness;
|
2023-04-07 06:17:37 +00:00
|
|
|
|
|
|
|
// 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);
|
2023-04-17 03:09:24 +00:00
|
|
|
// normalmap.glsl
|
|
|
|
vec3 perturb_normal(vec3 N, vec3 V, vec2 texcoord);
|
2023-04-07 06:17:37 +00:00
|
|
|
|
|
|
|
void main()
|
|
|
|
{
|
2023-04-17 03:09:24 +00:00
|
|
|
vec3 texel = texture(color_tex, fs_in.texcoord).rgb;
|
2023-04-07 06:17:37 +00:00
|
|
|
vec3 color = eotf_inverse_sRGB(texel);
|
|
|
|
|
2023-04-17 03:09:24 +00:00
|
|
|
vec3 N = normalize(fs_in.vertex_normal);
|
2023-04-07 06:17:37 +00:00
|
|
|
if (normalmap_enabled > 0) {
|
2023-04-17 03:09:24 +00:00
|
|
|
N = perturb_normal(N, fs_in.view_vector, fs_in.texcoord * normalmap_tiling);
|
2023-04-07 06:17:37 +00:00
|
|
|
}
|
|
|
|
|
2023-04-23 19:24:56 +00:00
|
|
|
gbuffer_pack(N, color, metallic, roughness, 1.0, vec3(0.0), 3u);
|
2023-04-07 06:17:37 +00:00
|
|
|
}
|