How to implement shadow in Defold

It seems to can not transmit light space matrix to vertex shader, any way else can implement shadow ?

Maybe you could explain a little bit more about what do you want to achieve?

1 Like

Are you talking about ray/shadowcasting like this:

My project is based 3d, I want to know how to implement shadow in 3d game ? like shadow mapping/shadow volume.

Ah, ok, @sven, @Mathias_Westerdahl or @jhonny.goransson might be able to help?

Well, realtime shadows is something of a jungle and not the easiest to jumpstart into but I would start by looking at and then see if you can figure out what to do with the render script to support that.

Something like this maybe:

  1. Render “something” into a texture / framebuffer, where something could be a textured quad or whatever or even just a clear color
  2. Verify the result when rendering out the scene, i.e use the texture and sample from it to make sure you rendered to it
  3. Switch to rendering the 3D scene with a depth shader to the texture with an orthographic camera
  4. Sample the shadow map with a different shader that projects the fragment into the shadow POV camera and compare the depths
  5. Celebrate success!

There’s obviously lot’s of steps and details in between, but I don’t think we can just provide a snippet of code that just works right off the shelf atm. If I have time some day maybe I can implement it :slight_smile:


Thank you ! if have chance, please give me a demo.

@sven started working on a demo this weekend afaik, and @Johan_Beck-Noren has some old example that maybe they could share :slight_smile: