Move shared code to base

This commit is contained in:
luboslenco
2023-02-13 21:07:13 +01:00
parent 4c811f8122
commit cf5e720d16
20 changed files with 3 additions and 101 deletions
@@ -0,0 +1,32 @@
#version 450
#include "../std/gbuffer.glsl"
in vec2 texCoord;
in vec3 wnormal;
in vec4 wvpposition;
in vec4 prevwvpposition;
out vec4 fragColor[3];
void main() {
vec3 n = normalize(wnormal);
vec3 basecol;
float roughness;
float metallic;
float occlusion;
float emission;
float Mix_fac = 0.0;
vec3 RGB_Color_res = vec3(0.2176000028848648, 0.2176000028848648, 0.2176000028848648);
vec3 Mix_Color_res = RGB_Color_res + texCoord.x * 0.0000001; // keep texCoord
basecol = Mix_Color_res;
roughness = 0.4000000059604645;
metallic = 0.0;
occlusion = 1.0;
emission = 0.0;
n /= (abs(n.x) + abs(n.y) + abs(n.z));
n.xy = n.z >= 0.0 ? n.xy : octahedronWrap(n.xy);
uint matid = 0;
if (emission > 0) { basecol *= emission; matid = 1; }
fragColor[0] = vec4(n.xy, roughness, packFloatInt16(metallic, matid));
fragColor[1] = vec4(basecol, occlusion);
vec2 posa = (wvpposition.xy / wvpposition.w) * 0.5 + 0.5;
vec2 posb = (prevwvpposition.xy / prevwvpposition.w) * 0.5 + 0.5;
fragColor[2].rg = vec2(posa - posb);
}
@@ -0,0 +1,20 @@
#version 450
in vec4 pos;
in vec2 nor;
in vec2 tex;
out vec2 texCoord;
out vec3 wnormal;
out vec4 wvpposition;
out vec4 prevwvpposition;
uniform mat3 N;
uniform mat4 WVP;
uniform float texUnpack;
uniform mat4 prevWVP;
void main() {
vec4 spos = vec4(pos.xyz, 1.0);
texCoord = tex * texUnpack;
wnormal = normalize(N * vec3(nor.xy, pos.w));
gl_Position = WVP * spos;
wvpposition = gl_Position;
prevwvpposition = prevWVP * spos;
}
+8
View File
@@ -0,0 +1,8 @@
#version 330
uniform sampler2D tex;
in vec2 texCoord;
in vec4 color;
out vec4 FragColor;
void main() {
FragColor = textureLod(tex, texCoord, 0).rgba * color;
}
@@ -0,0 +1,8 @@
#version 330
uniform sampler2D tex;
in vec2 texCoord;
in vec4 color;
out vec4 FragColor;
void main() {
FragColor = textureLod(tex, texCoord, 0).bgra * color;
}
+12
View File
@@ -0,0 +1,12 @@
#version 330
in vec3 pos;
in vec2 tex;
in vec4 col;
uniform mat4 projectionMatrix;
out vec2 texCoord;
out vec4 color;
void main() {
gl_Position = projectionMatrix * vec4(pos, 1.0);
texCoord = tex;
color = col;
}
+10
View File
@@ -0,0 +1,10 @@
#version 330
uniform sampler2D tex0;
uniform sampler2D texa;
in vec2 texCoord;
out vec4 FragColor;
void main() {
vec4 col0 = textureLod(tex0, texCoord, 0);
float mask = textureLod(texa, texCoord, 0).r;
FragColor = vec4(col0.rgb, col0.a * mask);
}