Simple shader problem?

I’m getting this error

Shader error in ‘Custom/Specular Rim Light’: incorrect number of arguments to numeric-type constructor at line 58 (on d3d11)

based off of this code

float3 viewDirection = normalize(float3(float4(_WorldSpaceCameraPos.xyz, 1.0) - i.posWorld).xyz);

I’ve been writing and re-writing these simple shaders so I can learn, but I have no idea why this shader won’t compile. Can anyone shed light? here’s the whole shader

Shader "Custom/Specular Rim Light"
{
    Properties
    {
        _Color ("Color", Color) = (1.0,1.0,1.0,1.0)
        _SpecColor ("Spec Color", Color) = (1.0,1.0,1.0,1.0)
        _Shininess ("Shininess", float) = 10
        _RimColor ("Rim Color", Color) = (1.0,1.0,1.0,1.0)
        _RimPower ("Rim Power", float) = 5
    }
   
    SubShader
    {
        Pass
        {
            Tags{"LightMode" = "ForwardBase"}
           
            CGPROGRAM
            #pragma vertex vert
            #pragma fragment frag
           
            uniform float4 _Color;
            uniform float4 _SpecColor;
            uniform float _Shininess;
            uniform float4 _RimColor;
            uniform float _RimPower;
           
            uniform float4 _LightColor0;
           
            struct vertexInput
            {
                float4 vertex : POSITION;
                float3 normal : NORMAL;
            };
           
            struct vertexOutput
            {
                float4 pos : SV_POSITION;
                float4 posWorld : TEXCOORD0;
                float3 normalDir : TEXCOORD1;
            };
           
            vertexOutput vert(vertexInput v)
            {
                vertexOutput o;
               
                o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
                o.posWorld = mul(_Object2World, v.vertex);
                o.normalDir = normalize(mul(float4(v.normal, 0.0), _World2Object).xyz);
               
                return o;
            }
           
            float4 frag(vertexOutput i) : COLOR
            {
                float3 normalDirection = i.normalDir;
                float3 lightDirection = normalize(_WorldSpaceLightPos0.xyz);
                float3 viewDirection = normalize(float3(float4(_WorldSpaceCameraPos.xyz, 1.0) - i.posWorld).xyz);
                float atten = 1.0;
               
                float rim = 1 - saturate(dot(lightDirection, normalDirection));
                float3 rimLighting = atten * _LightColor0.xyz * _RimColor.rgb * saturate(dot(lightDirection, normalDirection)) * pow(rim, _RimPower);
               
           
           
                return _Color;
            }
           
           
            ENDCG
        }
    }
}

Internet gods can play their jokes - as soon as I post it becomes solved, but I still don’t understand why the above code doesn’t compile, if anyone can explain it that would be greatly appreciated. Sry for the wasted thread

I used this instead
float3 viewDirection = normalize(_WorldSpaceCameraPos.xyz - i.posWorld.xyz);

which I thought would have been the same as line 58 up above?

Your original code tries to construct a float3 by passing it a float4:

float3( float4(_WorldSpaceCameraPos.xyz, 1.0) - i.posWorld )

i.posWorld is declared as a float4, subtracting it from the float4 you explicitly create makes another float4.