General Lighting / Textures

Started by
7 comments, last by kieren_j 23 years, 11 months ago
In games like Quake II, Half-Life, etc., the levels are lit throughout - and quickly as well. I know these games don''t use actual "light objects" (i.e. D3DLIGHTs), and I think they use "lightmaps" instead. I saw a screenshot using only lightmaps on the CAVE Quake II site, and this definitely looks about right for the lighting seen in the levels. This is obviously a lot better than vertex lighting. I have a few questions to do with lightmaps, and also textures.
  • How would you go about generating lightmaps?
  • How would you store these lightmaps? As textures?
  • A lot of games use tiled or repeating textures - how do you do this in Direct3D? Is there a renderstate you can set to allow it, or would you need to subdivide the polys?
  • How would you detect the light level for any specified area in the level? (I''ve done some Quake2 programming before, and there''s a lightlevel variable somewhere that''s used by the monster AI to see the player)
  • How would you apply a lightmap to a texture? I''m guessing you use multiple texture stages? Thanks --------------- kieren_j
  • Advertisement
    try to commpress them...
    lol..


    Posted By Xeno.
    Kobe Bryant- "Just believe in yourself"

    ------------------------------- Goblineye Entertainment------------------------------

    yep, once you compress the textures to 5% of their original size, hell, you could assign a unique texture to every polygon in the world.

    -goltrpoat


    --
    Float like a butterfly, bite like a crocodile.

    --Float like a butterfly, bite like a crocodile.
  • How would you go about generating lightmaps?

    You start by mapping the lightmap to the polygon, then you can for each texel in the lightmap find its position in the world where you can light it.

  • How would you store these lightmaps? As textures?

    The lightmaps are just textures so storing them as textures would be right.

  • A lot of games use tiled or repeating textures - how do you do this in Direct3D? Is there a renderstate you can set to allow it, or would you need to subdivide the polys?

    Yes you can set the texture addressing mode with SetRenderState() with D3DRENDERSTATE_WRAP0 through D3DRENDERSTATE_WRAP7, and SetTextureStageState() with D3DTSS_ADDRESS, D3DTSS_ADDRESSU, and D3DTSS_ADDRESSV. You have to check the manual on how to use these.

  • How would you detect the light level for any specified area in the level?
    (I''ve done some Quake2 programming before, and there''s a lightlevel variable somewhere that''s used by the monster AI to see the player)

    This is done by calculating the distance to the lightsources and checking wether the lightsource is occluded or not.

  • How would you apply a lightmap to a texture? I''m guessing you use multiple texture stages?

    Either multiple texture stages or multiple render stages. In both methods the lightmap should be multiplied with the texture.


    WitchLord
  • AngelCode.com - game development and more - Reference DB - game developer references
    AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

    Thanks WL

    ---------------
    kieren_j
    WitchLord,
    __On the last part you say multiply the texture by the lightmap. That takes care of regular light intensity. What about "over-bright" / "washed-out" parts?
    __Would they be stored as sepereate maps and how would they be blended?
    Yes, the lightmap that is multiplied with the texture is only the diffuse light. To add specular light you would need to add a second lightmap, this time you add the color of the lightmap to the previous rendering.

    - WitchLord

    AngelCode.com - game development and more - Reference DB - game developer references
    AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

    When you say unique image, are you saying that there is a texture saved in texture space for every polygon?
    quote:Original post by Xeno

    try to commpress them...
    lol..


    Posted By Xeno.
    Kobe Bryant- "Just believe in yourself"


    That sucks!

    This topic is closed to new replies.

    Advertisement