Hi again :).<br><br>Considering a 2D top-view game, using oblique projection to be more precise (think of oldschool RPGs for instance), I'd like buildings in a given scenario to cast shadows all in the same angle, as if the light origin was very, veeeery far - just like the sun is far from us.<br>Using light2d and light occluder2D I was unsuccessful trying to achieve the desired effect, unless placing the light2d very far, far enough to feel wrong :neutral: <br>Is it possible to achieve this "directional 2D light" effect?<br>Thanks in advance!<br><br>
Can 2D casted shadows behave as "sun" casted shadows?
OK, so what you're talking about is isometric projection if I'm not mistaking. Godot as far as I know can do it yes, I think there are a couple of examples that you can download from the godot demo repository. About the shadow you might feel that this is hack but if I were you (and you find this in many games, even 3D through baking), I'd make the shadow myself, as part of the art. You don't need light for what you want to achieve.<br><br>I can think of two ways on how to cast shadow on characters. Either make a transparent png as the shadow and have the characters render behind it or use an area2d with the shape of the shadow and trigger change in color or whatever effect you want on characters that get in contact with this area2d things.<br><br>Good luck!
- Edited
Thanks for answering, Razvanc<br>Actually it's not isometric projection, I was referring to games like SNES rpgs (Final Fantasy III for instance) and not isometric titles like Fallout or Diablo. My mistake for not expressing myself with examples.<br>I am currently doing exactly as you suggested, using shadows as part of the artwork. However it would be easier to do otherwise, a projected shadow, with occluders (considering that I could project all the shadows at the same angle as said in OP) could allow me to easily give the player a notion of what's time of the day in a given scene (a 45 degrees shadow indicating sunrise, opposed to a -45 degrees indicating sunset, for instance). Of course some area effects would be used together to affect the environment "light" (in this case emulated just changing the contrast / brightness of the artwork a little).<br><br>Just illustrating a little (forgive-me for the "crudeness" of the images :blush: ) here's what I can do with Light2D and oclluders (not the desired "sun casted shadows" effect):<br> <img title="Image: http://www.4shared.com/img/q6pYSf3Uce/s25/156d5bd4fe8/spot_light" src="http://www.4shared.com/img/q6pYSf3Uce/s25/156d5bd4fe8/spot_light" alt=""> <br><br>And here's the effect I'd like to achieve:<br><img title="Image: http://www.4shared.com/img/ahKpEEE7ce/s25/156d5be6d10/directional" src="http://www.4shared.com/img/ahKpEEE7ce/s25/156d5be6d10/directional" alt=""><br><br>Once again thank you for your time :).<br><br>
Well... I don't see any other way of doing it other than either include it in the art or as you mentioned with a very distant light...
By going under the hood and playing with the cpp code it shouldn't be hard to create such a behavior just by modifying a little the existing raycast algorithms of the Light2D. I just don't want to recreate the wheel, maybe someone else has done it or has an idea of how to do it with the existing tools and maybe some gdscript "guru-ing"<br>
- Edited
Essentially, in most any engine, unless there are built-in types that already do this: This is a job for Shader-Man!<br>e.g.:<br><br>1. http://www.mattgreer.org/articles/dynamic-lighting-and-shadows/<br><br>2.
http://www.java-gaming.org/index.php?topic=24683.60<br><br>Now as a disclaimer i haven't fully read the above links, but it doesnt matter, they are trying to implement the same thing you are.<br>You can go online and search for 2d penumbra shader, for instance, should give you some results.<br>Shaders control your presentation, in essence, they -can- behave like a dynamic layer of paint atop your original texture/art, among other things.(hence the shade part)<br>This is how games with great graphics, including the effect you're looking for, were made with "limited" engines like game maker.<br><br>Now what you have to do is sit down, read lots, understand it, experiment, research, port any number of such implementations to Godot's GLSL and be happy. There are lots of pre-made shader implementations online.<br>Also, hopefully share it with the community later on, so other ppl have a shortcut, and don't have to do all the work you did.<br><br>Most good looking effects will not be a simple plug and play, unless one of the devs already did the heavy lifting for you. Sorry I can't give you a more direct solution but I'm ultra busy atm.<br>OH and btw, check out the forum's shader section. Researching shaders is always good!<br><br>Best of luck!<br>
Thanks, Kiori :).<br>My small team has a inhouse engine for another project in which we deal with shaders quite a bit :). It is indeed fascinating and I'm always amazing me with other people's creative uses for shaders. I really wanted to know if there was an object like "Sun light 2D" or a way for the Light2D to behave as said, just to avoid scripting shaders if it invest some time.<br>Thank you all, guys!<br>