2023-02-08 14:51:54 +01:00
|
|
|
#version 450
|
2023-02-15 17:16:58 +01:00
|
|
|
|
2023-02-21 14:06:58 +01:00
|
|
|
#include "std/gbuffer.glsl"
|
2023-02-15 17:16:58 +01:00
|
|
|
|
2024-08-15 20:29:14 +02:00
|
|
|
in vec2 tex_coord;
|
2023-02-08 14:51:54 +01:00
|
|
|
in vec3 wnormal;
|
|
|
|
|
in vec4 wvpposition;
|
|
|
|
|
in vec4 prevwvpposition;
|
2024-08-15 20:29:14 +02:00
|
|
|
out vec4 frag_color[3];
|
2023-02-15 17:16:58 +01:00
|
|
|
|
2023-02-08 14:51:54 +01:00
|
|
|
void main() {
|
|
|
|
|
vec3 n = normalize(wnormal);
|
2024-08-15 20:29:14 +02:00
|
|
|
vec3 basecol = vec3(0.2, 0.2, 0.2) + tex_coord.x * 0.0000001; // keep tex_coord
|
2023-02-14 14:37:16 +01:00
|
|
|
float roughness = 0.4;
|
|
|
|
|
float metallic = 0.0;
|
|
|
|
|
float occlusion = 1.0;
|
2023-02-08 14:51:54 +01:00
|
|
|
n /= (abs(n.x) + abs(n.y) + abs(n.z));
|
2024-08-15 20:29:14 +02:00
|
|
|
n.xy = n.z >= 0.0 ? n.xy : octahedron_wrap(n.xy);
|
2024-11-14 23:12:30 +01:00
|
|
|
uint matid = uint(0);
|
2024-08-15 20:29:14 +02:00
|
|
|
frag_color[0] = vec4(n.xy, roughness, pack_f32_i16(metallic, matid));
|
|
|
|
|
frag_color[1] = vec4(basecol, occlusion);
|
2023-02-08 14:51:54 +01:00
|
|
|
vec2 posa = (wvpposition.xy / wvpposition.w) * 0.5 + 0.5;
|
|
|
|
|
vec2 posb = (prevwvpposition.xy / prevwvpposition.w) * 0.5 + 0.5;
|
2024-08-15 20:29:14 +02:00
|
|
|
frag_color[2].rg = vec2(posa - posb);
|
2023-02-08 14:51:54 +01:00
|
|
|
}
|