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 chef_seppel · Jun 15, 2015 at 03:32 PM · camerashaderrenderingrenderwithshader

Render everything in black, but the enemies in red

Hello,

i want to make a heat-vision like effect and for that i have a second camera that renders to a texture. What i now want is to render everything in the scene in solid black, except for the enemies. They should appear in solid red. Im looking into Camera.RenderWithShader right now, but i still dont get how to do that. I guess i can turn everything into solid black, but i dont know how to "tag" enemies so they become red.

Any hints?

Thanks in advance chef_seppel

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

Answer by The-Game-Master · Jun 15, 2015 at 03:53 PM

This is what I'd do. I would make 2 cameras. On camera 1, I would set "Clear Flags" to "Solid Color", set the background color to black, and then set "Culling Mask" to "Nothing". Then, on the second camera, I'd give the enemies their own layer, then set the background to black, set "Clear Flags" to "Solid Color", then set the "Culling Mask" to "Enemies" (or whatever layer you assigned your enemy characters). I'm not sure how to make them red, but I know how to only make the enemies visible. Edit: This is only theoretical, I'm not 100% sure that this will work. I see no reason, however, that it wouldn't.

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 chef_seppel · Jun 15, 2015 at 05:57 PM 0
Share

i tried it and it doesnt work. The second Camera shows exactly what you described. All my enemies on a black background. But the first one is just black. What is pretty much what i was expecting... because it just renders the background and nothing else. Did i miss something?

avatar image
0

Answer by suchoparek · Jun 16, 2015 at 05:42 AM

Probably you should create a Camera and set the culling mask to only show the enemies layer, then adding a Color Adjustment Component to render everything in red (you will probably need a Color Correction or something...)

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 chef_seppel · Jun 16, 2015 at 08:49 AM 1
Share

that would be no problem, but then i would always see the enemies. No matter if they are behind an obstacle or not. But i want them to be occluded by obstacles.

avatar image suchoparek · Jun 16, 2015 at 09:24 AM 0
Share

$$anonymous$$aybe this is a little overdoing, but you could use Depth$$anonymous$$ask: http://wiki.unity3d.com/index.php/Depth$$anonymous$$ask Basically this shader draws the depth buffer but not the RGBA channel. You can assign this shader to every object that has to cover the enemies, then raise the RenderQueue of the enemies. As a result, the enemies will be drawn behind the objects with the shader.

avatar image chef_seppel · Jun 16, 2015 at 10:47 AM 0
Share

hmm, assigning a special shader manually to all obstacles is not practical in my case. So could i do it with Camera.RenderWithShader?

avatar image suchoparek · Jun 16, 2015 at 12:42 PM 0
Share

Take a look at 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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

CommandBuffer's CameraEvent ordering not in sync with shader rendering queue? 1 Answer

Is it possible to only render on one side of a plane? 4 Answers

RenderTexture to Shader everyframe 0 Answers

"Motion vectors" and "depth with normals" from camera's target texture 1 Answer

Uniform Texture, Rendering Problem 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