- Declare new textures for specular and pbr modes

This commit is contained in:
Magnus Norddahl 2018-01-23 20:51:48 +01:00
parent c7ec489846
commit e045fb57c9
2 changed files with 32 additions and 1 deletions

View file

@ -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; uniform sampler2D texture2;
#define brighttexture texture2
#endif
vec4 ProcessTexel() vec4 ProcessTexel()
{ {
@ -7,6 +16,6 @@ vec4 ProcessTexel()
vec4 ProcessLight(vec4 color) 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); return vec4(min (color.rgb + brightpix.rgb, 1.0), color.a);
} }

View file

@ -28,6 +28,22 @@ out vec4 FragNormal;
uniform sampler2D tex; uniform sampler2D tex;
uniform sampler2D ShadowMap; 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 Process(vec4 color);
vec4 ProcessTexel(); vec4 ProcessTexel();
vec4 ProcessLight(vec4 color); vec4 ProcessLight(vec4 color);
@ -441,6 +457,12 @@ void main()
{ {
vec4 frag = ProcessTexel(); vec4 frag = ProcessTexel();
#if defined(SPECULAR)
frag = texture(speculartexture, vTexCoord.st);
#elif defined(PBR)
frag = texture(metallictexture, vTexCoord.st);
#endif
#ifndef NO_ALPHATEST #ifndef NO_ALPHATEST
if (frag.a <= uAlphaThreshold) discard; if (frag.a <= uAlphaThreshold) discard;
#endif #endif