/******************************************************************************
* The following code was generated by the mental mill(R)                     *
*                                                                            *
* Copyright 1986-2007 by mental images GmbH, Fasanenstr. 81, D-10623         *
* Berlin, Germany. All rights reserved.                                      *
******************************************************************************/

//
// The state structure is used internally within the fragment shader to
// commonly used values.
//
struct State
{
   vec4 tex_coord[4];
   vec3 tex_tangent[1];
   vec3 tex_binormal[1];
   float refracted_ior;
   float incident_ior;
   vec3 origin;
   vec3 position;
   vec3 normal;
   vec3 motion;
   vec2 raster;
   vec3 direction;
   float ray_length;
   float dot_nd;
   mat3 tangent_space[1];
   float importance;
   vec3 texture_du[256];
   vec3 texture_dv[256];
   vec4 volume_input;
   vec3 light_position;
   vec3 light_direction;
   vec3 light_to_surface;
   float light_distance;
   float light_dotnl;
   int light_type;
   float light_spread;
   float light_spread_cos;
   float light_distance_limit;
};

//
// Values for the light_type parameter of light shaders
//
const int LIGHT_POINT    = 0;
const int LIGHT_SPOT     = 1;
const int LIGHT_INFINITE = 2;
const int LIGHT_PLANAR   = 3;

//
// The light iterator structure holds the return values resulting from
// evaluating a light.
//
struct Light_iterator {
   vec3 point;
   vec3 direction;
   float distance;
   float dot_nl;
   vec4 contribution;
   vec4 raw_contribution;
   vec4 shadow;
   int count;
};

struct Ray {
   vec3 origin;
   vec3 direction;
};

vec4 illumination(float ndotl,float ndoth,float m);

float log10(float x);
vec2 log10(vec2 x);
vec3 log10(vec3 x);
vec4 log10(vec4 x);

float modf(float a,out float b);
vec2 modf(vec2 a,out vec2 b);
vec3 modf(vec3 a,out vec3 b);
vec4 modf(vec4 a,out vec4 b);

float round(float x);
vec2 round(vec2 x);
vec3 round(vec3 x);
vec4 round(vec4 x);

float saturate(float x);
vec2 saturate(vec2 x);
vec3 saturate(vec3 x);
vec4 saturate(vec4 x);

void sincos(float x,out float s,out float c);
void sincos(vec2 x,out vec2 s,out vec2 c);
void sincos(vec3 x,out vec3 s,out vec3 c);
void sincos(vec4 x,out vec4 s,out vec4 c);

mat2 transpose(mat2);
mat3 transpose(mat3);
mat4 transpose(mat4);
float determinant(mat3);
float determinant(mat4);

void mi_component_illumination_base(
   vec4 msl_ambient_color,
   float msl_ambient_scalar,
   vec4 msl_diffuse_reflectance_color,
   vec4 msl_diffuse_color,
   float msl_diffuse_scalar,
   vec4 msl_specular_reflectance_color,
   vec4 msl_specular_color,
   float msl_specular_scalar,
   out vec4 msl_sum,
   out vec4 msl_ambient,
   out vec4 msl_diffuse,
   out vec4 msl_specular)
{
   msl_sum = vec4(0, 0, 0, 0);
   msl_ambient = vec4(0, 0, 0, 0);
   msl_diffuse = vec4(0, 0, 0, 0);
   msl_specular = vec4(0, 0, 0, 0);
   msl_ambient = ((msl_ambient_color * vec4(msl_ambient_scalar)));
   msl_sum += msl_ambient;
   vec4 msl_0 = msl_diffuse_reflectance_color * msl_diffuse_color;
   msl_diffuse += ((msl_0 * vec4(msl_diffuse_scalar)));
   msl_sum += msl_diffuse;
   vec4 msl_1 = msl_specular_reflectance_color * msl_specular_color;
   msl_specular += ((msl_1 * vec4(msl_specular_scalar)));
   msl_sum += msl_specular;
   msl_sum.a = 1.0;
   msl_ambient.a = 1.0;
   msl_diffuse.a = 1.0;
   msl_specular.a = 1.0;
}


vec4 mi_ashikhmin_shirley_diffuse(
   vec3 msl_lightDir,
   vec3 msl_eyeDir,
   vec3 msl_n,
   vec4 msl_Rd,
   vec4 msl_Rs)
{
   float msl_f1 = 1.0 - ((0.5 * dot(msl_lightDir,msl_n)));
   float msl_f2 = 1.0 - ((0.5 * (-dot(msl_eyeDir,msl_n))));
   float msl_d = ((((28.0 / ((23.0 * 3.14159265358979323846)))) * ((1.0 - pow(msl_f1,float(5)))))) * ((1.0 - pow(msl_f2,float(5))));
   vec4 msl_0 = vec4(1.0, 1.0, 1.0, 1.0);
   vec4 msl_1 = saturate(((msl_0 - msl_Rs)));
   vec4 msl_2 = msl_Rd * msl_1;
   return msl_2 * vec4(msl_d);
}


vec4 mi_ashikhmin_shirley_specular(
   float msl_shininess_u,
   float msl_shininess_v,
   vec3 msl_lightDir,
   vec3 msl_eyeDir,
   vec3 msl_n,
   vec3 msl_u,
   vec3 msl_v,
   vec4 msl_Rd,
   vec4 msl_Rs)
{
   vec3 msl_h = normalize(((msl_lightDir - msl_eyeDir)));
   float msl_kh = abs(dot(msl_eyeDir,msl_h));
   float msl_hv = dot(msl_h,msl_v);
   float msl_hu = dot(msl_h,msl_u);
   float msl_hn = dot(msl_h,msl_n);
   float msl_nk1 = abs(dot(msl_n,msl_lightDir));
   float msl_nk2 = abs(dot(msl_n,msl_eyeDir));
   float msl_c = sqrt(((((msl_shininess_u + 1.0)) * ((msl_shininess_v + 1.0))))) / ((8.0 * 3.14159265358979323846));
   float msl_exponent = ((((((msl_shininess_u * msl_hu)) * msl_hu)) + ((((msl_shininess_v * msl_hv)) * msl_hv)))) / ((1.0 - ((msl_hn * msl_hn))));
   vec4 msl_0 = vec4(1.0, 1.0, 1.0, 1.0);
   vec4 msl_1 = saturate(((msl_0 - msl_Rs)));
   float msl_2 = pow(max(1.0 - msl_kh,0.0),float(5));
   vec4 msl_3 = msl_1 * vec4(msl_2);
   vec4 msl_fresnel = msl_Rs + msl_3;
   float msl_4 = ((msl_c * pow(msl_hn,msl_exponent))) / ((msl_kh * max(msl_nk1,msl_nk2)));
   return vec4(msl_4) * msl_fresnel;
}


float mi_SQR(
   float msl_x)
{
   return msl_x * msl_x;
}


vec4 mi_cooktorr_specular(
   vec3 msl_di,
   vec3 msl_dr,
   vec3 msl_n,
   float msl_roughness,
   vec4 msl_ior)
{
   vec4 msl_result;
   vec4 msl_F,msl_g;
   vec3 msl_fhalf;
   float msl_nh,msl_nv,msl_nl,msl_vh,msl_nh2,msl_m2,msl_t;
   float msl_D,msl_G,msl_c,msl_otherterms,msl_expo;
   msl_fhalf = ((msl_dr - msl_di));
   msl_fhalf = normalize(msl_fhalf);
   msl_nh = dot(msl_n,msl_fhalf);
   msl_result.rgba = vec4(0, 0, 0, 0);
   if (msl_nh > 0.0)
   {
      msl_nl = dot(msl_n,msl_dr);
      msl_nv = (-dot(msl_n,msl_di));
      msl_vh = (-dot(msl_di,msl_fhalf));
      msl_nh2 = ((msl_nh * msl_nh));
      msl_m2 = ((msl_roughness * msl_roughness));
      msl_expo = ((((msl_nh2 - float(1))) / ((msl_nh2 * msl_m2))));
      msl_D = ((exp(msl_expo) / ((((((((float(4) * 3.14159265358979323846)) * msl_m2)) * msl_nh2)) * msl_nh2))));
      msl_G = ((((((2.0 * msl_nh)) * min(msl_nv,msl_nl))) / msl_vh));
      msl_G = min(msl_G,1.0);
      msl_c = dot(msl_dr,msl_fhalf);
      msl_t = ((msl_ior.r < float(1)) ? float(1) : float(msl_ior.r));
      msl_g.r = sqrt(((((((msl_t * msl_t)) + ((msl_c * msl_c)))) - float(1))));
      msl_t = ((msl_ior.g < float(1)) ? float(1) : float(msl_ior.g));
      msl_g.g = sqrt(((((((msl_t * msl_t)) + ((msl_c * msl_c)))) - float(1))));
      msl_t = ((msl_ior.b < float(1)) ? float(1) : float(msl_ior.b));
      msl_g.b = sqrt(((((((msl_t * msl_t)) + ((msl_c * msl_c)))) - float(1))));
      msl_F.r = ((((((0.5 * mi_SQR(((msl_g.r - msl_c))))) / mi_SQR(((msl_g.r + msl_c))))) * ((float(1) + ((mi_SQR(((((msl_c * ((msl_g.r + msl_c)))) - float(1)))) / mi_SQR(((((msl_c * ((msl_g.r - msl_c)))) + float(1))))))))));
      msl_F.g = ((((((0.5 * mi_SQR(((msl_g.g - msl_c))))) / mi_SQR(((msl_g.g + msl_c))))) * ((float(1) + ((mi_SQR(((((msl_c * ((msl_g.g + msl_c)))) - float(1)))) / mi_SQR(((((msl_c * ((msl_g.g - msl_c)))) + float(1))))))))));
      msl_F.b = ((((((0.5 * mi_SQR(((msl_g.b - msl_c))))) / mi_SQR(((msl_g.b + msl_c))))) * ((float(1) + ((mi_SQR(((((msl_c * ((msl_g.b + msl_c)))) - float(1)))) / mi_SQR(((((msl_c * ((msl_g.b - msl_c)))) + float(1))))))))));
      msl_otherterms = ((msl_G != 0.0) ? ((((msl_D * msl_G)) / ((((3.14159265358979323846 * msl_nv)) * msl_nl)))) : ((msl_D / ((3.14159265358979323846 * msl_nl)))));
      msl_result = ((msl_F * vec4(msl_otherterms)));
   }
   return msl_result;
}


