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 chbfiv · Dec 28, 2015 at 03:13 AM · renderinggraphicsprojectorrender texturedeferred rendering

How to set the render target(s) for projector shaders?

I would like to set SV_Target0 and SV_Target2 to the diffuse and normal gbuffers (deferred) for a projector shader. Am I on the right track? I guess it would also be nice if I could change the RT per projector params (so I don't change all projectors to the same RT's.

Todo this same concept for meshs I could just use a CommandBuffer and DrawMesh, but I wasn't sure about Projectors.

CommandBuffer

 CommandBuffer buf = new CommandBuffer();
 Camera.current.AddCommandBuffer (CameraEvent.BeforeLighting, buf);
 
 // OnRenderObject
 buf.SetRenderTarget(new RenderTargetIdentifier[] { 
     BuiltinRenderTextureType.GBuffer0, //color
     BuiltinRenderTextureType.GBuffer2 //normal
 }, BuiltinRenderTextureType.CameraTarget);
 
 // foreach Mesh
 buf.DrawMesh (_decalMesh, decal.transform.localToWorldMatrix, decal.Material);

Shader

 // ...
 Pass {
     Tags {"LightMode" = "Deferred"}
     //...
 
 struct rastInput {
         fixed4 albedo : SV_Target0;
         fixed4 normal : SV_Target2;
     };
 
     //...
     rastInput frag (fragInput i) {
         //...
     }
 }
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 chbfiv · Dec 30, 2015 at 03:32 AM 0
Share

After some more research I still haven't come up with a solution besides creating my own CommandBuffer for a custom projector implementation.

It turn's out the issue I was having with targeting to the normal buffer RT from the shader was just because I was using unity 5.3 with the newer deferred renderer, but my shader was trying to use the old deferred render path Light$$anonymous$$ode(s).

Switching the Pass "Light$$anonymous$$ode" = "Deferred" allowed me to write to the appropriate RT(s) without needing a CommandBuffer to switch RT(s) and draw a mesh.

However, Pass "Light$$anonymous$$ode" = "Deferred" for a Projector material doesn't work. I suspect this is because Projectors have their own render path? So, I think the question is still open.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by EvilSam · Dec 30, 2015 at 04:40 AM

In this blog, you can find a few examples of very similar situations, especially the "Deferred Decals" example does almost exactly what you want to do, you just may want implement perspective projection instead of the box projection in the example.

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 chbfiv · Dec 30, 2015 at 06:20 PM 0
Share

The command buffer stuff I was referring to was more or less the same as the example you provided. I understand I can create my own projector/decal system with Command Buffers.

However, the question is about unity projectors. Assu$$anonymous$$g you could use Light$$anonymous$$ode pass tag with a unity projector material, command buffers would not be needed. So, I think the question still stands. How do we specify the Projector RT(s) if Light$$anonymous$$ode doesn't seem to work?

Thanks

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

35 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 avatar image avatar image avatar image avatar image avatar image

Related Questions

Unity Blob shadow projector massive tris amount, why? 1 Answer

Complex Depth Shader 0 Answers

How to make transparent only colliding part of object? 0 Answers

How do I make a boat that doesn't let water enter?,How do I make a boat that water cant get in to 2 Answers

How to show a trail in the shape of a mesh to create the effect of it moving really fast? 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