light whole world

This is a discussion on light whole world within the Game Programming forums, part of the General Programming Boards category; Which light and how should I use it to light the whole world in my game? I have tried some ...

  1. #1
    Registered User
    Join Date
    Aug 2006
    Posts
    62

    light whole world

    Which light and how should I use it to light the whole world in my game? I have tried some ways and it gives me very different results, that are all are bad for some reasons.

  2. #2
    l'Anziano DavidP's Avatar
    Join Date
    Aug 2001
    Location
    Plano, Texas, United States
    Posts
    2,738
    Well, are you using OpenGL or DirectX?

    If you are making a "sun", you will probably want a diffuse light source and you will want it to be quite strong.

    Another option is to simply have no lighting....then everything is visible.
    My Website

    "Circular logic is good because it is."

  3. #3
    Registered User
    Join Date
    Aug 2006
    Posts
    62
    I am using DirectX.
    I'm not absolutely sure how to do it. Maybe you could explain a bit.

  4. #4
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,586
    This sets up fixed function diffuse and specular lighting. Keep in mind this is old school per-vertex lighting and does not produce good results. You must compute the normals for your surfaces and use an FVF format that contains D3DFVF_NORMAL for this to work.
    Code:
    m_pDevice->SetRenderState(D3DRS_LIGHTING,TRUE);
    
    D3DLIGHT9 light;
    light.Diffuse = D3DXCOLOR(1.0f,1.0f,1.0f,1.0f);
    light.Ambient = D3DXCOLOR(0.5f,0.5f,0.5f,1.0f);
    light.Specular = D3DXCOLOR(0.2f,0.2f,0.2f,1.0f);
    light.Emissive = D3DXCOLOR(0.2f,0.2f,0.2f,1.0f);
    light.Power = 1.0f;
    light.Type = D3DLIGHT_DIRECTIONAL;
    light.Direction = D3DXVECTOR3(1.0f,0.0f,0.0f);
    
    m_pDevice->SetLight(0,&light);
    m_pDevice->LightEnable(0,TRUE);
    m_pDevice->SetRenderState(D3DRS_SPECULARENABLE,true);

    The SDK has good documentation for this if you look at IDirect3DDevice9::SetLight().

  5. #5
    Registered User
    Join Date
    Aug 2006
    Posts
    62
    It gives me errors on light.emissive and light.power.

  6. #6
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459

  7. #7
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,586
    Aye, I got D3DLIGHT9 and D3DMATERIAL9 mixed up. D3DMATERIAL9 has emissive as well as power.

    Just remove those and it should work. My apologies. I don't work with fixed function much anymore. I did check the docs while posting but guess I just missed the emissive and power.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Critique my lighting model.
    By psychopath in forum Game Programming
    Replies: 4
    Last Post: 08-12-2006, 06:23 PM
  2. Obfuscated Code Contest: The Results
    By Stack Overflow in forum Contests Board
    Replies: 29
    Last Post: 02-18-2005, 04:39 PM
  3. geometry won't display!?
    By psychopath in forum Game Programming
    Replies: 17
    Last Post: 09-21-2004, 10:10 AM
  4. Converting from Screen to World Coordinates
    By DavidP in forum Game Programming
    Replies: 9
    Last Post: 05-11-2004, 12:51 PM
  5. Too much to ask ?
    By deflamol in forum C Programming
    Replies: 2
    Last Post: 05-06-2004, 04:30 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21