Simple shadow mapping example

#1

Here’s a (very) simple shadow mapping example that might get you started. Ask here if you have questions and I’ll do my best to answer them. I’ve annotated the code a little bit, but my intensions are to improve it more at some later time.

Code: https://github.com/jhonnyking/my-public-defold-examples/tree/master/shadow-mapping
HTML5 build: https://jhonnyking.github.io/my-public-defold-examples/shadow-mapping/

15 Likes

#2

When Defold editor can be a 3D editor?

2 Likes

#3

Don’t you think that you (as Defold engeneer) should use in examples render.set_render_target (introduced in 1.2.139) instead of old and deprecated enable/disable_render_target?

3 Likes

#4

Wow, the shadow is even casted on the other object :smiley: Do this method allows to cast self shadows? On the object itself?

1 Like

#5

Yeah you are right, totally forgot about that change :slight_smile:

4 Likes

#6

Yeah, it does self-shadow, look at the shadow side of the sphere to see the effect. It looks a “bit” strange now due to the bias value, but it’s a common issue with shadow mapping. There’s fixes and improvements to add that will make it better :slight_smile:

3 Likes

#7

Implemented cascaded shadow maps this weekend, I’ll clean up the code and put the source online later this week :slight_smile:

11 Likes