Guest User

ReflextSight.shader

a guest
Mar 14th, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Shader "Custom/ReflexSight" {
  2.     Properties {
  3.         _Color ("Color", Color) = (1,1,1,1)
  4.         [HideInInspector] _MainTex ("Albedo (RGB)", 2D) = "white" {}
  5.         _Glossiness ("Smoothness", Range(0,1)) = 0.5
  6.         _Metallic ("Metallic", Range(0,1)) = 0.0
  7.         _Sharpness ("Dot Sharpness", Range(0,100000)) = 10000
  8.     }
  9.     SubShader {
  10.         Tags {
  11.           "RenderType"="Transparent"
  12.           "Queue" = "Transparent"
  13.         }
  14.         LOD 200
  15.         ZWrite On
  16.         ZTest LEqual
  17.  
  18.         CGPROGRAM
  19.         #pragma surface surf Standard fullforwardshadows alpha
  20.  
  21.         #pragma target 3.0
  22.  
  23.         sampler2D _MainTex;
  24.  
  25.         struct Input {
  26.             float2 uv_MainTex;
  27.             float3 viewDir;
  28.         };
  29.  
  30.         half _Glossiness;
  31.         half _Metallic;
  32.         fixed4 _Color;
  33.         int _Sharpness;
  34.  
  35.         UNITY_INSTANCING_BUFFER_START(Props)
  36.         UNITY_INSTANCING_BUFFER_END(Props)
  37.  
  38.         void surf (Input IN, inout SurfaceOutputStandard o) {
  39.             // red dot is at float3(0,0,-1) direction (forward Z in unity space), in model space
  40.             float3 transformedForward =
  41.               normalize(mul((float3x3)unity_ObjectToWorld, float3(0,0,-1)));
  42.  
  43.             float strength = pow(dot(IN.viewDir, transformedForward), _Sharpness);
  44.             fixed4 c = fixed4(strength, 0, 0, strength);
  45.             o.Albedo = _Color * strength;
  46.             o.Emission = o.Albedo;
  47.             o.Metallic = _Metallic;
  48.             o.Smoothness = _Glossiness;
  49.             o.Alpha = strength;
  50.         }
  51.         ENDCG
  52.     }
  53.     FallBack "Diffuse"
  54. }
Advertisement
Add Comment
Please, Sign In to add comment