• Godot Help
  • How to set shadow filtering quality with GDScript

I am trying to change the shadow filtering quality in the project settings with GDScript using this code:

VisualServer.canvas_light_set_shadow_filter($DirectionalLight,VisualServer.CANVAS_LIGHT_FILTER_PCF13)

but I get this error message:

Parser Error: At "canvas_light_set_shadow_filter()" call, argument 1. The passed argument's type (Node) doesn't match the function's expected argument type (RID).

So how do I get the RID from my DirectionalLight or is there another way to do it?

  • I just realized I'm a fucking idiot. The problem with canvas_light_set_shadow_filter is that it focuses on a single, individual light instead of setting the filter quality for all shadows in the entire project globally.

    So all you need to do is modify your project settings directly:

    ProjectSettings.set_setting("rendering/quality/shadows/filter_mode", 2)

    0 = disabled, 1 = PCF5, 2 = PCF13

Any example code? Because this doesn't work:

RID.RID($DirectionalLight)

it says

Parser Error: Static constant 'RID' not present in built-in type RID.

Megalomaniak

Tried that, gives me this error:

Parser Error: No constructor of 'RID' matches the signature 'RID(Node)'.

It looks like it should work like this, but I get 0 every time.

onready var sun = get_node("SunLight")

func _ready():
	print(RID(sun).get_id())

Otherwise, you can use the visual sever to create the light.

var light_rid = VisualServer.directional_light_create()

But this seems odd.

I just realized I'm a fucking idiot. The problem with canvas_light_set_shadow_filter is that it focuses on a single, individual light instead of setting the filter quality for all shadows in the entire project globally.

So all you need to do is modify your project settings directly:

ProjectSettings.set_setting("rendering/quality/shadows/filter_mode", 2)

0 = disabled, 1 = PCF5, 2 = PCF13