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. Dismiss Notice

Hard surface shaders not working in unity 5?

Discussion in 'Shaders' started by tawdry, Mar 14, 2015.

  1. tawdry

    tawdry

    Joined:
    Sep 3, 2014
    Posts:
    1,356
    Hi
    Got these shaders off the asset store called hard surface
    http://u3d.as/content/bruno-rime/hard-surface-shaders-free/1RB
    Worked fine in unity 4 but they are broken in 5:(
    I know nothing about shaders anyone able to correct this code to get it to work in unity 5?

    Code (CSharp):
    1. Shader "HardSurface/Hardsurface Free/Opaque Specular"{
    2. Properties {
    3.     _Color ("Main Color", Color) = (1,1,1,1)
    4.     _SpecColor ("Specular Color", Color) = (1, 1, 1, 1)
    5.     _Shininess ("Shininess", Range (0.01, 3)) = 1.5
    6.     _Gloss("Gloss", Range (0.00, 1)) = .5
    7.     _Reflection("Reflection", Range (0.00, 1)) = 0.5
    8.     _Cube ("Reflection Cubemap", Cube) = "Black" { TexGen CubeReflect }
    9.     _FrezPow("Fresnel Reflection",Range(0,2)) = .25
    10.     _FrezFalloff("Fresnal/EdgeAlpha Falloff",Range(0,10)) = 4
    11.     _EdgeAlpha("Edge Alpha",Range(0,1)) = 0
    12.     _Metalics("Metalics",Range(0,1)) = .5
    13.  
    14.     _MainTex ("Diffuse(RGB) Alpha(A)",2D) = "White" {}
    15.     _BumpMap ("Normalmap", 2D) = "Bump" {}
    16.     _Spec_Gloss_Reflec_Masks ("Spec(R) Gloss(G) Reflec(B)",2D) = "White" {}
    17.  
    18. }
    19.  
    20.     SubShader {
    21.      
    22.         Tags {"Queue"="Geometry" "RenderType"="Opaque" "IgnoreProjector"="False" }
    23.         UsePass "Hidden/Hardsurface Pro Front Opaque Specular/FORWARD"
    24.      
    25.     }
    26.         Fallback "Diffuse"
    27.     }
    28.  
    See an error says function TexGen used it doesnt do anything now
    Thx
     
  2. gregroberts

    gregroberts

    Joined:
    Nov 21, 2014
    Posts:
    25
    I am in your same situation. Used those beautiful shaders extensively in a project, now its all plain looking. urgh.
    if Bruno Rime (the shader author) is here, could you please speak up?
     
  3. gregroberts

    gregroberts

    Joined:
    Nov 21, 2014
    Posts:
    25
  4. Noisecrime

    Noisecrime

    Joined:
    Apr 7, 2010
    Posts:
    1,998
    Unity 5 removed legacy opengl tex gen modes, e.g in the shader you posted the line
    Code (csharp):
    1. _Cube ("Reflection Cubemap", Cube)="Black"{ TexGen CubeReflect }
    will no longer work

    Luckily Aras create a page in the new Unity 5 manual full of examples of code for replacing that functionality. So you'll have to update the shader yourself, wait to see if the author does or hope someone with time does so here.

    At a guess as the shader you posted relies on another base shader, you would remove the texgen declaration from the cubemap (but not the cubemap itself). Then add the code for CubeReflect into the base shader.
     
  5. tawdry

    tawdry

    Joined:
    Sep 3, 2014
    Posts:
    1,356
    Code (CSharp):
    1. //Hard Surface Shader Package, Written for the Unity engine by Bruno Rime: http://www.behance.net/brunorime brunorime@gmail.com
    2. Shader "HardSurface/Hardsurface Free/Cut Out/Opaque Specular"{
    3.  
    4. Properties {
    5.     _Color ("Main Color", Color) = (1,1,1,1)
    6.     _SpecColor ("Specular Color", Color) = (1, 1, 1, 1)
    7.     _Shininess ("Shininess", Range (0.01, 3)) = 1.5
    8.     _Gloss("Gloss", Range (0.00, 1)) = .5
    9.     _Reflection("Reflection", Range (0.00, 1)) = 0.5
    10.     _Cube ("Reflection Cubemap", Cube) = "Black"
    11.     { Shader "TexGen/CubeReflect" {                                  //parseerror/syntax error
    12. Properties {
    13.     _Cube ("Cubemap", Cube) = "" { /* used to be TexGen CubeReflect */ }
    14. }
    15. SubShader {
    16.     Pass {
    17.         CGPROGRAM
    18.         #pragma vertex vert
    19.         #pragma fragment frag
    20.         #include "UnityCG.cginc"
    21.        
    22.         struct v2f {
    23.             float4 pos : SV_POSITION;
    24.             float3 uv : TEXCOORD0;
    25.         };
    26.  
    27.         v2f vert (float4 v : POSITION, float3 n : NORMAL)
    28.         {
    29.             v2f o;
    30.             o.pos = mul(UNITY_MATRIX_MVP, v);
    31.  
    32.             // TexGen CubeReflect:
    33.             // reflect view direction along the normal,
    34.             // in view space
    35.             float3 viewDir = normalize(ObjSpaceViewDir(v));
    36.             o.uv = reflect(-viewDir, n);
    37.             o.uv = mul(UNITY_MATRIX_MV, float4(o.uv,0));
    38.             return o;
    39.         }
    40.  
    41.         samplerCUBE _Cube;
    42.         half4 frag (v2f i) : SV_Target
    43.         {
    44.             return texCUBE(_Cube, i.uv);
    45.         }
    46.         ENDCG
    47.     }
    48. }
    49. } }
    50.     _FrezPow("Fresnel Reflection",Range(0,2)) = .25
    51.     _FrezFalloff("Fresnal/EdgeAlpha Falloff",Range(0,10)) = 4
    52.     _Metalics("Metalics",Range(0,1)) = .5
    53.     _Cutoff ("Alpha cutoff", Range(0,1)) = 0.5
    54.    
    55.     _MainTex ("Diffuse(RGB) Alpha(A)",2D) = "White" {}
    56.     _BumpMap ("Normalmap", 2D) = "Bump" {}
    57.     _Spec_Gloss_Reflec_Masks ("Spec(R) Gloss(G) Reflec(B)",2D) = "White" {}
    58.  
    59.    
    60. }
    61.  
    62.     SubShader {
    63.        
    64.  
    65.         // Front Faces
    66.         Tags {"Queue"="AlphaTest" "IgnoreProjector"="True" "RenderType"="TransparentCutout"}
    67.         UsePass "Hidden/Hardsurface Pro Front Cut Out Opaque Specular/FORWARD"
    68.        
    69.     }
    70.     FallBack "Transparent/Cutout/VertexLit"
    71. }
    72.  
    Get a parse syntax error now
     
  6. Noisecrime

    Noisecrime

    Joined:
    Apr 7, 2010
    Posts:
    1,998
    Because you can't simply copy and paste one shader into another. Firstly as I said the example code to replace the texgen will need to go into the base shader, here its the one referenced in UsePass. However you still wont be able to just copy and paste, you'll need to use the examples to update the code.

    If your knowledge of shaders is not up to this, then i'm afraid you'll have to wait for the author or someone else to convert them.