From e261abfbc95ba1fa478271692a631a8f339959fb Mon Sep 17 00:00:00 2001 From: VReaperV Date: Sat, 11 Jan 2025 15:36:49 +0300 Subject: [PATCH] Fix dynamic lights with material system The UBO bindings were conflicting with light UBO. --- src/engine/renderer/Material.cpp | 6 +++--- src/engine/renderer/gl_shader.cpp | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/engine/renderer/Material.cpp b/src/engine/renderer/Material.cpp index b7e5e9bb27..cc5600d399 100644 --- a/src/engine/renderer/Material.cpp +++ b/src/engine/renderer/Material.cpp @@ -37,9 +37,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "Material.h" #include "ShadeCommon.h" -GLUBO materialsUBO( "materials", 0, GL_MAP_WRITE_BIT, GL_MAP_INVALIDATE_RANGE_BIT ); -GLBuffer texDataBuffer( "texData", 6, GL_MAP_WRITE_BIT, GL_MAP_FLUSH_EXPLICIT_BIT ); -GLUBO lightmapDataUBO( "texData", 7, GL_MAP_WRITE_BIT, GL_MAP_FLUSH_EXPLICIT_BIT ); +GLUBO materialsUBO( "materials", 6, GL_MAP_WRITE_BIT, GL_MAP_INVALIDATE_RANGE_BIT ); +GLBuffer texDataBuffer( "texData", 7, GL_MAP_WRITE_BIT, GL_MAP_FLUSH_EXPLICIT_BIT ); +GLUBO lightmapDataUBO( "texData", 8, GL_MAP_WRITE_BIT, GL_MAP_FLUSH_EXPLICIT_BIT ); GLSSBO surfaceDescriptorsSSBO( "surfaceDescriptors", 1, GL_MAP_WRITE_BIT, GL_MAP_INVALIDATE_RANGE_BIT ); GLSSBO surfaceCommandsSSBO( "surfaceCommands", 2, GL_MAP_WRITE_BIT, GL_MAP_FLUSH_EXPLICIT_BIT ); diff --git a/src/engine/renderer/gl_shader.cpp b/src/engine/renderer/gl_shader.cpp index 3c1a5ef2ab..26bfc75895 100644 --- a/src/engine/renderer/gl_shader.cpp +++ b/src/engine/renderer/gl_shader.cpp @@ -1361,15 +1361,15 @@ std::string GLShaderManager::ShaderPostProcess( GLShader *shader, const std::str std::string materialStruct = "\nstruct Material {\n"; // 6 kb for materials const uint32_t count = ( 4096 + 2048 ) / shader->GetPaddedSize(); - std::string materialBlock = "layout(std140, binding = 0) uniform materialsUBO {\n" + std::string materialBlock = "layout(std140, binding = 6) uniform materialsUBO {\n" " Material materials[" + std::to_string( count ) + "]; \n" "};\n\n"; std::string texBuf = glConfig2.maxUniformBlockSize >= MIN_MATERIAL_UBO_SIZE ? - "layout(std140, binding = 6) uniform texDataUBO {\n" + "layout(std140, binding = 7) uniform texDataUBO {\n" " TexData texData[" + std::to_string( MAX_TEX_BUNDLES ) + "]; \n" "};\n\n" - : "layout(std430, binding = 6) restrict readonly buffer texDataSSBO {\n" + : "layout(std430, binding = 7) restrict readonly buffer texDataSSBO {\n" " TexData texData[];\n" "};\n\n"; // We have to store these as a bunch of vec4/uvec4 because std140 pads everything to a vec4 @@ -1390,7 +1390,7 @@ std::string GLShaderManager::ShaderPostProcess( GLShader *shader, const std::str " uvec2 u_LightMap;\n" " uvec2 u_DeluxeMap;\n" "};\n\n" - "layout(std140, binding = 7) uniform lightmapDataUBO {\n" + "layout(std140, binding = 8) uniform lightmapDataUBO {\n" " LightMapData lightmapData[256];\n" "};\n\n" "#define u_LightMap_initial lightmapData[( baseInstance >> 24 ) & 0xFF].u_LightMap\n"