Skip to content

Commit

Permalink
Fix dynamic lights with material system
Browse files Browse the repository at this point in the history
The UBO bindings were conflicting with light UBO.
  • Loading branch information
VReaperV committed Jan 17, 2025
1 parent 8750ff5 commit b8531e7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/engine/renderer/Material.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
8 changes: 4 additions & 4 deletions src/engine/renderer/gl_shader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 u_TextureMatrix as vec4 + vec2 because otherwise it would be aligned to a vec4 under std140
Expand All @@ -1393,7 +1393,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"
Expand Down

0 comments on commit b8531e7

Please sign in to comment.