Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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 Okari-Draconis · Jul 02, 2014 at 06:08 PM · shaderrenderingshaderscamera.render

Render the scene only using a given a renderType tag

Hi, is there a way I can tell the a Camera to render the whole scene, and only render objects with a specific RenderType

With Out replacing their current shader...

Basicly, I want to write an additional pass on multiple Shaders tagged renderType="AwesomePass" MainCamera will do its its normal stuff. Then I tell a 2nd camera to render the scene only using the AwesomePass, and then each object that has an AwesomePass will use its Own shader code, and not a replacement One.

another way to put this is...

I want to have Multiple Shaders that are on a Select few objects to have a Special pass tagged with renderType="AwesomePass" When I call a render to the scene, only the objects, that use a Shader that is tagged with "AwesomePass" will then render That specific Pass.

I am rending this AwesomePass to a render Texture. and Again, I DO NOT want to replace their current 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

2 Replies

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

Answer by Okari-Draconis · Jul 06, 2014 at 11:18 PM

I hade Posted my question here as well : http://forum.unity3d.com/threads/render-the-scene-only-using-a-given-a-rendertype-tag.254976/

After everyones Post, I was able to get the effects I wanted via Making Multiple Cameras to Control when things were Renderered. I also found out that when using a Replacement Shader, its being executed as if its running in that file : IE: that you have access to all the same properties and variables

And so I just had to do write a replacement shader for every rendertype I had that would Output this information. But instead of of using RenderType = AwesomePass. I used AwesomePass = Terrain, and AwesomePass = Fun, etc etc. Since I didn't want to completely overwrite the RenderTypes. Thusly because only 3 Different Shaders use my AwesomePass tag I only had to write 3 shaders.

I also did use some Camera Masking for some of the Render Passes. Thanks for the help :)

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
1

Answer by fafase · Jul 02, 2014 at 06:13 PM

I think you are after culling mask:

http://docs.unity3d.com/ScriptReference/Camera-cullingMask.html

EDIT: Considering your comment, so you want to modify the rendering of an object based on what camera is rendering. You can use one of the callback from MonoBehaviour for instance:

http://docs.unity3d.com/ScriptReference/MonoBehaviour.OnPreRender.html

Consider this script below:

 public class ModifyRendering: MonoBehaviour {
     public Renderer render;
     void OnPreRender()
     {
         render.material.color = Color.white;
         if(tag == "MainCamera"){
             render.material.color = Color.red;
         }
     }
 }

You attach that to all cameras and add as many checks you need. There is a reference to the object meant to be controlled.

Here below is a more advanced version that discard the check from the callback and only makes it happen once:

 public class ModifyRendering: MonoBehaviour 
 {
      delegate void EventHandler ();
      event EventHandler OnRenderProcess; 
      public Renderer render;
      // The event is set in the Start once
      void Start()
      {
          if(tag == "MainCamera")
          {
              OnRenderProcess = SetForMain;
              return;
          }
          // Can be as many if you need here based on tag or culling mask or else
          OnRenderProcess = SetForCamera;
      }
     // The callback
     // Using OnPreCull you are even earlier in the process
     void OnPreRender()
     {
         OnRenderProcess ();
     }
     // The methods
     void SetForMain()
     {
         // Here changing color but you can also change the shader
         render.material.color = Color.blue;
     }
     void SetForCamera()
     {
         render.material.color = Color.white;
     }
 }







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 Okari-Draconis · Jul 02, 2014 at 06:34 PM 0
Share

$$anonymous$$inda of... But that only gets me halfway there. Since I want to run a specific pass on each of those objects, And have that pass run from thier shader

avatar image Okari-Draconis · Jul 02, 2014 at 09:22 PM 0
Share

To clarify further i need to render the same object twice with different render outputs.. i need to access the texture and other properties on that object material.. but produce a different output. I also need those same objects to share the same layers that dont have this output for physics calculations

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

21 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

Related Questions

U5 shader coming out solid black on newer iOS devices (iPad 2 Air / iPhone 6) 1 Answer

Blender's Set Solid in Unity 1 Answer

Custom shaders cause objects to render behind other objects from certain angles 1 Answer

How to write an additive HDRP shader without glow 0 Answers

Universal Render is stuck applying Cyan 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