Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question Replace multiple baked lit shaders with dynamic with script

Discussion in 'General Graphics' started by SamTyurenkov, Nov 1, 2020.

  1. SamTyurenkov

    SamTyurenkov

    Joined:
    May 12, 2018
    Posts:
    95
    Hi there,

    I have a scene which is almost fully baked for optimization purposes in gameplay process. However I want to make a cinematic trailer on that scene and I want it to look cooler, than actual game footage.

    So for that purpose I wanted to replace ALL baked lit shaders with dynamic and apply various post processing effects.



    I read about ShaderReplacement:
    https://docs.unity3d.com/Manual/SL-ShaderReplacement.html

    But I can't figure out from documentation - how can I replace Universal Render Pipeline/Baked Lit with Universal Render Pipeline/Lit on all materials. And also replace Unlit with Lit as well.

    I tried applying the following script to camera, but it doesnt seem to do anything:

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. [ExecuteInEditMode]
    6. public class CinematicCamera : MonoBehaviour
    7. {
    8.  
    9.     public Camera cam;
    10.     public Shader replacementShader;
    11.  
    12. void OnEnable() {
    13.     if(replacementShader != null)
    14.     cam.SetReplacementShader (replacementShader, "");
    15. }
    16.  
    17. }
    P.S. Besides, I can't even pick the Lit shader from editor.

    Thanks for any advice.