#define GENERATOR_VERSION 1
#include "includes.cg.px"
#include "CustomizeOutColor.cg.px"

void Node_1_AddColor(in float4 A, in float4 B, in float amount, out float4 R)
{
R = A + B * amount;
}

void Node_2_MaterialPixelShader(in sampler2D inTexture, in float2 inUVs, in float3 inWorldPos, in float3 inNormal3, in float3 inTangent3, in float4 inColor, in float time, in float4 u_color, out float4 outDiffuse, out float4 outNormal, out float4 outSpec, out float4 outEmissive, out float4 outGlow)
{
float4 Node_1_AddColor_R;
Node_1_AddColor(u_color, float4(0.000000, 0.000000, 0.000000, 0.000000), 0.000000, Node_1_AddColor_R);

outDiffuse = float4(0.000000, 0.000000, 0.000000, 1.000000);
outNormal = float4(0.000000, 0.000000, 0.000000, 1.000000);
outSpec = float4(0.000000, 0.000000, 0.000000, 0.000000);
outEmissive = Node_1_AddColor_R;
outGlow = float4(0.000000, 0.000000, 0.000000, 1.000000);
}


void main_f(
	float4 inTexCoord:TEXCOORD0
	, float4 oWorldPosition:TEXCOORD1
	, float4 inNormal:TEXCOORD2
	, float4 inColor:TEXCOORD3
#ifndef SH_NOVXTRANSFORM
#ifdef SH_NORMALMAP
	, float4 inTangent:TEXCOORD4
#endif
#endif //SH_NOVXTRANSFORM
	, float4 inTexCoord2:TEXCOORD5
	, out float4 outColor:COLOR
	, uniform sampler2D Texture0

		, uniform float time
	, uniform float4 u_color

	)
{
	float4 userColor;
#ifdef SH_PARTICLE
	float2 inUVs = inTexCoord.xy;
	float fSlide = inTexCoord.z * f2ParticleTextureUvHeight.x;
	float2 f2SlideUVs = float2(fmod(fSlide, 1), floor(fSlide) * f2ParticleTextureUvHeight.y);
	inUVs = inUVs.xy * f2ParticleTextureUvHeight + f2SlideUVs;
#else //SH_PARTICLE
	float2 inUVs = inTexCoord.xy;
	float2 inUV2s = inTexCoord2.xy;
#endif //SH_PARTICLE
	sampler2D inTexture = Texture0;
	float3 inWorldPos = oWorldPosition.xyz;
	float3 inNormal3 = inNormal.xyz;
	float3 inTangent3;
#ifdef SH_NORMALMAP
	inTangent3 = inTangent.xyz;
#endif
	float4 userNormal;
	float4 userSpec;
	float4 userEmissive = 0;
	float4 userGlow = 0;
	Node_2_MaterialPixelShader(inTexture, inUVs, inWorldPos, inNormal3, inTangent3, inColor, time, u_color
		, userColor
		//#ifdef SH_NORMALMAP
		, userNormal
		//#endif
		//#ifdef SH_SPECULARMAP
		, userSpec
		//#endif
		, userEmissive, userGlow
	);
	DiscardIfAlphaTransparent(userColor+userEmissive);
	
#ifdef HAS_LIGHT
	ComputeLightingParams params;
	params.oWorldPosition = oWorldPosition;
	params.inNormal = inNormal;
	params.userColor = userColor;
	#ifdef SH_NORMALMAP
		params.userNormal = userNormal;
		params.tangent = inTangent;
	#endif //SH_NORMALMAP
	#ifdef SH_SPECULAR
		params.userSpec = userSpec;
	#endif //SH_SPECULAR
	outColor = ComputeLightning(params) + userEmissive;
	outColor.a = saturate(userColor.a + userEmissive.a);
#else // HAS_LIGHT
	outColor = saturate(userColor + userEmissive);
#endif // HAS_LIGHT

	outColor.r = 1;
	outColor.g = 0;
	
	
#ifdef SH_CUSTOMIZEOUTCLR
	outColor = UserCustomizeOutColor(outColor);
#endif // SH_CUSTOMIZEOUTCLR	
}
