The questions i have are from this shader which i found on 1 of the posts
Shader “XRay” {
Properties {
_Color (“Tint (RGB)”, Color) = (1,1,1,1)
_MainTex (“Main texture”,2D) = “white” {}
}
Category {
ZWrite Off
Tags {“Queue”=“Transparent”}
Lighting Off
SubShader {
Pass {
// Blend One One
Blend SrcAlpha OneMinusSrcAlpha
CGPROGRAM
// profiles arbfp1
// vertex vert
//fragment frag
//fragmentoption ARB_fog_exp2
#include “UnityCG.cginc”
sampler2D _MainTex : register(s0);
struct v2f {
V2F_POS_FOG;
float2 uv1 :TEXCOORD1;
float3 color : COLOR0;
float alpha;
};
v2f vert (appdata_base v) {
v2f o;
PositionFog( v.vertex, o.pos, o.fog );
o.uv1 = TRANSFORM_UV(0);
float3 viewDir = normalize(ObjSpaceViewDir(v.vertex));
o.alpha = dot(viewDir, v.normal) * dot(viewDir,v.normal);
return o;
}
half4 frag(v2f i) : COLOR {
half4 texcol = tex2D(_MainTex, i.uv1);
return half4(texcol.rgb, i.alpha);
}
ENDCG
SetTexture [_MainTex] {
combine texture
}
}
}
}
}
1)what is V2F_POS_FOG; in the struct v2f in the fragment shader?y do we need it although its not been used explicitly inside the shader.Does something happen behind the curtains?
2)why do we have to do PositionFog( v.vertex, o.pos, o.fog ); in the fragment shader.i saw that commenting out the line gave no colors in my case.
3)o.uv1 = TRANSFORM_UV(0);Is there something going on behind the scene for this 2 or is uv1 just going unsed for this shader?what does the transform do?is it multiplying localtoworld matrix?
4)What is register(s0) written next to sampler2D _MainTex?does it say that use a register instead of memory?
5)float2 uv1 :TEXCOORD1;
float3 color : COLOR0;
whats the point of tagging uv1 as texcoord1 and color as color0?if its just for passing them to the fragment shader then we are already passing the struct to the fragment shader.
Thx