SF_VFX_Materialization.shader 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. Shader "QFX/SF_VFX/Materialization" {
  2. Properties{
  3. _Color("Color", Color) = (1,1,1,1)
  4. _MainTex("Albedo (RGB)", 2D) = "white" {}
  5. _Glossiness("Smoothness", Range(0,1)) = 0.5
  6. [NoScaleOffset] _MetallicGlossMap("Metallic", 2D) = "white" {}
  7. [Gamma] _Metallic ("Metallic", Range(0,1)) = 0
  8. _DissTexture("Dissolve Texture", 2D) = "white" {}
  9. [HDR]_DissolveColor("Dissolve Color", Color) = (0,1,0,1)
  10. _ScrollXSpeed("Scroll X Speed", Float) = 0
  11. _ScrollYSpeed("Scroll Y Speed", Float) = 0
  12. _Center("Dissolve Center (W=Unused)", Vector) = (0,0,0,0)
  13. _Dissolve("Dissolve", Range(0,5)) = 1
  14. _Distance("Dissolve Distance", Float) = 1
  15. _Interpolation("Dissolve Interpolation", Range(0,5)) = 1
  16. _EmissionInterpolation("Emission Interpolation", Range(0,5)) = 1
  17. [NoScaleOffset] _BumpMap ("Normal Map", 2D) = "bump" {}
  18. [NoScaleOffset]_EmissionMap ("Emission", 2D) = "white" { }
  19. [HDR]_EmissionColor ("Color", Color) = (0,0,0,1)
  20. }
  21. SubShader{
  22. Tags { "RenderType" = "Opaque" }
  23. LOD 200
  24. CGPROGRAM
  25. #include "UnityPBSLighting.cginc"
  26. #pragma surface surf Standard addshadow
  27. #pragma target 3.0
  28. sampler2D _MainTex;
  29. struct Input {
  30. float2 uv_MainTex;
  31. float2 uv_BumpMap;
  32. float2 uv_DissTexture;
  33. float3 worldPos;
  34. };
  35. sampler2D _MetallicGlossMap, _EmissionMap, _BumpMap, _DissTexture;
  36. float4 _EmissionColor, _DissolveColor, _Center;
  37. half _Dissolve, _Distance, _Interpolation, _EmissionInterpolation, _Glossiness, _Metallic;
  38. half _ScrollXSpeed, _ScrollYSpeed;
  39. fixed4 _Color;
  40. void surf(Input IN, inout SurfaceOutputStandard o) {
  41. IN.uv_DissTexture.x += _Time.y * _ScrollXSpeed;
  42. IN.uv_DissTexture.y += _Time.y * _ScrollYSpeed;
  43. fixed4 dissTex = tex2D(_DissTexture, IN.uv_DissTexture);
  44. float distance = length(_Center.xyz - IN.worldPos.xyz);
  45. float invfade = (dissTex * _Interpolation * _Distance);
  46. clip(_Distance - distance + invfade);
  47. fixed4 color = tex2D(_MetallicGlossMap, IN.uv_MainTex);
  48. fixed4 emission = tex2D(_EmissionMap, IN.uv_MainTex);
  49. o.Metallic = color.r * _Metallic ;
  50. o.Smoothness = _Glossiness * color.a;
  51. color = tex2D(_MainTex, IN.uv_MainTex);
  52. o.Albedo = color.rgb * _Color.rgb;
  53. o.Normal = UnpackNormal (tex2D (_BumpMap, IN.uv_BumpMap));
  54. half em = saturate(1-(_Distance-distance+_EmissionInterpolation));
  55. if (_Distance - distance + invfade < _Dissolve)
  56. o.Emission = _DissolveColor;
  57. else o.Emission = emission * _EmissionColor + em *_DissolveColor.rgb; // * dissTex
  58. o.Alpha = color.a;
  59. }
  60. ENDCG
  61. }
  62. Fallback "Diffuse"
  63. }