2
\$\begingroup\$

I have a scene with a straight path. It looks something like this:

enter image description here

I've also wrote a vertex shader that bends the path. After applying the shader, it looks something like this:

enter image description here

If you were to look at the walls on the right, the emptiness is created by wall tiles that were culled by the camera's default frustum culling.

Is there a way fix this without disabling frustum culling completely?

\$\endgroup\$
  • \$\begingroup\$ Surely you'd have to apply the same math as in the vertex shader to the objects' transforms before frustum culling to match, doesn't have to be exact an approximation would be good enough. \$\endgroup\$ – Syntac_ Jun 16 '16 at 10:11
  • 1
    \$\begingroup\$ Moving the object's transform would result in the vertex shader moving it further, not sure if that's what you meant though. \$\endgroup\$ – Alchemist Jun 16 '16 at 10:15
  • \$\begingroup\$ I'm only talking about modifying a copy of the transform for frustum culling. \$\endgroup\$ – Syntac_ Jun 16 '16 at 12:16
  • \$\begingroup\$ I'm not sure I understand what you mean. Could you elaborate a bit more? \$\endgroup\$ – Alchemist Jun 16 '16 at 17:11
  • \$\begingroup\$ Sorry I didn't realise this was in Unity, I'm unable to provide details on how to do it. \$\endgroup\$ – Syntac_ Jun 17 '16 at 7:54
1
\$\begingroup\$

One of the solutions is to increase the size of bounding boxes of your meshes so they still touch the frustum. Usually it's much easier but in your case it depends on the distortion caused by vertex shader and you didn't say much about that.

You'll probably need some experiments to find optimal way to compute BBox extends for each mesh. For start try to increase them by some constant amounts and see if that's what you need.

I assume that at the Camera position you don't change the vertices and the vertex shader influence increases with Camera.forward vector. In your current example meshes at the right should have increased bounds but for meshes at the left you can actually decrease them.

Here you have an answer how to change mesh BBox.

| improve this answer | |
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.