Advertisement

blending problem

Started by June 16, 2004 04:55 PM
16 comments, last by JazzD 20 years, 5 months ago
okay guys, I basically just want to add a simple water surface to my map, everything is working but this damn bleding doesn't blend the surface under the water brush with its texture it ALWAYS blends with the skybox, i have no idea wtf im doing wrong.. shots: http://www.jazzd.de/shot0000.jpg (with bleding enabled) http://www.jazzd.de/shot0001.jpg (not rendering the water!) thanks for any help
www.prsoftware.de
What blending equation are you using, and what textures are bound to the texture units at that time? Make sure it's actually how you want it to be ( i.e. you haven't accidentily got a texture bound to tex1 by accident, and so on ).
If at first you don't succeed, redefine success.
Advertisement
Okay, so... how are you doing the blending?

Off the top of my rather non-guru head, I'd guess that you did something like rendered the water before the stuff below it, and you have depth testing enabled.
As Mr. Regious and Mr. Junkie said, for normal blending you'll need to have depth testing enabled and set to some normal mode, such as GL_LEQUAL, and blending to what you most likely want to be alpha testing: glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA). And most impoartantly, you'll want to set the alpha for the water: before drawing it, call glColor4f(red, green, blue, alpha), where alpha is less than 1 (if you want transparency). Odds are, you're just calling glColor3f(), which isn't enough.
"Literally, it means that Bob is everything you can think of, but not dead; i.e., Bob is a purple-spotted, yellow-striped bumblebee/dragon/pterodactyl hybrid with a voracious addiction to Twix candy bars, but not dead."- kSquared
I tried a lot blending funcs, fiddled with the depth testing and of course used the color4f.. Nothing did really work, also when I don't draw the sky then the "blended" texture is just adding some black to it.
www.prsoftware.de
Do you draw your water before or after the geometry of the pool and the... err... "green stuff"?

I suspect, as C-Junkie theorized, that you are drawing the water first, thus writing the depth values of the water to the depth buffer and causing the geometry that is rendered later to fail the depth test.

If this is not the problem then could you post relevant code snippets (using [code] and [source] tags as appropriate)?

Enigma
Advertisement
well also im using vertex arrays, and im drawing the water after the geometry. I tried the GL_LINE polygonemode and it shows me that the surface under it is rendered correctly:

http://www.jazzd.de/shot0003.jpg

I tried to render a simple cube with transparency in another part of the code and it works just like it has to, the problem is I must render it right there where it blends with the sky for some unknown reason... I can't really figure out what's wrong. Basically the surface is transparent but it doesn't use the right texture information for blending... Some buffer must be filled with a false value or something..
www.prsoftware.de
OK, next guess: Are you sure you've bound the correct texture and set the colour and blending mode correctly? Try the following:
// render solid parts of sceneglDisable(GL_TEXTURE_2D);glEnable(GL_BLEND);glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);glColor4f(1, 1, 1, 0.5f);// draw water quadglColor3f(1, 1, 1);glDisable(GL_BLEND);glEnable(GL_TEXTURE_2D);

If that fails to blend a white quad over the scene then please post some code so we can see what else might be wrong.

Enigma
i do it exactly like that....

void CBsp::RenderWater(int faceIndex) {	tBSPFace *pFace = &m_pFaces[faceIndex];	glClientActiveTextureARB(GL_TEXTURE0_ARB);	glDisable(GL_TEXTURE_2D);	glEnable(GL_BLEND);	glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);	glColor4f(1,1,1,0.5f);	glVertexPointer(3,GL_FLOAT,sizeof(tBSPVertex),&(m_pVerts[pFace->startVertIndex].vPosition));	glClientActiveTextureARB(GL_TEXTURE0_ARB);	glTexCoordPointer(2, GL_FLOAT,sizeof(tBSPVertex),&(m_pVerts[pFace->startVertIndex].vTextureCoord));		glDrawElements(GL_TRIANGLES, pFace->numMeshVerts,			GL_UNSIGNED_INT,&m_pIndexArray[pFace->meshVertIndex]);	glDisable(GL_BLEND);}
www.prsoftware.de
You're disabling the texture, then specifying texture coordinates.
If at first you don't succeed, redefine success.

This topic is closed to new replies.

Advertisement