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 Hoeloe · Sep 27, 2013 at 10:17 PM · shadervertexfragmentrenderqueuefur

Vertex/Fragment shaders - transparency ignoring Render Queue

So, I've been writing my own fur shader (because I have only seen one half-decent one around, and I don't have the money to buy it), and it's been going pretty well so far. Lighting is a bit dodgy, but only because I don't have Unity Pro (I could fix it with that, I think). I'm happy to use it as it is at the moment, except for one thing. This shader works by rendering a solid base layer, then gradually stepping out the vertices, and rendering 10 fur layers, stacking on top of each other to produce the hairs. The first layer is rendered with ZWrite On, as well as being tagged as Opaque. The fur layers, however, are rendered with ZWrite Off, and are tagged as Transparent (with the appropriate render queue). However, this is producing problems, as for some reason they seem to always render behind my trees' leaves. No matter what I do to the render queue, I can't seem to get this to work - instead, the only thing I can do is to turn on ZWrite, and this just culls out the leaves, which is almost as bad. I'm fairly new to fragment shaders (I've mostly worked with surface shaders before now), so if anyone could help me out here, I'd really appreciate it. Here's a screenshot of the effect:

Fur displays correctly against opaque objects, but appears behind billboarded objects.

I hope that someone can help me out!

fur issue.png (158.2 kB)
Comment
Add comment · Show 5
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 whydoidoit · Sep 28, 2013 at 09:38 AM 0
Share

Have you tried "Transparent+1000" etc? Try to bring it forward? If you make it work, it will of course render infront of the trees even when it's behind them...

avatar image Hoeloe · Sep 28, 2013 at 09:40 AM 0
Share

I have tried, that's the odd thing, and it changes nothing.

avatar image whydoidoit · Sep 28, 2013 at 09:42 AM 0
Share

Actually that's not right I guess, if they are using a cutout shader for leaves.

avatar image Hoeloe · Sep 28, 2013 at 09:43 AM 0
Share

The leaves are a cutout shader, but it also seems to render behind my custom water shader, which is not.

avatar image Hoeloe · Sep 28, 2013 at 11:01 AM 0
Share

I think I should clarify that no matter how much I fiddle with the render queue, it seems to change literally nothing - It will not render behind the geometry, no matter what I change, and nor will it do what I want and render in front of leaves and grass.

3 Replies

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

Answer by Hoeloe · Sep 28, 2013 at 11:33 AM

Aha! I fixed it! It turns out I needed the tags in the Subshader, rather than inside the Pass. The first pass (the base pass) now overwrites the tags from the Subshader, but the rest of the passes, the fur layers, use the default, and now it works perfectly.

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
0

Answer by highpockets · Sep 28, 2013 at 05:34 AM

I'm no shader expert and I can't see your code, but I think "Transparent" should be fine. Another thing to consider is the Blend options, which are typically right below the tags.

Try:

Tags{ "Queue", "Transparent" }

ZWrite Off

Blend SrcAlpha OneMinusSrcAlpha

This is Alpha blending.

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 Hoeloe · Sep 28, 2013 at 08:49 AM 0
Share

There are the tags on my first, base pass:

  Tags {"Light$$anonymous$$ode" = "ForwardBase" "RenderType"="Opaque"}
  ZWrite On

And these are the tags on my other passes:

  Tags { "RenderType"="Transparent" "IgnoreProjector"="True" "Queue"="Transparent"}
  Blend SrcAlpha One$$anonymous$$inusSrcAlpha
  ZWrite Off
  Cull Off
avatar image
0

Answer by Steviebops · Apr 14, 2014 at 07:46 PM

Would you be willing to share that shader? I've been looking at fur, and the existing free shaders don't seem to work with my texture's alpha. I get a black outline, as seen here. alt text


furissue.png (360.8 kB)
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

how can i catch the sky box and do a reflection in object 0 Answers

CG - Using Matrix as texcoord 1 Answer

Why does my shader only shade objects based on their normals in the X axis? 1 Answer

Additive shader visible in viewport but not in-game 3 Answers

Stop shader values from being clamped 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