Search Unity

  1. If you have experience with import & exporting custom (.unitypackage) packages, please help complete a survey (open until May 15, 2024).
    Dismiss Notice
  2. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice

Old School Super FX Shader

Discussion in 'Shaders' started by Dragonos, May 2, 2011.

  1. Dragonos

    Dragonos

    Joined:
    Nov 10, 2007
    Posts:
    42

    Has anyone tried to reproduce 3d shaders on older hardware such as the Super FX Chip produced similar to Vortex and Star Fox?
    It is very easy to get the faceted look, but I can't think of a decent way to get the classic dithering effect.
    One idea I had would be to over lay the rendered mesh with a static dithered grid. Has anyone tried anything similar? It would be cool to see something like this especially if it was compatible with iOS/Android.
     
    Last edited: May 3, 2011
  2. Dragonos

    Dragonos

    Joined:
    Nov 10, 2007
    Posts:
    42
    I thought I'd give it a try and this is what I got as a result:

    Webplayer
    It looks ok, but the shader seems too complex for what it is actually doing and I doubt it would run on iOS due to the fact it is a surface shader. It uses a ramp like toon shading and is also affected by lights. Any ideas on how to make this more vertex based and how to remove the dithering if it is bright enough?

    Code (csharp):
    1.  Shader "SuperFX/Default" {
    2.     Properties {
    3.       _MainTex ("Texture", 2D) = "white" {}
    4.       _Ramp ("Shading Ramp", 2D) = "gray" {}
    5.       _Detail ("Detail", 2D) = "gray" {}
    6.     }
    7.     SubShader {
    8.       Tags { "RenderType" = "Opaque" }
    9.       CGPROGRAM
    10.       #pragma surface surf Ramp
    11.  
    12.       sampler2D _Ramp;
    13.  
    14.       half4 LightingRamp (SurfaceOutput s, half3 lightDir, half atten) {
    15.           half NdotL = dot (s.Normal, lightDir);
    16.           half diff = NdotL * 0.5 + 0.5;
    17.           half3 ramp = tex2D (_Ramp, float2(diff)).rgb;
    18.           half4 c;
    19.           c.rgb = s.Albedo * _LightColor0.rgb * ramp * (atten * 2);
    20.           c.a = s.Alpha;
    21.           return c;
    22.       }
    23.  
    24.       struct Input {
    25.           float2 uv_MainTex;
    26.           float4 screenPos;
    27.       };
    28.       sampler2D _MainTex;
    29.       sampler2D _Detail;
    30.        
    31.       void surf (Input IN, inout SurfaceOutput o) {
    32.          
    33.           float2 screenUV = (IN.screenPos.xy) / (IN.screenPos.w);
    34.           screenUV *= float2(12*5,8*5);
    35.           o.Albedo = tex2D (_Detail, screenUV).rgb * 1;
    36.           o.Albedo *= tex2D (_MainTex, IN.uv_MainTex).rgb;
    37.       }
    38.       ENDCG
    39.     }
    40.     Fallback "Diffuse"
    41.   }
     
    Last edited: May 3, 2011
  3. tonycoculuzzi

    tonycoculuzzi

    Joined:
    Jun 2, 2011
    Posts:
    301
    What were you using as a ramp texture for this? Also, it compiles with errors in Unity 4, anyone know why?
     
  4. Daniel_Brauer

    Daniel_Brauer

    Unity Technologies

    Joined:
    Aug 11, 2006
    Posts:
    3,355
    The error text can be helpful in finding what caused them.
     
    meat5000 likes this.
  5. IsaacRenders87

    IsaacRenders87

    Joined:
    Apr 22, 2017
    Posts:
    1
    Theres a way? to open this Shader on Unity 5.6.0f3 (32-bit) Personal Editon?