i made a model which is made out of a high poly mesh and a low poly collisionmesh. the high poly mesh gets an alphastate, and the collision mesh is made invisible via setCullMode(SceneElement.Cull_always).
the collision mesh is now invisible, but the invisible triangles are causing the alphablended triangles behind it not to be rendered. looks like they are "rendered to the z-buffer but not on the screen". how can i fix this?
Try to put the collisionmodel on the TRANSPARENT QUEUE render. It will "render" the collisionmodel after the realmodel.
HamsterofDeath said:
the collision mesh is now invisible, but the invisible triangles are causing the alphablended triangles behind it not to be rendered.
I highly doubt that if you do not use any occlusion culling techniques. The z-buffer should not be affected by culled geometry. Probably the effect is caused by other things?
irrisor said:
I highly doubt that if you do not use any occlusion culling techniques. The z-buffer should not be affected by culled geometry. Probably the effect is caused by other things?
Agreed. What does it look like if you leave out the collision mesh and just attach the hi-poly model?
Setting the cull hint to "Always" will not try to render the model at all. The issue is somewhere else.
i did a few tests. everything is rendered correctly if i use an alpha test instead of blending:
final AlphaState l_alphaState = Core.getInstance().getSharedRenderStates().getDefaultAlphaTestState();
l_alphaState.setReference(0.5F);
l_alphaState.setTestEnabled(true);
l_alphaState.setTestFunction(AlphaState.TF_GREATER);
p_o.setRenderState(l_alphaState);
p_o.updateRenderState();
}
public AlphaState getDefaultAlphaTestState()
{
if (m_defaultAlphaTestState == null)
{
m_defaultAlphaTestState = m_core.getDisplay().getRenderer().createAlphaState();
m_defaultAlphaTestState.setReference(0.1F);
m_defaultAlphaTestState.setTestEnabled(true);
m_defaultAlphaTestState.setTestFunction(AlphaState.TF_GREATER);
m_defaultAlphaTestState.setEnabled(true);
}
return m_defaultAlphaTestState;
if i use blending, parts of the model are missing.:
public AlphaState getDefaultAlphaState()
{
if (m_defaultAlphaStateTransparent == null)
{
m_defaultAlphaStateTransparent = m_core.getDisplay().getRenderer().createAlphaState();
m_defaultAlphaStateTransparent.setReference(0.0F);
m_defaultAlphaStateTransparent.setBlendEnabled(true);
m_defaultAlphaStateTransparent.setSrcFunction(AlphaState.SB_SRC_ALPHA);
m_defaultAlphaStateTransparent.setDstFunction(AlphaState.DB_ONE_MINUS_SRC_ALPHA);
m_defaultAlphaStateTransparent.setEnabled(true);
}
return m_defaultAlphaStateTransparent;
}
final AlphaState l_alphaState = Core.getInstance().getSharedRenderStates().getDefaultAlphaState();
p_o.setRenderState(l_alphaState);
p_o.updateRenderState();
p_o.setRenderQueueMode(Renderer.QUEUE_TRANSPARENT);
should i tell the zbuffer not to write?
yep, solved
another problem:
particle effects are only shown when there is no alphablended triangle at the pixels where to particle should be renderes.
example:
player here projectile here alphablended objects here
the alphablended projectile is invisible, except where the alphablended/tested (tested both) object is invisible or if there are only solid objects. the renderqueue for particles is the to transparent. what else could cause the problem?
If both the particles and the alpha blended object are in the transparent queue, they should be sorted so that they are drawn correctly.