Archived

This topic is now archived and is closed to further replies.

Goodlife

DirectX + Radeon 7500 = No Fog?

Recommended Posts

Hi all, I''ve written a game (written on a Radeon 9500). It tests good on several NVidia cards, and on a Radeon 8500. Then I ran it on a mobile laptop with a Radeon 7500, and I have a funny problem: Instead of fogging (using pixel fog) the display simply cuts off at the edge of visibility, just as though I had fog turned off. I downloaded the latest drivers, double checked to make sure my projection matrix was W compliant, and still no goods. The code I use to set up the fog is here: mDevice->SetRenderState(D3DRS_FOGENABLE,true); Device->SetRenderState(D3DRS_FOGTABLEMODE, D3DFOG_LINEAR); // theNearValue=2000 // theFarValue=4000 (edge of view range) Device->SetRenderState(D3DRS_FOGSTART,*(DWORD *)(&theNearValue)); Device->SetRenderState(D3DRS_FOGEND,*(DWORD *)(&theFarValue)); // theColor=0xFFFFFFFF; Device->SetRenderState(D3DRS_FOGCOLOR,theColor A bit of reading turned up that you''re ''supposed'' to use a value from 0.0 to 1.0 for the FOGSTART/FOGEND values. That''s in DirectX9, not sure if it''s the same in DirectX8.1, which is what I''m using. Anyway, I tried it with a 0.0 thru 1.0 value setup, and still no fog. Does anyone know what the problem might be here? I know the Radeon 7500 card supports fog, because I play other games with fog on it. I assume there''s some sort of default that is different on this card, or something I need to set up. However, all the directx samples I''ve seen show only these renderstates getting set. Thanks in advance for any help

Share this post


Link to post
Share on other sites
I''m not sure what your problem is but I have a radeon 7200 and I''m able to render vertex fog like this:


  
m_pd3dDevice->SetRenderState(D3DRS_FOGENABLE, TRUE);
m_pd3dDevice->SetRenderState(D3DRS_FOGCOLOR, fogColor);
m_pd3dDevice->SetRenderState(D3DRS_FOGSTART, *(DWORD *) (&fogStart));
m_pd3dDevice->SetRenderState(D3DRS_FOGEND, *(DWORD *) (&fogEnd));
m_pd3dDevice->SetRenderState(D3DRS_FOGDENSITY, *(DWORD *) (&fogDensity));
m_pd3dDevice->SetRenderState(D3DRS_FOGVERTEXMODE, fogMode);
m_pd3dDevice->SetRenderState(D3DRS_RANGEFOGENABLE, TRUE);

Share this post


Link to post
Share on other sites
- DX8.1 docs on fogstart:
Depth at which pixel or vertex fog effects begin for linear fog mode. The default value is 0.0f. Depth is specified in world space for vertex fog, and either device space [0.0, 1.0] or world space for pixel fog. For pixel fog, these values are in device space when the system uses z for fog calculations, and world space when the system is using eye-relative fog (w-fog). For more information, see Fog Parameters and Eye-Relative vs. Z-Based Depth.
Values for this render state are floating-point values. Because the IDirect3DDevice8::SetRenderState method accepts DWORD values, your application must cast a variable that contains the value, as shown in the following code example.

pd3dDevice8->SetRenderState(D3DRS_FOGSTART, *((DWORD*) (&fFogStart)));


- If that doesn''t fix the problem, make sure the card supports it (it should, of course, but maybe the drivers don''t expose that).

- If you can try the MFCFog sample on the card, do so.

To Chaucer: He''s using pixel (table) fog, not vertex fog.

Cheers,
Muhammad Haggag

Share this post


Link to post
Share on other sites