Hobby Game Dev Log -07- Shaders, Grass, N Stuff

https://www.youtube.com/watc...
https://discord.gg/6STRB2n7pf https://twitter.com/M_attTaylor Interactive grass and roof fading shaders, UI improvements, a dynamic health bar and lots of set dressing for our camp tileset. [Interactive Grass Reference] https://forum.unity.com/threads/shader-setglobalvector.5785/ //Important part of the shader Properties { _bendAmount("BendAmount", Range(0,20)) = 10 _affectDist("AffectDistance", Range(0,20)) = 10 } SubShader { CGPROGRAM #pragma target 3.0 #pragma surface surf Lambert alphatest:_Cutoff vertex:vert addshadow half _bendAmount; half _affectDist; uniform float3 _obstacle; void vert (inout appdata_full i) { float3 worldPos = mul (unity_ObjectToWorld, i.vertex).xyz; float3 bendDir = normalize (float3(worldPos.x,0,worldPos.z)-float3(_obstacle.x,0,_obstacle.z)); float distLimit = _affectDist; float distMulti = (distLimit-min(distLimit,distance(float3(worldPos.x,0,worldPos.z),float3(_obstacle.x,0,_obstacle.z))))/distLimit; i.vertex.xz += bendDir.xz * distMulti * i.texcoord.y * i.texcoord.y * _bendAmount; }} Add this to a script on the player object in Update. Shader.SetGlobalVector("_obstacle", transform.position);