Advertisement
Guest User

Untitled

a guest
Jan 1st, 2015
268
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.89 KB | None | 0 0
  1. Shader "Jove/Forward/Particles/Unlit"
  2. {
  3.     Properties
  4.     {
  5.         _Color ("Color", Color) = (1.0,1.0,1.0,1.0)
  6.         _MainTex ("Particle Texture", 2D) = "white" {}
  7.         _Absorption ("Absorbtion", Range(0.0, 1.0)) = 1.0
  8.         _Addition ("Addition", Float) = 1.0
  9.         _InvFade ("Soft Particles Factor", Range(0.01,3.0)) = 1.0
  10.     }
  11.  
  12.     SubShader
  13.     {
  14.         Tags
  15.         {
  16.             "RenderType" = "Transparent"
  17.             "Queue" = "Transparent"
  18.             "IgnoreProjector" = "True"
  19.         }
  20.        
  21.         Pass
  22.         {
  23.             Cull Off
  24.             ZWrite Off
  25.             Fog { Mode Off }
  26.             ColorMask RGB
  27.             Blend One OneMinusSrcAlpha
  28.  
  29.             CGPROGRAM
  30.             #pragma vertex vert
  31.             #pragma fragment frag
  32.             #pragma target 4.0
  33.  
  34.             #include "Includes/JoveCG.cginc"
  35.             #include "UnityCG.cginc"
  36.  
  37.             sampler2D _MainTex;
  38.             float4 _Color;
  39.             float _Absorption;
  40.             float _Addition;
  41.             float _InvFade;
  42.            
  43.             struct appdata_t {
  44.                 float4 vertex : POSITION;
  45.                 float4 color : COLOR;
  46.                 float2 texcoord : TEXCOORD0;
  47.             };
  48.  
  49.             struct v2f {
  50.                 float4 pos : SV_POSITION;
  51.                 float4 color : COLOR;
  52.                 float2 texcoord : TEXCOORD0;
  53.                 #if (SOFT_PARTICLES == SOFT_PARTICLES_ON)
  54.                     float4 clipPos : TEXCOORD1;
  55.                 #endif
  56.             };
  57.            
  58.             float4 _MainTex_ST;
  59.  
  60.             v2f vert (appdata_t v)
  61.             {
  62.                 v2f o;
  63.                 o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
  64.                 o.color = v.color * _Color;
  65.                 o.texcoord = TRANSFORM_TEX(v.texcoord,_MainTex);
  66.                
  67.                 #if (SOFT_PARTICLES == SOFT_PARTICLES_ON)
  68.                     o.clipPos = o.pos;
  69.                 #endif
  70.                
  71.                 return o;
  72.             }
  73.            
  74.             float4 frag (v2f i) : SV_Target
  75.             {
  76.                 #if (SOFT_PARTICLES == SOFT_PARTICLES_ON)
  77.                     float2 screenUV = i.clipPos.xy / i.clipPos.w;
  78.                     screenUV.x = screenUV.x * 0.5f + 0.5f;
  79.                     screenUV.y = 0.5f - screenUV.y * 0.5f;
  80.                    
  81.                     float sceneZ = SampleDepth(screenUV);
  82.                     float partZ = i.clipPos.z;
  83.                     float fade = saturate (_InvFade * (sceneZ-partZ));
  84.                 #else
  85.                     float fade = 1.0;
  86.                 #endif
  87.                
  88.                 float4 clr = i.color * tex2D(_MainTex, i.texcoord);
  89.                 float alpha = fade * clr.a;
  90.                
  91.                 return float4(clr.rgb * alpha * _Addition, alpha * _Absorption);
  92.             }
  93.             ENDCG
  94.         }
  95.     }  
  96. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement