Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by $$anonymous$$ · Mar 23, 2020 at 11:42 PM · meshrenderingcullingvertex shaderinstancing

How to prevent frustum culling when using a vertex shader?

Here's the setup:

  • Unity 2019.3.6f1

  • I'm using GPU instancing to draw many things.

  • Each thing has it's own size (not scale), but uses the same base mesh

  • Vertex shader slices the mesh to correct size (similar to a 2d 9-slice sprite but in 3d, so 27-slice)

This all works great - very few draw calls, very low memory usage (no per-instance mesh), etc.

Except for two issues:

  1. Frustum culling seems to go off the base mesh or maybe mesh bounds.

  2. Ditto for editor hit testing.

Not unexpected since I didn't think it would run my vertex shader, but how do I work around it?

My first though was to set bounds on the Renderer - nope, it's read only.

Setting it on the mesh doesn't help because the size is per-instance and many instances use the same mesh.

Thoughts?

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by Bunny83 · Mar 24, 2020 at 03:08 AM

Well in your specific case your only solution would be to simply prevent frustum culling by setting a very large Bounds for your mesh. Keep in mind that the Mesh.bounds is defined in local space. Since you do some sort of 26 slice you probably have one corner fixed?! and you are moving the opposite corner depending on your size. If that's the case you could could just set the mesh bounds to a similar size but just increase your variable ends up to your expected max size. Of course this would almost in all cases disable frustum culling. However if one corner is fixed (in local space) you could still benefit from frustum culling in some cases. If your mesh can grow in any direction you would need to set the bounds to a large value in all directions. I'm not sure if you can use infinity for the bounds size / extent in order to get an infinitely large AABB so it will always overlap is the view frustum.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
1

Answer by $$anonymous$$ · Mar 25, 2020 at 07:20 PM

Thanks for the answer @Bunny83. That's what I suspected, but was hoping there was something I missed.

It's unfortunate that furstum culling is so inflexable...if anyone from unity is listening, please support per-instance / renderer culling bounds.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Pangamini · Oct 26, 2021 at 05:33 PM 0
Share

SkinnedMeshRenderers support this... I am now thinking about some custom "Renderer" Script that would use a MeshRenderer with an empty per-instance mesh that has some bounds, then using OnWillRenderObject to call Graphics.DrawMesh, or something like that

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

161 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How to compute shadows in custom Surface Shaders? 0 Answers

culling issues on dynamically generated mesh 1 Answer

Miegakure-esque Mesh culling? 0 Answers

Weapon system 0 Answers

UNITY4 all i see is the triangle/verts of objects 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges