Skip to content

Commit

Permalink
bugfix: resolve ghost particles
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Pollind <[email protected]>
  • Loading branch information
pollend committed Nov 6, 2023
1 parent 1ae76a7 commit 0ca90a4
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 16 deletions.
3 changes: 0 additions & 3 deletions HPL2/include/graphics/DrawPacket.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,10 @@ namespace hpl {
return m_unified.m_numIndices;
case DrawPacketType::DrawIndvidualBuffers:
return m_indvidual.m_numIndices;
default:
break;
}
return 0;
}


static void cmdBindBuffers(Cmd* cmd, ForgeRenderer::CommandResourcePool* resourcePool, DrawPacket* packet);

DrawPacket()
Expand Down
2 changes: 1 addition & 1 deletion HPL2/resource/translucency_particle.frag.fsl
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ float4 PS_MAIN(PsIn In)
}
}

if(finalColor.a == 0.0) {
if(finalColor.a < 0.01) {
discard;
}
RETURN(finalColor);
Expand Down
18 changes: 7 additions & 11 deletions HPL2/sources/graphics/RendererDeferred.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2433,8 +2433,6 @@ namespace hpl {
std::unique_ptr<iVertexBuffer>(loadVertexBufferFromMesh("core_5_5_sphere.dae", lVtxFlag));
m_shapePyramid = std::unique_ptr<iVertexBuffer>(loadVertexBufferFromMesh("core_pyramid.dae", lVtxFlag));
m_box = std::unique_ptr<iVertexBuffer>(loadVertexBufferFromMesh("core_box.dae", lVtxFlag));
////////////////////////////////////
// Batch vertex buffer
}

cRendererDeferred::~cRendererDeferred() {
Expand Down Expand Up @@ -4608,29 +4606,26 @@ namespace hpl {
switch (pMaterial->Descriptor().m_id) {
case MaterialID::Translucent:
{
// LegacyVertexBuffer::GeometryBinding binding;
DrawPacket drawPacket;
if (isParticleEmitter) {
std::array targets = { eVertexBufferElement_Position,
eVertexBufferElement_Texture0,
eVertexBufferElement_Color0 };
drawPacket = translucencyItem->ResolveDrawPacket(frame, targets);
if (drawPacket.m_type == DrawPacket::Unknown && drawPacket.numberOfIndecies() == 0) {
break;
}

} else {
std::array targets = { eVertexBufferElement_Position,
eVertexBufferElement_Texture0,
eVertexBufferElement_Normal,
eVertexBufferElement_Texture1Tangent,
eVertexBufferElement_Color0 };
drawPacket = translucencyItem->ResolveDrawPacket(frame, targets);
if (drawPacket.m_type == DrawPacket::Unknown && drawPacket.numberOfIndecies() == 0) {
break;
}
}
if (drawPacket.m_type == DrawPacket::Unknown ||
drawPacket.numberOfIndecies() == 0) {
break;
}


uint32_t instance = cmdBindMaterialAndObject(
frame.m_cmd, frame, pMaterial, translucencyItem, std::optional{ pMatrix ? *pMatrix : cMatrixf::Identity });
materialConst.objectId = instance;
Expand All @@ -4657,7 +4652,8 @@ namespace hpl {
DrawPacket::cmdBindBuffers(frame.m_cmd, frame.m_resourcePool, &drawPacket);

materialConst.m_options = (isFogActive ? TranslucencyFlags::UseFog : 0) |
(isRefraction ? TranslucencyFlags::UseRefractionTrans : 0) | translucencyBlendTable[pMaterial->GetBlendMode()];
(isRefraction ? TranslucencyFlags::UseRefractionTrans : 0) |
translucencyBlendTable[pMaterial->GetBlendMode()];

cmdBindPushConstants(frame.m_cmd, m_materialRootSignature.m_handle, materialObjectIndex, &materialConst);
cmdDrawIndexed(frame.m_cmd, drawPacket.numberOfIndecies(), 0, 0);
Expand Down
3 changes: 2 additions & 1 deletion HPL2/sources/impl/LegacyVertexBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,8 @@ namespace hpl {
stream.m_offset = found->m_activeCopy * found->m_shadowData.size();
stream.m_stride = found->Stride();
}
uint32_t numIndecies = (GetRequestNumberIndecies() > 0) ? GetRequestNumberIndecies() : static_cast<uint32_t>(m_indices.size()) ;
const int requestNumIndecies = GetRequestNumberIndecies();
const uint32_t numIndecies = (requestNumIndecies >= 0) ? requestNumIndecies : static_cast<uint32_t>(m_indices.size()) ;
packet.m_indvidual.m_indexStream.m_offset = m_indexBufferActiveCopy * m_indices.size() * sizeof(uint32_t);
packet.m_indvidual.m_numIndices = numIndecies;
packet.m_indvidual.m_indexStream.buffer = &m_indexBuffer;
Expand Down

0 comments on commit 0ca90a4

Please sign in to comment.