- Home /
Replacing custom shader with unity standard shader
Hey everyone, so I'm developing an VR application where the player in VR sees a special effect which another player (on PC) does not see. They do both see the same geometry though. Simply duplicating the object is no option since the app involves a rather pricy physics simulation which I can't afford to do twice.
So I thought I can use replacement shaders on the PC players camera. However, the original objects need my custom effects shader, since the objects need the effect in VR and I can't have multiple cameras in VR.
This is what the scene looks like without shader replacement from the PC players view: I have to replace my custom effects shader with the Unity Standard shader for the PC player. The effect also just applies to some objects in the scene.
So in my custom shader I did this:
Tags{"ReplaceDamage"="Opaque"}
Then I duplicated the Unity standard shader and added the tag to the Opaque subshader pass and called SetReplacementShader on the PC player's camera.
This is the result:
So it works fine except the objects which have the effect shader don't get their texture rendered by the PC Player camera which uses SetReplacementShader. However, my custom shader does define a "_MainTex" property which should get passed to the standard shader. Anyone have any idea why the texture is getting lost?
Thanks in advance for the help! - Paul
Your answer
Follow this Question
Related Questions
MaterialPropertyBlock ignored when rendering with replaced shaders? 0 Answers
How do I set the MaterialPropertyBlock for terrain grass? 0 Answers
Replace Vertex Shader for all Shaders 0 Answers
Rendertype for Unity's non-legacy Image UI 0 Answers
Camera.RenderWithShader() and GL drawing: possible? 1 Answer