Results 1 to 5 of 5

Thread: fog not working correctly.

  1. #1

    fog not working correctly.

    Hi all

    I'm implementing vertex fog, but it's not working correctly.
    Here is my code:

    [pascal]
    fogstart := 1;
    fogend := 5;
    with fD3DDevice do
    begin
    SetRenderState(D3DRS_FOGENABLE,1);
    SetRenderState(D3DRS_RANGEFOGENABLE,1);
    SetRenderState(D3DRS_FOGCOLOR,D3DCOLOR_XRGB(128,12 8,12);
    SetRenderState(D3DRS_FOGVERTEXMODE,D3DFOG_LINEAR);
    SetRenderState(D3DRS_FOGSTART,PDWORD(@FogStart)^);
    SetRenderState(D3DRS_FOGEND,PDWORD(@FogEnd)^);
    end;
    [/pascal]

    I have tried many value's for fogstart and fogend. When the values are too high, the whole scene was rendered without fog and when i set the too low, the whole scene was rendered gray.

    When i finetuned the values, the scene was fogged but all objects (far and near) were fogged with the same density/value/grayness.
    When i used values (1,1.5) the fog seemed to look better.
    The only problem was that the position of the clear circle was the area pointed by the lookat vector of my camera.
    So i can see a circle of my scene with fog around it.
    the camera must be IN that circle and must not look at it... it just drives me crazy. :x

    Can a weird camera setting be the cause of this, or some wierd matrices. Or are my fog settings wrong

    Can someone help me out?? :?

    {maybe i can post some pics later}
    Coders rule nr 1: Face ur bugz.. dont cage them with code, kill'em with ur cursor.

  2. #2

    fog not working correctly.

    Can it be that you set the camera after you set the fog?

    If so, try it vice versa...
    <a href="http://www.greatgamesexperiment.com/game/Valgard/?utm_source=gge&amp;utm_medium=badge_game"><img border="0" alt="GGE" title="GGE" src="http://static.greatgamesexperiment.com/badge/game/valgard/gge400x56.png"></a>

  3. #3

    fog not working correctly.

    Yeah thanx... that sounds like a logical sollution

    I read somewhere that the fog effect is based on the view matrix.
    When vertices are transformed to the view matrix, the fog can be easily computed by using the Z coordinates.
    But the problem is that i multiply all my matrices and send them to D3D as World matrix,
    So the view matrix is propably an identity matrix.
    That's why the fog effect didnt work.

    I have to rewrite my matrix code to solve this issue.
    I'll let you know wheter it works after these changes.
    Coders rule nr 1: Face ur bugz.. dont cage them with code, kill'em with ur cursor.

  4. #4

    fog not working correctly.

    I've rewritten my code and the problem seems to be solved.... thanx

    So multiply my view/proj/world matrices and pass them as world matrix wasn't a good idea after all.
    Coders rule nr 1: Face ur bugz.. dont cage them with code, kill'em with ur cursor.

  5. #5

    fog not working correctly.



    Glad to hear the problem is gone...
    <a href="http://www.greatgamesexperiment.com/game/Valgard/?utm_source=gge&amp;utm_medium=badge_game"><img border="0" alt="GGE" title="GGE" src="http://static.greatgamesexperiment.com/badge/game/valgard/gge400x56.png"></a>

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •