Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 BoZZoM · Apr 05, 2021 at 10:26 AM · shadershadersshader programmingshaderlabshader writing

"Stencil Operation" property setup?

I know when declaring the properties for a shader there are some types of "input": float, range, color, 2D.

but when I try to set up a Stencil Operation as a property. how to do this? I mean what I know that Stencil Operation is one of this list (Greater, GEqual, Less, LEqual, Equal, NotEqual, Always, Never) so then how to indicate which op from the editor.

I saw a line like this:

_StencilOp ("Stencil Operation", Float) = 0

so what "0" stands for?

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 · Apr 05, 2021 at 10:51 AM

Well, Unity has the enums Rendering.StencilOp and Rendering.CompareFunction which do reflect those int values. Unfortunately the documentation does not mention the actual index values. However since you can and should use the enum anyways this shouldn't really matter ^^. Though if you do want / need to know those values, someone posted them over here, though this list may not be up to date. The best source would be looking up the declaration of the enums in the source: CompareFunction and StencilOp. I'm sure there aren't much changes happening in those enums over time, but if you really want to be sure you can use ILSpy or any other reflector and look up the enum in your current Unity version.


Though as I said you usually want to use the enums directly. You may need to cast them to int in order to use them.

Comment
Add comment · Show 2 · 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 BoZZoM · Apr 05, 2021 at 11:09 AM 0
Share

Good. but what about the "color mask" property? do you have an idea? like this line: _ColorMask ("Color Mask", Float) = 15

avatar image Bunny83 BoZZoM · Apr 05, 2021 at 11:44 AM 0
Share

The color mask is as the name suggests a bit mask. The enum for it is right between the two enums I just linked ^^. The enum is called ColorWriteMask. The bits are ordered from leaset significant to most significant in the order A (1), B (2), G (4), R(8). So a value of 0x0F (or "15" or "00001111b") is just all 4 channels while a value of 14 (0x0E or "00001110b") would only write the 3 color channels but not the alpha channel. Since it's a bitmask you would combine the different bits using the bitwise or operator |.

 ColorWriteMask mask = ColorWriteMask.Red | ColorWriteMask.Blue;

This mask would only write the red and blue channel and would represent a value of "10" (0x0A or "00001010b")

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

190 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

Related Questions

Fog not working in my Shader~ 0 Answers

Header for material properties in inspector? 2 Answers

Addition to Standard Shader stopping it from batching? 0 Answers

Unity 3d Sprite Shader (How do I limit Max Brightness to 1 with Multiple Lights Hitting) 0 Answers

A Cg shader semantic problem 2 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