赞
踩
主要思路:将顶点延法线挤出,一层一层pass往外叠加形成毛发效果。
原文链接:https://blog.csdn.net/qq_24153371/article/details/81742337
噪声图:
cginc部分:
#include "Lighting.cginc" #include "UnityCG.cginc" #include "AutoLight.cginc" float4 _Color; float4 _Specular; float _Shininess; sampler2D _MainTex; float4 _MainTex_ST; sampler2D _FurTex; float4 _FurTex_ST; float _FurLength; float _FurDensity; float _FurThinness; float _FurShading; float _RimPower; struct v2f { float4 pos:SV_POSITION; float4 uv:TEXCOORD0; float3 worldNormal:TEXCOORD1; float3 worldPos:TEXCOORD2; }; v2f vert_surface(appdata_base v) { v2f o; o.pos = UnityObjectToClipPos(v.vertex); o.uv.xy = TRANSFORM_TEX(v.texcoord, _MainTex); o.worldNormal = UnityObjectToWorldNormal(v.normal); o.worldPos = mul(unity_ObjectToWorld, v.vertex).xyz; return o; } //lambert+blinn-phone float4 frag_surface(v2f i) :SV_Target{ float3 worldNormal = normalize(i.worldNormal); float3 worldLight = normalize(_WorldSpaceLightPos0.xyz); float3 worldView = normalize(_WorldSpaceCameraPos.xyz - i.worldPos.xyz); float3 worldHalf = normalize(worldView + worldLight); float3 albedo = tex2D(_MainTex, i.uv.xy).rgb *_Color; float3 ambient = UNITY_LIGHTMODEL_AMBIENT.xyz * albedo; float3 diffuse = _LightColor0.rgb*albedo*saturate(dot(worldNormal, worldLight)); float3 specular = _LightColor0.rgb*_Specular.rgb*pow(saturate(dot(worldNormal, worldHalf)), _Shininess); float3 color = ambient + diffuse + specular; return float4(color, 1.0); } v2f vert_base(appdata_base v) { v2f o; //每个pass延法线挤出顶点 float3 P = v.vertex.xyz + v.normal*_FurLength*FURSTEP; o.pos = UnityObjectToClipPos(float4(P, 1.0)); o.uv.xy = TRANSFORM_TEX(v.texcoord, _MainTex); o.uv.<
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。