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 michael 4 · Jun 13, 2011 at 06:43 PM · camerashaderreplacement shaderoverdraw

Global Shader Question

Right now Im applying a global shader that looks like overdraw mode using

Camera.SetReplacementShader();

That works fine, I can temporarily change everything in the scene to render with my overdraw shader when the function is utilized.

However, Now I have 2 gameobjects in the scene that are a type of tactical overlay. I dont want them to be rendered with my global overdraw shader like every other gameobject in the scene.

So is there a way to use Camera.SetReplacementShader() or something similar to apply a global shader to everything except one or two game objects? or am I out of luck because of the nature of using a global replacement shader?

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 Jessy · Jun 13, 2011 at 08:03 PM

There are a couple options I know of. The easiest is probably to just use a separate camera that renders only the tactical overlay mesh.

The other option involves a couple steps: you have to give your tactical overlay material a new replacement tag. (e.g. "RenderType"="TacticalOverlay"). In your replacement shader, you have to copy the SubShader(s) the tactical overlay is using. That way, the shader replaces the SubShader it had been using with identical code, and it only happens for that material.

http://unity3d.com/support/documentation/Components/SL-ShaderReplacement.html

Comment
Add comment · Show 4 · 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 michael 4 · Jun 14, 2011 at 01:29 PM 0
Share

The second way that you mentioned is the way that it needs to be done,However Im not sure how to set it up properly. The tactical overlay actually uses the Flare shader, everything else uses a normal diffuse texture.

So I tried using

Camera.main.SetReplacementShader(overdrawShader,"Opaque");

but when that runs, then nothing is rendered, the replacement tags are already built into unitys shaders right? The only user built shader Im using is the overdraw shader. Do I need to do anything special to that?

avatar image michael 4 · Jun 14, 2011 at 01:39 PM 0
Share

Actually when I read your response more clearly I think I got a better idea of what you where trying to say.

Are you saying that I need to copy the subshader code of the flare shader over to the subshader of my overdraw shader? $$anonymous$$y overdraw already has subshader properties so thats why Im confused about it.

Here is my overdraw shader:

Shader "Overdraw" {

Properties {

 _$$anonymous$$ainTex ("Base", 2D) = "white" {}

}

SubShader {

 Fog { $$anonymous$$ode Off }

 ZWrite Off

 ZTest Always

 Blend One One // additive blending

 Cull Off

 Tags { "RenderType"="Overdraw" }

 Pass {

     SetTexture[_$$anonymous$$ainTex] {

         constantColor(0.1, 0.04, 0.02, 0)

         combine constant, texture

     }

 }

}

}

avatar image Jessy · Jun 14, 2011 at 02:16 PM 0
Share

You're not using SetReplacementShader right. "RenderType" is the second argument, not "Opaque". Let me know if that clears things up for you.

avatar image michael 4 · Jun 14, 2011 at 02:23 PM 0
Share

Yes that worked, Thank you!

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

2 People are following this question.

avatar image avatar image

Related Questions

Using a camera replacement shader but keeping the underlying (original) colors? -4 Answers

Replace shader at runtime 0 Answers

Help with multi-purpose replacement shader for camera 1 Answer

Shader Replacement not working with a very simple shader. 0 Answers

Problem with camera target texture and replacement shader 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