A question about UVW.
Hello, everyone.
I'm working on volumetric clouds, and i've ran into an issue i'd like to know more about. So basically i use a compute shader to generate a 3D noise texture. It doesn't really matter.
Here is a part of debug shader i used to render my texture to a box while implementing noise compute shader:
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
struct appdata
{
float4 uvw : TEXCOORD0;
float4 vertex : POSITION;
};
struct v2f
{
float3 uvw : TEXCOORD0;
float4 vertex : SV_POSITION;
};
sampler3D _MainTex;
v2f vert (appdata v)
{
v2f i;
i.vertex = UnityObjectToClipPos(v.vertex);
i.uvw = v.uvw.xyz;
return i;
}
fixed4 frag(v2f i) : COLOR
{
fixed3 col = tex3D(_MainTex, i.uvw).r;
return fixed4(1.0 - col, 1.0);
}
Nothing special here, but notice i take TEXCOORD0.
Taking TEXCOORD0 gives me this result:
Notice that it behaves as if it is a 2D texure, upper and lower planes are the same. So i've struggled a bit with that, and then changed a code to take TEXCOORD1.
Now it gives the right behaviour:
So the question is:
Can someone briefly explain why doe's it work like that, or maybe point to a good advanced artice where can i read more about that?
The scale is not an problem, but as you can see it also changes, changing the TEXCOORD index, would be nice to know why, also.
I know this does matter on low level stuff and DirectX implemetation of Unity, but can't tie it all together :(
Your answer
Follow this Question
Related Questions
How add texture to skybox procedural shader 0 Answers
UV distortions in Blender when connecting vertices. 0 Answers
Toon Basic shader turns objects pink in 5.3.4f1 1 Answer
HDRP, terrain and layer count, 0 Answers
Is it possible to change the offset of a texture based on another textures UV? 0 Answers