- Home /
Shader - What is float3.xy?
(I've been having a pain trying to google this. and searching through Unity manual for it was revealing lots of results with no clear explanation)
I'm looking at equations in shader examples like:
float2 steppedUV = IN.grabUV.xy / IN.grabUV.w;
// where IN.grabUV is TEXCOORD0, which is at least a float2.
The problem is that I don't know what ".xy" is. is it the value of X * Y, is it a float2 being exported with the X & Y values? if it is a float 2 being returned, how does division work on float 2's. My impression is in Unity you can't divide a vector by another vector.
Thanks.
Answer by Harinezumi · Jan 30, 2018 at 02:47 PM
In shaders float3.xy (or float3.rg and all kinds of variations) address the subset referred to by the letters. So in case of float3.xy you get a float2 that has the x and y coordinates in it. In case of a float4.a you get the 4th component of the float, which is alpha channel for a color. Or a float4.w is also the 4th components.
If I remember correctly all combinations within the same set of letters are allowed (from rgba you can take just rb, or from xyzw yw (skipping z!), or from a texcoord uvw uw).
See here more examples (it's not the shader language Unity uses, but it has similar syntax).
Your answer
![](https://koobas.hobune.stream/wayback/20220612151539im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Fog not working in my Shader~ 0 Answers
Header for material properties in inspector? 2 Answers
Addition to Standard Shader stopping it from batching? 0 Answers
Unity 3d Sprite Shader (How do I limit Max Brightness to 1 with Multiple Lights Hitting) 0 Answers
"Stencil Operation" property setup? 1 Answer