Guest User

Untitled

a guest
Oct 13th, 2020
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Shader "Custom/ScreenOffset"
  2. {
  3.     Properties
  4.     {
  5.         _MainTex ("Albedo (RGB)", 2D) = "white" {}
  6.         _ScreenNo ("ScreenNo", Int) = 0
  7.     }
  8.     SubShader
  9.     {
  10.         Tags { "RenderType"="Opaque" }
  11.         LOD 200
  12.  
  13.         CGPROGRAM
  14.         // Physically based Standard lighting model, and enable shadows on all light types
  15.         #pragma surface surf Standard fullforwardshadows
  16.  
  17.         // Use shader model 3.0 target, to get nicer looking lighting
  18.         #pragma target 3.0
  19.  
  20.         sampler2D _MainTex;
  21.  
  22.         struct Input
  23.         {
  24.             float2 uv_MainTex;
  25.         };
  26.  
  27.         half _Glossiness;
  28.         half _Metallic;
  29.         int _ScreenNo;
  30.  
  31.         // Add instancing support for this shader. You need to check 'Enable Instancing' on materials that use the shader.
  32.         // See https://docs.unity3d.com/Manual/GPUInstancing.html for more information about instancing.
  33.         // #pragma instancing_options assumeuniformscaling
  34.         UNITY_INSTANCING_BUFFER_START(Props)
  35.             // put more per-instance properties here
  36.         UNITY_INSTANCING_BUFFER_END(Props)
  37.  
  38.         void surf (Input IN, inout SurfaceOutputStandard o)
  39.         {
  40.             float u = IN.uv_MainTex.x;
  41.             float su = (fmod(_ScreenNo, 3.0) + u) / 3.0;
  42.             float v = IN.uv_MainTex.y;
  43.             float sv = (floor(_ScreenNo / 3.0) + v) / 2.0;
  44.  
  45.             fixed4 c = tex2D(_MainTex, float2(su, sv));
  46.             o.Albedo = c.rgb;
  47.             o.Emission = c.rgb;
  48.             o.Metallic = 0;
  49.             o.Smoothness = 0;
  50.             o.Alpha = 1;
  51.         }
  52.         ENDCG
  53.     }
  54.     FallBack "Diffuse"
  55. }
  56.  
Add Comment
Please, Sign In to add comment