Unity the maximum number of vertices for a patch is 65524, so larger than this number, split into multiple patches 1. Get the maximum and minimum values for the x-axis of the car [ -2.5,2.5]+r
Surfaceshader syntax
Surf:surface Shader method Name vert: Using the Vertex program method name
Surface shader method cannot have a return value
Source:
Shader "Sbin/surfaceshader" {Properties {_glossiness ("smoothness", range (0,1)) = 0.5_metallic ("Metallic", range (0,1)) = 0.0_upcolor ("Upcolor", color) = (1,0,0,1) _downcolor ("Downcolor", color) = (0,1,0,1) _center ("Center", Range ( -0.7,0.7) = 0_r ("R", Range (0,0.5)) = 0.2}subshader {Tags {"rendertype" = "Opaque"}lod 200cgprogram#pragma surface surf Standard ver Tex:vert fullforwardshadows//Description: pragma surface method1 standard Vertex:method2fullforwardshadows#pragma target 3.0sampler2d _maintex;struct Input {float2 uv_maintex;float x:texcoord0;}; Half _glossiness;half _metallic;float4 _upcolor;float4 _downcolor;float _center; float _r; void Vert (inout appdata_full v,out Input o) {O.uv_maintex = v.texcoord.xy;o.x = v.vertex.x;} void Surf (Input in, InOut surfaceoutputstandard o) {fixed4 c = tex2d (_maintex, In.uv_maintex); O. Albedo = C.rgb;o. Metallic = _metallic;o. smoothness = _glossiness;o. Alpha = c.a;float D = in.x-_center;//fused with float s = ABS (d);d = d/s;//positive and negative values describe the upper and lower halves respectively, with values 1 and -1float f = s/_r;//Range>1: Represents the upper and lower part; Range <1: Represents the fused band F = saturate (f);d *= f;//for all [ -1,1]; Range >1: denotes the upper part; Range <1: Represents the fusion band; Range <-1: Represents the next section D = d/2+0.5 ;//control the range to [0,1], because the color value returned is [0,1]o.albedo + = Lerp (_upcolor,_downcolor,d);} Endcg}fallback "Diffuse"}
Effect:
Introduction to CG 20:fragment shader-fragment-level model dynamic discoloration (for automotive dynamic paint change)