Skip to content

Commit

Permalink
Fix rendering portals
Browse files Browse the repository at this point in the history
  • Loading branch information
SaiyansKing committed Oct 31, 2023
1 parent 2c21615 commit 095ebcb
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 16 deletions.
16 changes: 9 additions & 7 deletions D3D11Engine/D3D11GraphicsEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2759,16 +2759,18 @@ XRESULT D3D11GraphicsEngine::DrawWorldMesh( bool noTextures ) {
key.Texture = aniTex;
}

if ( worldMesh.first.Info->MaterialType == MaterialInfo::MT_Portal ) {
FrameTransparencyMeshesPortal.push_back( worldMesh );
continue;
} else if ( worldMesh.first.Info->MaterialType == MaterialInfo::MT_WaterfallFoam ) {
FrameTransparencyMeshesWaterfall.push_back( worldMesh );
continue;
}

// Check for alphablending
if ( worldMesh.first.Material->GetAlphaFunc() > zMAT_ALPHA_FUNC_NONE &&
worldMesh.first.Material->GetAlphaFunc() != zMAT_ALPHA_FUNC_TEST ) {
if ( worldMesh.first.Info->MaterialType == MaterialInfo::MT_Portal ) {
FrameTransparencyMeshesPortal.push_back( worldMesh );
} else if ( worldMesh.first.Info->MaterialType == MaterialInfo::MT_WaterfallFoam ) {
FrameTransparencyMeshesWaterfall.push_back( worldMesh );
} else {
FrameTransparencyMeshes.push_back( worldMesh );
}
FrameTransparencyMeshes.push_back( worldMesh );
} else {
// Create a new pair using the animated texture
meshList.emplace_back( key, worldMesh.second );
Expand Down
19 changes: 11 additions & 8 deletions D3D11Engine/WorldConverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -352,16 +352,19 @@ HRESULT WorldConverter::ConvertWorldMesh( zCPolygon** polys, unsigned int numPol
continue;
}

//Flag portals so that we can apply a different PS shader later
if ( poly->GetPolyFlags()->PortalPoly && poly->GetMaterial()->GetTexture() ) {
std::string textureName = poly->GetMaterial()->GetTexture()->GetNameWithoutExt();
if ( textureName == "OWODFLWOODGROUND" ) {
continue; //this is a ground texture that is sometimes re-used for visual tricks to darken tunnels, etc. We don't want to treat this as a portal.
} else {
MaterialInfo* info = Engine::GAPI->GetMaterialInfoFrom( poly->GetMaterial()->GetTexture() );
if ( info ) {
// Flag portals so that we can apply a different PS shader later
if ( poly->GetPolyFlags()->PortalPoly ) {
zCMaterial* polymat = poly->GetMaterial();
if ( zCTexture* tex = polymat->GetTextureSingle() ) {
std::string textureName = tex->GetNameWithoutExt();
if ( textureName == "OWODFLWOODGROUND" ) {
continue; // this is a ground texture that is sometimes re-used for visual tricks to darken tunnels, etc. We don't want to treat this as a portal.
} else {
MaterialInfo* info = Engine::GAPI->GetMaterialInfoFrom( tex );
info->MaterialType = MaterialInfo::MT_Portal;
}
} else {
continue;
}
}

Expand Down
2 changes: 1 addition & 1 deletion D3D11Engine/zCMaterial.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ class zCMaterial {
}

bool HasTexAniMap() {
return *reinterpret_cast<unsigned char*>(THISPTR_OFFSET( GothicMemoryLocations::zCMaterial::Offset_AlphaFunc )) & GothicMemoryLocations::zCMaterial::Mask_FlagTexAniMap;
return *reinterpret_cast<unsigned char*>(THISPTR_OFFSET( GothicMemoryLocations::zCMaterial::Offset_Flags )) & GothicMemoryLocations::zCMaterial::Mask_FlagTexAniMap;
}

XMFLOAT2 GetTexAniMapDelta() {
Expand Down

0 comments on commit 095ebcb

Please sign in to comment.