/******************************************************************************
 * The following code was generated by the mental mill(R) при содействии      *
 *                                                                            *
 * BROTHERMECHANIC                                                            *
 * Bishkek, Kirgizstan. All rights reserved.                                  *
******************************************************************************/

//
// Values for the light_type parameter of light shaders
//
#define LIGHT_POINT    0
#define LIGHT_SPOT     1
#define LIGHT_INFINITE 2
#define LIGHT_PLANAR   3

//
// The light iterator structure holds the return values resulting from
// evaluating a light.
//
struct Light_iterator {
	float3 _point;
	float4 contribution;
	float4 raw_contribution;
	float  dot_nl;
	float3 direction;
	float  distance;
	float4 shadow;
	int    count;
};

struct Ray {
	float3 origin;
	float3 direction;
};

Ray __Ray_ctor(float3 o, float3 d)
{
	Ray r;
	r.origin = o;
	r.direction = d;
	return r;
}

float2 __float2_ctor(float v)
{
	return v.xx;
}

float3 __float3_ctor(float v)
{
	return v.xxx;
}

float4 __float4_ctor(float v)
{
	return v.xxxx;
}

float4 __tex2D_flip_v(sampler2D samp, float2 uv)
{
	return tex2D(samp, float2(uv.x, 1.0-uv.y));
}

float4 __tex2D_flip_v(sampler2D samp, float2 uv, float2 ddu, float2 ddv)
{
	return tex2D(samp, float2(uv.x, 1.0-uv.y), ddu, ddv);
}

void __make_basis(const float3 n, const float3 u, const float3 v,
        out float3 t, out float3 b)
{
    b = normalize(cross(u,n));
    t = cross(n,b);
    if (dot(b,v) < 0.0)  b = -b;
}

float3 __perspective_divide(float4 pt)
{
    return pt.xyz/pt.w;
}

//
// The state structure is used internally within the fragment shader to
// commonly used values.
//
struct State
{
	float4 tex_coord[4];
	float3 position;
};

//
// The following are free parameters of the shader that should be set by the
// application at runtime.
//
float Set : CHANNELVALUE0 <
    string UIWidget = "slider";
    float UIMin = 0.0;
    float UIMax = 2.0;
    float UIStep = 1;
    string UIName =  "Set";
> = 0;

texture __Texture_lookup_2d_1_texture : TEXTURE0 <
	string UIName = "Texture_lookup_2d_1_texture";
	string ResourceName = "default.dds";
	string ResourceType = "2D";
>;

sampler2D Texture_lookup_2d_1_texture = sampler_state {
	Texture = <__Texture_lookup_2d_1_texture>;
	MinFilter = Linear;
	MagFilter = Linear;
	MipFilter = Linear;
};



//
// The following are parameters representing non-varying state variables 
// referenced by the shader. These should be set by the application at runtime.
// Note that vector parameters should be provided in camera space.
//
float4x4 __object_to_ndc : WorldViewProjection
<
	string UIWidget = "none";
>;
float4x4 __world_to_object : WorldInverse
<
	string UIWidget = "none";
>;
float4x4 __object_to_world : World
<
	string UIWidget = "none";
>;

//
// The App2vert structure defines the vertex attributes used by the vertex
// shader. The application should supply a vertex stream containing these 
// elements.
//
struct App2vert
{
	float3 position : POSITION;
	float4 texcoord0 : TEXCOORD0;
	float4 texcoord1 : TEXCOORD1;
	float4 texcoord2 : TEXCOORD2;
	float4 texcoord3 : TEXCOORD3;
};

//
// The Vert2frag_out structure defines values output by the vertex shader.
//
struct Vert2frag_out
{
	float4 hpos : POSITION;
	float4 tex_coord[4] : TEXCOORD0;
	float3 position : TEXCOORD4;
};

//
// The Vert2frag_in structure defines values used by the fragment shader.
//
struct Vert2frag_in
{
	float4 hpos : POSITION;
	float4 tex_coord[4] : TEXCOORD0;
	float3 position : TEXCOORD4;
};

//
// This function is the main method of the vertex shader.
//
Vert2frag_out vertex_main(
	App2vert vs_in)
{
	Vert2frag_out vs_out;
	float4 position = float4(vs_in.position, 1);
	vs_out.hpos = mul(position, __object_to_ndc);
	vs_out.position = mul(position, __object_to_world).xyz;
	vs_out.tex_coord[0] = vs_in.texcoord0;
	vs_out.tex_coord[1] = vs_in.texcoord1;
	vs_out.tex_coord[2] = vs_in.texcoord2;
	vs_out.tex_coord[3] = vs_in.texcoord3;
	return vs_out;
}

//
// The following functions are generated from the MetaSL implementation of
// the shaders that are part of the compiled shader graph.
//

void Texture_lookup_2d_main(
	sampler2D _texture,
	int texture_space,
	float2 texture_uv,
	State state,
	out float4 result)
{
	{
		result = (__tex2D_flip_v(_texture, texture_uv));
	}
}

//
// The following method is the root function of the shader graph
//
float4 Texture_lookup_2d_1_eval(State state)
{
	float4 result;
	Texture_lookup_2d_main(Texture_lookup_2d_1_texture, 0, (state.tex_coord)[Set].xy, (state), result);
	return result;
}

//
// This function is the main method of the fragment shader. It initializes the
// values in the state structure that are used by nodes in the shader graph
// and produces the final result of the shader.
//
float4 fragment_main(
	Vert2frag_in fs_in) : COLOR
{
	State state;
	state.position = fs_in.position;
	state.tex_coord = fs_in.tex_coord;
	return Texture_lookup_2d_1_eval(state);
}

//
// The following define the default technique and pass of the effect.
//
technique T0
{
	pass P0
	{
		ZEnable      = true;
		ZWriteEnable = true;
		CullMode     = none;
		VertexShader = compile vs_3_0 vertex_main();
		PixelShader  = compile ps_3_0 fragment_main();
	}
}

 