# which caps to check for table/vertex fog?

This topic is 3934 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I am trying to add fixed function fog to my game. The problem is that I am currently using a rather cheap rental computer with a somewhat flaky video card. On this card, when I turn on vertex fog or table fog, both are 100% dense (you can't see through them) unless they are in D3DFOG_EXP mode with density set to below 0.01 (which is far lower than I should have to go, if the D3D docs are correct.) I want my users to be able to have fog enabled for my game. 1) What is the cap in D3DCAPS9 which indicates if vertex fog is supported? What about the one for table fog? I just looked through the docs and there do not seem to be any flags directly concerned with whether or not these kinds of fog actually work or not. 2) What are some good values for fog density/start/end? Since this video card handles fog so badly, I have no way of determining what a good setup should be. Thanks! Greg [Edited by - synth_cat on October 12, 2007 3:05:33 PM]

##### Share on other sites
D3DFOG_EXP mode with density set to below 0.01 (which is far lower than I should have to go, if the D3D docs are correct.)

*****

No, the equation is based on absolute distance from viewer not relative distance to clip plane, so the density parameter you need to use is completely different depending on the scale of your scene. Im using 0.001 in my scene which gets dark around 2000 units away. If you have a graphing calculator you can just graph the equation, its easier to see the difference explicitly in a plot. I found that the D3DFOG_EXP2 works best.

##### Share on other sites
OK, thanks for explaining that - now I understand why I had to use such low values.

I'm still a bit confused about which caps I need to check on a user's system.

Here are the only fog-relevant caps I was able to find in D3DCAPS9:

In RasterCaps:

- D3DPRASTERCAPS_FOGRANGE
- D3DPRASTERCAPS_FOGTABLE
- D3DPRASTERCAPS_FOGVERTEX
- D3DPRASTERCAPS_ZFOG
- D3DPRASTERCAPS_WFOG

In LineCaps:

- D3DLINECAPS_FOG

Let's say I just want to use table fog on a user's machine. Does this look OK to completely verify that table fog will work?

if(caps9.RasterCaps & D3DPRASTERCAPS_FOGTABLE){    if((caps9.RasterCaps & D3DPRASTERCAPS_WFOG)       || (caps9.RasterCaps & D3DPRASTERCAPS_ZFOG))    {        //all is good        enable_tablefog=true;     }}

Does this next snippet look OK to completely verify that vertex fog will work?
if(caps9.RasterCaps & D3DPRASTERCAPS_FOGVERTEX){    if((caps9.RasterCaps & D3DPRASTERCAPS_FOGRANGE)      && (caps9.ShadeCaps & D3DPSHADECAPS_FOGGOURAUD))    {        //all is good        enable_vertexfog=true;     }}

In the second snippet, is it really necessary to check the FOGRANGE cap? It doesn't seem as if range fog is necessary to make vertex fog work.

Anyway, please tell me if I've set up the caps-checking correctly for this stuff. Have I left anything out? I have a feeling there should be a more general cap like FOGSUPPORTED which would automatically tell if any kind of fixed-func fog were supported at all, but I can find no such thing in the docs.

##### Share on other sites
There's no "you have fixed function fog (of some variety)" cap bit. There's just the bit for vertex fog and the bit for pixel fog.

I cover vertex fog in Chapter 6. Vertex Transformations and pixel fog in Chapter 14. The Frame Buffer in my book.

My pipeline poster gives an overview of all the caps stuff and how it relates to different parts of the pipeline.

##### Share on other sites
I just went over the docs you sent me - they were very informative. Thanks a lot!

So am I correct to say that I do _not_ need to check the D3DPRASTERCAPS_FOGRANGE bit just to use basic vertex fog?

Also, your pipeline does not mention the D3DPSHADECAPS_FOGGOURAUD bit in the Vertex Fog section. So am I also correct to assume that I do not need to check this either?

I have another question about the table fog checking code:
if(caps9.RasterCaps & D3DPRASTERCAPS_FOGTABLE){    if((caps9.RasterCaps & D3DPRASTERCAPS_WFOG)       || (caps9.RasterCaps & D3DPRASTERCAPS_ZFOG))    {        //all is good        enable_tablefog=true;     }}

Is the second if statement redundant? Does the D3DPRASTERCAPS_FOGTABLE bit automatically mean that either W or Z fog is enabled?

1. 1
Rutin
26
2. 2
3. 3
4. 4
JoeJ
18
5. 5

• 14
• 21
• 11
• 11
• 9
• ### Forum Statistics

• Total Topics
631763
• Total Posts
3002187
×