Are shadows for 3d models possible in Codea4?

@John with Codea4 is it ‘easy’ to implement shadows for 3d models?

If so, could you provide a simple example using a sphere model. Thanks.

Hmm, shadows are enabled by default if you use scene.default3d() but I just tried it and I didn’t see any. There must be a bug preventing them from appearing. This is what I used to test it:

function setup()
    scn = scene.default3d()
    local rig =
    rig.angles.x = 45
    rig.angles.y = 45
    local sphere = scn:entity()
    sphere.y = 2
    scene.main = scn

I will have to look into it in the graphics debugger (shadows are hard)

  • John

ok, thanks. Let us know when you have fixed it.

@John did you get a chance to investigate the (lack of) shadows?

I’m having a look into it today

@piinthesky So it turned out that the shadows were working but the default HDR sky is just extremely bright and washed out the shadows so they basically were invisible. I’m working on some improvements to make it possible to easily adjust the environment lighting as well as the exposure / intensity settings for it. I’ve added = color() so you can just set it directly. I’ve also fixed = nil which was making the scene red

@John, great, i will slowly try to upgrade my km3net app to Codea4, it will be worth it to get the shadow effects. Thanks!

1 Like

Cool, let me know what kind of issues you run into since Codea 4 hasn’t been properly battle tested

@John @sim Just happened to try the above code I had saved from this discussion and noticed that the cube was casting a shadow. So I guess the 3D shadows are fixed.

The shadows were working but the ambient lighting from the default skybox was extremely bright to the point where they washed the shadows out completely