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.
-
AuthorPosts
-
August 27, 2017 at 3:25 am #10020
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!)
August 27, 2017 at 5:32 am #10023Easiest way to do this is probably just to use some 2d blending effect (additive, multiply, both, experiment!) and drawing a yellow ‘spotlight’ image.
August 27, 2017 at 6:05 am #10024I 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.
August 27, 2017 at 6:26 am #10026Actually, I think I might be able to do this just by writing a new ‘light’ shader…will have a play!
August 28, 2017 at 8:27 am #10060Cool, thanks Mark
August 30, 2017 at 9:47 am #10116I 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?
September 2, 2017 at 2:47 am #10197Bump?
September 2, 2017 at 2:52 am #10198I wont be able to do this right away, I have some other stuff to finished up first.
September 2, 2017 at 3:03 am #10199Sorry, 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.
September 2, 2017 at 3:07 am #10200No worries – Just wondering how you did your hack on post #3?
September 2, 2017 at 3:34 am #10201I 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.
-
AuthorPosts
You must be logged in to reply to this topic.