float mi_falloff(
   vec3 msl_direction,
   vec3 msl_normal,
   float msl_amount)
{
   float msl_f;
   float msl_0 = dot(-msl_direction,msl_normal);
   msl_f = ((msl_0 < 0.000000) ? 0.000000 : ((1.000000 < msl_0) ? 1.000000 : msl_0));
   msl_f = ((1.0 - pow(msl_f,1.0 / msl_amount)));
   return msl_f;
}


float mi_orennayar_diffuse(
   vec3 msl_lightDir,
   vec3 msl_eyeDir,
   vec3 msl_n,
   vec3 msl_tangent,
   float msl_diffuse_deviation)
{
   float msl_sigma2 = msl_diffuse_deviation * msl_diffuse_deviation;
   float msl_A = 1.0 - ((msl_sigma2 / ((2.0 * ((msl_sigma2 + 0.33))))));
   float msl_B = ((0.45 * msl_sigma2)) / ((msl_sigma2 + 0.09));
   float msl_cosThetaI = dot(msl_lightDir,msl_n);
   float msl_cosThetaO = -dot(msl_eyeDir,msl_n);
   float msl_sinThetaI = sqrt(max(0.0,1.0 - ((msl_cosThetaI * msl_cosThetaI))));
   float msl_sinThetaO = sqrt(max(0.0,1.0 - ((msl_cosThetaO * msl_cosThetaO))));
   float msl_cosPhiI = dot(msl_lightDir,msl_tangent);
   float msl_cosPhiO = -dot(msl_eyeDir,msl_tangent);
   float msl_sinPhiI = sqrt(max(0.0,1.0 - ((msl_cosPhiI * msl_cosPhiI))));
   float msl_sinPhiO = sqrt(max(0.0,1.0 - ((msl_cosPhiO * msl_cosPhiO))));
   float msl_maxcos = max(0.0,((msl_cosPhiI * msl_cosPhiO)) + ((msl_sinPhiI * msl_sinPhiO)));
   float msl_sinAlpha,msl_tanBeta;
   if (msl_cosThetaI > msl_cosThetaO)
   {
      msl_sinAlpha = msl_sinThetaO;
      msl_tanBeta = ((msl_sinThetaI / msl_cosThetaI));
   }
   else
   {
      msl_sinAlpha = msl_sinThetaI;
      msl_tanBeta = ((msl_sinThetaO / msl_cosThetaO));
   }
   float msl_0 = ((msl_A + ((((((msl_B * msl_maxcos)) * msl_sinAlpha)) * msl_tanBeta)))) / 3.14159265358979323846;
   return (msl_0 < 0.000000) ? 0.000000 : ((1.000000 < msl_0) ? 1.000000 : msl_0);
}


