Thanks for your reply.
The shader template like this(in fragment shader )
Code: Select all
/*ase_local_var*/half4 finalRGBA;
/*ase_local_var*/float ndotl;
fixed4 _MainTex_var;
/*ase_local_var*/fixed3 albedo;
/*ase_local_var*/float3 worldPos;
/*ase_local_var*/half3 normalLocal;
/*ase_local_var*/fixed metallic;
_MainTex_var = tex2D(_MainTex,i.uv0) * _Color;
albedo = _MainTex_var.rgb;
worldPos = i.posWorld.xyz;
#ifdef USE_NORMALMAP
fixed4 _Normal_var = tex2D(_Normal,i.uv0);
normalLocal = UnpackNormal(_Normal_var);
#else
fixed4 _Normal_var = 1.0;
normalLocal = half3(0,0,1);
#endif
#ifndef NO_MSA
fixed alpha = _MainTex_var.a;
#else
fixed alpha = 1.0;
#endif
#if defined(_ALPHATEST_ON)
clip(alpha - _Cutoff);
#endif
#ifndef NO_MSA
fixed4 control = tex2D(_Control,i.uv0);
#else
fixed4 control = fixed4(1.0, _MainTex_var.a, _Normal_var.a, 1.0);
#endif
metallic = control.r * metal;
/*ase_local_var*/fixed smoothness;
smoothness = control.g * smootha;
/*ase_local_var*/fixed occlusion;
occlusion = control.b;
fixed emission = control.a;
#if defined(_Raina)
half rainAmount;
rainAmount = _Rain * control.a;
ApplyRain(worldPos, rainAmount, normalLocal, smoothness, metallic);
#endif
#if defined(_SNOW)
/*ase_frag_out:Snow Function Replace Color;Float4*/ fixed4(0, 0, 0, 0) /*end*/;
//ApplySnow(worldPos, i.normalDir, albedo, normalLocal, metallic, smoothness, occlusion);
#endif
This is a pbr shader template . with snow effect added . which will use a texture to change the metallic and smoothness , also some other variables .
In here , the function replaced line , I directly use the original local variable name ,as input . and , don't need a temp_cast variable as Input .
The modify node code like this
Code: Select all
protected override void CommonInit(int uniqueId)
{
base.CommonInit(uniqueId);
//AddOutputPort(WirePortDataType.FLOAT, "Example Output Port (Index 0)");
}
public override string GenerateShaderForOutput(int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar)
{
//foreach(var na in m_dataLabels)
//{
// Debug.Log(na);
//}
return m_dataLabels[m_currentDataIdx];
}
The final generated shader code like this
Code: Select all
#if defined(_SNOW)
ApplySnow(worldPos,i.normalDir,albedo,normalLocal,metallic,smoothness,occlusion);
//ApplySnow(worldPos, i.normalDir, albedo, normalLocal, metallic, smoothness, occlusion);
#endif