Hi, I set up this shader for an afterburner effect. It all works fine and looks good in viewport, but not in the game viewport or at game run time.
It does however pop up in the frame debugger. Any ideas?
Shader "Afterburner/Flame" {
Properties {
_Color1 ("Main Color", Color) = (1,1,1,1)
_Color2 ("Secundary Color", Color) = (1,1,1,1)
_ColorBlendForce ("Color Blend", Float) = 1
_MainTex ("My tex", 2D) = "white" {}
_StartStrength("Base Strength", Range(0,20)) = 1
_VertexColorStrength("Vertex Color Strength", Range(0,1)) = 1
_Scroll_Mul("Base scroll mul", Range(0,10)) = 3
_Scroll_Mul_Rotation("Base scroll rotation mul", Range(-3,3)) = 0
_Noise_large_ClampMin ("Noise Large Min" , Range(0.1, 1)) = 0.1
_Noise_TileX ( "Noise Large X Tile", float ) = 0.5
_Noise_TileY ( "Noise Large Y Tile", float ) = 1.5
_Noise_small_amount ("Noise Small amount", Range(0,10)) = 4
_AlphaMax ( "Alpha Max", Range(0,1) ) = 1
}
SubShader {
Tags { "Queue"="Transparent+1" "IgnoreProjector"="True" "RenderType"="Transparent" }
Blend SrcAlpha One
Cull Off
Lighting Off
ZWrite Off
Fog {Mode Off}
Pass {
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
struct appdata
{
float4 vertex : POSITION;
float2 texcoord : TEXCOORD0;
float4 color : COLOR;
};
struct v2f
{
float4 pos :SV_POSITION;
float2 texcoord : TEXCOORD0;
fixed4 color : COLOR;
};
fixed4 _Color1;
fixed4 _Color2;
float _ColorBlendForce;
sampler2D _MainTex;
float _Base_Scroll1;
float _Base_Scroll2;
float _Scroll_Mul;
float _Scroll_Mul_Rotation;
float _Noise_large_ClampMin;
float _Noise_TileX;
float _Noise_TileY;
float _Noise_small_amount;
float _StartStrength;
float _VertexColorStrength;
float _AlphaMax;
v2f vert (appdata IN)
{
v2f OUT;
OUT.pos = mul(UNITY_MATRIX_MVP, IN.vertex);
OUT.texcoord = IN.texcoord;
OUT.color = IN.color;
return OUT;
}
fixed4 frag (v2f IN) : COLOR
{
// BASE SCROLLING COORDS
fixed2 base1Coords = IN.texcoord;
fixed2 base2Coords = IN.texcoord;
base1Coords.y += _Time.y * _Base_Scroll1 * _Scroll_Mul;
base2Coords.y += _Time.y * _Base_Scroll2 * _Scroll_Mul;
// GET GREEN CHANNELS FOR BASE LAYER
fixed4 base1 = tex2D(_MainTex, base1Coords).g;
fixed4 base2 = tex2D(_MainTex, base2Coords).g;
// NOISE SCROLLING COORDS
fixed2 noiseBlendCoords = IN.texcoord;
noiseBlendCoords += _Time * fixed2(-15,-0.5) * _Scroll_Mul;
// GET BLUE CHANNEL FOR NOISE LAYER
fixed4 noise = tex2D(_MainTex, noiseBlendCoords).b;
// BASE LAYERS BLENDED
fixed4 finalColor = lerp(base1, base2, noise);
// ADD LARGE SCALE NOISE
fixed2 noiseLargeCoords = IN.texcoord * fixed2(_Noise_TileX,_Noise_TileY) + (_Time * fixed2(-10,-0.1*_Scroll_Mul_Rotation) * _Scroll_Mul );
fixed4 noiseLarge = tex2D(_MainTex, noiseLargeCoords).b;
noiseLarge = clamp(noiseLarge, _Noise_large_ClampMin,1) * _StartStrength;
// ADD LOW SCALE NOISE
fixed2 noiseSmallCoords = IN.texcoord * fixed2(0.8,2.8) + (_Time * fixed2(-20,3*_Scroll_Mul_Rotation) * _Scroll_Mul );
fixed4 noiseSmall = tex2D(_MainTex, noiseSmallCoords).b;
noiseSmall = pow(noiseSmall, 10) * (noiseLarge * _Noise_small_amount * IN.color * _VertexColorStrength);
// Combine
finalColor = mul(finalColor, noiseLarge) + noiseSmall;
finalColor = finalColor * (IN.color * _VertexColorStrength);
// Tint the mesh
fixed4 colorGradient = lerp(_Color1, _Color2, pow(IN.color, _ColorBlendForce));
finalColor = finalColor * colorGradient;
finalColor.a = _AlphaMax;
return finalColor;
}
ENDCG
}
}
FallBack "Diffuse"
}