From 7c46dace031f067e77a615d7f727ec35d9bef5d7 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 12 Apr 2020 22:42:00 +0200 Subject: [PATCH] - this still doesn't work on Vulkan. :( --- src/rendering/hwrenderer/utility/hw_shaderpatcher.cpp | 4 ++-- src/rendering/vulkan/renderer/vk_renderstate.cpp | 4 ++-- wadsrc/static/shaders/glsl/main.fp | 3 +++ 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/rendering/hwrenderer/utility/hw_shaderpatcher.cpp b/src/rendering/hwrenderer/utility/hw_shaderpatcher.cpp index cfe2b754c..626d53494 100644 --- a/src/rendering/hwrenderer/utility/hw_shaderpatcher.cpp +++ b/src/rendering/hwrenderer/utility/hw_shaderpatcher.cpp @@ -59,7 +59,7 @@ static FString NextGlslToken(const char *chars, long len, long &pos) pos = tokenEnd; return FString(chars + tokenStart, tokenEnd - tokenStart); -} +} static bool isShaderType(const char *name) { @@ -271,7 +271,7 @@ const FDefaultShader defaultshaders[] = {"Specular", "shaders/glsl/func_spec.fp", "shaders/glsl/material_specular.fp", "#define SPECULAR\n#define NORMALMAP\n"}, {"PBR","shaders/glsl/func_pbr.fp", "shaders/glsl/material_pbr.fp", "#define PBR\n#define NORMALMAP\n"}, {"Paletted", "shaders/glsl/func_paletted.fp", "shaders/glsl/material_nolight.fp", ""}, - {"No Texture", "shaders/glsl/func_notexture.fp", "shaders/glsl/material_normal.fp", ""}, + {"No Texture", "shaders/glsl/func_notexture.fp", "shaders/glsl/material_normal.fp", "#define NO_LAYERS\n"}, {"Basic Fuzz", "shaders/glsl/fuzz_standard.fp", "shaders/glsl/material_normal.fp", ""}, {"Smooth Fuzz", "shaders/glsl/fuzz_smooth.fp", "shaders/glsl/material_normal.fp", ""}, {"Swirly Fuzz", "shaders/glsl/fuzz_swirly.fp", "shaders/glsl/material_normal.fp", ""}, diff --git a/src/rendering/vulkan/renderer/vk_renderstate.cpp b/src/rendering/vulkan/renderer/vk_renderstate.cpp index 11f040320..b0851f117 100644 --- a/src/rendering/vulkan/renderer/vk_renderstate.cpp +++ b/src/rendering/vulkan/renderer/vk_renderstate.cpp @@ -228,7 +228,7 @@ void VkRenderState::ApplyRenderPass(int dt) pipelineKey.StencilPassOp = mStencilOp; pipelineKey.ColorMask = mColorMask; pipelineKey.CullMode = mCullMode; - pipelineKey.NumTextureLayers = mMaterial.mMaterial ? mMaterial.mMaterial->GetLayers() : 1; // Always force minimum 1 texture as the shader requires it + pipelineKey.NumTextureLayers = mMaterial.mMaterial ? mMaterial.mMaterial->GetLayers() : 4; // Always force minimum 1 texture as the shader requires it if (mSpecialEffect > EFF_NONE) { pipelineKey.SpecialEffect = mSpecialEffect; @@ -373,7 +373,7 @@ void VkRenderState::ApplyPushConstants() mPushConstants.uFogEnabled = fogset; int f = mTextureModeFlags; - if (!mBrightmapEnabled) f &= TEXF_Detailmap; + if (!mBrightmapEnabled) mPushConstants.uTextureMode = (mTextureMode == TM_NORMAL && tempTM == TM_OPAQUE ? TM_OPAQUE : mTextureMode) | f; mPushConstants.uLightDist = mLightParms[0]; mPushConstants.uLightFactor = mLightParms[1]; diff --git a/wadsrc/static/shaders/glsl/main.fp b/wadsrc/static/shaders/glsl/main.fp index 06011501b..8960103bf 100644 --- a/wadsrc/static/shaders/glsl/main.fp +++ b/wadsrc/static/shaders/glsl/main.fp @@ -543,6 +543,8 @@ void SetMaterialProps(inout Material material, vec2 texCoord) material.Base = getTexel(texCoord.st); material.Normal = ApplyNormalMap(texCoord.st); +// OpenGL doesn't care, but Vulkan pukes all over the place if these texture samplings are included in no-texture shaders, even though never called. +#ifndef NO_LAYERS if ((uTextureMode & TEXF_Brightmap) != 0) material.Bright = texture(brighttexture, texCoord.st); @@ -554,6 +556,7 @@ void SetMaterialProps(inout Material material, vec2 texCoord) if ((uTextureMode & TEXF_Glowmap) != 0) material.Glow = texture(glowtexture, texCoord.st); +#endif } //===========================================================================