Cannot implicitly convert from 'const float2' to 'float4'
I'm having a very odd error. I recently got into writing custom shaders and today began working on a simple water shader. I made some basic distortion by doing GrabPass{"_GrabTex"} at the start of the shader and using it with a normal-map based UV offset for distortion. Problem is, Unity returns an error if I go and use the result (local variable 'lol') as emission. Yet, it doesn't if I either don't set the emission property, or if I set lol to total 0. The error only occurs on Vulkan, as it seems. Why is this happening?
This works:
half4 lol = half4(0, 0, 0, 0);
o.Emission = lol.rgb;
This works:
half4 lol = tex2Dproj(_GrabTex, IN.uvgrab) * (1 - c.a);
//o.Emission = lol.rgb;
This doesn't work:
half4 lol = tex2Dproj(_GrabTex, IN.uvgrab) * (1 - c.a);
o.Emission = lol.rgb;
And here's the full shader:
Shader "Custom/GargWater"
{
Properties
{
_Color ("Color", Color) = (1,1,1,1)
_MainTex ("Albedo (RGB)", 2D) = "white" {}
[Normal] [NoScaleOffset] _BumpMap ("Normal map (RGB)", 2D) = "bump" {}
_BumpMult ("Normal Intensity", Range(0,2)) = 1
_Metallic ("Metallic", Range(0,1)) = 0
_Glossiness ("Smoothness", Range(0,1)) = 0.25
_Distortion ("Distortion", Range(0,1)) = 0
_Speed ("Speed", Range(0,0.1)) = 0.1
}
SubShader
{
Tags { "Queue"="Transparent" "RenderType"="Transparent" }
GrabPass{"_GrabTex"}
LOD 200
CGPROGRAM
// Physically based Standard lighting model, and enable shadows on all light types
#pragma surface surf Standard alpha
// Use shader model 3.0 target, to get nicer looking lighting
#pragma target 3.0
sampler2D _MainTex;
sampler2D _BumpMap;
sampler2D _GrabTex;
struct Input
{
float2 uv_MainTex;
float4 position;
float4 uvgrab;
};
half _BumpMult;
half _Distortion;
half _Glossiness;
half _Metallic;
half _Speed;
fixed4 _Color;
void vert (appdata_base IN, out Input OUT)
{
OUT.position = UnityObjectToClipPos(IN.vertex);
OUT.uv_MainTex = IN.texcoord;
OUT.uvgrab = ComputeGrabScreenPos(OUT.position);
}
void surf (Input IN, inout SurfaceOutputStandard o)
{
fixed2 uv1 = IN.uv_MainTex + fixed2(_Time.y, _Time.y) * _Speed;
fixed2 uv2 = IN.uv_MainTex + fixed2(_Time.y * 0.5, -_Time.y) * _Speed;
half4 bump = tex2D(_BumpMap, uv1);
half4 bump2 = tex2D(_BumpMap, uv2);
o.Normal = UnpackScaleNormal(bump, _BumpMult) * UnpackScaleNormal(bump2, _BumpMult);
half4 c = tex2D (_MainTex, uv1) * tex2D (_MainTex, uv2) * _Color;
o.Albedo = c.rgb;
o.Metallic = _Metallic;
o.Smoothness = _Glossiness;
o.Alpha = c.a;
IN.uvgrab.x += bump.g * _Distortion * 0.1;
IN.uvgrab.y += bump.g * _Distortion * 0.1;
half4 lol = tex2Dproj(_GrabTex, IN.uvgrab) * (1 - c.a);
o.Emission = lol.rgb;
}
ENDCG
}
}
Am I missing something here? The line the error points to is line 167, which, considering the shader ends at 75, is astoundingly useless. I'm using Unity 2019.3.15f1.