float mi_phong_specular(
   vec3 msl_lightDir,
   vec3 msl_eyeDir,
   vec3 msl_n,
   float msl_specular_shininess)
{
   float msl_0 = 2. * (-dot(msl_eyeDir,msl_n));
   vec3 msl_1 = vec3(msl_0) * msl_n;
   vec3 msl_refl = msl_1 + msl_eyeDir;
   float msl_h = dot(msl_refl,msl_lightDir);
   return ((pow(max(msl_h,0.),msl_specular_shininess) * ((msl_specular_shininess + 2.)))) / ((2.0 * 3.14159265358979323846));
}


float mi_ward_anisglossy(
   vec3 msl_di,
   vec3 msl_dr,
   vec3 msl_n,
   vec3 msl_u,
   vec3 msl_v,
   float msl_shiny_u,
   float msl_shiny_v)
{
   vec3 msl_h;
   float msl_cosr,msl_cosi,msl_shiny_u2,msl_shiny_v2;
   float msl_hn,msl_hu,msl_hv,msl_expo;
   float msl_result = float(0);
   msl_cosr = dot(msl_dr,msl_n);
   msl_cosi = (-dot(msl_di,msl_n));
   if (((msl_cosi * msl_cosr)) >= 0.0001)
   {
      msl_shiny_u2 = ((msl_shiny_u * msl_shiny_u));
      msl_shiny_v2 = ((msl_shiny_v * msl_shiny_v));
      msl_h = ((msl_dr - msl_di));
      msl_h = normalize(msl_h);
      msl_hn = dot(msl_h,msl_n);
      msl_hn *= msl_hn;
      if (msl_hn > 1.0)
      {
         msl_hn = 1.0;
      }
      msl_hu = dot(msl_h,msl_u);
      msl_hu *= msl_hu;
      msl_hv = dot(msl_h,msl_v);
      msl_hv *= msl_hv;
      if (msl_hn >= ((0.0001 * ((((msl_hu * msl_shiny_u2)) + ((msl_hv * msl_shiny_v2)))))))
      {
         msl_expo = (((-((((msl_hu * msl_shiny_u2)) + ((msl_hv * msl_shiny_v2))))) / msl_hn));
         msl_result = ((((((exp(msl_expo) * msl_shiny_u)) * msl_shiny_v)) / ((((sqrt(((msl_cosi * msl_cosr))) * 4.0)) * 3.14159265358979323846))));
      }
   }
   return msl_result;
}


vec4 rgb_to_hsv(
   vec4 msl_rgb)
{
   vec4 msl_result;
   float msl_channelMin,msl_channelMax,msl_delta;
   msl_channelMin = min(msl_rgb.r,min(msl_rgb.g,msl_rgb.b));
   msl_channelMax = max(msl_rgb.r,max(msl_rgb.g,msl_rgb.b));
   msl_result.b = msl_channelMax;
   msl_delta = ((msl_channelMax - msl_channelMin));
   if (msl_channelMax != float(0))
   {
      msl_result.g = ((msl_delta / msl_channelMax));
   }
   else
   {
      msl_result.g = float(0);
      msl_result.r = float((-1));
      return msl_result;
   }
   if (msl_rgb.r == msl_channelMax)
   {
      msl_result.r = ((((msl_rgb.g - msl_rgb.b)) / msl_delta));
   }
   else
   {
      if (msl_rgb.g == msl_channelMax)
      {
         msl_result.r = ((float(2) + ((((msl_rgb.b - msl_rgb.r)) / msl_delta))));
      }
      else
      {
         msl_result.r = ((float(4) + ((((msl_rgb.r - msl_rgb.g)) / msl_delta))));
      }
   }
   msl_result.r *= float(60);
   if (msl_result.r < float(0))
   {
      msl_result.r += float(360);
   }
   return msl_result;
}


