Advertisement
Guest User

Untitled

a guest
Jul 20th, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.53 KB | None | 0 0
  1. // Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
  2.  
  3. // Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
  4.  
  5. Shader "Custom/SimpleShieldShader2" {
  6. Properties {
  7. _Color ("Color", Color) = (1,1,1,1)
  8. _PointColor("Point Color (RGB)", Color) = (1,0,0,1)
  9. _MainTex ("Albedo (RGB)", 2D) = "white" {}
  10. _ImpactSize("ImpactSize", Float) = 0.5
  11.  
  12. }
  13. SubShader {
  14. Tags { "Queue" = "Transparent" }
  15.  
  16. LOD 200
  17.  
  18. Blend One One
  19. Lighting Off
  20.  
  21. CGPROGRAM
  22. // Physically based Standard lighting model, and enable shadows on all light types
  23. #pragma surface surf Standard //NoLighting
  24.  
  25. // Use shader model 3.0 target, to get nicer looking lighting
  26. #pragma target 3.0
  27.  
  28. sampler2D _MainTex;
  29.  
  30. struct Input {
  31.  
  32. float2 uv_MainTex;
  33. float3 worldPos;
  34. };
  35.  
  36. fixed4 _Color;
  37. fixed4 _PointColor;
  38. float _ImpactSize;
  39. int _PointsSize;
  40. fixed4 _Points[50];
  41.  
  42. void surf (Input IN, inout SurfaceOutputStandard o) {
  43.  
  44. fixed4 c = tex2D (_MainTex, IN.uv_MainTex) * _Color;
  45. fixed emissive = 0;
  46.  
  47. float3 objPos = mul(unity_WorldToObject, float4(IN.worldPos, 1)).xyz;
  48. for (int i = 0; i < _PointsSize; ++i) {
  49. float amount = max(0, frac(1.0 - max(0, (_Points[i].w * _ImpactSize) - distance(_Points[i].xyz, objPos.xyz)) / _ImpactSize) * (1 - _Points[i].w));
  50. emissive += amount;
  51. }
  52.  
  53. o.Albedo = c.rgb;
  54. o.Emission = emissive * _PointColor;
  55. o.Metallic = 0;
  56. o.Smoothness = 0;
  57. o.Alpha = c.r;
  58. }
  59. ENDCG
  60. }
  61. FallBack "Diffuse"
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement