Skyspheres and Pointsprites, zbuffer issiue
I am trying to setup a sort method for my renderer container, im currently using a stl deque, I push_back objects that zbuffer check, and i push_front objects that disable the zbuffer check state, problem is, my skysphere should be the last object of the nonzbuffer objects to be drawn, and im not sure how to do this. my point sprites are drawing second, and i see the skysphere background always in their texture alpha.
sorry if this dosent make too much sense, ive stayed up way passed my bedtime to try and figure out a way to do this, but no luck :/
Don't draw the sky last. In fact, draw it first. Turn off depth writes, and draw a very small sphere that is just outside the near clip plane. Then proceed to normal rendering. You also get to skip clearing the frame buffer this way too.
well, ill just put in my 2 cents, just really passing along information, you might want to look into it ect. anyways, the info was that drawing the skybox first is a fill rate killer, which is obvious, now, i dont know exactly how fill rate limited we are these days, but its just a thought
hope that helps
-Dan
hope that helps
-Dan
Ah i described that wrong.
my renderer list looks like this.
front*******************back
|--------------|--------------|
***nonzbuffer******zbuffer***
my scene graph is at the front of the nonzbuffer, and my pointsprites are next to the scenegraph, and my planets and space station follow that and end up in the back.
problem is, my point sprites draw with the skysphere texture in their alpha component of their texture, so it looks really bad.
also if i try to push the point sprites to the back of the list, they dont draw at all.
my renderer list looks like this.
front*******************back
|--------------|--------------|
***nonzbuffer******zbuffer***
my scene graph is at the front of the nonzbuffer, and my pointsprites are next to the scenegraph, and my planets and space station follow that and end up in the back.
problem is, my point sprites draw with the skysphere texture in their alpha component of their texture, so it looks really bad.
also if i try to push the point sprites to the back of the list, they dont draw at all.
I just thought it could be my alpha blending
HRESULT Emitter::PreRender()
{
Engine::mp_Render->GetD3DRender()->SetRenderState(D3DRS_LIGHTING, false);
Engine::mp_Render->GetD3DRender()->SetRenderState( D3DRS_POINTSPRITEENABLE, TRUE ); // Turn on point sprites
Engine::mp_Render->GetD3DRender()->SetRenderState( D3DRS_POINTSCALEENABLE, TRUE ); // Allow sprites to be scaled with distance
Engine::mp_Render->GetD3DRender()->SetRenderState( D3DRS_POINTSIZE, FtoDW( m_ParticleSize ) ); // Float value that specifies the size to use for point size computation in cases where point size is not specified for each vertex.
Engine::mp_Render->GetD3DRender()->SetRenderState( D3DRS_POINTSIZE_MIN, FtoDW(0.0f) ); // Float value that specifies the minimum size of point primitives. Point primitives are clamped to this size during rendering.
Engine::mp_Render->GetD3DRender()->SetTexture( 0, m_pTexture );
Engine::mp_Render->GetD3DRender()->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_MODULATE);
Engine::mp_Render->GetD3DRender()->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
Engine::mp_Render->GetD3DRender()->SetTextureStageState(0, D3DTSS_ALPHAARG2, D3DTA_CURRENT);
Engine::mp_Render->GetD3DRender()->SetRenderState( D3DRS_ALPHABLENDENABLE, TRUE );
Engine::mp_Render->GetD3DRender()->SetRenderState( D3DRS_SRCBLEND, D3DBLEND_SRCALPHA );
Engine::mp_Render->GetD3DRender()->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_ONE );
//
// Set up the render states for using point sprites...
//
Engine::mp_Render->GetD3DRender()->SetRenderState( D3DRS_POINTSCALE_A, FtoDW(0.0f) ); // Default 1.0
Engine::mp_Render->GetD3DRender()->SetRenderState( D3DRS_POINTSCALE_B, FtoDW(0.0f) ); // Default 0.0
Engine::mp_Render->GetD3DRender()->SetRenderState( D3DRS_POINTSCALE_C, FtoDW(1.0f) ); // Default 0.0
return S_OK;
}
HRESULT Emitter::PostRender()
{
//
// Reset render states...
//
Engine::mp_Render->GetD3DRender()->SetRenderState( D3DRS_POINTSPRITEENABLE, FALSE );
Engine::mp_Render->GetD3DRender()->SetRenderState( D3DRS_POINTSCALEENABLE, FALSE );
Engine::mp_Render->GetD3DRender()->SetRenderState( D3DRS_ALPHABLENDENABLE, FALSE );
Engine::mp_Render->GetD3DRender()->SetRenderState(D3DRS_LIGHTING, true);
return S_OK;
}
HRESULT Emitter::PreRender()
{
Engine::mp_Render->GetD3DRender()->SetRenderState(D3DRS_LIGHTING, false);
Engine::mp_Render->GetD3DRender()->SetRenderState( D3DRS_POINTSPRITEENABLE, TRUE ); // Turn on point sprites
Engine::mp_Render->GetD3DRender()->SetRenderState( D3DRS_POINTSCALEENABLE, TRUE ); // Allow sprites to be scaled with distance
Engine::mp_Render->GetD3DRender()->SetRenderState( D3DRS_POINTSIZE, FtoDW( m_ParticleSize ) ); // Float value that specifies the size to use for point size computation in cases where point size is not specified for each vertex.
Engine::mp_Render->GetD3DRender()->SetRenderState( D3DRS_POINTSIZE_MIN, FtoDW(0.0f) ); // Float value that specifies the minimum size of point primitives. Point primitives are clamped to this size during rendering.
Engine::mp_Render->GetD3DRender()->SetTexture( 0, m_pTexture );
Engine::mp_Render->GetD3DRender()->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_MODULATE);
Engine::mp_Render->GetD3DRender()->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
Engine::mp_Render->GetD3DRender()->SetTextureStageState(0, D3DTSS_ALPHAARG2, D3DTA_CURRENT);
Engine::mp_Render->GetD3DRender()->SetRenderState( D3DRS_ALPHABLENDENABLE, TRUE );
Engine::mp_Render->GetD3DRender()->SetRenderState( D3DRS_SRCBLEND, D3DBLEND_SRCALPHA );
Engine::mp_Render->GetD3DRender()->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_ONE );
//
// Set up the render states for using point sprites...
//
Engine::mp_Render->GetD3DRender()->SetRenderState( D3DRS_POINTSCALE_A, FtoDW(0.0f) ); // Default 1.0
Engine::mp_Render->GetD3DRender()->SetRenderState( D3DRS_POINTSCALE_B, FtoDW(0.0f) ); // Default 0.0
Engine::mp_Render->GetD3DRender()->SetRenderState( D3DRS_POINTSCALE_C, FtoDW(1.0f) ); // Default 0.0
return S_OK;
}
HRESULT Emitter::PostRender()
{
//
// Reset render states...
//
Engine::mp_Render->GetD3DRender()->SetRenderState( D3DRS_POINTSPRITEENABLE, FALSE );
Engine::mp_Render->GetD3DRender()->SetRenderState( D3DRS_POINTSCALEENABLE, FALSE );
Engine::mp_Render->GetD3DRender()->SetRenderState( D3DRS_ALPHABLENDENABLE, FALSE );
Engine::mp_Render->GetD3DRender()->SetRenderState(D3DRS_LIGHTING, true);
return S_OK;
}
i ruled out blending being a factor to this proble.
I commented out the blending code, and my point sprites still didnt draw when i put them last on the renderer.
I had z testing on, but z writing disabled, I tried a few combinations with no luck.
I commented out the blending code, and my point sprites still didnt draw when i put them last on the renderer.
I had z testing on, but z writing disabled, I tried a few combinations with no luck.
So you have 3 things you're drawing: skysphere, point sprites, and "scene graph" which I take to mean level geometry or something.
You say you're getting the sky sphere texture in the alpha component of the point sprites. My best guess is that you're describing the effect of the point sprites occluding the level geometry, so that the sky sphere shows up behind.
This suggests that your draw order is [sky sphere] [point sprites] scene graph].
I suggest trying the draw order [sky sphere] [scene graph] [point sprites].
If this doesn't help or is otherwise not applicable, then I guess I've misunderstood your description.
You say you're getting the sky sphere texture in the alpha component of the point sprites. My best guess is that you're describing the effect of the point sprites occluding the level geometry, so that the sky sphere shows up behind.
This suggests that your draw order is [sky sphere] [point sprites] scene graph].
I suggest trying the draw order [sky sphere] [scene graph] [point sprites].
If this doesn't help or is otherwise not applicable, then I guess I've misunderstood your description.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement