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 /
This post has been wikified, any user with enough reputation can edit it.
avatar image
1
Question by Kangoo13 · Jul 02, 2015 at 07:17 PM · cameratexturerenderingmultiplealgorithm

Two camera rendering an object differents textures

Hello everyone,

I have an issue of algorithmy. Here is what I have to explain the context : I have one camera, displaying the object in his "normal" texture, and I want another camera to show the same object but with a different texture (Infrared texture), because I want a normal and an Infrared camera.

But I can't find an optimised way to do that.. Because I have a lot of objects which some are pretty heavy. Duplicating the object will make the program very very slow...

Thanks for your help.

Comment
Add comment · Show 5
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 meat5000 ♦ · Jul 02, 2015 at 03:47 PM 0
Share

You dont need to duplicate anything. Just have another camera and slap some image effects on it.

avatar image Kangoo13 · Jul 02, 2015 at 04:03 PM 0
Share

I can't put a shader on my camera, because i'm working on a simulation and so that i have pre-made texture with infrared put on the good spots of the object. (So in fact the infrared texture is generated by a special software)

avatar image AlwaysSunny · Jul 02, 2015 at 07:17 PM 0
Share

This sounds like a job for RenderWithShader to me. This is a powerful, often-overlooked, and slightly confusing feature. Look into it and see if it will satisfy your request. If not, or if you get stuck, please explain why this will not work for you, and perhaps we'll come up with some alternatives.

http://docs.unity3d.com/ScriptReference/Camera.RenderWithShader.html

avatar image Kangoo13 · Jul 06, 2015 at 06:55 AM 0
Share

Well I don't know if RenderWithShader can allow a changing of texture ? I mean here is my example : One camera Cam1 is looking at the world with normal texture, Cam2 is also looking at the world with normal texture too, and when I want the infrared to come the Cam1 now see the world with Infrared textures (But not with maths on shader, just on replacing a texture by another one in Resources) do you see?

avatar image AlwaysSunny · Jul 06, 2015 at 10:17 AM 0
Share

Ah, I see the conundrum now: Not all cameras should view the infrared textures, and the method doesn't (yet) involve an image effect.

Something tells me an image effect is still the best approach. Ideally you would store the infrared textures with the material as an extra texture property on the shader, which implies editing whatever shader you're using.

This is a request I have no experience with. If no one comes along to help, you might consider asking the question in the shader forum armed with the knowledge of which approach you want to use. Any workable approach is going to involve an image effect, or at least the OnPreRender/OnPostRender methods of a camera script.

e.g. in descending order of wisdom:

A) image effects + edited shader with alternate texture property
B) multiple materials switched on/off during OnPreRender / OnPostRender
C) multiple independent objects on respective layers to achieve desired render results.

2 Replies

· Add your reply
  • Sort: 
avatar image
-1

Answer by AurimasBlazulionis · Jul 06, 2015 at 10:33 AM

You are wrong about duplicating objects making your program super slow, just put the normal ones to 1 layer and infrared to another layer, then one camera draws normal objects (choosing their culling mask), and another infrared ones, enable and disable cameras when you need another one to be drawn (you can also make both cameras visible at the same time). Also remove colliders from infrared ones to not be interacted by physics. Make infrared objects be a child of normal one and you are good to go.

You can also simply change the material of object to make it infrared. If you want to do so you are probably interested in this question. This should be used if you want to switch between modes, but won't really work if you want to display both infrared and normal object at the same time.

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 Kangoo13 · Jul 06, 2015 at 11:26 AM 0
Share

The thing is, I already duplicate every object by 3, because what I am making is a drone simulator, and we need to duplicate each objects 3 times for 3 different drones (not only the drones, but the ground as well, I am using a system of bundle and chunk so the drones are already not on the same layer and the cameras currently display the good culling mask) so If I do your method, I will have 6 duplication to do right ? Won't it be a bit heavy ? I am sorry for my bad english tell me if you don't understand what I am saying.

avatar image AlwaysSunny · Jul 06, 2015 at 05:17 PM 0
Share

@TheDiamondPlay - This is not sound advice. It is true that extra game objects do not necessarily cripple draw calls if they're culled properly, and duplicates can be a valid solution to some problems. This is not one of those situations. GameObjects most definitely have a negative impact on performance, even if they're not drawn or even active. Technically duplicates could solve the OP's problem, but that's also the worst possible approach. The better "brute force" method would involve switching out materials during OnPre/OnPostRender of the specific camera(s).

@$$anonymous$$angoo13 - Why do you need to "duplicate every object by 3"? I cannot imagine a good reason for this. What does this help you accomplish? There's got to be a better way. Definitely don't make it 6. You should try very hard to avoid using duplication as a design strategy; there's almost always a better way.

avatar image
0

Answer by patchworkx · Jan 06, 2017 at 06:04 PM

Whats about an video texture with 2 frames .. 1 frame normal../2nd frame infrared.. camera 1 stop@first frame.... or frame 1 / camera 2 stop @last frame .. or 2nd frame..

u Can have more than 2 different textuers that way

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

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

6 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Capturing the real-time output of multiple cameras in a scene 1 Answer

Rendering a Pygame surface in Unity 0 Answers

Create texture from current camera view 3 Answers

Multiple Render Texture and Ordering 0 Answers

Render texture and shader issues 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