0 votes

The issue I have is simple: a mesh is animated via a vertex shader (a swimming fish).
It is lighten by a spotlight that projects its shadow on a plane.

If spotlight, plane and mesh are still (no modification of transform), the shadow is not updated, and it ends up with an inaccurate shadow on the ground (see screenshot).

error in shadow due to optimised shadow computation

If I move any of the spatials, the shadows is updated correctly, but as soon as everything is still, the issue reappear.

I've temporarly fixed this with a script on the spotlight that randomises slightly its position.


extends SpotLight

export (bool) var _vibrate : bool = true

var initialised : bool = false
var fixed_translation : Vector3 = Vector3()

func _process(delta):
    if not _vibrate:
    if not initialised:
        fixed_translation = translation
        initialised = true
    translation = fixed_translation + Vector3(rand_range(-0.001,0.001),0,0)

It triggers the shadows rendering (see below)

vibrating spotlight to update shadows

I think it's a dirty solution, but I couldn't find a way in the documentation to enforce shadow re-computation in a standard scene.

Does anybody have a solution for this?

All the best, godot rocks!

in Engine by (115 points)

1 Answer

0 votes

You should be able to force recomputation by changing the SpotLight's cull margin or some property like that.

by (12,869 points)

At each frame also?

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.