直接上码
1 Shader "Custom/3DVideo" { 2 Properties { 3 _Color ("Color", Color) = (1,1,1,1) 4 _MainTex ("Albedo (RGB)", 2D) = "white" {} 5 _Glossiness ("Smoothness", Range(0,1)) = 0.5 6 _Metallic ("Metallic", Range(0,1)) = 0.0 7 _x("x", Range(0.1, 1)) = 1 8 _y("y", Range(0.1, 1)) = 1 9 } 10 SubShader { 11 Tags { "RenderType"="Opaque" } 12 LOD 200 13 Cull Front 14 Lighting Off 15 16 CGPROGRAM 17 // Physically based Standard lighting model, and enable shadows on all light types 18 // #pragma surface surf Standard fullforwardshadows 19 #pragma surface surf Unlit noambient 20 21 // Use shader model 3.0 target, to get nicer looking lighting 22 #pragma target 3.0 23 24 half4 LightingUnlit (SurfaceOutput s, half3 lightDir, half atten) { 25 return fixed4(s.Albedo, s.Alpha); 26 } 27 28 sampler2D _MainTex; 29 float _x; 30 float _y; 31 32 struct Input { 33 float2 uv_MainTex; 34 }; 35 36 half _Glossiness; 37 half _Metallic; 38 fixed4 _Color; 39 40 // Add instancing support for this shader. You need to check 'Enable Instancing' on materials that use the shader. 41 // See https://docs.unity3d.com/Manual/GPUInstancing.html for more information about instancing. 42 // #pragma instancing_options assumeuniformscaling 43 UNITY_INSTANCING_BUFFER_START(Props) 44 // put more per-instance properties here 45 UNITY_INSTANCING_BUFFER_END(Props) 46 47 // void surf (Input IN, inout SurfaceOutputStandard o) { 48 void surf (Input IN, inout SurfaceOutput o) { 49 float2 uv_XY = IN.uv_MainTex; 50 float2 uv_MainTex2 = float2(uv_XY.x * _x, uv_XY.y * _y); 51 // Albedo comes from a texture tinted by color 52 fixed4 c = tex2D (_MainTex, uv_MainTex2) * _Color; 53 o.Albedo = c.rgb; 54 // Metallic and smoothness come from slider variables 55 // o.Metallic = _Metallic; 56 // o.Smoothness = _Glossiness; 57 o.Alpha = c.a; 58 } 59 ENDCG 60 } 61 FallBack "Diffuse" 62 }