I write a surface shader is as follows:
shader “Sbin/surface/002”
{
properties
{
_MainTex(“main tex”,2d)=“white”{}
}
subshader
{
Tags { “RenderType” = “Opaque” }
CGPROGRAM
#pragma surface surf Lambert
struct Input
{
float2 uv_MainTex;
};
sampler2D _MainTex;
void surf(Input IN, inout SurfaceOutput o)
{
o.Albedo=tex2D(_MainTex,IN.uv_MainTex).rgb;
}
ENDCG
}
fallback “diffuse”
}
/*
When I changed the struct Input of members called other times, such as: uv_TexMain
Will be a mistake, ask why. In addition, the properties _MainTex to _TexMain a mistake, do _MainTex are keywords?
*/
If you change the input struct to uv_TexMain, you’ll also have to change the properties to have a _TexMain texture and add a sampler2D _TexMain and a tex2D _TexMain.
Yes, I have done as you said, the compiler has passed, can not map display. Please copy the code and then test it, thank you
//Is the member name of the structure associated with the property name ?
//I tested the vertex shader and fragment shader, in both the shader, structure member names and property’s names there is no correlation
//English is not very good, I hope to forgive
=============================
shader “Sbin/surface/002”
{
properties
{
_TexMain(“main tex”,2d)=“white”{}
}
subshader
{
Tags { “RenderType” = “Opaque” }
CGPROGRAM
#pragma surface surf Lambert
struct Input
{
float2 uv_tm; //changed to uv_tm
};
sampler2D _TexMain;
void surf(Input IN, inout SurfaceOutput o)
{
o.Albedo=tex2D(_TexMain,IN.uv_tm).rgb;
}
ENDCG
}
fallback “diffuse”
}
What do you mean by cannot map display?
Can you give screenshots of the object and the material inspector?
cannot map display == Can not display the texture map
Is the member name of the structure associated with the property name ?
I tested the vertex shader and fragment shader, in both the shader, structure member names and property’s names there is no correlation
English is not very good, I hope to forgive