Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Shader "Effect/fire" {
- Properties {
- _OffsetTex ("Offset Tex", 2D) = "white" {}
- _MainTex("Mask(A) ", 2D) = "white" {}
- _TxtrScale ("Texture scale", Range(0, 4)) = .125
- _TxtrSpeed ("Texture speed", Range(-2, 2)) = .2
- _Brightness ("Brightness", Range(0, 4)) = 1
- _Flatten ("Flatten", Range(1, 10)) = 5.72
- _Gamma ("Gamma", Range(0, 3)) = 1
- _AlphaAdd ("Alpha affect", Range (0, 1)) = .612
- _TxtrMult ("Texture multi", Range (0, 4)) = .5
- _TxtrAdd ("Texture add", Range (-1, .01)) = -.192
- }
- Category {
- Tags { "Queue"="Transparent+3000" "RenderType"="Transparent" }
- Blend SrcAlpha One
- AlphaTest Greater .01
- Cull Off Lighting Off ZWrite Off
- SubShader {
- Pass {
- Name "BASE"
- Tags { "LightMode" = "Always" }
- CGPROGRAM
- #pragma vertex vert
- #pragma fragment frag
- #pragma target 2.0
- #pragma multi_compile_particles
- #pragma multi_compile_fog
- #include "UnityCG.cginc"
- struct appdata_t {
- float4 vertex : POSITION;
- fixed4 color : COLOR;
- float2 texcoord: TEXCOORD0;
- float4 random: TEXCOORD2;
- float4 center: TEXCOORD1;
- };
- struct v2f {
- float4 vertex : POSITION;
- fixed4 color : COLOR;
- float2 uvmain : TEXCOORD0;
- float2 worldPosition: TEXCOORD1;
- float4 random: TEXCOORD3;
- float4 center: TEXCOORD4;
- };
- float _Brightness;
- float _Flatten;
- float _Gamma;
- float _TxtrMult;
- float _TxtrAdd;
- float _TxtrScale;
- float _TxtrSpeed;
- half4 _DisplacementScrollSpeed;
- half4 _Strength;
- half4 _Params;
- float _AlphaAdd;
- float4 _OffsetTex_ST;
- float4 _CellSize;
- sampler2D _OffsetTex;
- sampler2D _MainTex;
- v2f vert (appdata_t v)
- {
- v2f o;
- o.vertex = mul(UNITY_MATRIX_MVP, v.vertex);
- o.uvmain = v.texcoord;//TRANSFORM_TEX(v.texcoord, _OffsetTex);
- o.worldPosition = mul(UNITY_MATRIX_T_MV, v.vertex);
- o.color = v.color;
- o.center = v.center;// + _Time.yyyy*_DisplacementScrollSpeed.xyxy;
- o.random = v.random;
- return o;
- }
- float2 quant(float2 f, float2 q ){
- return round(f/q)*q;
- }
- float2 ttex(float2 tex, float4 st) {
- return tex.xy * st.xy + st.zw;
- }
- float2 rotate(float2 original, float angle ){
- angle = angle * 0.01745329252;
- float sinX = sin ( angle );
- float cosX = cos ( angle );
- float2x2 rotationMatrix = float2x2( cosX, -sinX, sinX, cosX);
- return mul(original, rotationMatrix );
- }
- half4 frag( v2f i ) : COLOR
- {
- half2 uv = i.uvmain;
- fixed4 txtr = tex2D(_MainTex, uv);
- uv = i.worldPosition * _TxtrScale
- - i.center * _TxtrSpeed
- + i.random.xy;
- fixed offset = tex2D(_OffsetTex, uv).r;
- offset = saturate( offset + (i.color.a-1)*_AlphaAdd + _TxtrAdd);
- float f = exp(_Flatten);
- txtr = clamp(txtr.r * offset * _TxtrMult , 0, 1/f) * f * _Brightness;
- return pow( txtr * i.color, _Gamma);
- }
- ENDCG
- }
- }
- // ------------------------------------------------------------------
- // Fallback
- SubShader{
- Blend DstColor Zero
- Pass{
- Name "BASE"
- SetTexture[_MainTex]{ combine texture }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement