PDA

View Full Version : Normal glFog vs Register Combiner Fog



JelloFish
12-06-2002, 12:22 PM
Hi im having some variance between what opengl gives me for fog and what register combiners give me. Passing both systems the exact same fog coord and color i get different output results.

For a fogcoord of 1 with a fogcolor of 243,220,197, register combiners give me 243,220,197 but normal glFog gives me 211,141,90.

In another scene changing the fogcolor to 204,204,187 gives me exactly that in regcomb, where normal fog gives me 104,104,73.

Does anybody know what extra math OpenGL is applying to my fog to get its color? Thanks.

JelloFish
12-09-2002, 01:10 PM
Still no idea what causes this. Any clues? Is there a glFog setting that could cause these results? Im using arb_vertex_program to send fogcoords to OpenGL in both cases.

davepermen
12-09-2002, 09:08 PM
read it up. in short, there are 3 ways, and gl can choose if it wants to do it per vertex or perpixel.

JelloFish
12-10-2002, 07:28 AM
But is there any place where I can retrieve the alternate formulas so that my two fog colors can match up?

vincoof
12-10-2002, 08:49 AM
I don't think you can since OpenGL does not guarantee the exact fog computations.

[This message has been edited by vincoof (edited 12-10-2002).]

davepermen
12-10-2002, 09:07 AM
it does. i said read it up. opengl is fully documented. and you're on opengl.org. why do you ask?

there are three types, linear, exp, and exp2, all 3 are perfectly documented how they get calculated, and how to force an implementation to do it per vertex, or per pixel, or how ever you want..

JelloFish
12-10-2002, 10:42 AM
The fog mode is compleatly a vertex parameter is it not? I can change my glFogf parameters without affecting my end result at all when arb_vertex_program is enabled. All the OpenGL spec to my knowledge says is If enabled, fog blends a fog color with a rasterized fragment’s post-texturing color
using a blending factor f. That blending factor is given by result.fogcoord.x in ARBVP.

Now if i tell glFog that my color is a certain color why is my regcomb final combiner doing the correct blend of fogcol,finalcol, and fogfactor, whereas opengl is doing something different.

I ask because the problem doesnt seem as simple as the fogcoord isnt being generated correctly. In both cases my entire scene is bicolored one correct color my fog color for the regcomb objects, and two some seemingly random color for all glFogged objects. I deduce that in both cases my fogCoord is correctly set to 1 since all textures are bled out to the fog color.

vincoof
12-10-2002, 10:58 AM
davepermen: because hints implementations are free, you never know how OpenGL interprets the hint. That's why IMO you can't be 100% sure of what's happening.

vincoof
12-10-2002, 12:38 PM
When you write "For a fogcoord of 1 with a fogcolor of 243,220,197, register combiners give me 243,220,197 but normal glFog gives me 211,141,90.", what do you mean by "gives me" ? How do you query the value ?

JelloFish
12-10-2002, 03:50 PM
I query the value by taking a screen capture and looking at the colors via picker in photoshop. Im sure doing a glReadPixels would probably give me the same results.

JelloFish
12-10-2002, 06:27 PM
Sorry bout all the hassle fellows. I discovered the problem and as you can imagine it was pretty simple, that section of code was going through extra blending passes, to which fog was also enabled. Thanks for all the interest... I spend way to much time looking for something complicated to be the solution.