From f3c55c01c86fbc48e92ed401c4ab618143b7e152 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sat, 20 Jan 2018 16:28:24 +0100 Subject: [PATCH 01/11] Add material definition to GLDEFS --- src/g_shared/a_dynlightdata.cpp | 8 ++- src/gl/textures/gl_texture.cpp | 111 ++++++++++++++++++++++++++++++++ src/textures/textures.h | 10 +++ 3 files changed, 128 insertions(+), 1 deletion(-) diff --git a/src/g_shared/a_dynlightdata.cpp b/src/g_shared/a_dynlightdata.cpp index fcdbcd3d1..2c2a6bd08 100644 --- a/src/g_shared/a_dynlightdata.cpp +++ b/src/g_shared/a_dynlightdata.cpp @@ -56,6 +56,7 @@ int ScriptDepth; void gl_InitGlow(FScanner &sc); void gl_ParseBrightmap(FScanner &sc, int); +void gl_ParseMaterial(FScanner &sc, int); void gl_DestroyUserShaders(); void gl_ParseHardwareShader(FScanner &sc, int deflump); void gl_ParseDetailTexture(FScanner &sc); @@ -906,7 +907,8 @@ static const char *CoreKeywords[]= "hardwareshader", "detail", "#include", - NULL + "material", + nullptr }; @@ -928,6 +930,7 @@ enum TAG_HARDWARESHADER, TAG_DETAIL, TAG_INCLUDE, + TAG_MATERIAL }; @@ -1285,6 +1288,9 @@ static void DoParseDefs(FScanner &sc, int workingLump) case TAG_BRIGHTMAP: gl_ParseBrightmap(sc, workingLump); break; + case TAG_MATERIAL: + gl_ParseMaterial(sc, workingLump); + break; case TAG_HARDWARESHADER: gl_ParseHardwareShader(sc, workingLump); break; diff --git a/src/gl/textures/gl_texture.cpp b/src/gl/textures/gl_texture.cpp index ddfd7ecc9..e7e459186 100644 --- a/src/gl/textures/gl_texture.cpp +++ b/src/gl/textures/gl_texture.cpp @@ -195,6 +195,11 @@ FTexture::MiscGLInfo::MiscGLInfo() throw() Material[1] = Material[0] = NULL; SystemTexture[1] = SystemTexture[0] = NULL; Brightmap = NULL; + Normal = NULL; + Specular = NULL; + Metallic = NULL; + Roughness = NULL; + AmbientOcclusion = NULL; } FTexture::MiscGLInfo::~MiscGLInfo() @@ -542,6 +547,112 @@ int FBrightmapTexture::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotat return 0; } +//========================================================================== +// +// Parses a material definition +// +//========================================================================== + +void gl_ParseMaterial(FScanner &sc, int deflump) +{ + int type = FTexture::TEX_Any; + bool disable_fullbright = false; + bool disable_fullbright_specified = false; + bool thiswad = false; + bool iwad = false; + + FTexture *textures[6]; + const char *keywords[7] = { "brightmap", "normal", "specular", "metallic", "roughness", "ao", nullptr }; + const char *notFound[6] = { "Brightmap", "Normalmap", "Specular texture", "Metallic texture", "Roughness texture", "Ambient occlusion texture" }; + memset(textures, 0, sizeof(textures)); + + sc.MustGetString(); + if (sc.Compare("texture")) type = FTexture::TEX_Wall; + else if (sc.Compare("flat")) type = FTexture::TEX_Flat; + else if (sc.Compare("sprite")) type = FTexture::TEX_Sprite; + else sc.UnGet(); + + sc.MustGetString(); + FTextureID no = TexMan.CheckForTexture(sc.String, type, FTextureManager::TEXMAN_TryAny | FTextureManager::TEXMAN_Overridable); + FTexture *tex = TexMan[no]; + + sc.MustGetToken('{'); + while (!sc.CheckToken('}')) + { + sc.MustGetString(); + if (sc.Compare("disablefullbright")) + { + // This can also be used without a brightness map to disable + // fullbright in rotations that only use brightness maps on + // other angles. + disable_fullbright = true; + disable_fullbright_specified = true; + } + else if (sc.Compare("thiswad")) + { + // only affects textures defined in the WAD containing the definition file. + thiswad = true; + } + else if (sc.Compare ("iwad")) + { + // only affects textures defined in the IWAD. + iwad = true; + } + else + { + for (int i = 0; keywords[i] != nullptr; i++) + { + if (sc.Compare (keywords[i])) + { + sc.MustGetString(); + if (textures[i]) + Printf("Multiple %s definitions in texture %s\n", keywords[i], tex? tex->Name.GetChars() : "(null)"); + textures[i] = TexMan.FindTexture(sc.String, FTexture::TEX_Any, FTextureManager::TEXMAN_TryAny); + if (!textures[i]) + Printf("%s '%s' not found in texture '%s'\n", notFound[i], sc.String, tex? tex->Name.GetChars() : "(null)"); + break; + } + } + } + } + if (!tex) + { + return; + } + if (thiswad || iwad) + { + bool useme = false; + int lumpnum = tex->GetSourceLump(); + + if (lumpnum != -1) + { + if (iwad && Wads.GetLumpFile(lumpnum) <= Wads.GetIwadNum()) useme = true; + if (thiswad && Wads.GetLumpFile(lumpnum) == deflump) useme = true; + } + if (!useme) return; + } + + FTexture **bindings[6] = + { + &tex->gl_info.Brightmap, + &tex->gl_info.Normal, + &tex->gl_info.Specular, + &tex->gl_info.Metallic, + &tex->gl_info.Roughness, + &tex->gl_info.AmbientOcclusion + }; + for (int i = 0; keywords[i] != nullptr; i++) + { + if (textures[i]) + { + textures[i]->bMasked = false; + *bindings[i] = textures[i]; + } + } + + if (disable_fullbright_specified) + tex->gl_info.bDisableFullbright = disable_fullbright; +} //========================================================================== // diff --git a/src/textures/textures.h b/src/textures/textures.h index 539d38c43..72501e492 100644 --- a/src/textures/textures.h +++ b/src/textures/textures.h @@ -328,6 +328,11 @@ protected: Rotations = other->Rotations; gl_info = other->gl_info; gl_info.Brightmap = NULL; + gl_info.Normal = NULL; + gl_info.Specular = NULL; + gl_info.Metallic = NULL; + gl_info.Roughness = NULL; + gl_info.AmbientOcclusion = NULL; gl_info.areas = NULL; } @@ -362,6 +367,11 @@ public: FMaterial *Material[2]; FGLTexture *SystemTexture[2]; FTexture *Brightmap; + FTexture *Normal; // Normal map texture + FTexture *Specular; // Specular light texture for the diffuse+normal+specular light model + FTexture *Metallic; // Metalness texture for the physically based rendering (PBR) light model + FTexture *Roughness; // Roughness texture for PBR + FTexture *AmbientOcclusion; // Ambient occlusion texture for PBR PalEntry GlowColor; int GlowHeight; FloatRect *areas; From 4dd2d789f47fba1178e89bd49ae59f541de9c610 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sun, 21 Jan 2018 01:19:16 +0100 Subject: [PATCH 02/11] - Rename mTextureEffects to mMaterialShaders to help distinguish between those and effect shaders (mEffectShaders) - Add MaterialShaderIndex enum --- src/gl/shaders/gl_shader.cpp | 45 ++++++++++++++++----------------- src/gl/shaders/gl_shader.h | 35 +++++++++++++++++-------- src/gl/textures/gl_material.cpp | 8 +++--- 3 files changed, 51 insertions(+), 37 deletions(-) diff --git a/src/gl/shaders/gl_shader.cpp b/src/gl/shaders/gl_shader.cpp index d551106a4..c7944f141 100644 --- a/src/gl/shaders/gl_shader.cpp +++ b/src/gl/shaders/gl_shader.cpp @@ -376,8 +376,7 @@ struct FDefaultShader const char * gettexelfunc; }; -// Note: the FIRST_USER_SHADER constant in gl_shader.h needs -// to be updated whenever the size of this array is modified. +// Note: the ShaderIndex enum in gl_shader.h needs to be updated whenever this array is modified. static const FDefaultShader defaultshaders[]= { {"Default", "shaders/glsl/func_normal.fp"}, @@ -522,8 +521,8 @@ FShaderCollection::~FShaderCollection() void FShaderCollection::CompileShaders(EPassType passType) { - mTextureEffects.Clear(); - mTextureEffectsNAT.Clear(); + mMaterialShaders.Clear(); + mMaterialShadersNAT.Clear(); for (int i = 0; i < MAX_EFFECTS; i++) { mEffectShaders[i] = NULL; @@ -532,11 +531,11 @@ void FShaderCollection::CompileShaders(EPassType passType) for(int i=0;defaultshaders[i].ShaderName != NULL;i++) { FShader *shc = Compile(defaultshaders[i].ShaderName, defaultshaders[i].gettexelfunc, true, passType); - mTextureEffects.Push(shc); - if (i <= 3) + mMaterialShaders.Push(shc); + if (i <= SHADER_Brightmap) { FShader *shc = Compile(defaultshaders[i].ShaderName, defaultshaders[i].gettexelfunc, false, passType); - mTextureEffectsNAT.Push(shc); + mMaterialShadersNAT.Push(shc); } } @@ -546,7 +545,7 @@ void FShaderCollection::CompileShaders(EPassType passType) FName sfn = name; FShader *shc = Compile(sfn, usershaders[i], true, passType); - mTextureEffects.Push(shc); + mMaterialShaders.Push(shc); } for(int i=0;imName == sfn) + if (mMaterialShaders[i]->mName == sfn) { return i; } @@ -636,19 +635,19 @@ void FShaderCollection::ApplyMatrices(VSMatrix *proj, VSMatrix *view) VSMatrix norm; norm.computeNormalMatrix(*view); - for (int i = 0; i < 4; i++) + for (int i = 0; i < SHADER_NoTexture; i++) { - mTextureEffects[i]->ApplyMatrices(proj, view, &norm); - mTextureEffectsNAT[i]->ApplyMatrices(proj, view, &norm); + mMaterialShaders[i]->ApplyMatrices(proj, view, &norm); + mMaterialShadersNAT[i]->ApplyMatrices(proj, view, &norm); } - mTextureEffects[4]->ApplyMatrices(proj, view, &norm); + mMaterialShaders[SHADER_NoTexture]->ApplyMatrices(proj, view, &norm); if (gl_fuzztype != 0) { - mTextureEffects[4 + gl_fuzztype]->ApplyMatrices(proj, view, &norm); + mMaterialShaders[SHADER_NoTexture + gl_fuzztype]->ApplyMatrices(proj, view, &norm); } - for (unsigned i = 12; i < mTextureEffects.Size(); i++) + for (unsigned i = FIRST_USER_SHADER; i < mMaterialShaders.Size(); i++) { - mTextureEffects[i]->ApplyMatrices(proj, view, &norm); + mMaterialShaders[i]->ApplyMatrices(proj, view, &norm); } for (int i = 0; i < MAX_EFFECTS; i++) { diff --git a/src/gl/shaders/gl_shader.h b/src/gl/shaders/gl_shader.h index f41f7467b..6995c7b28 100644 --- a/src/gl/shaders/gl_shader.h +++ b/src/gl/shaders/gl_shader.h @@ -355,8 +355,8 @@ private: class FShaderCollection { - TArray mTextureEffects; - TArray mTextureEffectsNAT; + TArray mMaterialShaders; + TArray mMaterialShadersNAT; FShader *mEffectShaders[MAX_EFFECTS]; void Clean(); @@ -372,13 +372,13 @@ public: void ResetFixedColormap() { - for (unsigned i = 0; i < mTextureEffects.Size(); i++) + for (unsigned i = 0; i < mMaterialShaders.Size(); i++) { - mTextureEffects[i]->currentfixedcolormap = -1; + mMaterialShaders[i]->currentfixedcolormap = -1; } - for (unsigned i = 0; i < mTextureEffectsNAT.Size(); i++) + for (unsigned i = 0; i < mMaterialShadersNAT.Size(); i++) { - mTextureEffectsNAT[i]->currentfixedcolormap = -1; + mMaterialShadersNAT[i]->currentfixedcolormap = -1; } } @@ -387,17 +387,32 @@ public: // indices 0-2 match the warping modes, 3 is brightmap, 4 no texture, the following are custom if (!alphateston && eff <= 3) { - return mTextureEffectsNAT[eff]; // Non-alphatest shaders are only created for default, warp1+2 and brightmap. The rest won't get used anyway + return mMaterialShadersNAT[eff]; // Non-alphatest shaders are only created for default, warp1+2 and brightmap. The rest won't get used anyway } - if (eff < mTextureEffects.Size()) + if (eff < mMaterialShaders.Size()) { - return mTextureEffects[eff]; + return mMaterialShaders[eff]; } return NULL; } }; -#define FIRST_USER_SHADER 12 +enum MaterialShaderIndex +{ + SHADER_Default = 0, + SHADER_Warp1 = 1, + SHADER_Warp2 = 2, + SHADER_Brightmap = 3, + SHADER_NoTexture = 4, + SHADER_BasicFuzz = 5, + SHADER_SmoothFuzz = 6, + SHADER_SwirlyFuzz = 7, + SHADER_TranslucentFuzz = 8, + SHADER_JaggedFuzz = 9, + SHADER_NoiseFuzz = 10, + SHADER_SmoothNoiseFuzz = 11, + FIRST_USER_SHADER = 12 +}; enum { diff --git a/src/gl/textures/gl_material.cpp b/src/gl/textures/gl_material.cpp index 53d22f857..c716f5717 100644 --- a/src/gl/textures/gl_material.cpp +++ b/src/gl/textures/gl_material.cpp @@ -438,7 +438,7 @@ int FMaterial::mMaxBound; FMaterial::FMaterial(FTexture * tx, bool expanded) { - mShaderIndex = 0; + mShaderIndex = SHADER_Default; tex = tx; // TODO: apply custom shader object here @@ -449,7 +449,7 @@ FMaterial::FMaterial(FTexture * tx, bool expanded) */ if (tx->bWarped) { - mShaderIndex = tx->bWarped; + mShaderIndex = tx->bWarped; // This picks SHADER_Warp1 or SHADER_Warp2 tx->gl_info.shaderspeed = static_cast(tx)->GetSpeed(); } else if (tx->bHasCanvas) @@ -474,7 +474,7 @@ FMaterial::FMaterial(FTexture * tx, bool expanded) ValidateSysTexture(tx->gl_info.Brightmap, expanded); FTextureLayer layer = {tx->gl_info.Brightmap, false}; mTextureLayers.Push(layer); - mShaderIndex = 3; + mShaderIndex = SHADER_Brightmap; } } } @@ -804,7 +804,7 @@ void FMaterial::GetTexCoordInfo(FTexCoordInfo *tci, float x, float y) const int FMaterial::GetAreas(FloatRect **pAreas) const { - if (mShaderIndex == 0) // texture splitting can only be done if there's no attached effects + if (mShaderIndex == SHADER_Default) // texture splitting can only be done if there's no attached effects { FTexture *tex = mBaseLayer->tex; *pAreas = tex->gl_info.areas; From 0f69778e233ebab0b8eafe2fb02e206a535bc109 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sun, 21 Jan 2018 01:53:44 +0100 Subject: [PATCH 03/11] - Add new material shader entries for specular and PBR light modes --- src/gl/scene/gl_sprite.cpp | 2 +- src/gl/scene/gl_weapon.cpp | 2 +- src/gl/shaders/gl_shader.cpp | 44 ++++++++++++++++++++---------------- src/gl/shaders/gl_shader.h | 32 ++++++++++++++------------ 4 files changed, 45 insertions(+), 35 deletions(-) diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index edd0da1d9..3a27a7cde 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -991,7 +991,7 @@ void GLSprite::Process(AActor* thing, sector_t * sector, int thruportal) { // Todo: implement shader selection here RenderStyle = LegacyRenderStyles[STYLE_Translucent]; - OverrideShader = gl_fuzztype + 4; + OverrideShader = SHADER_NoTexture + gl_fuzztype; trans = 0.99f; // trans may not be 1 here hw_styleflags = STYLEHW_NoAlphaTest; } diff --git a/src/gl/scene/gl_weapon.cpp b/src/gl/scene/gl_weapon.cpp index 69551f28a..2061d67f3 100644 --- a/src/gl/scene/gl_weapon.cpp +++ b/src/gl/scene/gl_weapon.cpp @@ -355,7 +355,7 @@ void GLSceneDrawer::DrawPlayerSprites(sector_t * viewsector, bool hudModelStep) { // Todo: implement shader selection here RenderStyle = LegacyRenderStyles[STYLE_Translucent]; - OverrideShader = gl_fuzztype + 4; + OverrideShader = SHADER_NoTexture + gl_fuzztype; trans = 0.99f; // trans may not be 1 here } else diff --git a/src/gl/shaders/gl_shader.cpp b/src/gl/shaders/gl_shader.cpp index c7944f141..5d7cdd359 100644 --- a/src/gl/shaders/gl_shader.cpp +++ b/src/gl/shaders/gl_shader.cpp @@ -325,9 +325,10 @@ bool FShader::Bind() // //========================================================================== -FShader *FShaderCollection::Compile (const char *ShaderName, const char *ShaderPath, bool usediscard, EPassType passType) +FShader *FShaderCollection::Compile (const char *ShaderName, const char *ShaderPath, const char *shaderdefines, bool usediscard, EPassType passType) { FString defines; + defines += shaderdefines; // this can't be in the shader code due to ATI strangeness. if (gl.MaxLights() == 128) defines += "#define MAXLIGHTS128\n"; if (!usediscard) defines += "#define NO_ALPHATEST\n"; @@ -374,24 +375,29 @@ struct FDefaultShader { const char * ShaderName; const char * gettexelfunc; + const char * Defines; }; -// Note: the ShaderIndex enum in gl_shader.h needs to be updated whenever this array is modified. +// Note: the MaterialShaderIndex enum in gl_shader.h needs to be updated whenever this array is modified. static const FDefaultShader defaultshaders[]= { - {"Default", "shaders/glsl/func_normal.fp"}, - {"Warp 1", "shaders/glsl/func_warp1.fp"}, - {"Warp 2", "shaders/glsl/func_warp2.fp"}, - {"Brightmap","shaders/glsl/func_brightmap.fp"}, - {"No Texture", "shaders/glsl/func_notexture.fp"}, - {"Basic Fuzz", "shaders/glsl/fuzz_standard.fp"}, - {"Smooth Fuzz", "shaders/glsl/fuzz_smooth.fp"}, - {"Swirly Fuzz", "shaders/glsl/fuzz_swirly.fp"}, - {"Translucent Fuzz", "shaders/glsl/fuzz_smoothtranslucent.fp"}, - {"Jagged Fuzz", "shaders/glsl/fuzz_jagged.fp"}, - {"Noise Fuzz", "shaders/glsl/fuzz_noise.fp"}, - {"Smooth Noise Fuzz", "shaders/glsl/fuzz_smoothnoise.fp"}, - {NULL,NULL} + {"Default", "shaders/glsl/func_normal.fp", ""}, + {"Warp 1", "shaders/glsl/func_warp1.fp", ""}, + {"Warp 2", "shaders/glsl/func_warp2.fp", ""}, + {"Brightmap","shaders/glsl/func_brightmap.fp", ""}, + {"Specular","shaders/glsl/func_normal.fp", "#define SPECULAR\n"}, + {"SpecularBrightmap","shaders/glsl/func_brightmap.fp", "#define SPECULAR\n"}, + {"PBR","shaders/glsl/func_normal.fp", "#define PBR\n"}, + {"PBRBrightmap","shaders/glsl/func_brightmap.fp", "#define PBR\n"}, + {"No Texture", "shaders/glsl/func_notexture.fp", ""}, + {"Basic Fuzz", "shaders/glsl/fuzz_standard.fp", ""}, + {"Smooth Fuzz", "shaders/glsl/fuzz_smooth.fp", ""}, + {"Swirly Fuzz", "shaders/glsl/fuzz_swirly.fp", ""}, + {"Translucent Fuzz", "shaders/glsl/fuzz_smoothtranslucent.fp", ""}, + {"Jagged Fuzz", "shaders/glsl/fuzz_jagged.fp", ""}, + {"Noise Fuzz", "shaders/glsl/fuzz_noise.fp", ""}, + {"Smooth Noise Fuzz", "shaders/glsl/fuzz_smoothnoise.fp", ""}, + {NULL,NULL,NULL} }; static TArray usershaders; @@ -530,11 +536,11 @@ void FShaderCollection::CompileShaders(EPassType passType) for(int i=0;defaultshaders[i].ShaderName != NULL;i++) { - FShader *shc = Compile(defaultshaders[i].ShaderName, defaultshaders[i].gettexelfunc, true, passType); + FShader *shc = Compile(defaultshaders[i].ShaderName, defaultshaders[i].gettexelfunc, defaultshaders[i].Defines, true, passType); mMaterialShaders.Push(shc); - if (i <= SHADER_Brightmap) + if (i < SHADER_NoTexture) { - FShader *shc = Compile(defaultshaders[i].ShaderName, defaultshaders[i].gettexelfunc, false, passType); + FShader *shc = Compile(defaultshaders[i].ShaderName, defaultshaders[i].gettexelfunc, defaultshaders[i].Defines, false, passType); mMaterialShadersNAT.Push(shc); } } @@ -544,7 +550,7 @@ void FShaderCollection::CompileShaders(EPassType passType) FString name = ExtractFileBase(usershaders[i]); FName sfn = name; - FShader *shc = Compile(sfn, usershaders[i], true, passType); + FShader *shc = Compile(sfn, usershaders[i], "", true, passType); mMaterialShaders.Push(shc); } diff --git a/src/gl/shaders/gl_shader.h b/src/gl/shaders/gl_shader.h index 6995c7b28..aa81808ec 100644 --- a/src/gl/shaders/gl_shader.h +++ b/src/gl/shaders/gl_shader.h @@ -365,7 +365,7 @@ class FShaderCollection public: FShaderCollection(EPassType passType); ~FShaderCollection(); - FShader *Compile(const char *ShaderName, const char *ShaderPath, bool usediscard, EPassType passType); + FShader *Compile(const char *ShaderName, const char *ShaderPath, const char *shaderdefines, bool usediscard, EPassType passType); int Find(const char *mame); FShader *BindEffect(int effect); void ApplyMatrices(VSMatrix *proj, VSMatrix *view); @@ -399,19 +399,23 @@ public: enum MaterialShaderIndex { - SHADER_Default = 0, - SHADER_Warp1 = 1, - SHADER_Warp2 = 2, - SHADER_Brightmap = 3, - SHADER_NoTexture = 4, - SHADER_BasicFuzz = 5, - SHADER_SmoothFuzz = 6, - SHADER_SwirlyFuzz = 7, - SHADER_TranslucentFuzz = 8, - SHADER_JaggedFuzz = 9, - SHADER_NoiseFuzz = 10, - SHADER_SmoothNoiseFuzz = 11, - FIRST_USER_SHADER = 12 + SHADER_Default, + SHADER_Warp1, + SHADER_Warp2, + SHADER_Brightmap, + SHADER_Specular, + SHADER_SpecularBrightmap, + SHADER_PBR, + SHADER_PBRBrightmap, + SHADER_NoTexture, + SHADER_BasicFuzz, + SHADER_SmoothFuzz, + SHADER_SwirlyFuzz, + SHADER_TranslucentFuzz, + SHADER_JaggedFuzz, + SHADER_NoiseFuzz, + SHADER_SmoothNoiseFuzz, + FIRST_USER_SHADER }; enum From e045fb57c9e57ca94cf66d19312cfa664a741251 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Tue, 23 Jan 2018 20:51:48 +0100 Subject: [PATCH 04/11] - 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 From 81c6808d2ac681765f07f72988c50c693be9451f Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Tue, 23 Jan 2018 23:10:28 +0100 Subject: [PATCH 05/11] - Add specular and normal map handling to main.fp --- src/gl/textures/gl_material.cpp | 26 +++++- wadsrc/static/shaders/glsl/main.fp | 140 +++++++++++++++++++++++------ 2 files changed, 137 insertions(+), 29 deletions(-) diff --git a/src/gl/textures/gl_material.cpp b/src/gl/textures/gl_material.cpp index c716f5717..859706772 100644 --- a/src/gl/textures/gl_material.cpp +++ b/src/gl/textures/gl_material.cpp @@ -468,13 +468,37 @@ FMaterial::FMaterial(FTexture * tx, bool expanded) } else { + if (tx->gl_info.Normal && tx->gl_info.Specular) + { + for (auto &texture : { tx->gl_info.Normal, tx->gl_info.Specular }) + { + ValidateSysTexture(texture, expanded); + mTextureLayers.Push({ texture, false }); + } + mShaderIndex = SHADER_Specular; + } + else if (tx->gl_info.Normal && tx->gl_info.Metallic && tx->gl_info.Roughness && tx->gl_info.AmbientOcclusion) + { + for (auto &texture : { tx->gl_info.Normal, tx->gl_info.Metallic, tx->gl_info.Roughness, tx->gl_info.AmbientOcclusion }) + { + ValidateSysTexture(texture, expanded); + mTextureLayers.Push({ texture, false }); + } + mShaderIndex = SHADER_PBR; + } + tx->CreateDefaultBrightmap(); if (tx->gl_info.Brightmap != NULL) { ValidateSysTexture(tx->gl_info.Brightmap, expanded); FTextureLayer layer = {tx->gl_info.Brightmap, false}; mTextureLayers.Push(layer); - mShaderIndex = SHADER_Brightmap; + if (mShaderIndex == SHADER_Specular) + mShaderIndex = SHADER_SpecularBrightmap; + else if (mShaderIndex == SHADER_PBR) + mShaderIndex = SHADER_PBRBrightmap; + else + mShaderIndex = SHADER_Brightmap; } } } diff --git a/wadsrc/static/shaders/glsl/main.fp b/wadsrc/static/shaders/glsl/main.fp index 3aa404162..71e973c17 100644 --- a/wadsrc/static/shaders/glsl/main.fp +++ b/wadsrc/static/shaders/glsl/main.fp @@ -268,29 +268,112 @@ float diffuseContribution(vec3 lightDirection, vec3 normal) //=========================================================================== // -// Calculates the brightness of a dynamic point light -// Todo: Find a better way to define which lighting model to use. -// (Specular mode has been removed for now.) +// Blinn specular light calculation // //=========================================================================== -float pointLightAttenuation(vec4 lightpos, float lightcolorA) +float blinnSpecularContribution(float diffuseContribution, vec3 lightDirection, vec3 faceNormal, float glossiness, float specularLevel) +{ + if (diffuseContribution > 0.0f) + { + vec3 viewDir = normalize(uCameraPos.xyz - pixelpos.xyz); + vec3 halfDir = normalize(lightDirection + viewDir); + float specAngle = max(dot(halfDir, faceNormal), 0.0f); + float phExp = glossiness * 4.0f; + return specularLevel * pow(specAngle, phExp); + } + else + { + return 0.0f; + } +} + +//=========================================================================== +// +// Adjust normal vector according to the normal map +// +//=========================================================================== + +#if defined(SPECULAR) || defined(PBR) +mat3 cotangent_frame(vec3 n, vec3 p, vec2 uv) +{ + // get edge vectors of the pixel triangle + vec3 dp1 = dFdx(p); + vec3 dp2 = dFdy(p); + vec2 duv1 = dFdx(uv); + vec2 duv2 = dFdy(uv); + + // solve the linear system + vec3 dp2perp = cross(n, dp2); // cross(dp2, n); + vec3 dp1perp = cross(dp1, n); // cross(n, dp1); + vec3 t = dp2perp * duv1.x + dp1perp * duv2.x; + vec3 b = dp2perp * duv1.y + dp1perp * duv2.y; + + // construct a scale-invariant frame + float invmax = inversesqrt(max(dot(t,t), dot(b,b))); + return mat3(t * invmax, b * invmax, n); +} + +vec3 ApplyNormalMap() +{ + #define WITH_NORMALMAP_UNSIGNED + #define WITH_NORMALMAP_GREEN_UP + //#define WITH_NORMALMAP_2CHANNEL + + vec3 interpolatedNormal = normalize(gl_FrontFacing ? -vWorldNormal.xyz : vWorldNormal.xyz); + + vec3 map = texture(normaltexture, vTexCoord.st).xyz; + #if defined(WITH_NORMALMAP_UNSIGNED) + map = map * 255./127. - 128./127.; // Math so "odd" because 0.5 cannot be precisely described in an unsigned format + #endif + #if defined(WITH_NORMALMAP_2CHANNEL) + map.z = sqrt(1 - dot(map.xy, map.xy)); + #endif + #if defined(WITH_NORMALMAP_GREEN_UP) + map.y = -map.y; + #endif + + mat3 tbn = cotangent_frame(interpolatedNormal, pixelpos.xyz, vTexCoord.st); + vec3 bumpedNormal = normalize(tbn * map); + return bumpedNormal; +} +#else +vec3 ApplyNormalMap() +{ + return normalize(vWorldNormal.xyz); +} +#endif + +//=========================================================================== +// +// Calculates the brightness of a dynamic point light +// +//=========================================================================== + +vec2 pointLightAttenuation(vec4 lightpos, float lightcolorA) { float attenuation = max(lightpos.w - distance(pixelpos.xyz, lightpos.xyz),0.0) / lightpos.w; - if (attenuation == 0.0) return 0.0; + if (attenuation == 0.0) return vec2(0.0); #ifdef SUPPORTS_SHADOWMAPS float shadowIndex = abs(lightcolorA) - 1.0; attenuation *= shadowmapAttenuation(lightpos, shadowIndex); #endif if (lightcolorA >= 0.0) // Sign bit is the attenuated light flag { - return attenuation; + return vec2(attenuation, 0.0); } else { vec3 lightDirection = normalize(lightpos.xyz - pixelpos.xyz); - float diffuseAmount = diffuseContribution(lightDirection, normalize(vWorldNormal.xyz)); - return attenuation * diffuseAmount; + vec3 pixelnormal = ApplyNormalMap(); + float diffuseAmount = diffuseContribution(lightDirection, pixelnormal); + +#if defined(SPECULAR) + float specularAmount = blinnSpecularContribution(diffuseAmount, lightDirection, pixelnormal, 10.0, 0.12); + return vec2(diffuseAmount, specularAmount) * attenuation; +#else + return vec2(attenuation * diffuseAmount, 0.0); +#endif } } @@ -315,7 +398,7 @@ float spotLightAttenuation(vec4 lightpos, vec3 spotdir, float lightCosInnerAngle // //=========================================================================== -vec4 getLightColor(float fogdist, float fogfactor) +vec4 getLightColor(vec4 material, vec4 materialSpec, float fogdist, float fogfactor) { vec4 color = vColor; @@ -361,6 +444,7 @@ vec4 getLightColor(float fogdist, float fogfactor) // vec4 dynlight = uDynLightColor; + vec4 specular = vec4(0.0, 0.0, 0.0, 1.0); #if defined NUM_UBO_LIGHTS || defined SHADER_STORAGE_LIGHTS if (uLightIndex >= 0) @@ -378,11 +462,11 @@ vec4 getLightColor(float fogdist, float fogfactor) vec4 lightspot1 = lights[i+2]; vec4 lightspot2 = lights[i+3]; - float attenuation = pointLightAttenuation(lightpos, lightcolor.a); + vec2 attenuation = pointLightAttenuation(lightpos, lightcolor.a); if (lightspot1.w == 1.0) - attenuation *= spotLightAttenuation(lightpos, lightspot1.xyz, lightspot2.x, lightspot2.y); - lightcolor.rgb *= attenuation; - dynlight.rgb += lightcolor.rgb; + attenuation.xy *= spotLightAttenuation(lightpos, lightspot1.xyz, lightspot2.x, lightspot2.y); + dynlight.rgb += lightcolor.rgb * attenuation.x; + specular.rgb += lightcolor.rgb * attenuation.y; } // // subtractive lights @@ -394,19 +478,20 @@ vec4 getLightColor(float fogdist, float fogfactor) vec4 lightspot1 = lights[i+2]; vec4 lightspot2 = lights[i+3]; - float attenuation = pointLightAttenuation(lightpos, lightcolor.a); + vec2 attenuation = pointLightAttenuation(lightpos, lightcolor.a); if (lightspot1.w == 1.0) - attenuation *= spotLightAttenuation(lightpos, lightspot1.xyz, lightspot2.x, lightspot2.y); - lightcolor.rgb *= attenuation; - dynlight.rgb -= lightcolor.rgb; + attenuation.xy *= spotLightAttenuation(lightpos, lightspot1.xyz, lightspot2.x, lightspot2.y); + dynlight.rgb -= lightcolor.rgb * attenuation.x; + specular.rgb -= lightcolor.rgb * attenuation.y; } } } #endif color.rgb = clamp(color.rgb + desaturate(dynlight).rgb, 0.0, 1.4); - + specular.rgb = clamp(specular.rgb + desaturate(specular).rgb, 0.0, 1.4); + // prevent any unintentional messing around with the alpha. - return vec4(color.rgb, vColor.a); + return vec4(material.rgb * color.rgb + materialSpec.rgb * specular.rgb, material.a * vColor.a); } //=========================================================================== @@ -457,12 +542,6 @@ 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 @@ -492,8 +571,13 @@ void main() fogfactor = exp2 (uFogDensity * fogdist); } - - frag *= getLightColor(fogdist, fogfactor); +#if defined(SPECULAR) + vec4 materialSpec = texture(speculartexture, vTexCoord.st); +#else + vec4 materialSpec = vec4(0.0); +#endif + + frag = getLightColor(frag, materialSpec, fogdist, fogfactor); #if defined NUM_UBO_LIGHTS || defined SHADER_STORAGE_LIGHTS if (uLightIndex >= 0) @@ -513,7 +597,7 @@ void main() vec4 lightspot1 = lights[i+2]; vec4 lightspot2 = lights[i+3]; - float attenuation = pointLightAttenuation(lightpos, lightcolor.a); + float attenuation = pointLightAttenuation(lightpos, lightcolor.a).x; if (lightspot1.w == 1.0) attenuation *= spotLightAttenuation(lightpos, lightspot1.xyz, lightspot2.x, lightspot2.y); lightcolor.rgb *= attenuation; From 18759024143f81ce180590d87b91167adf07ded8 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Tue, 23 Jan 2018 23:59:58 +0100 Subject: [PATCH 06/11] - Do not flip the normal based on face direction --- wadsrc/static/shaders/glsl/main.fp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wadsrc/static/shaders/glsl/main.fp b/wadsrc/static/shaders/glsl/main.fp index 71e973c17..6bc9f7a90 100644 --- a/wadsrc/static/shaders/glsl/main.fp +++ b/wadsrc/static/shaders/glsl/main.fp @@ -320,7 +320,7 @@ vec3 ApplyNormalMap() #define WITH_NORMALMAP_GREEN_UP //#define WITH_NORMALMAP_2CHANNEL - vec3 interpolatedNormal = normalize(gl_FrontFacing ? -vWorldNormal.xyz : vWorldNormal.xyz); + vec3 interpolatedNormal = normalize(vWorldNormal.xyz); vec3 map = texture(normaltexture, vTexCoord.st).xyz; #if defined(WITH_NORMALMAP_UNSIGNED) @@ -369,7 +369,7 @@ vec2 pointLightAttenuation(vec4 lightpos, float lightcolorA) float diffuseAmount = diffuseContribution(lightDirection, pixelnormal); #if defined(SPECULAR) - float specularAmount = blinnSpecularContribution(diffuseAmount, lightDirection, pixelnormal, 10.0, 0.12); + float specularAmount = blinnSpecularContribution(diffuseAmount, lightDirection, pixelnormal, 100.0, 200.0); return vec2(diffuseAmount, specularAmount) * attenuation; #else return vec2(attenuation * diffuseAmount, 0.0); From e7286344975fc51379e34a1f4e6016dd94bb7de5 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Thu, 25 Jan 2018 13:23:12 +0200 Subject: [PATCH 07/11] Use dummy Get...() functions for all Intel targets 64-bit Intel targets built with GCC/Clang were using strict memory alignment versions of GetShort(), GetInt(), GetBigInt() functions --- src/m_swap.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/m_swap.h b/src/m_swap.h index 982aa5ca1..1ab82d3b1 100644 --- a/src/m_swap.h +++ b/src/m_swap.h @@ -177,7 +177,7 @@ inline int BigLong (int x) // Data accessors, since some data is highly likely to be unaligned. -#if defined(_M_IX86) || defined(_M_X64) || defined(__i386__) +#if defined(_M_IX86) || defined(_M_X64) || defined(__i386__) || defined(__x86_64__) inline int GetShort(const unsigned char *foo) { return *(const short *)foo; From 1b4e3d3f9447571da680a977c0142e475b6efbb4 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Thu, 25 Jan 2018 13:35:34 +0200 Subject: [PATCH 08/11] Added overloaded Little...() functions for big endian targets https://forum.zdoom.org/viewtopic.php?t=59197 --- src/m_swap.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/m_swap.h b/src/m_swap.h index 1ab82d3b1..a68a0837b 100644 --- a/src/m_swap.h +++ b/src/m_swap.h @@ -91,6 +91,16 @@ inline unsigned short LittleShort (unsigned short x) return (unsigned short)((x>>8) | (x<<8)); } +inline short LittleShort (int x) +{ + return LittleShort((short)x); +} + +inline unsigned short LittleShort (unsigned int x) +{ + return LittleShort((unsigned short)x); +} + // Swapping 32bit. inline unsigned int LittleLong (unsigned int x) { @@ -110,6 +120,16 @@ inline int LittleLong (int x) | (((unsigned int)x)<<24)); } +inline unsigned int LittleLong(unsigned long x) +{ + return LittleLong((unsigned int)x); +} + +inline int LittleLong(long x) +{ + return LittleLong((int)x); +} + #define BigShort(x) (x) #define BigLong(x) (x) From 7a59bcde4c0c77314b88125b6af5eba56f6e3289 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Thu, 25 Jan 2018 19:53:55 +0100 Subject: [PATCH 09/11] - move glossiness and specular level to GLDEFS --- src/gl/renderer/gl_renderstate.cpp | 3 +++ src/gl/renderer/gl_renderstate.h | 8 ++++++++ src/gl/shaders/gl_shader.cpp | 1 + src/gl/shaders/gl_shader.h | 1 + src/gl/textures/gl_texture.cpp | 14 ++++++++++++++ src/textures/textures.h | 2 ++ wadsrc/static/shaders/glsl/main.fp | 2 +- wadsrc/static/shaders/glsl/shaderdefs.i | 3 +++ 8 files changed, 33 insertions(+), 1 deletion(-) diff --git a/src/gl/renderer/gl_renderstate.cpp b/src/gl/renderer/gl_renderstate.cpp index 119444af6..499303cab 100644 --- a/src/gl/renderer/gl_renderstate.cpp +++ b/src/gl/renderer/gl_renderstate.cpp @@ -87,6 +87,8 @@ void FRenderState::Reset() mSpecialEffect = EFF_NONE; mClipHeight = 0.f; mClipHeightDirection = 0.f; + mGlossiness = 0.0f; + mSpecularLevel = 0.0f; mShaderTimer = 0.0f; ClearClipSplit(); @@ -178,6 +180,7 @@ bool FRenderState::ApplyShader() activeShader->muLightIndex.Set(mLightIndex); // will always be -1 for now activeShader->muClipSplit.Set(mClipSplit); activeShader->muViewHeight.Set(viewheight); + activeShader->muSpecularMaterial.Set(mGlossiness, mSpecularLevel); if (mGlowEnabled) { diff --git a/src/gl/renderer/gl_renderstate.h b/src/gl/renderer/gl_renderstate.h index 92de96e9a..e6a6c1dcb 100644 --- a/src/gl/renderer/gl_renderstate.h +++ b/src/gl/renderer/gl_renderstate.h @@ -94,6 +94,7 @@ class FRenderState bool mLastDepthClamp; float mInterpolationFactor; float mClipHeight, mClipHeightDirection; + float mGlossiness, mSpecularLevel; float mShaderTimer; FVertexBuffer *mVertexBuffer, *mCurrentVertexBuffer; @@ -152,6 +153,7 @@ public: } mEffectState = overrideshader >= 0? overrideshader : mat->mShaderIndex; mShaderTimer = mat->tex->gl_info.shaderspeed; + SetSpecular(mat->tex->gl_info.Glossiness, mat->tex->gl_info.SpecularLevel); mat->Bind(clampmode, translation); } @@ -386,6 +388,12 @@ public: mObjectColor2 = pe; } + void SetSpecular(float glossiness, float specularLevel) + { + mGlossiness = glossiness; + mSpecularLevel = specularLevel; + } + void SetFog(PalEntry c, float d) { const float LOG2E = 1.442692f; // = 1/log(2) diff --git a/src/gl/shaders/gl_shader.cpp b/src/gl/shaders/gl_shader.cpp index 833c1722d..bcaea9bb4 100644 --- a/src/gl/shaders/gl_shader.cpp +++ b/src/gl/shaders/gl_shader.cpp @@ -254,6 +254,7 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char * muClipHeight.Init(hShader, "uClipHeight"); muClipHeightDirection.Init(hShader, "uClipHeightDirection"); muAlphaThreshold.Init(hShader, "uAlphaThreshold"); + muSpecularMaterial.Init(hShader, "uSpecularMaterial"); muViewHeight.Init(hShader, "uViewHeight"); muTimer.Init(hShader, "timer"); diff --git a/src/gl/shaders/gl_shader.h b/src/gl/shaders/gl_shader.h index 5b4e23c63..8041f4880 100644 --- a/src/gl/shaders/gl_shader.h +++ b/src/gl/shaders/gl_shader.h @@ -285,6 +285,7 @@ class FShader FBufferedUniform1f muClipHeightDirection; FBufferedUniform1f muAlphaThreshold; FBufferedUniform1i muViewHeight; + FBufferedUniform2f muSpecularMaterial; FBufferedUniform1f muTimer; int lights_index; diff --git a/src/gl/textures/gl_texture.cpp b/src/gl/textures/gl_texture.cpp index e7e459186..6501d9709 100644 --- a/src/gl/textures/gl_texture.cpp +++ b/src/gl/textures/gl_texture.cpp @@ -191,6 +191,8 @@ FTexture::MiscGLInfo::MiscGLInfo() throw() mIsTransparent = -1; shaderspeed = 1.f; shaderindex = 0; + Glossiness = 0.0f; + SpecularLevel = 0.0f; Material[1] = Material[0] = NULL; SystemTexture[1] = SystemTexture[0] = NULL; @@ -598,6 +600,18 @@ void gl_ParseMaterial(FScanner &sc, int deflump) // only affects textures defined in the IWAD. iwad = true; } + else if (sc.Compare("glossiness")) + { + sc.MustGetFloat(); + if (tex) + tex->gl_info.Glossiness = sc.Float; + } + else if (sc.Compare("specularlevel")) + { + sc.MustGetFloat(); + if (tex) + tex->gl_info.SpecularLevel = sc.Float; + } else { for (int i = 0; keywords[i] != nullptr; i++) diff --git a/src/textures/textures.h b/src/textures/textures.h index 72501e492..c80abf87b 100644 --- a/src/textures/textures.h +++ b/src/textures/textures.h @@ -372,6 +372,8 @@ public: FTexture *Metallic; // Metalness texture for the physically based rendering (PBR) light model FTexture *Roughness; // Roughness texture for PBR FTexture *AmbientOcclusion; // Ambient occlusion texture for PBR + float Glossiness; + float SpecularLevel; PalEntry GlowColor; int GlowHeight; FloatRect *areas; diff --git a/wadsrc/static/shaders/glsl/main.fp b/wadsrc/static/shaders/glsl/main.fp index 6bc9f7a90..d1ae8f50f 100644 --- a/wadsrc/static/shaders/glsl/main.fp +++ b/wadsrc/static/shaders/glsl/main.fp @@ -369,7 +369,7 @@ vec2 pointLightAttenuation(vec4 lightpos, float lightcolorA) float diffuseAmount = diffuseContribution(lightDirection, pixelnormal); #if defined(SPECULAR) - float specularAmount = blinnSpecularContribution(diffuseAmount, lightDirection, pixelnormal, 100.0, 200.0); + float specularAmount = blinnSpecularContribution(diffuseAmount, lightDirection, pixelnormal, uSpecularMaterial.x, uSpecularMaterial.y); return vec2(diffuseAmount, specularAmount) * attenuation; #else return vec2(attenuation * diffuseAmount, 0.0); diff --git a/wadsrc/static/shaders/glsl/shaderdefs.i b/wadsrc/static/shaders/glsl/shaderdefs.i index 15d68428e..6836135d3 100644 --- a/wadsrc/static/shaders/glsl/shaderdefs.i +++ b/wadsrc/static/shaders/glsl/shaderdefs.i @@ -51,6 +51,9 @@ uniform int uLightIndex; // Software fuzz scaling uniform int uViewHeight; +// Blinn glossiness and specular level +uniform vec2 uSpecularMaterial; + // quad drawer stuff #ifdef USE_QUAD_DRAWER uniform mat4 uQuadVertices; From 2c9a2e7170828ac4d82b81deda0fd106b362b1cf Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Thu, 25 Jan 2018 19:59:57 +0100 Subject: [PATCH 10/11] - fix specular defaults to be a little more sane --- src/gl/textures/gl_texture.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gl/textures/gl_texture.cpp b/src/gl/textures/gl_texture.cpp index 6501d9709..7e39fd9f8 100644 --- a/src/gl/textures/gl_texture.cpp +++ b/src/gl/textures/gl_texture.cpp @@ -191,8 +191,8 @@ FTexture::MiscGLInfo::MiscGLInfo() throw() mIsTransparent = -1; shaderspeed = 1.f; shaderindex = 0; - Glossiness = 0.0f; - SpecularLevel = 0.0f; + Glossiness = 10.0f; + SpecularLevel = 0.1f; Material[1] = Material[0] = NULL; SystemTexture[1] = SystemTexture[0] = NULL; From 30af6d38b35f29c85349df89baf9f6ed73e735ab Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Thu, 25 Jan 2018 20:22:51 +0100 Subject: [PATCH 11/11] - fix automap render bug --- src/gl/renderer/gl_renderstate.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gl/renderer/gl_renderstate.cpp b/src/gl/renderer/gl_renderstate.cpp index 499303cab..593b7490e 100644 --- a/src/gl/renderer/gl_renderstate.cpp +++ b/src/gl/renderer/gl_renderstate.cpp @@ -139,7 +139,7 @@ bool FRenderState::ApplyShader() } else { - activeShader = GLRenderer->mShaderManager->Get(mTextureEnabled ? mEffectState : 4, mAlphaThreshold >= 0.f, mPassType); + activeShader = GLRenderer->mShaderManager->Get(mTextureEnabled ? mEffectState : SHADER_NoTexture, mAlphaThreshold >= 0.f, mPassType); activeShader->Bind(); }