diff --git a/Include/RTGL1/RTGL1.h b/Include/RTGL1/RTGL1.h index f14ffe36..0f54d57a 100644 --- a/Include/RTGL1/RTGL1.h +++ b/Include/RTGL1/RTGL1.h @@ -369,6 +369,12 @@ typedef enum RgMeshInfoFlagBits RG_MESH_EXPORT_AS_SEPARATE_FILE = 1 << 0, RG_MESH_FIRST_PERSON = 1 << 1, RG_MESH_FIRST_PERSON_VIEWER = 1 << 2, + // Force all primitives of this mesh to be a mirror. Useful for overriding replacement RgMeshPrimitiveFlags. + RG_MESH_FORCE_MIRROR = 1 << 3, + // Force all primitives of this mesh to be a glass. Useful for overriding replacement RgMeshPrimitiveFlags. + RG_MESH_FORCE_GLASS = 1 << 4, + // Force all primitives of this mesh to be a water. Useful for overriding replacement RgMeshPrimitiveFlags. + RG_MESH_FORCE_WATER = 1 << 5, } RgMeshInfoFlagBits; typedef uint32_t RgMeshInfoFlags; diff --git a/Source/ASManager.cpp b/Source/ASManager.cpp index 8106c335..4ddc666a 100644 --- a/Source/ASManager.cpp +++ b/Source/ASManager.cpp @@ -873,7 +873,7 @@ bool RTGL1::ASManager::AddMeshPrimitive( uint32_t frameIndex, .prevModel_1 = { /* set in geomInfoManager */ }, .prevModel_2 = { /* set in geomInfoManager */ }, - .flags = GeomInfoManager::GetPrimitiveFlags( primitive, !isStatic && !isReplacement ), + .flags = GeomInfoManager::GetPrimitiveFlags( &mesh, primitive, !isStatic && !isReplacement ), .texture_base = layerTextures[ 0 ].indices[ TEXTURE_ALBEDO_ALPHA_INDEX ], .texture_base_ORM = diff --git a/Source/GeomInfoManager.cpp b/Source/GeomInfoManager.cpp index aca74f26..f306a29e 100644 --- a/Source/GeomInfoManager.cpp +++ b/Source/GeomInfoManager.cpp @@ -109,7 +109,9 @@ const RgFloat2D* RTGL1::GeomInfoManager::AccessLayerTexCoords( const RgMeshPrimi return nullptr; } -uint32_t RTGL1::GeomInfoManager::GetPrimitiveFlags( const RgMeshPrimitiveInfo& info, bool isDynamicVertexData ) +uint32_t RTGL1::GeomInfoManager::GetPrimitiveFlags( const RgMeshInfo* mesh, + const RgMeshPrimitiveInfo& info, + bool isDynamicVertexData ) { uint32_t f = 0; @@ -126,12 +128,14 @@ uint32_t RTGL1::GeomInfoManager::GetPrimitiveFlags( const RgMeshPrimitiveInfo& i f |= GetMaterialBlendFlags( *layers, 3 ); } - if( info.flags & RG_MESH_PRIMITIVE_MIRROR ) + if( ( info.flags & RG_MESH_PRIMITIVE_MIRROR ) || + ( mesh && ( mesh->flags & RG_MESH_FORCE_MIRROR ) ) ) { f |= GEOM_INST_FLAG_REFLECT; } - if( info.flags & RG_MESH_PRIMITIVE_WATER ) + if( ( info.flags & RG_MESH_PRIMITIVE_WATER ) || + ( mesh && ( mesh->flags & RG_MESH_FORCE_WATER ) ) ) { f |= GEOM_INST_FLAG_MEDIA_TYPE_WATER; f |= GEOM_INST_FLAG_REFLECT; @@ -145,7 +149,8 @@ uint32_t RTGL1::GeomInfoManager::GetPrimitiveFlags( const RgMeshPrimitiveInfo& i f |= GEOM_INST_FLAG_REFRACT; } - if( info.flags & RG_MESH_PRIMITIVE_GLASS ) + if( ( info.flags & RG_MESH_PRIMITIVE_GLASS ) || + ( mesh && ( mesh->flags & RG_MESH_FORCE_GLASS ) ) ) { f |= GEOM_INST_FLAG_MEDIA_TYPE_GLASS; f |= GEOM_INST_FLAG_REFLECT; diff --git a/Source/GeomInfoManager.h b/Source/GeomInfoManager.h index 2bdf911f..a96209dd 100644 --- a/Source/GeomInfoManager.h +++ b/Source/GeomInfoManager.h @@ -75,7 +75,9 @@ class GeomInfoManager static bool LayerExists( const RgMeshPrimitiveInfo& info, uint32_t layerIndex ); - static uint32_t GetPrimitiveFlags( const RgMeshPrimitiveInfo& info, bool isDynamicVertexData ); + static uint32_t GetPrimitiveFlags( const RgMeshInfo* mesh, + const RgMeshPrimitiveInfo& info, + bool isDynamicVertexData ); static const RgFloat2D* AccessLayerTexCoords( const RgMeshPrimitiveInfo& info, uint32_t layerIndex ); diff --git a/Source/RasterizedDataCollector.cpp b/Source/RasterizedDataCollector.cpp index 18028a8c..cf4ad698 100644 --- a/Source/RasterizedDataCollector.cpp +++ b/Source/RasterizedDataCollector.cpp @@ -232,7 +232,7 @@ void RTGL1::RasterizedDataCollector::AddPrimitive( uint32_t fr PushInfo( rasterType ) = { .transform = transform, - .flags = GeomInfoManager::GetPrimitiveFlags( info, false ), + .flags = GeomInfoManager::GetPrimitiveFlags( nullptr, info, false ), .texture_base = textures[ 0 ].indices[ TEXTURE_ALBEDO_ALPHA_INDEX ], .texture_base_ORM = textures[ 0 ].indices[ TEXTURE_OCCLUSION_ROUGHNESS_METALLIC_INDEX ], diff --git a/Source/VertexCollectorFilterType.cpp b/Source/VertexCollectorFilterType.cpp index ba24fa98..4eb2b97d 100644 --- a/Source/VertexCollectorFilterType.cpp +++ b/Source/VertexCollectorFilterType.cpp @@ -83,7 +83,9 @@ FL RTGL1::VertexCollectorFilterTypeFlags_GetForGeometry( const RgMeshInfo& flags |= FL( FT::PT_ALPHA_TESTED ); } else if( ( primitive.flags & RG_MESH_PRIMITIVE_WATER ) || + ( mesh.flags & RG_MESH_FORCE_WATER ) || ( primitive.flags & RG_MESH_PRIMITIVE_GLASS ) || + ( mesh.flags & RG_MESH_FORCE_GLASS ) || ( primitive.flags & RG_MESH_PRIMITIVE_GLASS_IF_SMOOTH ) || ( primitive.flags & RG_MESH_PRIMITIVE_ACID ) ) { diff --git a/Source/VulkanDevice.cpp b/Source/VulkanDevice.cpp index 8cd302b1..bb2c3fbb 100644 --- a/Source/VulkanDevice.cpp +++ b/Source/VulkanDevice.cpp @@ -985,7 +985,9 @@ namespace } if( !( primitive.flags & RG_MESH_PRIMITIVE_GLASS ) && + !( mesh.flags & RG_MESH_FORCE_GLASS ) && !( primitive.flags & RG_MESH_PRIMITIVE_WATER ) && + !( mesh.flags & RG_MESH_FORCE_WATER ) && !( primitive.flags & RG_MESH_PRIMITIVE_ACID ) ) { if( primitive.flags & RG_MESH_PRIMITIVE_TRANSLUCENT )