Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


RenderWithShader(Shader, string)

Render the camera with shader replacement.
Read time 1 minuteLast updated 5 days ago

Definition

  • Type: Method
  • Namespace: UnityEngine
  • Assembly: UnityEngine.CoreModule
public void RenderWithShader(Shader shader, string replacementTag)

Parameters

shader


replacementTag

Remarks

See Rendering with Replaced Shaders page for details.
This will render the camera. It will use the camera's clear flags, target texture and all other settings.
If the replacementTag argument is not in use, pass an empty string as the value.
The camera will not send MonoBehaviour.OnPreCull(), MonoBehaviour.OnPreRender() or MonoBehaviour.OnPostRender() to attached scripts. Image filters will not be rendered either.
This is used for special effects, e.g. rendering screen space normal buffer of the whole Scene, heat vision and so on. To make use of this feature, usually you create a camera and disable it. Then call RenderWithShader on it.
You are not able to call the Render function from a camera that is currently rendering. If you wish to do this create a copy of the camera, and make it match the original one using Camera.CopyFrom.