2
0

SquishyDeform.shader 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. Shader "Custom/SquishyDeform" {
  2. Properties {
  3. _MainTex ("Albedo (RGB)", 2D) = "white" {}
  4. _Metallic("Metallic/Smoothness", 2D) = "white" {}
  5. _Normal("Normal", 2D) = "bump" {}
  6. _Deform("Deform Factor", Range(0,1)) = 0
  7. _PinchDeform("Pinch Deform Factor", Range(0,1)) = 0
  8. _Rough("Deform Roughness", Range(0,1)) = 0.1
  9. _Goo("Goo Texture", 2D) = "white" {}
  10. _ColorA ("Goo Color A", Color) = (1,1,1,1)
  11. _ColorB("Goo Color B", Color) = (1,0,0,1)
  12. _GooN("Goo Flow", 2D) = "bump" {}
  13. _Flow("Flow Speed", Vector) = (0,1,0,-1)
  14. _FlowFac("Flow Factor", Range(-1,1)) = 1
  15. }
  16. SubShader {
  17. Tags { "RenderType"="Opaque" }
  18. LOD 200
  19. CGPROGRAM
  20. // Physically based Standard lighting model, and enable shadows on all light types
  21. #pragma surface surf Standard fullforwardshadows
  22. #pragma target 3.0
  23. #include "Tessellation.cginc"
  24. struct appdata {
  25. float4 vertex : POSITION;
  26. float4 tangent : TANGENT;
  27. float3 normal : NORMAL;
  28. float2 texcoord : TEXCOORD0;
  29. };
  30. sampler2D _MainTex;
  31. sampler2D _Metallic;
  32. sampler2D _Normal;
  33. sampler2D _Goo;
  34. sampler2D _GooN;
  35. struct Input {
  36. float2 uv_MainTex;
  37. float2 uv_Goo;
  38. float2 uv_GooN;
  39. float4 col : COLOR;
  40. };
  41. half _Deform;
  42. half _PinchDeform;
  43. half _Rough;
  44. fixed4 _ColorA;
  45. fixed4 _ColorB;
  46. half4 _Flow;
  47. half _FlowFac;
  48. void surf (Input IN, inout SurfaceOutputStandard o) {
  49. // Albedo comes from a texture tinted by color
  50. fixed4 goo = _ColorA;
  51. half t = _Time.r;
  52. float2 goon = UnpackNormal(tex2D(_GooN, IN.uv_GooN + float2(t*_Flow.x, _Time.r * _Flow.y)));
  53. half gool = tex2D(_Goo, IN.uv_Goo + float2(t*_Flow.z, t* _Flow.w) + goon * _FlowFac);
  54. goo = lerp(goo, _ColorB, gool);
  55. fixed4 c = tex2D (_MainTex, IN.uv_MainTex);
  56. half def = lerp(saturate(_Deform)* saturate(pow(IN.col.r, 0.4)),1, saturate(_PinchDeform)* saturate(pow(IN.col.g, 0.4))) ;
  57. o.Albedo = lerp(c.rgb,goo,def);
  58. o.Normal = UnpackNormal(tex2D(_Normal, IN.uv_MainTex));
  59. fixed4 ms = tex2D(_Metallic, IN.uv_MainTex);
  60. o.Metallic = ms.r;
  61. o.Smoothness = lerp(ms.a, 1-_Rough, def);
  62. o.Alpha = c.a;
  63. }
  64. ENDCG
  65. }
  66. FallBack "Diffuse"
  67. }