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.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Modifying Standard Shader to support 2 textures, 2 sides

Discussion in 'Shaders' started by eco_bach, Dec 23, 2015.

  1. eco_bach

    eco_bach

    Joined:
    Jul 8, 2013
    Posts:
    1,601
    Hi
    Downloaded the latest source for the built in shaders but am confused. Upon examining the Standard Shader, in the various passes all I can see are a bunch of #pragma statements.
    Where are the vertex and fragment methods and the actual code?
     
  2. StevenGerrard

    StevenGerrard

    Joined:
    Jun 1, 2015
    Posts:
    97
    => First I will suggest make your own shader to support "2 textures, 2 sides". This is not hard, just use two uniform texture2D and set Cull Off.
    => Second not sure why just a bunch of #pragma ... I see clear source code in built in shaders ... they use surface function.
     
  3. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,245
    The standard.shader does not use a surface function, it is using #include to have all of the important functions in an external .cginc file. These same functions are the basis of the shader constructed by the #pragma surface Standard type shaders. Using a standard surface shader might be the easiest way to do a two sided material, especially now that VFACE is supported. Just add float facing : VFACE to your Input struct.
     
  4. eco_bach

    eco_bach

    Joined:
    Jul 8, 2013
    Posts:
    1,601
    Thanks. Might give that a try. What I ended up doing is using ShaderForge. Making a shader that works with PBR is as simple as a mouse click and I can study the resulting shader code.