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 Tudor · Aug 31, 2015 at 11:14 AM · shaderrenderingcgpassdeferred rendering

Forcing Multi-Pass shader to use Deferred passes instead of Forward passes?

I wrote a Multi-pass CG vertex/fragment shader that does some stencil masking before finally rendering the object.

My issue is that as soon as I use more than one pass in my Opaque shader, it is rendered with Forward Alpha (unity 5's profiler says RenderForwardAlpha.Render).

Render tags for masking pass:

 Tags { "RenderType"="Opaque" "Queue"="Geometry+1"}
 ColorMask 0
 ZWrite off
 Cull Front
 ZTest Less

Render tags for final pass:

 Tags { "RenderType" = "Opaque" "Queue" = "Geometry+3" }
 ZWrite Off
 Blend Off
 Lighting Off
 ColorMask RGB
 ZTest Always

As you can see, I am trying my best to tell Unity to render an Opaque object, using nothing except Deferred Rendering.

I debugged it to the point where if I have nothing in my CG vert/frag but I have two Opaque passes, those meshes go to the ForwardAlpha renderer...

What am I missing? How can you write a muliple pass Deferred CG shader?

PS: I can successfully use sampler2D _CameraDepthNormalsTexture;, but whether I use it or not, it still renders in ForwardAlpha if it has more than 1 pass.

Comment
Add comment · Show 2
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 _Gkxd · Aug 31, 2015 at 02:25 PM 0
Share

Did you set the rendering path of the camera to deferred rendering?

http://docs.unity3d.com/$$anonymous$$anual/class-Camera.html

avatar image Tudor · Aug 31, 2015 at 03:26 PM 0
Share

_Gkxd Yes, I have. Both the camera and the player settings are on (non-legacy) Deferred just to make sure. But either way, the Profiler shows all other (and non transparent) geometry still being rendered in Deferred Rendering mode; it's just this thing with passes that turns that specific geometry to forward.

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by Llockham-Industries · Oct 27, 2017 at 02:01 AM

You could try adding Tags{ "LightMode" = "Deferred" }. But I'm not certain deferred rendering supports multipass shaders. You could get around it by giving your objects renderer multiple materials, but if it has multiple submeshes this quickly falls apart. :/

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 Llockham-Industries · Nov 30, 2017 at 10:37 AM 0
Share

Did a quick test, you can have multiple passes with the deferred tag render in the order listed in the shader. Though you'll need a fair understanding of ver/frag shaders and Unity's deferred rendering path to make any use of this.

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

30 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

Related Questions

Surface Shader World Normal 0 Answers

Parsing values in multipass cg shader 0 Answers

Multipass Shader Question - How to handle alpha blending between passes 0 Answers

Shader - Share values between different pass 0 Answers

Get color of pixel before pass: prefer cg, shaderlab is last resort 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