vec4 hsv_to_rgb(
   vec4 msl_hsv)
{
   vec4 msl_result;
   int msl_i;
   float msl_f,msl_p,msl_q,msl_t;
   if (msl_hsv.g == float(0))
   {
      float msl_0 = msl_hsv.b;
      msl_result = vec4(msl_0, msl_0, msl_0, msl_0);
      return msl_result;
   }
   msl_hsv.r /= float(60);
   msl_i = (int (floor(msl_hsv.r)));
   msl_f = ((msl_hsv.r - float(msl_i)));
   msl_p = ((msl_hsv.b * ((float(1) - msl_hsv.g))));
   msl_q = ((msl_hsv.b * ((float(1) - ((msl_hsv.g * msl_f))))));
   msl_t = ((msl_hsv.b * ((float(1) - ((msl_hsv.g * ((float(1) - msl_f))))))));
   if((msl_i == 0))
   {
      msl_result.r = msl_hsv.b;
      msl_result.g = msl_t;
      msl_result.b = msl_p;
   }
   else
   if((msl_i == 1))
   {
      msl_result.r = msl_q;
      msl_result.g = msl_hsv.b;
      msl_result.b = msl_p;
   }
   else
   if((msl_i == 2))
   {
      msl_result.r = msl_p;
      msl_result.g = msl_hsv.b;
      msl_result.b = msl_t;
   }
   else
   if((msl_i == 3))
   {
      msl_result.r = msl_p;
      msl_result.g = msl_q;
      msl_result.b = msl_hsv.b;
   }
   else
   if((msl_i == 4))
   {
      msl_result.r = msl_t;
      msl_result.g = msl_p;
      msl_result.b = msl_hsv.b;
   }
   else
   {
      msl_result.r = msl_hsv.b;
      msl_result.g = msl_p;
      msl_result.b = msl_q;
   }

   return msl_result;
}


varying vec3 position;
varying vec3 normal;

//
// The following are free parameters of the shader
// that should be set by the application at runtime.
//
uniform vec4 msl_light0_Light_point_1_color;
uniform float msl_light0_Light_point_1_intensity;
uniform float msl_light0_Light_point_1_distance_falloff_exponent;
uniform float msl_light0_Light_point_1_distance_falloff_start;
uniform float msl_light0_Light_point_1_distance_falloff_limit;
uniform float msl_light0_Light_point_1_distance_scale;
uniform vec3 msl_light0_position;
uniform vec4 msl_Illumination_phong_1_diffuse_color;
uniform float msl_Illumination_phong_1_diffuse_scalar;
uniform vec4 msl_Illumination_phong_1_specular_color;
uniform float msl_Illumination_phong_1_specular_scalar;
uniform float msl_Illumination_phong_1_specular_shininess;

//
// 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.
//
uniform mat4 object_to_camera;
uniform mat4 camera_to_object;
uniform vec4 scene_ambient;

//
// The following functions are generated from the MetaSL implementation of
// the shaders that are part of the compiled shader graph.
//

void Illumination_phong_1_Light_point_main(
   vec4 msl_color,
   float msl_intensity,
   float msl_distance_falloff_exponent,
   float msl_distance_falloff_start,
   float msl_distance_falloff_limit,
   float msl_distance_scale,
   State state,
   out vec4 msl_result,
   out vec4 msl_light_shadow)
{
   {
      float msl_0 = (((state.light_distance) / ((msl_distance_scale - msl_distance_falloff_start)))) / ((msl_distance_falloff_limit - msl_distance_falloff_start));
      float msl_d = (msl_0 < 0.000000) ? 0.000000 : ((1.000000 < msl_0) ? 1.000000 : msl_0);
      float msl_f = 1.0 / ((1.0 + pow(msl_d,msl_distance_falloff_exponent)));
      vec4 msl_1 = msl_color * vec4(msl_intensity);
      msl_result = ((msl_1 * vec4(msl_f)));
      msl_light_shadow = (vec4(1.0));
      msl_result *= vec4(3.14159265358979323846, 3.14159265358979323846, 3.14159265358979323846, 3.14159265358979323846);
   }
}


