Guest User

Untitled

a guest
Jan 4th, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Shader "Custom/DistortionSurfaceShader" {
  2.     Properties {
  3.         _MainTex ("Tint Color (RGB)", 2D) = "white" {}
  4.         _BumpAmt  ("Distortion", range (0,128)) = 10
  5.         _BumpMap ("Normalmap", 2D) = "bump" {}
  6.         _Color ("Color", Color) = (1,1,1,1)
  7.         _Glossiness ("Smoothness", Range(0,1)) = 0.5
  8.         _Metallic ("Metallic", Range(0,1)) = 0.0
  9.     }
  10.     SubShader {
  11.  
  12.         GrabPass {}
  13.  
  14.         Cull Off
  15.  
  16.  
  17.         Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Opaque" }
  18.         LOD 200
  19.  
  20.         CGPROGRAM
  21.         // Physically based Standard lighting model, and enable shadows on all light types
  22.         #pragma surface surf Standard fullforwardshadows
  23.  
  24.         // Use shader model 3.0 target, to get nicer looking lighting
  25.         #pragma target 3.0
  26.  
  27.         sampler2D _MainTex;
  28.         sampler2D _BumpMap;
  29.         sampler2D _GrabTexture;
  30.        
  31.         float4 _GrabTexture_TexelSize;
  32.            
  33.         float _BumpAmt;
  34.  
  35.         struct Input {
  36.             float2 uv_MainTex;
  37.             float2 uv_BumpMap;
  38.             float4 screenPos;
  39.         };
  40.  
  41.         half _Glossiness;
  42.         half _Metallic;
  43.         fixed4 _Color;
  44.  
  45.         // Add instancing support for this shader. You need to check 'Enable Instancing' on materials that use the shader.
  46.         // See https://docs.unity3d.com/Manual/GPUInstancing.html for more information about instancing.
  47.         // #pragma instancing_options assumeuniformscaling
  48.         UNITY_INSTANCING_BUFFER_START(Props)
  49.             // put more per-instance properties here
  50.         UNITY_INSTANCING_BUFFER_END(Props)
  51.  
  52.         void surf (Input IN, inout SurfaceOutputStandard o) {
  53.             float2 screenUV = IN.screenPos.xy / IN.screenPos.w;
  54.             fixed3 nor = _BumpAmt * UnpackNormal(tex2D(_BumpMap, IN.uv_BumpMap));
  55.             float2 offset = nor.rg * _GrabTexture_TexelSize.xy;
  56.             half4 col = tex2D( _GrabTexture, screenUV + offset);
  57.  
  58.             half4 tex = tex2D(_MainTex, IN.uv_MainTex);
  59.             o.Albedo = tex.rgb * _Color.rgb * col.rgb;
  60.             o.Normal = nor;
  61.             o.Alpha = tex.a * _Color.a;
  62.  
  63.             // Metallic and smoothness come from slider variables
  64.             o.Metallic = _Metallic;
  65.             o.Smoothness = _Glossiness;
  66.         }
  67.         ENDCG
  68.     }
  69.     //FallBack "Diffuse"
  70. }
Advertisement
Add Comment
Please, Sign In to add comment