0 votes

Does anyone know how to properly setup occluder instances on the RenderingServer? The interface seems pretty barren at the moment, but I've been trying to set it up similar to a normal visual instance, with no luck.

So far I have tried something like this:

RenderingServer.viewport_set_use_occlusion_culling(get_viewport(), true)

var occluder_instance: RID = RenderingServer.occluder_create()
RenderingServer.instance_set_scenario(occluder_instance, scenario)
#RenderingServer.instance_set_transform(occluder_instance, transform)

var vertices: PackedVector3Array = PackedVector3Array()
vertices.append(Vector3(0, 0, 0))
vertices.append(Vector3(10, 0, 0))
vertices.append(Vector3(10, 10, 0))

var indices: PackedInt32Array = PackedInt32Array()

RenderingServer.occluder_set_mesh(occluder_instance, vertices, indices)
  • Occlusion culling is also enabled in project settings, which should make the first line unnecessary.
  • I'm unsure if the instance_set_* functions work on occluder instances, but I'm assuming the scenario must be set somehow.
  • A reference to occluder_instance is being kept to ensure it doesn't get freed.
  • The occluder is not visible using get_viewport().debug_draw = Viewport.DEBUG_DRAW_OCCLUDERS
Godot version v4.0.beta3
in Engine by (1,111 points)
edited by

1 Answer

0 votes
Best answer

Figured out why it didn't work. The occluder instance must be added to a visual instance, which then has the scenario and transform.

So all that was missing was putting this at the end:

var instance = RenderingServer.instance_create2(occluder_instance, scenario)
by (1,111 points)
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.