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\$
5
  • \$\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_
    Commented Jun 16, 2016 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\$
    – eclmist
    Commented Jun 16, 2016 at 10:15
  • \$\begingroup\$ I'm only talking about modifying a copy of the transform for frustum culling. \$\endgroup\$
    – Syntac_
    Commented Jun 16, 2016 at 12:16
  • \$\begingroup\$ I'm not sure I understand what you mean. Could you elaborate a bit more? \$\endgroup\$
    – eclmist
    Commented Jun 16, 2016 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_
    Commented Jun 17, 2016 at 7:54

1 Answer 1

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.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .