科幻风格shader

今天分享几个科幻风格的shader

科幻风格shader_第1张图片
Paste_Image.png
  Shader "Character/Hologram" {
    Properties {
      _MainTex ("Texture", 2D) = "white" {}
      _BumpMap ("Bumpmap", 2D) = "bump" {}
      _RimColor ("Rim Color", Color) = (0.26,0.7,1.0,0.0)
      _RimPower ("Rim Power", Range(0.1,8.0)) = 3.0
      _ClipPower("Clip Power", Range(0.0,301.0)) = 200.0
      _Brightness ("Brightness",Range(0.0,3.0)) = 1.5   
      _DiffuseAmount("Diffuse Amount", Range(0.0,1.0)) = 0.0   
    }
    SubShader {
      Tags { "RenderType" = "Transparent"  "Queue"="Transparent" "IgnoreProjector"="True"}
      
    // extra pass that renders to depth buffer only
     Pass {
        ZWrite On
        ColorMask 0
       }
          
      CGPROGRAM
      #pragma surface surf Lambert alpha noambient nolightmap nodirlightmap  novertexlights
      struct Input {
          float2 uv_MainTex;
          float2 uv_BumpMap;
          float3 viewDir;
          float3 worldPos;    
          float4 screenPos;      
      };
      sampler2D _MainTex;
      sampler2D _BumpMap;
      float4 _RimColor;
      float _RimPower;
      float _ClipPower;
      float _Brightness;
      float _DiffuseAmount;

      void surf (Input IN, inout SurfaceOutput o) {
          float2 screenUV = IN.screenPos.xy / IN.screenPos.w;
          
          if (_ClipPower <= 300.0f)
             clip (frac(screenUV.y * _ClipPower) - 0.5);
          half4 basecol = tex2D (_MainTex, IN.uv_MainTex);
          half3 graycol = dot(basecol.rgb,float3(0.3,0.59,0.11));
          o.Albedo = basecol;//lerp(graycol,basecol,_DiffuseAmount);
          o.Normal = UnpackNormal (tex2D (_BumpMap, IN.uv_BumpMap));
          half rim = 1.0 - saturate(dot (normalize(IN.viewDir), o.Normal));
          o.Emission = lerp(_RimColor.rgb * pow (rim, _RimPower) * _Brightness,basecol,_DiffuseAmount);
          o.Alpha = o.Emission;
      }
      ENDCG
    } 
    Fallback "Diffuse"
  }

透明的

科幻风格shader_第2张图片
Paste_Image.png
  Shader "Character/Ghost Shader" {
    Properties {
      _MainTex ("Texture", 2D) = "white" {}
      _BumpMap ("Bumpmap", 2D) = "bump" {}
      _RimColor ("Rim Color", Color) = (0.46,0.0,1.0,0.0)
      _RimPower ("Rim Power", Range(0.2,2.0)) = 0.5
      _Brightness ("Brightness",Range(0.0,3.0)) = 1.0
    }
    SubShader {
      Tags { "RenderType" = "Transparent" "Queue"="Transparent" "IgnoreProjector"="True"}
      
    // extra pass that renders to depth buffer only
     Pass {
        ZWrite On
        ColorMask 0
       }
          
      CGPROGRAM
      #pragma surface surf Lambert alpha noambient nolightmap nodirlightmap  novertexlights
      struct Input {
          float2 uv_MainTex;
          float2 uv_BumpMap;
          float3 viewDir;
      };
      sampler2D _MainTex;
      sampler2D _BumpMap;
      float4 _RimColor;
      float _RimPower;
      float _Brightness;

      void surf (Input IN, inout SurfaceOutput o) {
        half4 basecol = tex2D (_MainTex, IN.uv_MainTex);
            half3 graycol = dot(basecol.rgb,float3(0.3,0.59,0.11));
          o.Albedo = graycol;
          o.Normal = UnpackNormal (tex2D (_BumpMap, IN.uv_BumpMap));
          half rim = 1.0 - saturate(dot (normalize(IN.viewDir), o.Normal));
          o.Emission = _RimColor.rgb * pow (rim, _RimPower) * _Brightness;
          o.Alpha = (o.Emission.r+o.Emission.g+o.Emission.b) / 3.0;
      }
      ENDCG
    } 
    Fallback "Diffuse"
  }

溶解

科幻风格shader_第3张图片
Paste_Image.png
  Shader "Character/Disintegrate Bumped Diffuse" {
    Properties {
      _MainTex ("Texture (RGB)", 2D) = "white" {}
      _BumpMap ("Texture (RGB)", 2D) = "bump" {}
      _NoiseTex ("Effect Map (RGB)", 2D) = "white" {}
      _DisintegrateAmount ("Effect Amount", Range(0.0, 1.01)) = 0.0
      _DissolveColor("Edge Color", Color) = (1.0,0.5,0.2,0.0)
      _EdgeEmission ("Edge Emission", Color) = (0,0,0,0)
      _DissolveEdge("Edge Range",Range(0.0,0.1)) = 0.01
      _TileFactor ("Tile Factor", Range(0.0,4.0)) = 1.0
    }
    SubShader {
      Tags { "RenderType" = "Opaque" }
      CGPROGRAM
      #pragma target 3.0
      #pragma surface surf Lambert addshadow nolightmap
      struct Input {
          float2 uv_MainTex;
          float2 uv_BumpMap;
      };
      sampler2D _MainTex;
      sampler2D _BumpMap;
      sampler2D _NoiseTex;
      float  _DisintegrateAmount;
      float4 _DissolveColor;
      float  _DissolveEdge;
      float  _TileFactor;
      float4 _EdgeEmission;  
      
      void surf (Input IN, inout SurfaceOutput o) 
      {
          float clipval = tex2D (_NoiseTex, IN.uv_MainTex * _TileFactor).rgb - _DisintegrateAmount; 
          
          clip(clipval);
          

          if (clipval < _DissolveEdge && _DisintegrateAmount > 0)
          {
              o.Emission = _EdgeEmission;
              o.Albedo = _DissolveColor;          
          }
          else
          {
              o.Albedo = tex2D (_MainTex, IN.uv_MainTex).rgb;
          }     
          float4 nrm =  tex2D (_BumpMap,IN.uv_BumpMap);    
          o.Normal = UnpackNormal(nrm);       
      }
      ENDCG
    }
    Fallback "Disintegrate"
  }

石化效果

科幻风格shader_第4张图片
Paste_Image.png
Shader "Character/StatueBmp" {
    Properties {
        _Color ("Main Color", Color) = (1,1,1,1)
        _MainTex("Diffuse (RGB)", 2D) = "white" {}
        _GrungeTex ("Grunge (RGB)", 2D) = "white" {}
        _BumpMap ("Bump (RGB) Illumin (A)", 2D) = "bump" {}
        _BaseTex ("Base (RGB)", 2D) = "white" {}
        _Scale("Scale", Float) = 1
        _Tighten("Tighten",Range(0.1,0.45))=0.3     
        _DiffuseAmount("Diffuse Amount", Range(0,1)) = 0.2
        _GrungeAmount("Grunge Amount", Range(0,2)) = 1
    }
    
    SubShader
    {  
            Tags { "RenderType"="Opaque" }
            LOD 200
 
        CGPROGRAM
        #pragma debug
        #pragma surface surf Lambert nolightmap
        #pragma target 3.0
        
        sampler2D _MainTex; 
        sampler2D _GrungeTex;
        sampler2D _BumpMap;
        sampler2D _BaseTex;
        fixed4 _Color;
        fixed _GrungeAmount;
        fixed _DiffuseAmount;
        half  _Scale;
        half _Tighten;
 
        struct Input
        {
            float2 uv_MainTex;
            float2 uv_BumpMap;
            half3 worldPos;
            fixed3 worldNormal; INTERNAL_DATA       
        };
 
        void surf (Input IN, inout SurfaceOutput o)
        {
            // tighten the blending zone
            float4 nrm =  tex2D (_BumpMap,IN.uv_BumpMap); 
            o.Normal = UnpackNormal(nrm); 
            float3 realNormal = WorldNormalVector(IN,o.Normal);
            
            float3 blend_weights = abs(realNormal)- _Tighten;
            blend_weights = max(blend_weights, 0);
            blend_weights /= (blend_weights.x + blend_weights.y + blend_weights.z).xxx;

            float4 d = tex2D(_MainTex, IN.uv_MainTex);
            float4 grunge = tex2D(_GrungeTex, IN.worldPos.xz/_Scale);
            float4 cy =  lerp(tex2D(_BaseTex, IN.worldPos.xz/_Scale),grunge,_GrungeAmount);
            float4 cz = tex2D(_BaseTex, IN.worldPos.xy/_Scale);
            float4 cx = tex2D(_BaseTex, IN.worldPos.zy/_Scale);
            float4 result = cx.xyzw * blend_weights.xxxx +  
                            cy.xyzw * blend_weights.yyyy +  
                            cz.xyzw * blend_weights.zzzz;

            result = lerp(result,d,_DiffuseAmount); 
            
            o.Albedo = result.rgb * _Color.rgb;
            o.Alpha = result.a * _Color.a;

        }
        ENDCG
    }
 
    Fallback "VertexLit"
}

本文资源下载链接

链接:http://pan.baidu.com/s/1qY8nKIC 密码:grhz

你可能感兴趣的:(科幻风格shader)