Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Set shader property by RenderWithShader() oder replacement.

Discussion in 'Shaders' started by Sam55555, Sep 3, 2009.

  1. Sam55555

    Sam55555

    Joined:
    Jun 26, 2009
    Posts:
    17
    Hallo,
    need help.How can i set oder get shader property by rendering with RenderWithShader().I try in OnWillRenderObject() to get material,but get main material and not replacement shader.
    Thanks for antworts.
     
    IgorAherne likes this.
  2. Aras

    Aras

    Unity Technologies

    Joined:
    Nov 7, 2005
    Posts:
    4,770
    The replacement shader will get all the properties from the original material. So if original material had _MainTex texture (for example), it will be set in the replacement shader.

    If you need to have some other values in your replacement shader (some that are not in the original material), best bet is to use global values (Shader.SetGlobalTexture etc.)
     
    IgorAherne likes this.
  3. Sam55555

    Sam55555

    Joined:
    Jun 26, 2009
    Posts:
    17
    Thank you,that is what i searched
     
  4. nasos_333

    nasos_333

    Joined:
    Feb 13, 2013
    Posts:
    11,170
    Hi, is this the same with the new URP renderer feature "Render Objects" ?

    If i want to grab the texture and color will it be grabbed directly if in the replacement material i add "_BaseMap" and "_BaseColor" for example ?

    Thanks
     
unityunity