Layering lighting.

About Monkey 2 Forums Monkey 2 Programming Help Layering lighting.

This topic contains 4 replies, has 2 voices, and was last updated by  Mark Sibly 2 years, 5 months ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #4696

    Richard Betson
    Participant

    Hi,

    I’m working on ways to layer lighting within my gaming framework. Can I do a loop like in this pseudo code?

     

    This seems to work for me but I am noticing an issue. Before I continue I wanted to make sure implementing lighting this way is kosher.

    #4697

    Richard Betson
    Participant

    The above does seem to work. In the attached image I have lighting applied to two separate layers of asteroids. You can see that this so because the bright light of the weapons impact does not effect the blue lighted layer of asteroids below. It is awesome to be able to layer lighting this way.

    I have encountered an issue where a light will wink out based on map position. I am not sure why this happens yet but I am able to get the light to stop winking out by moving my particle effect out of lighting (Begin/End Lighting). I’m not altering viewport or scissors with particles (uses non-bumped images) and I am able to draw other non-bumped images with no issues while lighting is on.

    I will try to duplicate this issue and post some code assuming layering lighting in this way is proper.

    Attachments:
    #4700

    Mark Sibly
    Keymaster

    > Can I do a loop like in this pseudo code?

    This should work fine, just remember that EndLighting() clears out all add lights and shadowcasters, but that’s generally what you want if you’re doing ‘layers’.

    Beats the hell out of the old ‘renderer’ system doesn’t it?

    #4701

    Richard Betson
    Participant

    Beats the hell out of the old ‘renderer’ system doesn’t it?

    OMG Yes! It’s flexible enough to just sort of plugin to my window frameworks render. Layering it ought to yield some cool effects.

    but that’s generally what you want if you’re doing ‘layers’.

    It is. For example, in my case, I can layer impact lighting among five layers of asteroids. That should add to depth. Time to experiment. 😉

    #4703

    Mark Sibly
    Keymaster

    I’d recommend doing things like this if possible:

    For each layer:

    Draw unlit background (if any)

    BeginLighting

    Add lights and draw any opaque/alpha stuff that needs to be lit.

    EndLighting

    Draw non-additive particles (if any)

    Draw additive particles/fake lights.

    Draw unlit overlays (if any)

    Next

    Drawing particles/fake lights inside lighting should still work, but it will incur extra overhead.

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.