- Home /
Using alternative shaders for my HUD camera
I'm designing a space exploration game and I have a working HUD camera that shows a close-up of the in-game object the player is currently 'scanning' at the top right of the main camera screen.
Trouble is, I'd like to display the scanned game objects in a different style to how they look in the 'real' camera. If possible, I'd like each object to have a hudScannerShader property (which would vary from object to object) that gets used in the HUD camera only. Does anyone know how I would implement that?
I know there's a Camera.RenderWithShader() method, but I don't see how that can allow for different shaders per object. Any help, much appreciated.
Thanks.
Answer by moosefetcher · Aug 17, 2016 at 07:50 AM
It turns out, I only ever need to render one scanned object at a time with the HUD camera, so I've used... https://docs.unity3d.com/ScriptReference/Camera.SetReplacementShader.html ...and the replacement shader gets pulled from the currently scanned object. Seems to work well. In case it's useful to anyone, the script attached to each prefab GameObject has a public Shader 'hudCameraShader' property that has the correct HUD shader slotted into it.