Skip to content

Commit

Permalink
Mesh flags to override replacements
Browse files Browse the repository at this point in the history
  • Loading branch information
sultim-t committed Dec 2, 2023
1 parent 8759591 commit f6ca972
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 7 deletions.
6 changes: 6 additions & 0 deletions Include/RTGL1/RTGL1.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion Source/ASManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down
13 changes: 9 additions & 4 deletions Source/GeomInfoManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;
Expand All @@ -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;
Expand Down
4 changes: 3 additions & 1 deletion Source/GeomInfoManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
2 changes: 1 addition & 1 deletion Source/RasterizedDataCollector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 ],
Expand Down
2 changes: 2 additions & 0 deletions Source/VertexCollectorFilterType.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) )
{
Expand Down
2 changes: 2 additions & 0 deletions Source/VulkanDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand Down

0 comments on commit f6ca972

Please sign in to comment.