Skip to content

Instantly share code, notes, and snippets.

@unitycoder
Last active October 9, 2021 16:36
Show Gist options
  • Select an option

  • Save unitycoder/322c40f58ce1693bde9adc38ac023e14 to your computer and use it in GitHub Desktop.

Select an option

Save unitycoder/322c40f58ce1693bde9adc38ac023e14 to your computer and use it in GitHub Desktop.

Revisions

  1. unitycoder revised this gist Oct 9, 2021. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions UnityLogoShader.cs
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,4 @@
    // https://unitycoder.com/blog/2021/10/09/draw-new-unity-logo-using-surface-shader-default-cube/
    Shader "Custom/UnityLogoShader"
    {
    Properties
  2. unitycoder revised this gist Oct 5, 2021. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion UnityLogoShader.cs
    Original file line number Diff line number Diff line change
    @@ -34,7 +34,7 @@ struct Input
    void vert (inout appdata_full v, out Input o)
    {
    UNITY_INITIALIZE_OUTPUT(Input,o);
    o.vertexNormal = abs(v.normal);
    o.vertexNormal = abs(v.normal); // Aah, this is why normal wasnt Normal!
    }

    void surf (Input IN, inout SurfaceOutputStandard o)
  3. unitycoder created this gist Oct 5, 2021.
    69 changes: 69 additions & 0 deletions UnityLogoShader.cs
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,69 @@
    Shader "Custom/UnityLogoShader"
    {
    Properties
    {
    _Color ("Color", Color) = (1,1,1,1)
    _MainTex ("Albedo (RGB)", 2D) = "white" {}
    _Glossiness ("Smoothness", Range(0,1)) = 0.5
    _Metallic ("Metallic", Range(0,1)) = 0.0
    }
    SubShader
    {
    Tags { "RenderType"="Opaque" }
    LOD 200

    CGPROGRAM
    #pragma surface surf Standard fullforwardshadows vertex:vert
    #pragma target 3.0

    sampler2D _MainTex;

    struct Input
    {
    float2 uv_MainTex;
    float3 vertexNormal;
    };

    half _Glossiness;
    half _Metallic;
    fixed4 _Color;

    UNITY_INSTANCING_BUFFER_START(Props)
    UNITY_INSTANCING_BUFFER_END(Props)

    void vert (inout appdata_full v, out Input o)
    {
    UNITY_INITIALIZE_OUTPUT(Input,o);
    o.vertexNormal = abs(v.normal);
    }

    void surf (Input IN, inout SurfaceOutputStandard o)
    {
    float2 uv = IN.uv_MainTex;
    float3 normal = IN.vertexNormal;
    float c=0;

    float s1 = 0.37;
    float s2 = 0.8;

    // right panel
    if (normal.z>0.99)
    {
    c= 1-((step(uv.x,0.8)-step(uv.x,0.37))*(step(uv.y,0.63)-step(uv.y,0.2)));
    float l =1-(distance(uv.x,1-uv.y)<0.1&uv.y>0.5);

    o.Albedo = c*l;
    }else{ // other panels

    c = 1-((step(uv.x,s2)-step(uv.x,s1))*(step(uv.y,s2)-step(uv.y,s1))); // lol
    float l =1-(distance(uv.x,uv.y)<0.1&uv.x<0.5); // lolx2
    o.Albedo = c*l;
    }
    o.Metallic = _Metallic;
    o.Smoothness = _Glossiness;
    o.Alpha = 1;
    }
    ENDCG
    }
    FallBack "Diffuse"
    }