Introduction to CG 20:fragment shader-fragment-level model dynamic discoloration (for automotive dynamic paint change)

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.