From e045fb57c9e57ca94cf66d19312cfa664a741251 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Tue, 23 Jan 2018 20:51:48 +0100 Subject: [PATCH] - Declare new textures for specular and pbr modes --- wadsrc/static/shaders/glsl/func_brightmap.fp | 11 +++++++++- wadsrc/static/shaders/glsl/main.fp | 22 ++++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/wadsrc/static/shaders/glsl/func_brightmap.fp b/wadsrc/static/shaders/glsl/func_brightmap.fp index 8e5f44d04..00760bd62 100644 --- a/wadsrc/static/shaders/glsl/func_brightmap.fp +++ b/wadsrc/static/shaders/glsl/func_brightmap.fp @@ -1,4 +1,13 @@ +#if defined(SPECULAR) +uniform sampler2D texture4; +#define brighttexture texture4 +#elif defined(PBR) +uniform sampler2D texture6; +#define brighttexture texture6 +#else uniform sampler2D texture2; +#define brighttexture texture2 +#endif vec4 ProcessTexel() { @@ -7,6 +16,6 @@ vec4 ProcessTexel() vec4 ProcessLight(vec4 color) { - vec4 brightpix = desaturate(texture(texture2, vTexCoord.st)); + vec4 brightpix = desaturate(texture(brighttexture, vTexCoord.st)); return vec4(min (color.rgb + brightpix.rgb, 1.0), color.a); } diff --git a/wadsrc/static/shaders/glsl/main.fp b/wadsrc/static/shaders/glsl/main.fp index 25a2c14d2..3aa404162 100644 --- a/wadsrc/static/shaders/glsl/main.fp +++ b/wadsrc/static/shaders/glsl/main.fp @@ -28,6 +28,22 @@ out vec4 FragNormal; uniform sampler2D tex; uniform sampler2D ShadowMap; +#if defined(SPECULAR) +uniform sampler2D texture2; +uniform sampler2D texture3; +#define normaltexture texture2 +#define speculartexture texture3 +#elif defined(PBR) +uniform sampler2D texture2; +uniform sampler2D texture3; +uniform sampler2D texture4; +uniform sampler2D texture5; +#define normaltexture texture2 +#define metallictexture texture3 +#define roughnesstexture texture4 +#define aotexture texture5 +#endif + vec4 Process(vec4 color); vec4 ProcessTexel(); vec4 ProcessLight(vec4 color); @@ -441,6 +457,12 @@ void main() { vec4 frag = ProcessTexel(); +#if defined(SPECULAR) + frag = texture(speculartexture, vTexCoord.st); +#elif defined(PBR) + frag = texture(metallictexture, vTexCoord.st); +#endif + #ifndef NO_ALPHATEST if (frag.a <= uAlphaThreshold) discard; #endif