Transparent rendering

Transparent rendering

Post by jbwes » Thu, 22 Nov 2007 11:45:00


"Pierre Alliez" < XXXX@XXXXX.COM > wrote in message
news:fi20vt$u2r$ XXXX@XXXXX.COM ...


What's wrong with the result ?
And, you've enabled alpha testing but haven't provided the test function.
You don't need alpha testing for blending.

BTW, line smooth is a poor way to do AA. And, it's often done in software
unless you use a Quadro card.

-jbw


 
 
 

Transparent rendering

Post by jbwes » Fri, 23 Nov 2007 02:23:12


Full-screen Anti Aliasing. Doesn't require sorting your lines, and is
accelerated, and works on triangles also.

jbw

 
 
 

Transparent rendering

Post by Pierre All » Fri, 23 Nov 2007 04:30:00

hi all,

I am trying to render a triangle surface mesh with transparency (no textures).
After reading the documentation about what should be done (blending, depth mask,
blend function, and z-sorting) - but cannot figure out what is wrong in my code.

Any help would be much appreciate.

Pierre


here is my code:

::glColor4f(0.5f, 0.5f, 0.5f, 0.5f);
::glEnable(GL_CULL_FACE);
::glEnable(GL_BLEND);
::glDepthMask(GL_FALSE);
::glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);

// get camera parameters
int viewport[4];
double modelMatrix[16];
double projMatrix[16];
::glGetDoublev(GL_MODELVIEW_MATRIX,modelMatrix);
::glGetDoublev(GL_PROJECTION_MATRIX,projMatrix);
::glGetIntegerv(GL_VIEWPORT,viewport);

// render primitives while sorting them wrt z,
// using gluProject with camera parameters
...


elsewhere, my default setting parameters are

glEnable(GL_DEPTH_TEST);
glClearColor(1.0f,1.0f,1.0f,1.0f);

// activate lighting
glEnable(GL_LIGHT0);
glEnable(GL_LIGHTING);
float lpos[4] = { -.2f, .2f, .9797958971f, 0.0f };
glLightfv(GL_LIGHT0,GL_POSITION,lpos);
glLightModelf(GL_LIGHT_MODEL_TWO_SIDE, 1.0f);

::glEnable(GL_NORMALIZE);
::glPolygonMode(GL_FRONT_AND_BACK,GL_FILL);

// antialiasing
::glEnable(GL_BLEND);
::glEnable(GL_ALPHA_TEST);
::glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
::glEnable(GL_LINE_SMOOTH);
::glHint(GL_LINE_SMOOTH_HINT,GL_NICEST);



pixelDesc.nSize = sizeof(PIXELFORMATDESCRIPTOR);
pixelDesc.nVersion = 1;

pixelDesc.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL |
PFD_DOUBLEBUFFER | PFD_STEREO_DONTCARE;

pixelDesc.iPixelType = PFD_TYPE_RGBA;
pixelDesc.cColorBits = 32;
pixelDesc.cRedBits = 8;
pixelDesc.cRedShift = 16;
pixelDesc.cGreenBits = 8;
pixelDesc.cGreenShift = 8;
pixelDesc.cBlueBits = 8;
pixelDesc.cBlueShift = 0;
pixelDesc.cAlphaBits = 0;
pixelDesc.cAlphaShift = 0;
pixelDesc.cAccumBits = 64;
pixelDesc.cAccumRedBits = 16;
pixelDesc.cAccumGreenBits = 16;
pixelDesc.cAccumBlueBits = 16;
pixelDesc.cAccumAlphaBits = 0;
pixelDesc.cDepthBits = 32;
pixelDesc.cStencilBits = 8;
pixelDesc.cAuxBuffers = 0;
pixelDesc.iLayerType = PFD_MAIN_PLANE;
pixelDesc.bReserved = 0;
pixelDesc.dwLayerMask = 0;
pixelDesc.dwVisibleMask = 0;
pixelDesc.dwDamageMask = 0;

m_GLPixelIndex = ChoosePixelFormat(hDC,&pixelDesc);
if(m_GLPixelIndex == 0) // Choose default
{
m_GLPixelIndex = 1;
if(DescribePixelFormat(hDC,m_GLPixelIndex,
sizeof(PIXELFORMATDESCRIPTOR),&pixelDesc)==0)
return FALSE;
}

if(!SetPixelFormat(hDC,m_GLPixelIndex,&pixelDesc))
return FALSE;

return TRUE;
}
 
 
 

Transparent rendering

Post by fungu » Fri, 23 Nov 2007 11:49:15

On Nov 21, 8:30 pm, Pierre Alliez < XXXX@XXXXX.COM >


A screenshot on a website would be worth a thousand
lines of code....
 
 
 

Transparent rendering

Post by anon » Fri, 23 Nov 2007 17:33:14


What does "AA" stands for?
 
 
 

Transparent rendering

Post by Sascha Boh » Fri, 23 Nov 2007 17:38:37

> What does "AA" stands for?

anti-aliasing
 
 
 

Transparent rendering

Post by Pierre All » Fri, 23 Nov 2007 21:32:27

> What's wrong with the result ?
I had no transparency. but in the meantime enabling COLOR_MATERIAL solved my
problem perfectly.

thanks - I have updated my code.

I do have a FX 5600 (a monster) - so it works fine this way. but if you have
better advice I would be glad to hear about this too.

thanks for your time,

pierre
 
 
 

Transparent rendering

Post by Pierre All » Sat, 24 Nov 2007 17:24:19

> Full-screen Anti Aliasing. Doesn't require sorting your lines, and is

thanks again for your advice.

Pierre