blending /depth_test

nv_dv

Newcomer
trying to render multiple aplha maps ONE_MINUS_SRC.... but
blending seems to only works with object rendered from back to top :???:

eg: A is rendered before B , but B is lower (on depth_test)



/////////////////////////////// Render tree (stock) /////////////////////////////////

Code:
vtx_smap(){
	extern m_cnt,m_start;
	extern f_cnt,f_start;

	struct vtx_flg *rend;
	struct vtx_map *midx;
	struct vtx *vec;

	uint x,i,j;

	rend= f_start; 
	midx= m_start; 
	vec= v_start;

	//----------------------------------------- LAYER
	for( x=0; x < activl ; x++){


		////// texture
		if( rend->flg&VL_TEX){
			activtex( rend->rsd, rend->tex);
			glEnable( GL_TEXTURE_2D);	
		}

			///////////////////////////////
			if( rend->flg&VL_RS)	glDepthMask( GL_FALSE);
			//////////////////////////////

		////////// blend	
		if( rend->flg&VL_MASK ){
		glEnable( GL_BLEND);
			/* high_light  */
			if( rend->flg&VL_LONL) glBlendFunc( GL_SRC_ALPHA, GL_ONE);
			/* alpha channel */
			if( rend->flg&VL_AC) glBlendFunc( GL_SRC_ALPHA , GL_ONE_MINUS_SRC_ALPHA); 
			/* overlay  */
			if( rend->flg&VL_OL) glBlendFunc( GL_DST_COLOR, GL_DST_COLOR); 
			
		}


	glBegin( GL_TRIANGLE_STRIP);

		for( i= 0; i < rend->idxL; i++){ //IDXL


 			for( j= 1; j < midx->idx ;j++)
			if( j < v_cnt)
			vec= vec->next;
		

			if( rend->flg&VL_SUV)
				glTexCoord2f( midx->s, midx->t);
		
			else
				glTexCoord2f( vec->s, vec->t);
		
			
			if( rend->flg&VL_SRGB)
				glColor4ub( midx->r, midx->g, midx->b, midx->a);
	
			else
				glColor4ub( vec->r, vec->g, vec->b, vec->a);
		

			glVertex3f( vec->x, vec->y, vec->z);


		vec= v_start;
		midx= midx->next;

		}//--------------------------- IDXL


	glEnd();

	////////////////////////////
	if( rend->flg&VL_TEX) glDisable( GL_TEXTURE_2D);
	///////////////////////////////
	if( rend->flg&VL_RS)	glDepthMask( GL_TRUE);
	//////////////////////////////
	if( rend->flg&VL_MASK) glDisable( GL_BLEND);
	

	rend= rend->next;
	}//f_cnt -----------------------LAYER
}



init()
----------------------------------------------------------------------------
glClearColor( r, g, b, a); //default bg
//default matrix is on modelview


//glMatrixMode( GL_MODELVIEW); //default
//glLoadIdentity();


glPerspecv( view); //NEHE
set_vpos( v_pos); //set cam

glCullFace( GL_BACK);
glPointSize( 1.5);
glEnable( GL_CULL_FACE);
--------------------------------------------------------------------------------

render()
--------------------------------------------------------------------------------------------
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );


extern float v_pos[3]; //view pos (z)



glPushMatrix();
////////////////////// view dist
set_vpos( v_pos);
////////////////////////////////

glRotatef( rt[0], 1.0,.0,.0);
glRotatef( rt[1], .0,1.0,.0);
glTranslatef( wt[0], wt[1], wt[2]);

glPushMatrix();

///////////////////////////////////////////////////////
glEnable( GL_DEPTH_TEST);


vtx_smap(); //<---------------------- render tree + enable/disable Blend


glDisable( GL_DEPTH_TEST);
///////////////////////////////////////////////////////

glPopMatrix();

glPopMatrix();

vtx_menu( -0.55,0.12,1,28);

cursor( tool);

=================================================

is there any way you can correctly blend surfaces regardless of rendering order
 
Last edited by a moderator:
Look for a method titled order independent transparency with linked lists. AMD published details about a method and Intel has as well.
 
As 3dcgi says, both AMD and intel have papers on this, with slightly different approaches.
Here is a nice presentation, with informative pictures, of AMDs solution. And here you can find Intels GDC presentation and source code.


But I recommend that you look at what Cyril Crassin has done, since he too is using OpenGL. You should be able to re-implement it with standard OpenGL, and if you want to save space you can use intels AT approach with it.
 
That reply makes it sound like you think the above solutions will not work on nv hardware

not at all :LOL:, i was reffering the other platform as an old embded system using a PVR gpu
apparently there's automatic OIT support in hardware

@MrGaribaldi
thanks
 
Last edited by a moderator:
not at all :LOL:, i was reffering the other platform as an old embded system using a PVR gpu
apparently there's automatic OIT support in hardware

@MrGaribaldi
thanks

That would be a Dreamcast or a Naomi arcade board, as they are the only ones featuring that capability. (AFAIK)
 
OIT is supported on SGX as long as depth writes are disabled. (AFAIK)

Nope. I think Imagination stopped doing OIT way back sometime in the dreamcast timeframe.

Current Imagination devices will always blend strictly in submission order, just like every other GPU (and like OGL/D3D mandate).
 
Back
Top