Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 codingboss777 · Jan 07, 2020 at 11:15 PM · mesh3drendering

Disable Mesh Culling

I am working on a 3D graphing calculator project where an XZ grid mesh is procedurally generated and the Y position of each vertex is dictated by an expression in terms of x and z. The issue is when the expression is x^2 + z^2, for example, all the triangles are facing towards the inside of the paraboloid and the triangles in the front do not show. Also when I try and make the mesh double-sided there is a lighting glitch and the whole mesh turns black. What I really need is a way to disable culling for this mesh.

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

1 Reply

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

Answer by Bunny83 · Jan 08, 2020 at 08:32 AM

No, this has nothing to do with culling. You simply can not render a single triangle that looks like two surfaces from two different angles. Disabling backface culling will just always render the triangle no matter from which side it's viewed. However that doesn't help if you actually want to have proper lighting. Every vertex has a vertex normal which specifies the surface front and angle. This normal is required for proper light calculation.


You essentially have those options:

  • You simply can model your triangles two sided. That means you need your x-z plane twice.

  • You could write a specialized two-pass shader where the first pass renders the front face normally (culling the backface) and have the second pass only rendering the backface (culling the front face) but manually invert the vertex normals in the shader for this pass.

  • What's also possible on newer devices is to use a geometry shader which could take in a triangle and emits two triangles (the proper front and back face).

  • Another solution could be to use the "approximate partial derivative" functions ddx and ddy together with the cross product to calculate the flat surface normal inside the fragment shader to decide if the normal should be flipped or not. However this also limits the usecases and might cause issues for some edge cases.


The most flexible approach is the first one. Since it doesn't depend on some special shader so you could use pretty much any shader you like. Of course it doubles your vertex and poly count. However this implicitly happens in the other cases as well at least from the rendering overhead's perspective.


To address your title and your last sentence I'd like to add that culling is just the process of removing "things" based on some criteria. There are many different culling processes involved. First of all Unity does a CPU side frustum culling of gameobjects based on their AABB (Bounds). Many people who create meshes manually forget to call RecalculateBounds. That could mean Unity decides to not render an object (because its bounds is completely outisde the camera frustum) even parts of the mesh could potentially be seen. That's why the bounds has to enclose the whole mesh.

Next we have the GPU performing also frustum culling. It simply discards all triangles which are not intersecting the camera frustum. The remaining triangles are clipped and rasterized to the screen.

Next we have the backface culling. A single triangle always has a front face and a back face. Which side is which depends on the winding order of the vertices on the screen. In Unity a clockwise winding oder is usually the front face and a counter clockwise order represents the backface. The main point why we do backface culling is, like i mentioned above, that we need lighting relevant data at each vertex to model a proper surface (most important the vertex normal). However this can only be done for one surface. When not using backface culling both sides would be treated equally. That means when the light comes from behind the surface (behind the front face, not facing the vertex normal) the face is in shade. Since the backface face the other direction the lighting would appear inverted.

Finally there might be "depth culling". Though this is one of the latest stages and just involves a depth test against the depth buffer if the fragment that is processed should actually be rendered or not


So "culling" applies to many different thing and disabling any of them won't fix your issue.

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

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

179 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 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

Problem with graphics on Android (Opengl) 0 Answers

Performance Optimization for Mobile 3D, No Static 2 Answers

Close meshes render in 2D, but not 3D 0 Answers

3D Text Mesh - Display Glitch 0 Answers

More tris after adding material?! 0 Answers


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