Lighting a 2D Image without bump?

About Monkey 2 Forums Monkey 2 Programming Help Lighting a 2D Image without bump?

This topic contains 10 replies, has 2 voices, and was last updated by  Mark Sibly 1 year, 7 months ago.

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #10020

    therevills
    Participant

    Is it possible?

    I’m after a similar effect that be seen on Thimbleweed Park, where I can get a character to walk under a street light:

    https://blog.thimbleweedpark.com/quickiepal

    (oh I’m getting Forbidden. You submitted too quickly. You may try again in a few seconds. alot!)

    #10023

    Mark Sibly
    Keymaster

    Easiest way to do this is probably just to use some 2d blending effect (additive, multiply, both, experiment!) and drawing a yellow ‘spotlight’ image.

    #10024

    Mark Sibly
    Keymaster

    I just had a hack around with the simplelight banana, and it is possible for 2d lights to work without normal maps.

    Hoever, to make this work, I used a ‘default’ normal of 0,0,1. This is a massive cheat that may or may not look like crap depending on usage.

    I’ll leave this hack in (it just allows you to use Image.LoadBump without specifying normal/specular maps) but I think  you’ll get the best results kludging your own 2d blending approach together.

    To render lights you probably want to do something like using multiply blending to multiply light * scenes colors (result is lighting contribution) and then add this back to the original scene colors. This can be done by drawing the scene to one texture, lighting to another, and copying/drawing one texture to another using multiply/additive blending etc.

    #10026

    Mark Sibly
    Keymaster

    Actually, I think I might be able to do this just by writing a new ‘light’ shader…will have a play!

    #10060

    therevills
    Participant

    Cool, thanks Mark 🙂

    #10116

    therevills
    Participant

    I just had a hack around with the simplelight banana, and it is possible for 2d lights to work without normal maps.

    Hoever, to make this work, I used a ‘default’ normal of 0,0,1. This is a massive cheat that may or may not look like crap depending on usage.

    How did you do this in code?

    #10197

    therevills
    Participant

    Bump?

    #10198

    Mark Sibly
    Keymaster

    I wont be able to do this right away, I have some other stuff to finished up first.

    #10199

    Mark Sibly
    Keymaster

    Sorry, but I’m a bit busy with other stuff and wont be able to look into this for a while yet.

    You are of course welcome to try yourself! It should be fairly easy with a combination of multiply/additive blending and offscreen rendering. You are likely to have to tweaks things a bit anyway if you want to get *exactly* the same result as above which highly stylized.

    #10200

    therevills
    Participant

    No worries – Just wondering how you did your hack on post #3?

    #10201

    Mark Sibly
    Keymaster

    I did briefly hack LoadBump so it didn’t need an actual normal map to load – instead it used a default  0,0,1 normal map. This alone allowed you to run stuff like simplelight and lightsparks without having to use bump/specular maps. I reverted this though as I wanted to spend more time on it.

    The only bit ‘wrong’ about this is the light intensity was still being multiplied by the ‘N dot L’ term of the lighting equation, which will give different intensities depending on relative positions of pixels/light, which is probably not want you want. I’m guessing you’re after a more full on 2d effect that ignores light direction etc, and this should be doable by tweaking the existing lighting shader a bit.

    I now tend to think that just keeping everything 2d and hacking around with blending and offscreen rendering is probably the better solution anyway as even with a hacked lighting shader, you’re still gonna have to do some kludgy rendering to achieve the groovy ‘light cone’ effect. On the other hand, the light shader approach will actually integrate with shadows should  you want to use them.

    Anyway, either approach will take a bit of time to experiment with, but like I say it could probably be done right now without having to get down with shaders by using a combo of fancy blending modes and offscreen rendering.

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

You must be logged in to reply to this topic.