3D Camera manually choose what to unload

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Bob

Hey,
I want to make a project where I distort meshes using a vertex shader. This works fine, except when the mesh would not be in the camera when the shader is not applied. Then the Camera seems to auto-unload that mesh and not render it, until the camera is moved so that the mesh would be visible without the shader.
So is there a possibility to manually choose which mesh to render and which to unload?

Hi! Have you tried vortext shader module because what you try to do is not simple with 4 lines of code as I have looked up it earlier

Okan Ozdemir | 2020-03-29 17:40

What is a vortext shader module? I can’t find anything about that.

Bob | 2020-03-29 18:46

That is an interesting demo, but sadly I don’t know how this helps with my problem.

Bob | 2020-03-29 21:04

:bust_in_silhouette: Reply From: Joel_127

Hello!

Godot have an invisible box around meshes, called the AABB (axis aligned bounding box). When this box is not visible (out of camera), the mesh is not displayed. This is an optimization trick to not draw objects that are not visible.

You are using a shader to move the vertexes of your object, however the AABB is static and will not adjust to the new vertex positions, this is the problem.

Unfortunately I don’t know how to fix this, since I don’t think there is a way to set a custom AABB, you can only get it. VisualInstance — Godot Engine (3.1) documentation in English

:bust_in_silhouette: Reply From: Joel_127

Ok, I found the solution :slight_smile: If you click on your MeshInstance, you can set a customer Aabb:

“Overrides the AABB with one defined by user for use with frustum culling. Especially useful to avoid unexpected culling when using a shader to offset vertices.”