Page 2 of 3

Re: A way to do simple shadows

Posted: Wed Sep 21, 2022 9:21 pm
by Gunroar:Cannon()
milon wrote: Wed Sep 21, 2022 4:37 pm EDIT: Just for funsies, here's a modified version where the light source follows the mouse instead.
Was useful to really let the "example" shine.
pgimeno wrote: Wed Sep 21, 2022 7:40 pm Put simply, it's what can be done using slant and size alone, which is what the OP specified.
Yeah, it even exceeded expectations with the glare and everything else ReFreezed added :3
In fact, slant does not produce correct results even admitting that the object is 2D. Since the light is a point, each side of the object should have a different angle with respect to the light, resulting in a shape for the shadow with diverging sides, not parallel.
I was thinking of a way to explain it, and yeah, this is what I was imagining. The shadow should ...slant? I'll just let my pictures do the talking.

So any way to make it diverge like that?

Re: A way to do simple shadows

Posted: Wed Sep 21, 2022 10:24 pm
by BrotSagtMist
With a point the shadow will get wider, not narrower tho.

If the lightsource is an area it may work to fill this area with source points and create a few dozen half transparent shadows instead one based on all these points.
That should look natural.

Re: A way to do simple shadows

Posted: Thu Sep 22, 2022 9:21 am
by Gunroar:Cannon()
BrotSagtMist wrote: Wed Sep 21, 2022 10:24 pm With a point the shadow will get wider, not narrower tho.
Yeah, I guess. Though I think it depends sometimes (like maybe if perspective is considered or something :?)
If the lightsource is an area it may work to fill this area with source points and create a few dozen half transparent shadows instead one based on all these points.
That should look natural.
... I don't know how to do that :( :ultrahappy:

Re: A way to do simple shadows

Posted: Thu Sep 22, 2022 9:37 am
by BrotSagtMist
you run the code twice...

Edit: Had to try this for fun:
shm.love
(3.91 KiB) Downloaded 125 times
These are softer shadows rendered three times. Just copy the shadow part with an X offset to make the shadows as fine as you like.

This can be tweaked to look quite nice but i think we will get performance problems rather fast.

Re: A way to do simple shadows

Posted: Thu Sep 22, 2022 9:08 pm
by Gunroar:Cannon()
Ahh, I guess it's better.
These shadows are da-best.

Re: A way to do simple shadows

Posted: Sat Sep 24, 2022 7:28 pm
by ReFreezed
I spent some more time adding to the "example". It fixes the perspective issue pgimeno mentioned (using shaders, tears, and blood from an eldritch beast), and you can tweak the light's height and strength dynamically. I'd say the project has moved beyond simple at this point.

Code is here: https://github.com/ReFreezed/LoveFlatShadows
.love file at the bottom of the post.
Screenshot 2022-09-24.png
Screenshot 2022-09-24.png (148.1 KiB) Viewed 3007 times
FlatShadows.20220924.love
(6.01 KiB) Downloaded 100 times

Re: A way to do simple shadows

Posted: Sat Sep 24, 2022 7:52 pm
by pgimeno
Awesome! Very well done.

But it's still not 3D... /s

(maybe the OP should remove the word "simple" from the title)

Edit: After looking into the code a bit, this thread came to my mind: viewtopic.php?f=5&t=12483

Re: A way to do simple shadows

Posted: Sat Sep 24, 2022 7:58 pm
by GVovkiv
ReFreezed wrote: Sat Sep 24, 2022 7:28 pm I spent some more time adding to the "example". It fixes the perspective issue pgimeno mentioned (using shaders, tears, and blood from an eldritch beast), and you can tweak the light's height and strength dynamically. I'd say the project has moved beyond simple at this point.

Code is here: https://github.com/ReFreezed/LoveFlatShadows
.love file at the bottom of the post.
It's amazing how people can achieve something like this easly, while i myself sometimes might struggle with something like "soemthing = something1" instead of "something = something1" and unironically waste 10 mins trying to understand where i made mistake

Re: A way to do simple shadows

Posted: Sat Sep 24, 2022 9:11 pm
by ReFreezed
GVovkiv wrote: Sat Sep 24, 2022 7:58 pm It's amazing how people can achieve something like this easly, while i myself sometimes might struggle with something like "soemthing = something1" instead of "something = something1" and unironically waste 10 mins trying to understand where i made mistake
Heh, well you don't know the (many painful) hours it took me to fix the darn perspective issue. :death:

Re: A way to do simple shadows

Posted: Sat Sep 24, 2022 9:46 pm
by Gunroar:Cannon()
(maybe the OP should remove the word "simple" from the title)
:rofl:
pgimeno wrote: Sat Sep 24, 2022 7:52 pm Awesome! Very well done.

But it's still not 3D... /s
Doesn't need to be 3D. just appear so. This version is better and still wonderful, but yes, it still gives of that paper-vibe a little...
but it gives it off wAAAY less than before. Especially since it can be tweaked. Nice job.

And...ehem...I...heheheh...Yes, this passes the scope of the topic and the thread is already solved but since we're just saying...the shadows are fine now and I think what makes it look 2D now is the... shading on the objects themselves (*runs away*)
GVovkiv wrote: Sat Sep 24, 2022 7:58 pm struggle with something like "soemthing = something1" instead of "something = something1" and unironically waste 10 mins trying to understand where i made mistake
That's the worst :crazy:

Oh, and
ReFreezed wrote: Sat Sep 24, 2022 7:28 pm (using shaders, tears, and blood from an eldritch beast
Wondering how you got the eldritch blood (asking for a friend)...