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) /////////////////////////////////
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
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: