代码:
Shader "Unlit/P_Gradient" { Properties{ _BasicColor("基础颜色",Color)=(1.0,1.0,1.0,1.0) _ControlDegree("控制强度",Color)=(1.0,0.0,0.0,0.0) } SubShader { Pass { CGPROGRAM #pragma vertex vert #pragma fragment frag #include "UnityCG.cginc" float4 _BasicColor; float4 _ControlDegree; struct a2v{ float4 position :position; float3 normal :normal; }; struct v2f{ float4 sv_position :sv_position; float3 texcoord :texcoord0; }; v2f vert(a2v a){ v2f v; v.sv_position=UnityObjectToClipPos(a.position); v.texcoord=UnityObjectToWorldNormal(a.normal); return v; } float4 frag(v2f v) :SV_Target{ float3 IDir=_WorldSpaceLightPos0.xyz; float4 GradientDegree=_ControlDegree*(0.5+0.5*dot(v.texcoord,IDir)); float4 FinalColor=_BasicColor*(float4(1.0,1.0,1.0,1.0)-_ControlDegree)+GradientDegree; return FinalColor; } ENDCG } } } 标签:1.0,兰伯特,0.0,渐变,Shader,v2f,float4,position,ControlDegree From: https://www.cnblogs.com/vusblog/p/17133469.html