shader float3 syntax question

how do I write this function in CG

doesnt work:

half wavy1d(float3 pos){ 
       return round(sin(pos.x*r1+sin(pos.z*r3)));
       }

This works:

half wavy1d(float px,float py,float pz){ 
         return round(sin(px*r1+sin(pz*r3)));
         }

I know I can write 3x single floats instead of the float3, can’t I write float 3? How do I specify the XYZ part? Sometimes it is RGB, how do I specify it?

You can use the notation: float3(x,y,z) to specify a constant float3 value. Also, xyz and rgb are interchangeable - they mean exactly the same thing semantically, but it allows the programmer to more easily see which values are colours and which are vectors.

It works for me just fine, as in the simple example below. There’s an error somewhere else in your code - if you post your complete shader and the error(s) reported by Unity it will be easier to diagnose…

Shader "Test" {
Properties {
    r1 ("r1", float) = 1.0
    r3 ("r3", float) = 1.0                                                  
    }
    SubShader {
        Pass {
            CGPROGRAM
            
    			#pragma vertex vert
    			#pragma fragment frag
    			#include "UnityCG.cginc"

				uniform float r1;
				uniform float r3;

				half wavy1d(float3 pos){
					return round(sin(pos.x*r1+sin(pos.z*r3)));
				}

				struct v2f {
					float4 pos : SV_POSITION;
					float3 stuff : TEXCOORD0;
				};

            	v2f vert (appdata_base v)
            	{
               		v2f o;
                	o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
                	o.stuff = o.pos;
                	return o;
            	}
            	
				fixed4 frag (v2f IN) : COLOR
				{
					return fixed4(wavy1d(IN.stuff),0,0,1);
				}
            ENDCG
        }
    }
}