void Illumination_phong_1_Light_point_1_main(
   vec4 msl_Light_point_1_color,
   float msl_Light_point_1_intensity,
   float msl_Light_point_1_distance_falloff_exponent,
   float msl_Light_point_1_distance_falloff_start,
   float msl_Light_point_1_distance_falloff_limit,
   float msl_Light_point_1_distance_scale,
   vec3 msl_light_position,
   State state,
   out Light_iterator msl_light)
{
   {
      vec4 msl_light_shadow = vec4(0.000000, 0.000000, 0.000000, 0.000000);
      vec4 msl_result = vec4(0.000000, 0.000000, 0.000000, 0.000000);
      msl_light.direction = ((msl_light_position - (state.position)));
      msl_light.distance = length(msl_light.direction);
      float msl_0 = msl_light.distance;
      msl_light.direction /= vec3(msl_0, msl_0, msl_0);
      msl_light.dot_nl = dot(msl_light.direction,state.normal);
      msl_light.contribution = vec4(0.0, 0.0, 0.0, 0.0);
      msl_light.raw_contribution = vec4(0.0, 0.0, 0.0, 0.0);
      msl_light.count = int(0.0);
      msl_light.shadow = vec4(0.0, 0.0, 0.0, 0.0);
      msl_light.point = vec3(0.0, 0.0, 0.0);
      (state.light_to_surface) = (-msl_light.direction);
      (state.light_distance) = msl_light.distance;
      (state.light_dotnl) = msl_light.dot_nl;
      (state.light_position) = msl_light_position;
      Illumination_phong_1_Light_point_main(msl_Light_point_1_color,msl_Light_point_1_intensity,msl_Light_point_1_distance_falloff_exponent,msl_Light_point_1_distance_falloff_start,msl_Light_point_1_distance_falloff_limit,msl_Light_point_1_distance_scale,(state),msl_result,msl_light_shadow);
      msl_light.point = msl_light_position;
      msl_light.shadow = msl_light_shadow;
      msl_light.count = 0;
      msl_light.raw_contribution = msl_result;
      msl_light.contribution = ((msl_result * msl_light_shadow));
   }
}


void Illumination_phong_1_Illumination_phong_main(
   vec4 msl_diffuse_color,
   float msl_diffuse_scalar,
   vec4 msl_specular_color,
   float msl_specular_scalar,
   float msl_specular_shininess,
   State state,
   out vec4 msl_sum,
   out vec4 msl_diffuse,
   out vec4 msl_specular)
{
   {
      msl_diffuse = vec4(0, 0, 0, 0);
      msl_specular = vec4(0, 0, 0, 0);
      vec4 msl_Rd = msl_diffuse_color * vec4(msl_diffuse_scalar);
      vec4 msl_Rs = msl_specular_color * vec4(msl_specular_scalar);
      vec3 msl_vdir = state.direction;
      Light_iterator msl_light;
      {
         {
            Illumination_phong_1_Light_point_1_main(msl_light0_Light_point_1_color,msl_light0_Light_point_1_intensity,msl_light0_Light_point_1_distance_falloff_exponent,msl_light0_Light_point_1_distance_falloff_start,msl_light0_Light_point_1_distance_falloff_limit,msl_light0_Light_point_1_distance_scale,msl_light0_position,(state),msl_light);
            float msl_0 = msl_light.dot_nl;
            float msl_cos = (msl_0 < 0.000000) ? 0.000000 : ((1.000000 < msl_0) ? 1.000000 : msl_0);
            if (msl_cos > 0.0)
            {
               float msl_1 = msl_cos / 3.14159265358979323846;
               vec4 msl_2 = msl_light.contribution;
               msl_diffuse += ((vec4(msl_1) * msl_2));
               float msl_s = mi_phong_specular(msl_light.direction,msl_vdir,(state.normal),msl_specular_shininess);
               float msl_3 = msl_s * msl_cos;
               vec4 msl_4 = msl_light.contribution;
               msl_specular += ((vec4(msl_3) * msl_4));
            }
         }
      }
      msl_diffuse *= msl_Rd;
      msl_specular *= msl_Rs;
            ;
      vec4 msl_5 = scene_ambient;
      msl_diffuse += ((msl_Rd * msl_5));
      msl_diffuse.a = 1.0;
      msl_specular.a = 1.0;
      msl_sum = ((msl_diffuse + msl_specular));
   }
}


//
// The following method is the root function of the shader graph
//
vec4 Illumination_phong_1_eval(State state)
{
   vec4 msl_sum;
   vec4 msl_diffuse;
   vec4 msl_specular;
   Illumination_phong_1_Illumination_phong_main(msl_Illumination_phong_1_diffuse_color,msl_Illumination_phong_1_diffuse_scalar,msl_Illumination_phong_1_specular_color,msl_Illumination_phong_1_specular_scalar,msl_Illumination_phong_1_specular_shininess,(state),msl_sum,msl_diffuse,msl_specular);
   return msl_sum;
}

//
// 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.
//
void main()
{
   State state;
   state.position = position;
   state.normal = normalize(normal);
   state.direction = normalize(state.position);
   state.light_position = vec3(0.0,0.0,0.0);
   state.light_to_surface = vec3(-1.0,0.0,0.0);
   state.light_distance = 0.0;
   state.light_dotnl = 0.0;
   gl_FragColor = Illumination_phong_1_eval(state);
}
