![]() Alter color based on depth buffer (soft particles technique) Half foamTerm = (smoothstep(foam.r - _FoamSmooth, foam.r + _FoamSmooth, saturate(_FoamStrength - foamDepth)) * saturate(1 - foamDepth)) * _FoamColor.a SceneZ = (sceneZ * _ProjectionParams.z) + _ProjectionParams.y įloat depthDiff = abs(sceneZ - partZ) //这里算出了水的深度įloat foamDepth = saturate(_FoamSpread * depthDiff) Half ndv = saturate(dot(IN.viewDir, o.Normal)) //法线和视角的点乘。įixed4 mainTex = tex2D(_MainTex, IN.texcoord.xy) įloat sceneZ = SAMPLE_DEPTH_TEXTURE_PROJ(_CameraDepthTexture, UNITY_PROJ_COORD(IN.sPos)) //此点的深度值,这里是关键。 Void surf(Input IN, inout SurfaceOutputWater o) Half4 waveXZn = cos((_pos.xxzz * vsw_offsets) + (_phase.xxxx * vsw_ph_offsets)) * (vsw_offsets / 2) įloat xn = -_WaveHeight * (waveXZn.x + waveXZn.y) įloat zn = -_WaveHeight * (waveXZn.z + waveXZn.w) įloat4 pos = UnityObjectToClipPos(v.vertex) ĬOMPUTE_EYEDEPTH(o.sPos.z) //将z值赋值为点到视点的深度 V.vertex.y += (waveFactorX + waveFactorZ) * VSW_STRENGTH float waveFactorZ = (waveXZ.z + waveXZ.w) * _WaveHeight / 2 įloat waveFactorX = dot(waveXZ.xy, 1) * _WaveHeight / 2 įloat waveFactorZ = dot(waveXZ.zw, 1) * _WaveHeight / 2 float waveFactorX = (waveXZ.x + waveXZ.y) * _WaveHeight / 2 Half4 waveXZ = sin((_pos.xxzz * vsw_offsets) + (_phase.xxxx * vsw_ph_offsets)) Half2 x = ((v.vertex.xy + v.vertex.yz) * _UVWaveFrequency) + (TIME.xx * _UVWaveSpeed) įloat3 _pos = worldPos.xyz * _WaveFrequency O.texcoord.xy = TRANSFORM_TEX(mainTexcoords.xy, _MainTex) //根据texture的缩放 Void vert(inout appdata_tcp2 v, out Input o)įloat3 worldPos = mul(unity_ObjectToWorld, v.vertex).xyz S.atten = data.atten //transfer attenuation to lighting function Gi.lor = _LightColor0.rgb //remove attenuation Gi = UnityGlobalIllumination(data, 1.0, s.Normal) Void LightingToon圜olorsWater_GI(inout SurfaceOutputWater s, UnityGIInput data, inout UnityGI gi) #ifdef UNITY_LIGHT_FUNCTION_APPLY_INDIRECT Ramp = lerp(_SColor.rgb, _HColor.rgb, ramp) Ĭ.rgb = s.Albedo * lightColor.rgb * ramp _SColor = lerp(_HColor, _SColor, _SColor.a) //Shadows intensity through alpha Inline half4 LightingToon圜olorsWater(inout SurfaceOutputWater s, half3 viewDir, UnityGI gi)įixed ndl = max(0, dot(s.Normal, lightDir)) įixed3 ramp = smoothstep(RAMP_THRESHOLD - RAMP_SMOOTH * 0.5, RAMP_THRESHOLD + RAMP_SMOOTH * 0.5, NDL) #pragma instancing_options assumeuniformscaling See for more information about instancing. You need to check 'Enable Instancing' on materials that use the shader. #pragma surface surf Toon圜olorsWater keepalpha vertex:vert nolightmap ![]() ![]() _MainTex("Main Texture (RGB)", 2D) = "white" Shader "Toony Colors Pro 2/Examples/Cat Demo/Water" Upgrade NOTE: upgraded instancing buffer 'Props' to new syntax. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |