Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 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 /
  • Help Room /
avatar image
0
Question by Honorsoft · Aug 21, 2020 at 01:37 PM · renderingculling

How do you use "UnityEngine.Rendering.CullMode.Off"?

I know you can switch culling off using a shader, but it would be better to be able to just switch culling off through script than to have to make shaders that have culling set to Off. The Unity script reference mentions "UnityEngine.Rendering.CullMode.Off", but gives little-to-no information about it or how to implement it.

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
1
Best Answer

Answer by ASGS_DumbFox · Mar 10, 2021 at 08:02 PM

Hey @Honorsoft

I came across your posting while Also looking for my own solution to doing this and figured out how CullMode works! You can see the forum that I used here link text.

As Glitchers has posted in the original forum using:

 Shader "Example/CullControl" {
         Properties
         {
             [Enum(UnityEngine.Rendering.CullMode)] _Cull ("Cull", Float) = 0
         }
         SubShader
         {
             Cull [_Cull]
         }
     }

in the shader allows you have create an accessible parameter in your shader (this only works on custom shaders you've created). This parameter can then be accessed through code as such:

 rend.material.SetFloat("_Cull", 2);

once you have a reference to a renderer you can access that renderers material property and change the float value of the "_Cull" parameter. This leads back to the API info about Cull Mode and effectively it goes: 0 - No Culling, 1 - Front Face Culling, 2 - Back Face Culling.

Hope that helps!!

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 Honorsoft · Aug 23, 2021 at 05:06 AM 0
Share

Thanks a lot for this answer, and I love that you showed an example of accessing a shader variable from script (which is always my preference). I see a lot of other people online that are/were having trouble with back-face culling, I have said before (to Unity also) that I am surprised that there is no checkbox or anything in the material inspector for culling, since it seems common to need to turn culling off for things like hair, capes, and the walls of structures, etc. But I guess your example shows you could add a checkbox to the shader for culling ( [ToggleOff] ). Your example also gives more control than just toggling culling on/off, that is also handy. If someone needed to have back-face culling for efficiency, then they could even dynamically control the culling setting during runtime using the SetFloat. Thanks.

*By the way, I forgot I wrote this question and I have advanced in Unity a lot since then, however I am still looking for a good 2-sided shader that is close to Unity's standard shader. Just to summarize my problem from the start (for you or anyone having the same issues or who knows what I may be doing wrong), I edited the Unity 5 standard shader to add culling off in the sub-shader section which worked great in Unity 5 only. So I edited a Unity 2018 standard shader the same way and that seemed to work but the other side of the object was semi-transparent (even when opaque). Maybe I didn't put the "Cull Off" in the right place? I will try this method you showed though, thanks again.

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

229 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image 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

Render 2 cameras with same depth. Not split screen. 0 Answers

How to further optimize this project? 2 Answers

Using C# Jobs and Burst Compiler for Foliage System 0 Answers

Triangle culling glitch 0 Answers

Cut through camera render and display LITERALLY NOTHINGNESS 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