Fog and Blend

Started by
41 comments, last by TylerO 19 years, 8 months ago
I've heard alot of this problem but I don't know what to do about it. I've searched the forum but didn't find any results so I hope you guys can help me. First have a look at this screenshot:
Advertisement
fog works per vertex thus tesselate the water quad more.
also check out radex fog (or someit, it was first a nvidia extension) its better than linear.
Sorry to say it, but that did not help me that much :( Can't you, or someone else, point me to a internetpage with some "hard stuff" to work with. 'Cause I've tried to solve this problem and I can't find a soulution.
tesselate means to devide up into smaller area
thus if youre using 1 quad to draw the water, draw the water with say 10,000 quads (which are each 10,000x as small)
First of all, tell me one thing better with drawing 10000 quads instead of 1 ... :) An no, it is not 1 quad, it's about 100, cause they are still quite big. That is not the problem however, the problem is that I don't want it to be visual where the terrain is "building up" in the end of the fog.

The problem is that the blending, as I said before, works poor with fog. If I remove the blend from the water, just making it to solid quads, then the fog works. So it has nothing to do with the size of the quads.

Anyone with another solution ?
How do you want fog to work with blnding if you didn't take it into account?


Look at what you are doing:

1. FragmentColor = PixelColor*fog + (1-fog)*FogColor
2. NewFrameBuffer = BLEND( OldFrameBuffer, FragmentColor )


So you are blending AFTER fogging!! You have to recalculate it to achieve desirable results. There is no 'one valid way' to do it - just recalculate it to work good - you can change blending mode, make two passes or sth else...

I usually solve an equation and adjust background color
www.tmreality.com
Try switching the fog colour to black before rendering your stuff using blending, and switch it back to whatever it previously was before continuing, that sometimes helps fog & blending issues along.
Quote:
glActiveTextureARB(GL_TEXTURE2_ARB);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, bakgrund[2].texturId);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_BLEND);


What are you trying to do here?GL_BLEND works only with 1 or 2-component textures.For 3 or 4,the results are undefined.The procedure you should follow is simple,and I don't know why you need multitexturing to blend the water with the background.
1)Enable fog
2)Render all solid geometry:trees,ground,and the ground below the water
3)glEnable(GL_BLEND);glBlendFunc(...);
4)Render the water
5)Disable blending








Are all your texstages setup correctly?

You may be doing a glTexEnv(...,GL_ADD) somewhere there still. Disable your unused texture stages - what happened to GL_TEXTURE0_ARB? is it still active?


do unto others... and then run like hell.
mikeman: The steps you explain is the steps I take, even if it maybe doesn't look like that. If I changed the order, than it doesn't work at all. Well, it is like you said so it don't matter anyway :)

FReY: Yeah it is correct, or at least I'm 90% sure at it. If I use like GL_ADD, then it won't work as it should at all. And GL_TEXTURE0_ARB is already disabled.


Anyway, the problem is like when the fog fade's to one color, the blended water blends the fog (or really, the water, that is blended in one color and now get many colors) and because of that you still can see the water. But how to .. argh. Any new ideas?

This topic is closed to new replies.

Advertisement