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
3
Question by OtsegoDoom · Oct 11, 2013 at 01:53 PM · rendertagsqueue

Shader with adjustable render queue

Hi,

I'm trying to build a shader that has a text field for a custom render queue tag. I'd like this to be a number I can specify so that I don't have to create a new copy of my shader every time I want to adjust the queue.

I've got the text field working, and I know where the number needs to go. I'm just not sure how to tell the shader to use the number, and now I'm wondering if this is a limitation of this in Unity.

I guess my question is, can I use a variable in my shader to define the render queue, and if so, how would I get that to work?

 Shader "Render Queue" {
     Properties {
         _Color ("Color Tint", Color) = (1,1,1,1)    
         _MainTex ("Base (RGB) Alpha (A)", 2D) = "white"
         _Depth ("Render Depth", Float) = 0  //This is what I'd like to add
     }
 
     Category {
         Lighting Off
         ZWrite Off
         Cull back
         Blend SrcAlpha OneMinusSrcAlpha
 
         SubShader {
             
             Tags {"Queue" = [_Depth]}  //This line doesn't work, but it gives an idea of what I'm trying to do
             
             Pass {
                 SetTexture [_MainTex] {
                     ConstantColor [_Color]
                     Combine Texture * constant
                 }
             }
         }
     }
 }
Comment
Add comment · Show 1
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 Vicas · Apr 07, 2014 at 07:03 AM 0
Share

Did you figure this one out? I'm looking for the same solution.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Wolfram · Sep 17, 2015 at 05:01 PM

Just modify the material's "renderQueue" field instead, it directly overrides the one defined in the shader.

However, my guess is you want to store this with the asset, and not apply it at runtime via script? In that case it should be possible to write a short Editor script for that. Take a look at StandardShaderGUI.cs which is part of the builtin-shader download, as a starting point.

Be warned, though, that this will permanently override that material's renderQueue; even switching shaders afterwards will no longer modify the actual queue value! To restore the default behaviour, you need to reset the material's renderQueue to -1 using your Editor script.

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

18 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

Related Questions

Render object through terrain 2 Answers

render object on top of everything with dynamic shadows (for mobile) 1 Answer

Rendering order of objects in different depths not correct. 1 Answer

Custom Render Queue 0 Answers

Queue Order and Billboarded Trees 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