- Home /
Render object with different shader depending on the camera
I have an object with a custom shader. When it is being rendered by cameraA, then I want it to render a particular way (ex red). When it is rendered by another cameraB, I want it to render a different way (ex green).
Is there some way I can tell what is the current camera rendering in the shader? Or perhaps I can toggle a boolean value in my shader between rendering of each camera? Where would I do this (OnPostRender() maybe?).
Answer by Namey5 · Jul 24, 2016 at 09:11 PM
You can set replacement shaders per camera, which through use of shader tags will replace object shaders when rendering with said camera.
Answer by Glurth · Jul 24, 2016 at 09:32 PM
Not quite clear where you are looking for this information. If it's in your monobehavior, say.. in OnRenderObject(), you can use Camera.current
to get a reference to the currently rendering camera.
Your answer
Follow this Question
Related Questions
object not rendered correctly when i take camera away from object in unity vuforia 0 Answers
Dividng clip space by "w" warps the output? 1 Answer
Render group of objects in front? 0 Answers
Is there a way to render a single object with a unique color per active camera? 1 Answer
How can I make a quad render below absolutely everything else? 1 Answer