It seems you have kind of answered your own question. But yes, when dealing with isometric (which is basically fake 3d) it is really hard to get the lighting right. Lighting in isometric view is usually what create the illusion of 3d, and adding this lighting engine will kinda kill that i think. If you manage to do it though, kudo's to you, really impressive. I'd recommend using a real 3d lighting engine, even when dealing with 2d sprites in an isometric view. But that is just my opinion ofc.
Furthermore, I don't really understand what you need help with. Could you provide a screenshot showing the problem? The thing I made with the user Eben, a few post above, might also help out a bit here.
Anyway, thanks for the compliment though!
I really hope it's not an isometric view, because that would be above what I'm aiming for (I'm striving for simple graphics so I can put in as much content as possible without making the game a juggernaut; also, I suck at graphics), but here goes:
Image box doesn't work, so: http://imgur.com/a/uVCwl
Side notes: the guy is from a free sprite editor, the white boxes up high is a menu for key rebinding.
Before I continue, yes, the thing you and Eben cooked up looks great and adds to the feel. I think it might be part of the solution, but as you'll see below, I'm having trouble figuring out what part of the code does what (and what to keep of the original lightmap script so it doesn't give errors) in order to get the shadows to do their own, separate thing, at a different depth. So, kinda the opposite of what Eben needed? I'm also real fidgety about the performance, wanna keep it as low as possible, as I have or plan on having: pathfinding AI, shooter AI, melee AI, melee-collision detection, huge maps, inventory systems, a big roster of characters, etc. I'll be sure to study the code (sounds like The Matrix up in here) in the meantime.
So I put the ambient on 0.05 and as you can see, obj_lightmap has a depth above the player's, causing both the shadows and the 'darkness' to be drawn on top of him. His shadow is provided by a separate object that follows him around, as otherwise, the player's sprite is noticeably darkened.
-> haven't figured out why, but the only thing I changed was the ambient, so the order in which everything is drawn (depth wise) is the same as in your first post's example.
In the screenshot and the example game file it's harder to tell, but the shadows are indeed drawn on top of the player object, instead of beneath him (as you would expect in a top-down view). Of course, the 'darkness' is also drawn on top of him so he's harder to discern in the darkness, which is what we want.
So in short, all of this, can be made even more amazing than it is, by splitting the obj_lightmap into two objects with each a different depth: one drawing above everything (so when players and enemies are in non-lit areas, they're harder to spot because they're covered by darkness; the other drawing their shadows underneath them, as it would appear in real life. For this you'd also have to split up the lightmap script( s ). I tried to do so, by foolishly taking the shadows part out of the main script, getting lots of errors, re-establishing necessary variables from the main script into the new shadows script. Finally got it working and... everything's over-lit. The script is complex, yet elegant so I feel bad butchering it to get what I want. Plus I don't like feeling stupid and going by trial and error.
Then I thought, well this is a super-recent topic and the talented creator (and equally talented forum members) are conversing in it. Hence, I've come to request your help! So... which parts of the code draw the shadows (and which part would I need to 'keep' from the original script so I don't get errors)? I'm not being a complete noob, I have tried isolating the code, but it's quite interwoven (which is commendable) and my try... turned out horrible as I said before.
Btw, as far as I can tell, writing to two surfaces is very taxing and not recommendable and two objects writing to one surface is something I can't seem to find information on. I'm guessing I've tried and will do the latter (I thiiink I'm doing it... or my laptop is powerful to run two surfaces named the same way, maybe they're not global?), just had it turn out wrong so far. Will put screenshot if needed, but I feel it's just a mess, overlit through mysterious means. Can also put my 'trimmed' version of the code with only the shadows, though it looks more like a Frankensteinian swamp monster than simplified shadow making code.
However... One tricky bit remains: when players are in the shadows of objects (and enemies, though that'll tie into my future 'shadow on part of sprite' script that will have to be separate anyway), they should also be covered by these shadows instead of standing on top of them. Since you can make the depths of objects (walls for example) and characters different (because they're separate objects), the only problem would be having a different object draw lifeless objects' shadows than the one drawing people's shadows.
So okay, two objects, two lightmap script versions: one is almost the same as the original one, except it doesn't draw people's shadows (maybe if they have a different parent object?) and another small one that only draws people's shadows and nothing else (otherwise the game's drawing almost everything twice at two different depths and that's not only wasteful, it's taxing I'm told).
One note superceding all others: what if I just not draw to a surface for people's shadows? But I hear it's a lot less taxing than regular drawing.
Edited by InventorOfTheBizarre, 04 February 2016 - 09:03 PM.