PDA

View Full Version : A question about transparency ,deep test,color and light.



Mickey008
11-24-2003, 02:05 AM
A question about transparency ,deep test,color and light.
Please check the following codes.My question is that when I add the line marked with (*),the cone will not be disguised by other objects;while when I remove the line,the cone will have some problems on color and light,the cone will not be smooth,and there is a cover in the middle of the cone.How can I both get the disguised effect and the smooth surface and proper color and light£¿
Thanks a lot!


pfPushState();
pfPushMatrix();
pfBasicState();
glPushMatrix();

GLint matmode;
GLfloat projmat[16];
static int flag = 0;

static GLfloat ambient[4] = { 1.0, 1.0, 1.0, 0.0 };
pfCullFace(PFCF_OFF);
pfTransparency( PFTR_FAST );

glEnable(GL_DEPTH_TEST);

glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);
glLightModelfv(GL_LIGHT_MODEL_AMBIENT, ambient);

glDisable( GL_DEPTH_TEST ); //£¨*£©
glGetIntegerv( GL_MATRIX_MODE, &matmode );
glMatrixMode( GL_PROJECTION );
glGetFloatv( GL_PROJECTION_MATRIX, projmat );
glMatrixMode( matmode );

......here we draw a cone£¨code omitted£©

glPopMatrix();
pfPopMatrix();


pfPopState();

knackered
11-24-2003, 04:04 AM
I presume pfTransparency(PFTR_FAST) is the Performer equivalent to glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) (aka alpha blending)?
Although the fastest cheap transparency is using glBlendFunc(GL_ONE, GL_ONE) (aka additive blending), so it could be using that.
If it is using proper alpha blending, then the objects and (in non-convex volumes) the polygons need to be drawn in the back-to-front order.
If it's using additive blending, then the order is irrelevant, but the effect is not correct, making objects look luminescent.
Either way, you most definitely do need to have depth testing enabled.
BTW, try:-
glEnable(GL_CULL_FACE);

and

glDepthMask(GL_FALSE);

You may get round your problem like that.

[This message has been edited by knackered (edited 11-24-2003).]

Mickey008
11-24-2003, 07:38 PM
I have added the two lines of code you told me.The problem I refered seems to be solved
,but new problem comes.The texture of the globe seems to be cutted into black pieces.The globe can cover the cone,but the globe seems ugly.The globe is created by MultiGen Creator,the programing environment is VC6.0 . How can I solve the new problem?
thanks.

I have added the code.
glEnable(GL_CULL_FACE);
glDepthMask(GL_FALSE);

knackered
11-24-2003, 11:24 PM
It's probably wise for you to ask this question in the beginners forum, as you're describing very basic problems - the solutions to these problems are by no means simple, but nor could they be considered 'advanced'. This forum is for questions about advanced features and usage of opengl - such as per-pixel lighting.
In fact, seeing as though you're working in a Performer framework, why don't you ask the question in the Performer forum? They may be able to point you towards a Perfomer feature that could save you a lot of time.

Mickey008
11-26-2003, 01:50 AM
Thanks£¬I know.I have solved the problem.Thanks very much.