Unity2D: Remove Shader Colour
Hi, I have a shader that I found to help me with a battle transition, I've done all my scripting for it; and it does work, I only have one problem with the shader I found, which is the colour. I want to remove the colour within the shader or at least make it transparent so that the natural texture colour can show! I tried removing anything to do with colour in the shader script, but I got an error and it also made my shader pink! It would me much appreciated if anyone can help me! Thank you :)
The error:
Shader error in 'Hidden/BattleTransitions': 'lerp': no matching 2 parameter intrinsic function; Possible intrinsic functions are: lerp(float|half|min10float|min16float, float|half|min10float|min16float, float|half|min10float|min16float) at line 104 (on d3d11) Compiling Vertex program Platform defines: UNITY_ENABLE_REFLECTION_BUFFERS UNITY_PBS_USE_BRDF1 UNITY_SPECCUBE_BOX_PROJECTION UNITY_SPECCUBE_BLENDING
The Script:
Shader "Hidden/BattleTransitions"
{
Properties
{
_MainTex("Texture", 2D) = "white" {}
_ TransitionTex("Transition Texture", 2D) = "white" {}
_Color("Screen Color", Color) = (1,1,1,1)
_Cutoff("Cutoff", Range(0, 1)) = 0
[MaterialToggle] _Distort("Distort", Float) = 0
_Fade("Fade", Range(0, 1)) = 0
}
SubShader
{
// No culling or depth
Cull Off ZWrite Off ZTest Always
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
struct appdata
{
float4 vertex : POSITION;
float2 uv : TEXCOORD0;
};
struct v2f
{
float2 uv : TEXCOORD0;
float2 uv1 : TEXCOORD1;
float4 vertex : SV_POSITION;
};
float4 _MainTex_TexelSize;
v2f simplevert(appdata v)
{
v2f o;
o.vertex = mul(UNITY_MATRIX_MVP, v.vertex);
o.uv = v.uv;
return o;
}
v2f vert(appdata v)
{
v2f o;
o.vertex = mul(UNITY_MATRIX_MVP, v.vertex);
o.uv = v.uv;
o.uv1 = v.uv;
#if UNITY_UV_STARTS_AT_TOP
if (_MainTex_TexelSize.y < 0)
o.uv1.y = 1 - o.uv1.y;
#endif
return o;
}
sampler2D _TransitionTex;
int _Distort;
float _Fade;
sampler2D _MainTex;
float _Cutoff;
fixed4 _Color;
fixed4 simplefrag(v2f i) : SV_Target
{
if (i.uv.x < _Cutoff)
return _Color;
return tex2D(_MainTex, i.uv);
}
fixed4 simplefragopen(v2f i) : SV_Target
{
if (0.5 - abs(i.uv.y - 0.5) < abs(_Cutoff) * 0.5)
return _Color;
return tex2D(_MainTex, i.uv);
}
fixed4 simpleTexture(v2f i) : SV_Target
{
fixed4 transit = tex2D(_TransitionTex, i.uv);
if (transit.b < _Cutoff)
return _Color;
return tex2D(_MainTex, i.uv);
}
fixed4 frag(v2f i) : SV_Target
{
fixed4 transit = tex2D(_TransitionTex, i.uv1);
fixed2 direction = float2(0,0);
if(_Distort)
direction = normalize(float2((transit.r - 0.5) * 2, (transit.g - 0.5) * 2));
fixed4 col = tex2D(_MainTex, i.uv + _Cutoff * direction);
if (transit.b < _Cutoff)
return col = lerp(col, _Color, _Fade);
return col;
}
ENDCG
}
}
}
Your answer
Follow this Question
Related Questions
Using Texture as HDR color? 2 Answers
Need help to combine shaders, is this possible? 0 Answers
Solid color texture or adding a color property to shader? 1 Answer
Tint Multiple Textures Separately 1 Answer
Small bug? on ShaderGraph 0 Answers