Hello,
I am new to shader coding and I am trying to make sense of some of the basics. In particular I am trying to better understand uv coordinates by visualising them.
I am using a basic surface shader and I am assigning the i.uv.x and i.uv.y floats to o.Albedo in order to see what they look like.
I would expect the result to be exactly the same as in my understanding both i.uv.x and i.uv.y range from 0 to 1 and should be float numbers.
However, when I assign them to o.Albedo I get different results. See pictures.
Here is the code, extremely simple and standard:
Shader "Custom/MyFloorShader"
{
Properties
{
_Color ("Color", Color) = (1,1,1,1)
_MainTex ("Albedo (RGB)", 2D) = "white" {}
_Glossiness ("Smoothness", Range(0,1)) = 0.5
_Metallic ("Metallic", Range(0,1)) = 0.0
}
SubShader
{
Tags { "RenderType"="Opaque" }
LOD 200
CGPROGRAM
// Physically based Standard lighting model, and enable shadows on all light types
#pragma surface surf Standard fullforwardshadows
// Use shader model 3.0 target, to get nicer looking lighting
#pragma target 3.0
sampler2D _MainTex;
struct Input
{
float2 uv_MainTex;
};
half _Glossiness;
half _Metallic;
fixed4 _Color;
// Add instancing support for this shader. You need to check 'Enable Instancing' on materials that use the shader.
// See https://docs.unity3d.com/Manual/GPUInstancing.html for more information about instancing.
// #pragma instancing_options assumeuniformscaling
UNITY_INSTANCING_BUFFER_START(Props)
// put more per-instance properties here
UNITY_INSTANCING_BUFFER_END(Props)
void surf (Input IN, inout SurfaceOutputStandard o)
{
float2 uv = IN.uv_MainTex;
/*Albedo comes from a texture tinted by color */
fixed4 c = tex2D (_MainTex, IN.uv_MainTex) * _Color;
o.Albedo = uv.x; //uv.y;
//Metallic and smoothness come from slider variables
o.Metallic = _Metallic;
o.Smoothness = _Glossiness;
o.Alpha = c.a;
}
ENDCG
}
FallBack "Diffuse"
}
Can anybody help me understand?

