
#ifndef GL3
#define sampleShadow(map,pos) shadow2DProj(map,pos).r
#else
#define sampleShadow(map,pos) textureProj(map,pos)
#endif

#ifdef GL3
#define texture2D texture
#define texture2DProj textureProj
#define texture3D texture
#define textureCube texture
#define texture2DLod textureLod
#define texture2DLodOffset textureLodOffset
#endif

// ==================================== PREPASS ====================================
#if defined(PREPASS)
#if !defined(GLSL)
#define GLSL
#endif
#if defined(DX11)
#undef DX11
#endif

// ------------------- Vertex Shader ---------------

#if defined(DIRLIGHT) && (!defined(GL_ES) || defined(WEBGL))
    #define NUMCASCADES 4
#else
    #define NUMCASCADES 1
#endif

#ifdef COMPILEVS

// Silence GLSL 150 deprecation warnings
#ifdef GL3
#define attribute in
#define varying out
#endif

#if defined(SKINNED)
attribute vec4 iBlendWeights;
attribute vec4 iBlendIndices;
#endif
#if (!defined(SKINNED) && defined(INSTANCED))
attribute vec4 iTexCoord4;
attribute vec4 iTexCoord5;
attribute vec4 iTexCoord6;
#endif
attribute vec4 iPos;
attribute vec3 iNormal;
uniform vec4 cMatSpecColor;
uniform mat4 cModel;
uniform vec4 cSkinMatrices[MAXBONES*3];
uniform mat4 cViewProj;
uniform vec4 cDepthMode;
uniform vec4 cClipPlane;
varying vec3 vVarying1;
varying float vVarying4;
varying float vVarying3;
varying vec3 vVarying2;

attribute float iObjectIndex;


// --- GetNormalMatrix ---

mat3 GetNormalMatrix(mat4 modelMatrix)
{
    return mat3(modelMatrix[0].xyz, modelMatrix[1].xyz, modelMatrix[2].xyz);
}



void VS()
{
#if (!defined(SKINNED) && defined(INSTANCED))
// based on node ifdef(mat4x3) INSTANCED (type:ifdef(mat4x3), id:8)
mat4 ifdef2 = mat4(iTexCoord4, iTexCoord5, iTexCoord6, vec4(0.0, 0.0, 0.0, 1.0));
#endif
#if (!defined(SKINNED) && !defined(INSTANCED))
// based on node ifdef(mat4x3) INSTANCED (type:ifdef(mat4x3), id:8)
mat4 ifdef2 = cModel;
#endif
#if defined(SKINNED)
// based on node ifdef(mat4x3) SKINNED (type:ifdef(mat4x3), id:8)
mat4 ifdef1 = (((mat4(cSkinMatrices[ivec4(iBlendIndices).x*3], cSkinMatrices[ivec4(iBlendIndices).x*3+1],cSkinMatrices[ivec4(iBlendIndices).x*3+2], vec4(0.0, 0.0, 0.0, 1.0)) * iBlendWeights.x) + (mat4(cSkinMatrices[ivec4(iBlendIndices).y*3], cSkinMatrices[ivec4(iBlendIndices).y*3+1],cSkinMatrices[ivec4(iBlendIndices).y*3+2], vec4(0.0, 0.0, 0.0, 1.0)) * iBlendWeights.y)) + ((mat4(cSkinMatrices[ivec4(iBlendIndices).z*3], cSkinMatrices[ivec4(iBlendIndices).z*3+1],cSkinMatrices[ivec4(iBlendIndices).z*3+2], vec4(0.0, 0.0, 0.0, 1.0)) * iBlendWeights.z) + (mat4(cSkinMatrices[ivec4(iBlendIndices).w*3], cSkinMatrices[ivec4(iBlendIndices).w*3+1],cSkinMatrices[ivec4(iBlendIndices).w*3+2], vec4(0.0, 0.0, 0.0, 1.0)) * iBlendWeights.w)));
#endif
#if !defined(SKINNED)
// based on node ifdef(mat4x3) SKINNED (type:ifdef(mat4x3), id:8)
mat4 ifdef1 = ifdef2;
#endif
// based on node ifdef(mat4x3)  (type:ifdef(mat4x3), id:8)
mat4 var1 = ifdef1;
// based on node vec4*mat4x3  (type:vec4*mat4x3, id:8)
vec3 var0 = ((iPos * var1)).xyz;
vVarying1 = (vec3(0, 6, 0) - var0);
// based on node vec4*mat4  (type:vec4*mat4, id:13)
vec4 var8 = (vec4(var0, 1) * cViewProj);
vVarying4 = dot(var8.zw, cDepthMode.zw);
vVarying3 = (cMatSpecColor.w / 255.0);
vVarying2 = (iNormal * GetNormalMatrix(var1));
vec4 ret =  var8;


    // While getting the clip coordinate, also automatically set gl_ClipVertex for user clip planes
    #if !defined(GL_ES) && !defined(GL3)
       gl_ClipVertex = ret;
    #elif defined(GL3)
       gl_ClipDistance[0] = dot(cClipPlane, ret);
    #endif
    gl_Position = ret;
}

#else
// ------------------- Pixel Shader ---------------

varying float vVarying4;
varying float vVarying3;
varying vec3 vVarying2;
varying vec3 vVarying1;



void PS()
{
// based on node float  (type:default, id:0)
float var3 = (0.0);
if (bool(int(clamp(sign(vVarying1.y), var3, 1)))) discard;
// based on node per pixel float  (type:perPixelFloat, id:13)
float var2 = vVarying4;
#if !defined(GL3)
// based on node float*float  (type:float*float, id:13)
float var4 = (var2 * 255.0);
// based on node floor(float)  (type:floor(float), id:13)
float var5 = floor(var4);
// based on node float*float  (type:float*float, id:13)
float var6 = ((var4 - var5) * 255.0);
// based on node floor(float)  (type:floor(float), id:13)
float var7 = floor(var6);
#endif
#if defined(GL3)
// based on node ifdef(vec3) GL3 (type:ifdef(vec3), id:13)
vec3 ifdef1 = vec3(var2, var3, var3);
#endif
#if !defined(GL3)
// based on node ifdef(vec3) GL3 (type:ifdef(vec3), id:13)
vec3 ifdef1 = vec3((var5 * 0.0039215686274509803921568627451), (var7 * 0.0039215686274509803921568627451), (var6 - var7));
#endif
gl_FragData[1] = vec4(ifdef1, var3);
gl_FragData[0] = vec4(((normalize(vVarying2) * 0.5) + vec3(0.5, 0.5, 0.5)), vVarying3);

}
#endif
// ==================================== DEFERREDPASS ====================================
#elif defined(DEFERREDPASS)
#if !defined(GLSL)
#define GLSL
#endif
#if defined(DX11)
#undef DX11
#endif

// ------------------- Vertex Shader ---------------

#if defined(DIRLIGHT) && (!defined(GL_ES) || defined(WEBGL))
    #define NUMCASCADES 4
#else
    #define NUMCASCADES 1
#endif

#ifdef COMPILEVS

// Silence GLSL 150 deprecation warnings
#ifdef GL3
#define attribute in
#define varying out
#endif

#if defined(SKINNED)
attribute vec4 iBlendWeights;
attribute vec4 iBlendIndices;
#endif
#if (!defined(SKINNED) && defined(INSTANCED))
attribute vec4 iTexCoord4;
attribute vec4 iTexCoord5;
attribute vec4 iTexCoord6;
#endif
attribute vec4 iPos;
attribute vec3 iNormal;
uniform vec4 cMatDiffColor;
uniform vec4 cMatSpecColor;
uniform mat4 cModel;
uniform vec4 cAmbientColor;
uniform vec3 cCameraPos;
uniform vec4 cSkinMatrices[MAXBONES*3];
uniform mat4 cViewProj;
uniform vec4 cDepthMode;
uniform vec4 cClipPlane;
varying vec3 vVarying1;
varying float vVarying5;
varying vec3 vVarying4;
varying vec3 vVarying3;
varying vec3 vVarying2;
varying float vVarying8;
varying float vVarying7;
varying vec4 vVarying6;

attribute float iObjectIndex;


// --- GetNormalMatrix ---

mat3 GetNormalMatrix(mat4 modelMatrix)
{
    return mat3(modelMatrix[0].xyz, modelMatrix[1].xyz, modelMatrix[2].xyz);
}



void VS()
{
#if (!defined(SKINNED) && defined(INSTANCED))
// based on node ifdef(mat4x3) INSTANCED (type:ifdef(mat4x3), id:8)
mat4 ifdef2 = mat4(iTexCoord4, iTexCoord5, iTexCoord6, vec4(0.0, 0.0, 0.0, 1.0));
#endif
#if (!defined(SKINNED) && !defined(INSTANCED))
// based on node ifdef(mat4x3) INSTANCED (type:ifdef(mat4x3), id:8)
mat4 ifdef2 = cModel;
#endif
#if defined(SKINNED)
// based on node ifdef(mat4x3) SKINNED (type:ifdef(mat4x3), id:8)
mat4 ifdef1 = (((mat4(cSkinMatrices[ivec4(iBlendIndices).x*3], cSkinMatrices[ivec4(iBlendIndices).x*3+1],cSkinMatrices[ivec4(iBlendIndices).x*3+2], vec4(0.0, 0.0, 0.0, 1.0)) * iBlendWeights.x) + (mat4(cSkinMatrices[ivec4(iBlendIndices).y*3], cSkinMatrices[ivec4(iBlendIndices).y*3+1],cSkinMatrices[ivec4(iBlendIndices).y*3+2], vec4(0.0, 0.0, 0.0, 1.0)) * iBlendWeights.y)) + ((mat4(cSkinMatrices[ivec4(iBlendIndices).z*3], cSkinMatrices[ivec4(iBlendIndices).z*3+1],cSkinMatrices[ivec4(iBlendIndices).z*3+2], vec4(0.0, 0.0, 0.0, 1.0)) * iBlendWeights.z) + (mat4(cSkinMatrices[ivec4(iBlendIndices).w*3], cSkinMatrices[ivec4(iBlendIndices).w*3+1],cSkinMatrices[ivec4(iBlendIndices).w*3+2], vec4(0.0, 0.0, 0.0, 1.0)) * iBlendWeights.w)));
#endif
#if !defined(SKINNED)
// based on node ifdef(mat4x3) SKINNED (type:ifdef(mat4x3), id:8)
mat4 ifdef1 = ifdef2;
#endif
// based on node ifdef(mat4x3)  (type:ifdef(mat4x3), id:8)
mat4 var4 = ifdef1;
// based on node vec4*mat4x3  (type:vec4*mat4x3, id:8)
vec3 var1 = ((iPos * var4)).xyz;
vVarying1 = (vec3(0, 6, 0) - var1);
// based on node break vec4 to vec3, float  (type:breakVec4toVec3Float, id:13)
float var13 = cMatSpecColor.w;
vVarying5 = (var13 / 255.0);
vVarying4 = (var1 - cCameraPos);
// based on node MatDiffColor  (type:parameter(color), id:2)
vec4 var0 = cMatDiffColor;
// based on node vec4*vec4  (type:vec4*vec4, id:13)
vec4 var3 = (var0 * vec4(1.000, 0.998, 1.000, 1.000));
vVarying3 = (cAmbientColor.xyz * var3.xyz);
// based on node vec3*mat3  (type:vec3*mat3, id:9)
vec3 var2 = (iNormal * GetNormalMatrix(var4));
vVarying2 = var2;
vVarying8 = var3.w;
// based on node vec4*mat4  (type:vec4*mat4, id:13)
vec4 var11 = (vec4(var1, 1) * cViewProj);
vVarying7 = dot(var11.zw, cDepthMode.zw);
vVarying6 = vec4(var0.xyz, var13);
vec4 ret =  var11;


    // While getting the clip coordinate, also automatically set gl_ClipVertex for user clip planes
    #if !defined(GL_ES) && !defined(GL3)
       gl_ClipVertex = ret;
    #elif defined(GL3)
       gl_ClipDistance[0] = dot(cClipPlane, ret);
    #endif
    gl_Position = ret;
}

#else
// ------------------- Pixel Shader ---------------

uniform vec4 cMatEmissiveColor;
uniform vec4 cMatEnvMapColor;
uniform samplerCube sZoneCubeMap;
varying float vVarying5;
varying vec3 vVarying4;
varying float vVarying8;
varying vec3 vVarying3;
varying vec3 vVarying2;
varying vec3 vVarying1;
varying float vVarying7;
varying vec4 vVarying6;



void PS()
{
// based on node float  (type:default, id:0)
float var6 = (0.0);
if (bool(int(clamp(sign(vVarying1.y), var6, 1)))) discard;
// based on node get Varying2  (type:getVarying, id:0)
vec3 var12 = vVarying2;
gl_FragData[0] = vec4(vec4((vVarying3 + ((cMatEnvMapColor * textureCube(sZoneCubeMap, reflect(vVarying4, var12))) + cMatEmissiveColor).xyz), vVarying8).xyz, 1.0);
gl_FragData[1] = vVarying6;
gl_FragData[2] = vec4(((normalize(var12) * 0.5) + vec3(0.5, 0.5, 0.5)), vVarying5);
// based on node per pixel float  (type:perPixelFloat, id:13)
float var5 = vVarying7;
#if !defined(GL3)
// based on node float*float  (type:float*float, id:13)
float var7 = (var5 * 255.0);
// based on node floor(float)  (type:floor(float), id:13)
float var8 = floor(var7);
// based on node float*float  (type:float*float, id:13)
float var9 = ((var7 - var8) * 255.0);
// based on node floor(float)  (type:floor(float), id:13)
float var10 = floor(var9);
#endif
#if defined(GL3)
// based on node ifdef(vec3) GL3 (type:ifdef(vec3), id:13)
vec3 ifdef1 = vec3(var5, var6, var6);
#endif
#if !defined(GL3)
// based on node ifdef(vec3) GL3 (type:ifdef(vec3), id:13)
vec3 ifdef1 = vec3((var8 * 0.0039215686274509803921568627451), (var10 * 0.0039215686274509803921568627451), (var9 - var10));
#endif
gl_FragData[3] = vec4(ifdef1, var6);

}
#endif
// ==================================== SHADOWPASS ====================================
#elif defined(SHADOWPASS)
#if !defined(GLSL)
#define GLSL
#endif
#if defined(DX11)
#undef DX11
#endif

// ------------------- Vertex Shader ---------------

#if defined(DIRLIGHT) && (!defined(GL_ES) || defined(WEBGL))
    #define NUMCASCADES 4
#else
    #define NUMCASCADES 1
#endif

#ifdef COMPILEVS

// Silence GLSL 150 deprecation warnings
#ifdef GL3
#define attribute in
#define varying out
#endif

#if defined(SKINNED)
attribute vec4 iBlendWeights;
attribute vec4 iBlendIndices;
#endif
#if (!defined(SKINNED) && defined(INSTANCED))
attribute vec4 iTexCoord4;
attribute vec4 iTexCoord5;
attribute vec4 iTexCoord6;
#endif
attribute vec4 iPos;
uniform mat4 cModel;
uniform vec4 cSkinMatrices[MAXBONES*3];
uniform mat4 cViewProj;
uniform vec4 cClipPlane;
varying vec3 vVarying1;
varying vec2 vVarying2;

attribute float iObjectIndex;




void VS()
{
#if (!defined(SKINNED) && defined(INSTANCED))
// based on node ifdef(mat4x3) INSTANCED (type:ifdef(mat4x3), id:8)
mat4 ifdef2 = mat4(iTexCoord4, iTexCoord5, iTexCoord6, vec4(0.0, 0.0, 0.0, 1.0));
#endif
#if (!defined(SKINNED) && !defined(INSTANCED))
// based on node ifdef(mat4x3) INSTANCED (type:ifdef(mat4x3), id:8)
mat4 ifdef2 = cModel;
#endif
#if defined(SKINNED)
// based on node ifdef(mat4x3) SKINNED (type:ifdef(mat4x3), id:8)
mat4 ifdef1 = (((mat4(cSkinMatrices[ivec4(iBlendIndices).x*3], cSkinMatrices[ivec4(iBlendIndices).x*3+1],cSkinMatrices[ivec4(iBlendIndices).x*3+2], vec4(0.0, 0.0, 0.0, 1.0)) * iBlendWeights.x) + (mat4(cSkinMatrices[ivec4(iBlendIndices).y*3], cSkinMatrices[ivec4(iBlendIndices).y*3+1],cSkinMatrices[ivec4(iBlendIndices).y*3+2], vec4(0.0, 0.0, 0.0, 1.0)) * iBlendWeights.y)) + ((mat4(cSkinMatrices[ivec4(iBlendIndices).z*3], cSkinMatrices[ivec4(iBlendIndices).z*3+1],cSkinMatrices[ivec4(iBlendIndices).z*3+2], vec4(0.0, 0.0, 0.0, 1.0)) * iBlendWeights.z) + (mat4(cSkinMatrices[ivec4(iBlendIndices).w*3], cSkinMatrices[ivec4(iBlendIndices).w*3+1],cSkinMatrices[ivec4(iBlendIndices).w*3+2], vec4(0.0, 0.0, 0.0, 1.0)) * iBlendWeights.w)));
#endif
#if !defined(SKINNED)
// based on node ifdef(mat4x3) SKINNED (type:ifdef(mat4x3), id:8)
mat4 ifdef1 = ifdef2;
#endif
// based on node vec4*mat4x3  (type:vec4*mat4x3, id:8)
vec3 var0 = ((iPos * ifdef1)).xyz;
vVarying1 = (vec3(0, 6, 0) - var0);
// based on node vec4*mat4  (type:vec4*mat4, id:13)
vec4 var1 = (vec4(var0, 1) * cViewProj);
vVarying2 = var1.zw;
vec4 ret =  var1;


    // While getting the clip coordinate, also automatically set gl_ClipVertex for user clip planes
    #if !defined(GL_ES) && !defined(GL3)
       gl_ClipVertex = ret;
    #elif defined(GL3)
       gl_ClipDistance[0] = dot(cClipPlane, ret);
    #endif
    gl_Position = ret;
}

#else
// ------------------- Pixel Shader ---------------

varying vec2 vVarying2;
varying vec3 vVarying1;



void PS()
{
if (bool(int(clamp(sign(vVarying1.y), (0.0), 1)))) discard;
    #ifdef VSM_SHADOW
        float depth = vVarying2.x / vVarying2.y * 0.5 + 0.5;
        gl_FragColor = vec4(depth, depth * depth, 1.0, 1.0);
    #else
        gl_FragColor = vec4(1.0);
    #endif

}
#endif
// ==================================== LIGHTBASEPASS ====================================
#elif defined(LIGHTBASEPASS)
#if !defined(GLSL)
#define GLSL
#endif
#if defined(DX11)
#undef DX11
#endif

// ------------------- Vertex Shader ---------------

#if defined(DIRLIGHT) && (!defined(GL_ES) || defined(WEBGL))
    #define NUMCASCADES 4
#else
    #define NUMCASCADES 1
#endif

#ifdef COMPILEVS

// Silence GLSL 150 deprecation warnings
#ifdef GL3
#define attribute in
#define varying out
#endif

#if defined(SKINNED)
attribute vec4 iBlendWeights;
attribute vec4 iBlendIndices;
#endif
#if (!defined(SKINNED) && defined(INSTANCED))
attribute vec4 iTexCoord4;
attribute vec4 iTexCoord5;
attribute vec4 iTexCoord6;
#endif
attribute vec4 iPos;
attribute vec3 iNormal;
uniform vec4 cMatDiffColor;
uniform vec4 cMatSpecColor;
uniform mat4 cModel;
uniform vec4 cLightColor;
uniform vec4 cAmbientColor;
uniform vec3 cCameraPos;
uniform vec4 cSkinMatrices[MAXBONES*3];
uniform vec3 cCameraPosPS;
uniform mat4 cViewProj;
uniform vec4 cDepthMode;
uniform vec4 cLightOffsetScale;
uniform mat4 cLightMatrices[4];
uniform vec4 cShadowSplits;
uniform vec4 cNormalOffsetScale;
uniform vec4 cShadowDepthFade;
uniform vec4 cLightPos;
uniform vec3 cLightDir;
uniform vec2 cVSMShadowParams;
uniform vec4 cClipPlane;
varying float vVarying5;
varying vec3 vVarying1;
varying vec3 vVarying3;
varying vec3 vVarying2;
varying float vVarying9;
varying vec3 vVarying4;
varying float vVarying20;
varying float vVarying19;
varying vec4 vVarying18;
varying float vVarying17;
varying vec4 vVarying14;
varying float vVarying23;
varying float vVarying24;
varying vec4 vVarying13;
varying float vVarying25;
varying float vVarying27;
varying float vVarying21;
varying vec3 vVarying7;
varying vec3 vVarying11;
varying vec4 vVarying15;
varying float vVarying22;
varying float vVarying12;
varying vec4 vVarying16;
varying float vVarying8;
varying vec3 vVarying6;
varying vec3 vVarying10;
varying float vVarying26;

attribute float iObjectIndex;


// --- GetNormalMatrix ---

mat3 GetNormalMatrix(mat4 modelMatrix)
{
    return mat3(modelMatrix[0].xyz, modelMatrix[1].xyz, modelMatrix[2].xyz);
}



void VS()
{
vVarying5 = cLightColor.w;
#if (!defined(SKINNED) && defined(INSTANCED))
// based on node ifdef(mat4x3) INSTANCED (type:ifdef(mat4x3), id:8)
mat4 ifdef2 = mat4(iTexCoord4, iTexCoord5, iTexCoord6, vec4(0.0, 0.0, 0.0, 1.0));
#endif
#if (!defined(SKINNED) && !defined(INSTANCED))
// based on node ifdef(mat4x3) INSTANCED (type:ifdef(mat4x3), id:8)
mat4 ifdef2 = cModel;
#endif
#if defined(SKINNED)
// based on node ifdef(mat4x3) SKINNED (type:ifdef(mat4x3), id:8)
mat4 ifdef1 = (((mat4(cSkinMatrices[ivec4(iBlendIndices).x*3], cSkinMatrices[ivec4(iBlendIndices).x*3+1],cSkinMatrices[ivec4(iBlendIndices).x*3+2], vec4(0.0, 0.0, 0.0, 1.0)) * iBlendWeights.x) + (mat4(cSkinMatrices[ivec4(iBlendIndices).y*3], cSkinMatrices[ivec4(iBlendIndices).y*3+1],cSkinMatrices[ivec4(iBlendIndices).y*3+2], vec4(0.0, 0.0, 0.0, 1.0)) * iBlendWeights.y)) + ((mat4(cSkinMatrices[ivec4(iBlendIndices).z*3], cSkinMatrices[ivec4(iBlendIndices).z*3+1],cSkinMatrices[ivec4(iBlendIndices).z*3+2], vec4(0.0, 0.0, 0.0, 1.0)) * iBlendWeights.z) + (mat4(cSkinMatrices[ivec4(iBlendIndices).w*3], cSkinMatrices[ivec4(iBlendIndices).w*3+1],cSkinMatrices[ivec4(iBlendIndices).w*3+2], vec4(0.0, 0.0, 0.0, 1.0)) * iBlendWeights.w)));
#endif
#if !defined(SKINNED)
// based on node ifdef(mat4x3) SKINNED (type:ifdef(mat4x3), id:8)
mat4 ifdef1 = ifdef2;
#endif
// based on node ifdef(mat4x3)  (type:ifdef(mat4x3), id:8)
mat4 var5 = ifdef1;
// based on node vec4*mat4x3  (type:vec4*mat4x3, id:8)
vec3 var1 = ((iPos * var5)).xyz;
vVarying1 = (vec3(0, 6, 0) - var1);
vVarying3 = var1;
// based on node MatSpecColor  (type:parameter(color), id:3)
vec4 var0 = cMatSpecColor;
vVarying2 = var0.xyz;
vVarying9 = cShadowSplits.x;
// based on node vec3*mat3  (type:vec3*mat3, id:9)
vec3 var2 = (iNormal * GetNormalMatrix(var5));
vVarying4 = var2;
// based on node break vec2  (type:breakVec2, id:13)
float var89 = cVSMShadowParams.y;
// based on node float-float  (type:float-float, id:13)
float var75 = (1.0 - var89);
vVarying20 = var75;
// based on node break vec2  (type:breakVec2, id:13)
float var64 = cVSMShadowParams.x;
vVarying19 = var64;
// based on node vec4(vec3,float)  (type:makeVec4fromVec3Float, id:13)
vec4 var14 = vec4(var1, 1.0);
#if ((defined(SPOTLIGHT) && defined(NORMALOFFSET)) || (!defined(SPOTLIGHT) && (defined(NORMALOFFSET) || (!defined(NORMALOFFSET) && !defined(DIRLIGHT)))))
// based on node break vec4 to vec3, float  (type:breakVec4toVec3Float, id:13)
vec3 var23 = var14.xyz;
#endif
#if ((defined(SPOTLIGHT) && (defined(NORMALOFFSET) && !defined(DIRLIGHT))) || (!defined(SPOTLIGHT) && ((defined(NORMALOFFSET) && !defined(DIRLIGHT)) || (!defined(NORMALOFFSET) && !defined(DIRLIGHT)))))
// based on node break vec4 to vec3, float  (type:breakVec4toVec3Float, id:13)
vec3 var28 = cLightPos.xyz;
#endif
#if ((defined(SPOTLIGHT) && (defined(NORMALOFFSET) && defined(DIRLIGHT))) || (!defined(SPOTLIGHT) && (defined(NORMALOFFSET) && defined(DIRLIGHT))))
// based on node ifdef(vec3) DIRLIGHT (type:ifdef(vec3), id:13)
vec3 ifdef5 = cLightDir;
#endif
#if (defined(SPOTLIGHT) && (defined(NORMALOFFSET) && !defined(DIRLIGHT)))
// based on node ifdef(vec3) DIRLIGHT (type:ifdef(vec3), id:13)
vec3 ifdef5 = normalize((var28 - var23));
#endif
#if ((defined(SPOTLIGHT) && defined(NORMALOFFSET)) || (!defined(SPOTLIGHT) && (defined(NORMALOFFSET) && defined(DIRLIGHT))))
// based on node clamp(float,float,float)  (type:clamp(float,float,float), id:13)
float var59 = clamp((1.0 - dot(var2, ifdef5)), (0.0), 1.0);
// based on node break vec4 to vec3, float  (type:breakVec4toVec3Float, id:13)
float var88 = var14.w;
// based on node ifdef(vec4) NORMALOFFSET (type:ifdef(vec4), id:13)
vec4 ifdef4 = vec4((var23 + (var2 * (var59 * cNormalOffsetScale.x))), var88);
#endif
#if ((defined(SPOTLIGHT) && !defined(NORMALOFFSET)) || (!defined(SPOTLIGHT) && (!defined(NORMALOFFSET) && defined(DIRLIGHT))))
// based on node ifdef(vec4) NORMALOFFSET (type:ifdef(vec4), id:13)
vec4 ifdef4 = var14;
#endif
#if (defined(SPOTLIGHT) || (!defined(SPOTLIGHT) && defined(DIRLIGHT)))
// based on node ifdef(vec4)  (type:ifdef(vec4), id:13)
vec4 var70 = ifdef4;
// based on node lightMatrices[int]  (type:lightMatrices[int], id:13)
mat4 var18 = cLightMatrices[1];
// based on node vec4*mat4  (type:vec4*mat4, id:13)
vec4 var49 = (var70 * var18);
#endif
#if (!defined(SPOTLIGHT) && !defined(DIRLIGHT))
// based on node vec4(vec3,float)  (type:makeVec4fromVec3Float, id:13)
vec4 var27 = vec4((var23 - var28), 1.0);
#endif
#if (defined(SPOTLIGHT) && !defined(DIRLIGHT))
// based on node ifdef(vec4) SPOTLIGHT (type:ifdef(vec4), id:13)
vec4 ifdef6 = var49;
#endif
#if (!defined(SPOTLIGHT) && !defined(DIRLIGHT))
// based on node ifdef(vec4) SPOTLIGHT (type:ifdef(vec4), id:13)
vec4 ifdef6 = var27;
#endif
#if defined(DIRLIGHT)
// based on node ifdef(vec4) DIRLIGHT (type:ifdef(vec4), id:13)
vec4 ifdef3 = var49;
#endif
#if !defined(DIRLIGHT)
// based on node ifdef(vec4) DIRLIGHT (type:ifdef(vec4), id:13)
vec4 ifdef3 = ifdef6;
#endif
vVarying18 = ifdef3;
vVarying17 = cShadowDepthFade.z;
#if ((defined(SPOTLIGHT) && defined(NORMALOFFSET)) || (!defined(SPOTLIGHT) && (defined(NORMALOFFSET) && defined(DIRLIGHT))))
// based on node ifdef(vec4) NORMALOFFSET (type:ifdef(vec4), id:13)
vec4 ifdef8 = vec4((var23 + (var2 * (var59 * cLightOffsetScale.y))), var88);
#endif
#if ((defined(SPOTLIGHT) && !defined(NORMALOFFSET)) || (!defined(SPOTLIGHT) && (!defined(NORMALOFFSET) && defined(DIRLIGHT))))
// based on node ifdef(vec4) NORMALOFFSET (type:ifdef(vec4), id:13)
vec4 ifdef8 = var14;
#endif
#if (defined(SPOTLIGHT) || (!defined(SPOTLIGHT) && defined(DIRLIGHT)))
// based on node vec4*mat4  (type:vec4*mat4, id:13)
vec4 var29 = (ifdef8 * var18);
#endif
#if (defined(SPOTLIGHT) && !defined(DIRLIGHT))
// based on node ifdef(vec4) SPOTLIGHT (type:ifdef(vec4), id:13)
vec4 ifdef9 = var29;
#endif
#if (!defined(SPOTLIGHT) && !defined(DIRLIGHT))
// based on node ifdef(vec4) SPOTLIGHT (type:ifdef(vec4), id:13)
vec4 ifdef9 = var27;
#endif
#if defined(DIRLIGHT)
// based on node ifdef(vec4) DIRLIGHT (type:ifdef(vec4), id:13)
vec4 ifdef7 = var29;
#endif
#if !defined(DIRLIGHT)
// based on node ifdef(vec4) DIRLIGHT (type:ifdef(vec4), id:13)
vec4 ifdef7 = ifdef9;
#endif
vVarying14 = ifdef7;
vVarying23 = cShadowSplits.y;
vVarying24 = cShadowSplits.z;
#if ((defined(SPOTLIGHT) && defined(NORMALOFFSET)) || (!defined(SPOTLIGHT) && (defined(NORMALOFFSET) && defined(DIRLIGHT))))
// based on node ifdef(vec4) NORMALOFFSET (type:ifdef(vec4), id:13)
vec4 ifdef11 = vec4((var23 + (var2 * (var59 * cLightOffsetScale.x))), var88);
#endif
#if ((defined(SPOTLIGHT) && !defined(NORMALOFFSET)) || (!defined(SPOTLIGHT) && (!defined(NORMALOFFSET) && defined(DIRLIGHT))))
// based on node ifdef(vec4) NORMALOFFSET (type:ifdef(vec4), id:13)
vec4 ifdef11 = var14;
#endif
#if (defined(SPOTLIGHT) || (!defined(SPOTLIGHT) && defined(DIRLIGHT)))
// based on node vec4*mat4  (type:vec4*mat4, id:13)
vec4 var26 = (ifdef11 * cLightMatrices[(0)]);
#endif
#if (defined(SPOTLIGHT) && !defined(DIRLIGHT))
// based on node ifdef(vec4) SPOTLIGHT (type:ifdef(vec4), id:13)
vec4 ifdef12 = var26;
#endif
#if (!defined(SPOTLIGHT) && !defined(DIRLIGHT))
// based on node ifdef(vec4) SPOTLIGHT (type:ifdef(vec4), id:13)
vec4 ifdef12 = var27;
#endif
#if defined(DIRLIGHT)
// based on node ifdef(vec4) DIRLIGHT (type:ifdef(vec4), id:13)
vec4 ifdef10 = var26;
#endif
#if !defined(DIRLIGHT)
// based on node ifdef(vec4) DIRLIGHT (type:ifdef(vec4), id:13)
vec4 ifdef10 = ifdef12;
#endif
// based on node ifdef(vec4)  (type:ifdef(vec4), id:13)
vec4 var25 = ifdef10;
vVarying13 = var25;
vVarying25 = cShadowDepthFade.y;
vVarying27 = var89;
vVarying21 = var0.w;
vVarying7 = (var1 - cCameraPos);
#if (defined(SPOTLIGHT) || (!defined(SPOTLIGHT) && defined(DIRLIGHT)))
// based on node vec4*mat4  (type:vec4*mat4, id:13)
vec4 var50 = (var70 * cLightMatrices[0]);
#endif
#if (defined(SPOTLIGHT) && !defined(DIRLIGHT))
// based on node ifdef(vec4) SPOTLIGHT (type:ifdef(vec4), id:13)
vec4 ifdef14 = var50;
#endif
#if (!defined(SPOTLIGHT) && !defined(DIRLIGHT))
// based on node ifdef(vec4) SPOTLIGHT (type:ifdef(vec4), id:13)
vec4 ifdef14 = var27;
#endif
#if defined(DIRLIGHT)
// based on node ifdef(vec4) DIRLIGHT (type:ifdef(vec4), id:13)
vec4 ifdef13 = var50;
#endif
#if !defined(DIRLIGHT)
// based on node ifdef(vec4) DIRLIGHT (type:ifdef(vec4), id:13)
vec4 ifdef13 = ifdef14;
#endif
// based on node break vec4 to vec3, float  (type:breakVec4toVec3Float, id:13)
vec3 var20 = ifdef13.xyz;
vVarying11 = var20;
#if ((defined(SPOTLIGHT) && defined(NORMALOFFSET)) || (!defined(SPOTLIGHT) && (defined(NORMALOFFSET) && defined(DIRLIGHT))))
// based on node ifdef(vec4) NORMALOFFSET (type:ifdef(vec4), id:13)
vec4 ifdef16 = vec4((var23 + (var2 * (var59 * cLightOffsetScale.z))), var88);
#endif
#if ((defined(SPOTLIGHT) && !defined(NORMALOFFSET)) || (!defined(SPOTLIGHT) && (!defined(NORMALOFFSET) && defined(DIRLIGHT))))
// based on node ifdef(vec4) NORMALOFFSET (type:ifdef(vec4), id:13)
vec4 ifdef16 = var14;
#endif
#if (defined(SPOTLIGHT) || (!defined(SPOTLIGHT) && defined(DIRLIGHT)))
// based on node vec4*mat4  (type:vec4*mat4, id:13)
vec4 var30 = (ifdef16 * cLightMatrices[2]);
#endif
#if (defined(SPOTLIGHT) && !defined(DIRLIGHT))
// based on node ifdef(vec4) SPOTLIGHT (type:ifdef(vec4), id:13)
vec4 ifdef17 = var30;
#endif
#if (!defined(SPOTLIGHT) && !defined(DIRLIGHT))
// based on node ifdef(vec4) SPOTLIGHT (type:ifdef(vec4), id:13)
vec4 ifdef17 = var27;
#endif
#if defined(DIRLIGHT)
// based on node ifdef(vec4) DIRLIGHT (type:ifdef(vec4), id:13)
vec4 ifdef15 = var30;
#endif
#if !defined(DIRLIGHT)
// based on node ifdef(vec4) DIRLIGHT (type:ifdef(vec4), id:13)
vec4 ifdef15 = ifdef17;
#endif
vVarying15 = ifdef15;
// based on node vec4*vec4  (type:vec4*vec4, id:13)
vec4 var3 = (cMatDiffColor * vec4(1.000, 0.998, 1.000, 1.000));
vVarying22 = var3.w;
vVarying12 = cShadowDepthFade.x;
#if ((defined(SPOTLIGHT) && defined(NORMALOFFSET)) || (!defined(SPOTLIGHT) && (defined(NORMALOFFSET) && defined(DIRLIGHT))))
// based on node ifdef(vec4) NORMALOFFSET (type:ifdef(vec4), id:13)
vec4 ifdef19 = vec4((var23 + (var2 * (var59 * cLightOffsetScale.w))), var88);
#endif
#if ((defined(SPOTLIGHT) && !defined(NORMALOFFSET)) || (!defined(SPOTLIGHT) && (!defined(NORMALOFFSET) && defined(DIRLIGHT))))
// based on node ifdef(vec4) NORMALOFFSET (type:ifdef(vec4), id:13)
vec4 ifdef19 = var14;
#endif
#if (defined(SPOTLIGHT) || (!defined(SPOTLIGHT) && defined(DIRLIGHT)))
// based on node vec4*mat4  (type:vec4*mat4, id:13)
vec4 var31 = (ifdef19 * cLightMatrices[3]);
#endif
#if (defined(SPOTLIGHT) && !defined(DIRLIGHT))
// based on node ifdef(vec4) SPOTLIGHT (type:ifdef(vec4), id:13)
vec4 ifdef20 = var31;
#endif
#if (!defined(SPOTLIGHT) && !defined(DIRLIGHT))
// based on node ifdef(vec4) SPOTLIGHT (type:ifdef(vec4), id:13)
vec4 ifdef20 = var27;
#endif
#if defined(DIRLIGHT)
// based on node ifdef(vec4) DIRLIGHT (type:ifdef(vec4), id:13)
vec4 ifdef18 = var31;
#endif
#if !defined(DIRLIGHT)
// based on node ifdef(vec4) DIRLIGHT (type:ifdef(vec4), id:13)
vec4 ifdef18 = ifdef20;
#endif
vVarying16 = ifdef18;
// based on node vec4*mat4  (type:vec4*mat4, id:13)
vec4 var15 = (vec4(var1, 1) * cViewProj);
vVarying8 = dot(var15.zw, cDepthMode.zw);
vVarying6 = (cAmbientColor.xyz * var3.xyz);
vVarying10 = normalize((cCameraPosPS - var1));
vVarying26 = cShadowDepthFade.w;
vec4 ret =  var15;


    // While getting the clip coordinate, also automatically set gl_ClipVertex for user clip planes
    #if !defined(GL_ES) && !defined(GL3)
       gl_ClipVertex = ret;
    #elif defined(GL3)
       gl_ClipDistance[0] = dot(cClipPlane, ret);
    #endif
    gl_Position = ret;
}

#else
// ------------------- Pixel Shader ---------------

uniform vec4 cMatEmissiveColor;
uniform vec4 cMatEnvMapColor;
uniform vec3 cLightDirPS;
uniform vec4 cLightPosPS;
uniform vec4 cShadowCubeAdjust;
uniform vec2 cShadowIntensity;
uniform vec2 cShadowMapInvSize;
uniform vec4 cMatDiffColor;
uniform samplerCube sZoneCubeMap;
#if ((defined(TRANSLUCENT) && !defined(DIRLIGHT)) || (!defined(TRANSLUCENT) && !defined(DIRLIGHT)))
uniform sampler2D sLightRampMap;
#endif
#if ((defined(VSM_SHADOW) && (!defined(SPOTLIGHT) && ((defined(SIMPLE_SHADOW) && ((defined(POINTLIGHT) && ((defined(PCF_SHADOW) && !defined(DIRLIGHT)) || (!defined(PCF_SHADOW) && !defined(DIRLIGHT)))) || (!defined(POINTLIGHT) && ((defined(PCF_SHADOW) && !defined(DIRLIGHT)) || (!defined(PCF_SHADOW) && !defined(DIRLIGHT)))))) || (!defined(SIMPLE_SHADOW) && ((defined(POINTLIGHT) && ((defined(PCF_SHADOW) && !defined(DIRLIGHT)) || (!defined(PCF_SHADOW) && !defined(DIRLIGHT)))) || (!defined(POINTLIGHT) && ((defined(PCF_SHADOW) && !defined(DIRLIGHT)) || (!defined(PCF_SHADOW) && !defined(DIRLIGHT))))))))) || (!defined(VSM_SHADOW) && (!defined(SPOTLIGHT) && ((defined(SIMPLE_SHADOW) && ((defined(POINTLIGHT) && ((defined(PCF_SHADOW) && !defined(DIRLIGHT)) || (!defined(PCF_SHADOW) && !defined(DIRLIGHT)))) || (!defined(POINTLIGHT) && ((defined(PCF_SHADOW) && !defined(DIRLIGHT)) || (!defined(PCF_SHADOW) && !defined(DIRLIGHT)))))) || (!defined(SIMPLE_SHADOW) && ((defined(POINTLIGHT) && (defined(PCF_SHADOW) && !defined(DIRLIGHT))) || (!defined(POINTLIGHT) && (defined(PCF_SHADOW) && !defined(DIRLIGHT)))))))))
uniform samplerCube sFaceSelectCubeMap;
uniform samplerCube sIndirectionCubeMap;
#endif
#if (defined(VSM_SHADOW) || (!defined(VSM_SHADOW) && ((defined(SPOTLIGHT) && (defined(SIMPLE_SHADOW) || (!defined(SIMPLE_SHADOW) && defined(PCF_SHADOW)))) || (!defined(SPOTLIGHT) && (defined(SIMPLE_SHADOW) || (!defined(SIMPLE_SHADOW) && defined(PCF_SHADOW)))))))

#ifndef GL_ES
    #ifdef VSM_SHADOW
        uniform sampler2D sShadowMap;
    #else
        uniform sampler2DShadow sShadowMap;
    #endif
#else
    uniform highp sampler2D sShadowMap;
#endif
	
#endif
#if ((defined(WEBGL) && ((defined(GL_ES) && defined(DIRLIGHT)) || (!defined(GL_ES) && defined(DIRLIGHT)))) || (!defined(WEBGL) && ((defined(GL_ES) && defined(DIRLIGHT)) || !defined(GL_ES))))
varying float vVarying8;
#endif
#if ((defined(TRANSLUCENT) && !defined(DIRLIGHT)) || (!defined(TRANSLUCENT) && !defined(DIRLIGHT)))
varying vec3 vVarying3;
#endif
#if ((defined(VSM_SHADOW) && (!defined(SPOTLIGHT) && ((defined(SIMPLE_SHADOW) && ((defined(POINTLIGHT) && ((defined(PCF_SHADOW) && !defined(DIRLIGHT)) || (!defined(PCF_SHADOW) && !defined(DIRLIGHT)))) || (!defined(POINTLIGHT) && ((defined(PCF_SHADOW) && !defined(DIRLIGHT)) || (!defined(PCF_SHADOW) && !defined(DIRLIGHT)))))) || (!defined(SIMPLE_SHADOW) && ((defined(POINTLIGHT) && ((defined(PCF_SHADOW) && !defined(DIRLIGHT)) || (!defined(PCF_SHADOW) && !defined(DIRLIGHT)))) || (!defined(POINTLIGHT) && ((defined(PCF_SHADOW) && !defined(DIRLIGHT)) || (!defined(PCF_SHADOW) && !defined(DIRLIGHT))))))))) || (!defined(VSM_SHADOW) && (!defined(SPOTLIGHT) && ((defined(SIMPLE_SHADOW) && ((defined(POINTLIGHT) && ((defined(PCF_SHADOW) && !defined(DIRLIGHT)) || (!defined(PCF_SHADOW) && !defined(DIRLIGHT)))) || (!defined(POINTLIGHT) && ((defined(PCF_SHADOW) && !defined(DIRLIGHT)) || (!defined(PCF_SHADOW) && !defined(DIRLIGHT)))))) || (!defined(SIMPLE_SHADOW) && ((defined(POINTLIGHT) && (defined(PCF_SHADOW) && !defined(DIRLIGHT))) || (!defined(POINTLIGHT) && (defined(PCF_SHADOW) && !defined(DIRLIGHT)))))))))
varying float vVarying25;
#endif
varying float vVarying5;
#if (defined(VSM_SHADOW) && ((defined(SPOTLIGHT) && (!defined(SIMPLE_SHADOW) && !defined(PCF_SHADOW))) || (!defined(SPOTLIGHT) && (!defined(SIMPLE_SHADOW) && !defined(PCF_SHADOW)))))
varying float vVarying19;
#endif
#if ((defined(VSM_SHADOW) && (defined(SPOTLIGHT) && ((defined(SIMPLE_SHADOW) && ((defined(POINTLIGHT) && ((defined(PCF_SHADOW) && !defined(DIRLIGHT)) || (!defined(PCF_SHADOW) && !defined(DIRLIGHT)))) || (!defined(POINTLIGHT) && ((defined(PCF_SHADOW) && !defined(DIRLIGHT)) || (!defined(PCF_SHADOW) && !defined(DIRLIGHT)))))) || (!defined(SIMPLE_SHADOW) && ((defined(POINTLIGHT) && ((defined(PCF_SHADOW) && !defined(DIRLIGHT)) || (!defined(PCF_SHADOW) && !defined(DIRLIGHT)))) || (!defined(POINTLIGHT) && ((defined(PCF_SHADOW) && !defined(DIRLIGHT)) || (!defined(PCF_SHADOW) && !defined(DIRLIGHT))))))))) || (!defined(VSM_SHADOW) && (defined(SPOTLIGHT) && ((defined(SIMPLE_SHADOW) && ((defined(POINTLIGHT) && ((defined(PCF_SHADOW) && !defined(DIRLIGHT)) || (!defined(PCF_SHADOW) && !defined(DIRLIGHT)))) || (!defined(POINTLIGHT) && ((defined(PCF_SHADOW) && !defined(DIRLIGHT)) || (!defined(PCF_SHADOW) && !defined(DIRLIGHT)))))) || (!defined(SIMPLE_SHADOW) && ((defined(POINTLIGHT) && (defined(PCF_SHADOW) && !defined(DIRLIGHT))) || (!defined(POINTLIGHT) && (defined(PCF_SHADOW) && !defined(DIRLIGHT)))))))))
varying vec4 vVarying18;
#endif
#if defined(DIRLIGHT)
varying float vVarying17;
#endif
varying vec3 vVarying2;
#if (!defined(WEBGL) && !defined(GL_ES))
varying float vVarying23;
varying float vVarying24;
#endif
varying vec4 vVarying13;
#if (defined(VSM_SHADOW) && ((defined(SPOTLIGHT) && (!defined(SIMPLE_SHADOW) && !defined(PCF_SHADOW))) || (!defined(SPOTLIGHT) && (!defined(SIMPLE_SHADOW) && !defined(PCF_SHADOW)))))
varying float vVarying20;
#endif
varying vec3 vVarying6;
varying vec3 vVarying10;
#if (!defined(WEBGL) && !defined(GL_ES))
varying vec4 vVarying14;
#endif
#if (defined(VSM_SHADOW) && ((defined(SPOTLIGHT) && (!defined(SIMPLE_SHADOW) && !defined(PCF_SHADOW))) || (!defined(SPOTLIGHT) && (!defined(SIMPLE_SHADOW) && !defined(PCF_SHADOW)))))
varying float vVarying27;
#endif
varying float vVarying21;
varying vec3 vVarying7;
#if ((defined(VSM_SHADOW) && (!defined(SPOTLIGHT) && ((defined(SIMPLE_SHADOW) && ((defined(POINTLIGHT) && ((defined(PCF_SHADOW) && !defined(DIRLIGHT)) || (!defined(PCF_SHADOW) && !defined(DIRLIGHT)))) || (!defined(POINTLIGHT) && ((defined(PCF_SHADOW) && !defined(DIRLIGHT)) || (!defined(PCF_SHADOW) && !defined(DIRLIGHT)))))) || (!defined(SIMPLE_SHADOW) && ((defined(POINTLIGHT) && ((defined(PCF_SHADOW) && !defined(DIRLIGHT)) || (!defined(PCF_SHADOW) && !defined(DIRLIGHT)))) || (!defined(POINTLIGHT) && ((defined(PCF_SHADOW) && !defined(DIRLIGHT)) || (!defined(PCF_SHADOW) && !defined(DIRLIGHT))))))))) || (!defined(VSM_SHADOW) && (!defined(SPOTLIGHT) && ((defined(SIMPLE_SHADOW) && ((defined(POINTLIGHT) && ((defined(PCF_SHADOW) && !defined(DIRLIGHT)) || (!defined(PCF_SHADOW) && !defined(DIRLIGHT)))) || (!defined(POINTLIGHT) && ((defined(PCF_SHADOW) && !defined(DIRLIGHT)) || (!defined(PCF_SHADOW) && !defined(DIRLIGHT)))))) || (!defined(SIMPLE_SHADOW) && ((defined(POINTLIGHT) && (defined(PCF_SHADOW) && !defined(DIRLIGHT))) || (!defined(POINTLIGHT) && (defined(PCF_SHADOW) && !defined(DIRLIGHT)))))))))
varying vec3 vVarying11;
#endif
#if (!defined(WEBGL) && !defined(GL_ES))
varying vec4 vVarying15;
#endif
varying float vVarying22;
#if ((defined(VSM_SHADOW) && (!defined(SPOTLIGHT) && ((defined(SIMPLE_SHADOW) && ((defined(POINTLIGHT) && ((defined(PCF_SHADOW) && !defined(DIRLIGHT)) || (!defined(PCF_SHADOW) && !defined(DIRLIGHT)))) || (!defined(POINTLIGHT) && ((defined(PCF_SHADOW) && !defined(DIRLIGHT)) || (!defined(PCF_SHADOW) && !defined(DIRLIGHT)))))) || (!defined(SIMPLE_SHADOW) && ((defined(POINTLIGHT) && ((defined(PCF_SHADOW) && !defined(DIRLIGHT)) || (!defined(PCF_SHADOW) && !defined(DIRLIGHT)))) || (!defined(POINTLIGHT) && ((defined(PCF_SHADOW) && !defined(DIRLIGHT)) || (!defined(PCF_SHADOW) && !defined(DIRLIGHT))))))))) || (!defined(VSM_SHADOW) && (!defined(SPOTLIGHT) && ((defined(SIMPLE_SHADOW) && ((defined(POINTLIGHT) && ((defined(PCF_SHADOW) && !defined(DIRLIGHT)) || (!defined(PCF_SHADOW) && !defined(DIRLIGHT)))) || (!defined(POINTLIGHT) && ((defined(PCF_SHADOW) && !defined(DIRLIGHT)) || (!defined(PCF_SHADOW) && !defined(DIRLIGHT)))))) || (!defined(SIMPLE_SHADOW) && ((defined(POINTLIGHT) && (defined(PCF_SHADOW) && !defined(DIRLIGHT))) || (!defined(POINTLIGHT) && (defined(PCF_SHADOW) && !defined(DIRLIGHT)))))))))
varying float vVarying12;
#endif
#if (!defined(WEBGL) && !defined(GL_ES))
varying vec4 vVarying16;
#endif
varying vec3 vVarying1;
varying vec3 vVarying4;
#if (!defined(WEBGL) && !defined(GL_ES))
varying float vVarying9;
#endif
#if defined(DIRLIGHT)
varying float vVarying26;

#endif


void PS()
{
// based on node float  (type:default, id:0)
float var17 = (0.0);
if (bool(int(clamp(sign(vVarying1.y), var17, 1)))) discard;
// based on node get Varying4  (type:getVarying, id:0)
vec3 var72 = vVarying4;
#if ((defined(TRANSLUCENT) && !defined(DIRLIGHT)) || (!defined(TRANSLUCENT) && !defined(DIRLIGHT)))
// based on node per pixel vec4  (type:perPixelVec4, id:13)
vec4 var6 = cLightPosPS;
// based on node vec3*float  (type:vec3*float, id:13)
vec3 var7 = ((var6.xyz - vVarying3) * var6.w);
// based on node length(vec3)  (type:length(vec3), id:13)
float var8 = length(var7);
#endif
#if defined(DIRLIGHT)
// based on node ifdef(vec3) DIRLIGHT (type:ifdef(vec3), id:13)
vec3 ifdef1 = cLightDirPS;
#endif
#if !defined(DIRLIGHT)
// based on node ifdef(vec3) DIRLIGHT (type:ifdef(vec3), id:13)
vec3 ifdef1 = (var7 / var8);
#endif
// based on node ifdef(vec3)  (type:ifdef(vec3), id:13)
vec3 var9 = ifdef1;
// based on node normalize(vec3)  (type:normalize(vec3), id:13)
vec3 var4 = normalize(var72);
// based on node per pixel vec2  (type:perPixelVec2, id:13)
vec2 var34 = cShadowIntensity;
// based on node break vec2  (type:breakVec2, id:13)
float var78 = var34.y;
// based on node break vec2  (type:breakVec2, id:13)
float var32 = var34.x;
// based on node get Varying13  (type:getVarying, id:0)
vec4 var51 = vVarying13;
#if ((defined(WEBGL) && ((defined(GL_ES) && defined(DIRLIGHT)) || (!defined(GL_ES) && defined(DIRLIGHT)))) || (!defined(WEBGL) && ((defined(GL_ES) && defined(DIRLIGHT)) || !defined(GL_ES))))
// based on node per pixel float  (type:perPixelFloat, id:13)
float var19 = vVarying8;
#endif
#if (defined(WEBGL) && !defined(GL_ES))
// based on node ifdef(vec4) WEBGL (type:ifdef(vec4), id:13)
vec4 ifdef6 = var51;
#endif
#if (!defined(WEBGL) && !defined(GL_ES))
// based on node ifdef(vec4) WEBGL (type:ifdef(vec4), id:13)
vec4 ifdef6 = (((var19 < vVarying9))?(var51):((((var19 < vVarying23))?(vVarying14):((((var19 < vVarying24))?(vVarying15):(vVarying16))))));
#endif
#if defined(GL_ES)
// based on node ifdef(vec4) GL_ES (type:ifdef(vec4), id:13)
vec4 ifdef5 = var51;
#endif
#if !defined(GL_ES)
// based on node ifdef(vec4) GL_ES (type:ifdef(vec4), id:13)
vec4 ifdef5 = ifdef6;
#endif
#if ((defined(VSM_SHADOW) && ((defined(SIMPLE_SHADOW) && ((defined(POINTLIGHT) && ((defined(PCF_SHADOW) && defined(DIRLIGHT)) || (!defined(PCF_SHADOW) && defined(DIRLIGHT)))) || (!defined(POINTLIGHT) && ((defined(PCF_SHADOW) && defined(DIRLIGHT)) || (!defined(PCF_SHADOW) && defined(DIRLIGHT)))))) || (!defined(SIMPLE_SHADOW) && ((defined(POINTLIGHT) && ((defined(PCF_SHADOW) && defined(DIRLIGHT)) || (!defined(PCF_SHADOW) && defined(DIRLIGHT)))) || (!defined(POINTLIGHT) && ((defined(PCF_SHADOW) && defined(DIRLIGHT)) || (!defined(PCF_SHADOW) && defined(DIRLIGHT)))))))) || (!defined(VSM_SHADOW) && ((defined(SIMPLE_SHADOW) && ((defined(POINTLIGHT) && ((defined(PCF_SHADOW) && defined(DIRLIGHT)) || (!defined(PCF_SHADOW) && defined(DIRLIGHT)))) || (!defined(POINTLIGHT) && ((defined(PCF_SHADOW) && defined(DIRLIGHT)) || (!defined(PCF_SHADOW) && defined(DIRLIGHT)))))) || (!defined(SIMPLE_SHADOW) && ((defined(POINTLIGHT) && (defined(PCF_SHADOW) && defined(DIRLIGHT))) || (!defined(POINTLIGHT) && (defined(PCF_SHADOW) && defined(DIRLIGHT))))))))
// based on node per pixel vec4  (type:perPixelVec4, id:13)
vec4 var39 = ifdef5;
#endif
#if ((defined(VSM_SHADOW) && (!defined(SIMPLE_SHADOW) && ((defined(PCF_SHADOW) && defined(DIRLIGHT)) || (!defined(PCF_SHADOW) && defined(DIRLIGHT))))) || (!defined(VSM_SHADOW) && (!defined(SIMPLE_SHADOW) && (defined(PCF_SHADOW) && defined(DIRLIGHT)))))
// based on node break vec4  (type:breakVec4, id:13)
float var33 = var39.x;
// based on node break vec4  (type:breakVec4, id:13)
float var79 = var39.y;
// based on node break vec4  (type:breakVec4, id:13)
float var80 = var39.z;
// based on node break vec4  (type:breakVec4, id:13)
float var81 = var39.w;
#endif
#if ((defined(SPOTLIGHT) && (!defined(SIMPLE_SHADOW) && ((defined(POINTLIGHT) && defined(PCF_SHADOW)) || (!defined(POINTLIGHT) && defined(PCF_SHADOW))))) || (!defined(SPOTLIGHT) && (!defined(SIMPLE_SHADOW) && ((defined(POINTLIGHT) && defined(PCF_SHADOW)) || (!defined(POINTLIGHT) && defined(PCF_SHADOW))))))
// based on node per pixel vec2  (type:perPixelVec2, id:13)
vec2 var36 = cShadowMapInvSize;
#endif
#if (!defined(SIMPLE_SHADOW) && (defined(POINTLIGHT) && (defined(PCF_SHADOW) && defined(DIRLIGHT))))
// based on node ifdef(vec2) POINTLIGHT (type:ifdef(vec2), id:13)
vec2 ifdef8 = (var36 * var39.w);
#endif
#if (!defined(SIMPLE_SHADOW) && (!defined(POINTLIGHT) && (defined(PCF_SHADOW) && defined(DIRLIGHT))))
// based on node ifdef(vec2) POINTLIGHT (type:ifdef(vec2), id:13)
vec2 ifdef8 = var36;
#endif
#if (!defined(SIMPLE_SHADOW) && (defined(PCF_SHADOW) && defined(DIRLIGHT)))
// based on node ifdef(vec2)  (type:ifdef(vec2), id:13)
vec2 var35 = ifdef8;
// based on node float+float  (type:float+float, id:13)
float var37 = (var33 + var35.x);
// based on node float+float  (type:float+float, id:13)
float var38 = (var35.y + var79);
#endif
#if (defined(VSM_SHADOW) && (!defined(SIMPLE_SHADOW) && (!defined(PCF_SHADOW) && defined(DIRLIGHT))))
// based on node float/float  (type:float/float, id:13)
float var41 = (var80 / var81);
// based on node sampleVSMShadow  (type:sampleVSMShadow(shadowMap,vec2), id:13)
vec2 var40 = texture2D(sShadowMap, (vec2(var33, var79) / var81)).rg;
// based on node break vec2  (type:breakVec2, id:13)
float var63 = var40.x;
#endif
#if (defined(VSM_SHADOW) && ((defined(SPOTLIGHT) && (!defined(SIMPLE_SHADOW) && !defined(PCF_SHADOW))) || (!defined(SPOTLIGHT) && (!defined(SIMPLE_SHADOW) && !defined(PCF_SHADOW)))))
// based on node get Varying19  (type:getVarying, id:0)
float var16 = vVarying19;
#endif
#if (defined(VSM_SHADOW) && (!defined(SIMPLE_SHADOW) && (!defined(PCF_SHADOW) && defined(DIRLIGHT))))
// based on node max(float,float)  (type:max(float,float), id:13)
float var66 = max((var40.y - (var63 * var63)), var16);
// based on node float-float  (type:float-float, id:13)
float var67 = (var41 - var63);
#endif
#if (defined(VSM_SHADOW) && ((defined(SPOTLIGHT) && (!defined(SIMPLE_SHADOW) && !defined(PCF_SHADOW))) || (!defined(SPOTLIGHT) && (!defined(SIMPLE_SHADOW) && !defined(PCF_SHADOW)))))
// based on node get Varying27  (type:getVarying, id:0)
float var61 = vVarying27;
// based on node get Varying20  (type:getVarying, id:0)
float var60 = vVarying20;
#endif
#if (defined(VSM_SHADOW) && (!defined(SIMPLE_SHADOW) && (!defined(PCF_SHADOW) && defined(DIRLIGHT))))
// based on node ifdef(float) VSM_SHADOW (type:ifdef(float), id:13)
float ifdef9 = max(float((var41 <= var63)), clamp((((var66 / (var66 + (var67 * var67))) - var61) / var60), var17, 1.0));
#endif
#if (!defined(VSM_SHADOW) && (!defined(SIMPLE_SHADOW) && (!defined(PCF_SHADOW) && defined(DIRLIGHT))))
// based on node ifdef(float) VSM_SHADOW (type:ifdef(float), id:13)
float ifdef9 = 1.0;
#endif
#if (!defined(SIMPLE_SHADOW) && (defined(PCF_SHADOW) && defined(DIRLIGHT)))
// based on node ifdef(float) PCF_SHADOW (type:ifdef(float), id:13)
float ifdef7 = ((sampleShadow(sShadowMap, vec4(var33, var79, var80, var81)) + sampleShadow(sShadowMap, vec4(var37, var79, var80, var81))) + (sampleShadow(sShadowMap, vec4(var33, var38, var80, var81)) + sampleShadow(sShadowMap, vec4(var37, var38, var80, var81))));
#endif
#if (!defined(SIMPLE_SHADOW) && (!defined(PCF_SHADOW) && defined(DIRLIGHT)))
// based on node ifdef(float) PCF_SHADOW (type:ifdef(float), id:13)
float ifdef7 = ifdef9;
#endif
#if (defined(SIMPLE_SHADOW) && defined(DIRLIGHT))
// based on node ifdef(float) SIMPLE_SHADOW (type:ifdef(float), id:13)
float ifdef4 = sampleShadow(sShadowMap, var39);
#endif
#if (!defined(SIMPLE_SHADOW) && defined(DIRLIGHT))
// based on node ifdef(float) SIMPLE_SHADOW (type:ifdef(float), id:13)
float ifdef4 = ifdef7;
#endif
#if ((defined(VSM_SHADOW) && (defined(SPOTLIGHT) && ((defined(SIMPLE_SHADOW) && ((defined(POINTLIGHT) && ((defined(PCF_SHADOW) && !defined(DIRLIGHT)) || (!defined(PCF_SHADOW) && !defined(DIRLIGHT)))) || (!defined(POINTLIGHT) && ((defined(PCF_SHADOW) && !defined(DIRLIGHT)) || (!defined(PCF_SHADOW) && !defined(DIRLIGHT)))))) || (!defined(SIMPLE_SHADOW) && ((defined(POINTLIGHT) && ((defined(PCF_SHADOW) && !defined(DIRLIGHT)) || (!defined(PCF_SHADOW) && !defined(DIRLIGHT)))) || (!defined(POINTLIGHT) && ((defined(PCF_SHADOW) && !defined(DIRLIGHT)) || (!defined(PCF_SHADOW) && !defined(DIRLIGHT))))))))) || (!defined(VSM_SHADOW) && (defined(SPOTLIGHT) && ((defined(SIMPLE_SHADOW) && ((defined(POINTLIGHT) && ((defined(PCF_SHADOW) && !defined(DIRLIGHT)) || (!defined(PCF_SHADOW) && !defined(DIRLIGHT)))) || (!defined(POINTLIGHT) && ((defined(PCF_SHADOW) && !defined(DIRLIGHT)) || (!defined(PCF_SHADOW) && !defined(DIRLIGHT)))))) || (!defined(SIMPLE_SHADOW) && ((defined(POINTLIGHT) && (defined(PCF_SHADOW) && !defined(DIRLIGHT))) || (!defined(POINTLIGHT) && (defined(PCF_SHADOW) && !defined(DIRLIGHT)))))))))
// based on node per pixel vec4  (type:perPixelVec4, id:13)
vec4 var46 = vVarying18;
#endif
#if ((defined(VSM_SHADOW) && (defined(SPOTLIGHT) && (!defined(SIMPLE_SHADOW) && ((defined(PCF_SHADOW) && !defined(DIRLIGHT)) || (!defined(PCF_SHADOW) && !defined(DIRLIGHT)))))) || (!defined(VSM_SHADOW) && (defined(SPOTLIGHT) && (!defined(SIMPLE_SHADOW) && (defined(PCF_SHADOW) && !defined(DIRLIGHT))))))
// based on node break vec4  (type:breakVec4, id:13)
float var42 = var46.x;
// based on node break vec4  (type:breakVec4, id:13)
float var82 = var46.y;
// based on node break vec4  (type:breakVec4, id:13)
float var83 = var46.z;
// based on node break vec4  (type:breakVec4, id:13)
float var84 = var46.w;
#endif
#if (defined(SPOTLIGHT) && (!defined(SIMPLE_SHADOW) && (defined(POINTLIGHT) && (defined(PCF_SHADOW) && !defined(DIRLIGHT)))))
// based on node ifdef(vec2) POINTLIGHT (type:ifdef(vec2), id:13)
vec2 ifdef13 = (var36 * var46.w);
#endif
#if (defined(SPOTLIGHT) && (!defined(SIMPLE_SHADOW) && (!defined(POINTLIGHT) && (defined(PCF_SHADOW) && !defined(DIRLIGHT)))))
// based on node ifdef(vec2) POINTLIGHT (type:ifdef(vec2), id:13)
vec2 ifdef13 = var36;
#endif
#if (defined(SPOTLIGHT) && (!defined(SIMPLE_SHADOW) && (defined(PCF_SHADOW) && !defined(DIRLIGHT))))
// based on node ifdef(vec2)  (type:ifdef(vec2), id:13)
vec2 var43 = ifdef13;
// based on node float+float  (type:float+float, id:13)
float var44 = (var42 + var43.x);
// based on node float+float  (type:float+float, id:13)
float var45 = (var43.y + var82);
#endif
#if (defined(VSM_SHADOW) && (defined(SPOTLIGHT) && (!defined(SIMPLE_SHADOW) && (!defined(PCF_SHADOW) && !defined(DIRLIGHT)))))
// based on node float/float  (type:float/float, id:13)
float var48 = (var83 / var84);
// based on node sampleVSMShadow  (type:sampleVSMShadow(shadowMap,vec2), id:13)
vec2 var47 = texture2D(sShadowMap, (vec2(var42, var82) / var84)).rg;
// based on node break vec2  (type:breakVec2, id:13)
float var65 = var47.x;
// based on node max(float,float)  (type:max(float,float), id:13)
float var68 = max((var47.y - (var65 * var65)), var16);
// based on node float-float  (type:float-float, id:13)
float var69 = (var48 - var65);
// based on node ifdef(float) VSM_SHADOW (type:ifdef(float), id:13)
float ifdef14 = max(float((var48 <= var65)), clamp((((var68 / (var68 + (var69 * var69))) - var61) / var60), var17, 1.0));
#endif
#if (!defined(VSM_SHADOW) && (defined(SPOTLIGHT) && (!defined(SIMPLE_SHADOW) && (!defined(PCF_SHADOW) && !defined(DIRLIGHT)))))
// based on node ifdef(float) VSM_SHADOW (type:ifdef(float), id:13)
float ifdef14 = 1.0;
#endif
#if (defined(SPOTLIGHT) && (!defined(SIMPLE_SHADOW) && (defined(PCF_SHADOW) && !defined(DIRLIGHT))))
// based on node ifdef(float) PCF_SHADOW (type:ifdef(float), id:13)
float ifdef12 = ((sampleShadow(sShadowMap, vec4(var42, var82, var83, var84)) + sampleShadow(sShadowMap, vec4(var44, var82, var83, var84))) + (sampleShadow(sShadowMap, vec4(var42, var45, var83, var84)) + sampleShadow(sShadowMap, vec4(var44, var45, var83, var84))));
#endif
#if (defined(SPOTLIGHT) && (!defined(SIMPLE_SHADOW) && (!defined(PCF_SHADOW) && !defined(DIRLIGHT))))
// based on node ifdef(float) PCF_SHADOW (type:ifdef(float), id:13)
float ifdef12 = ifdef14;
#endif
#if (defined(SPOTLIGHT) && (defined(SIMPLE_SHADOW) && !defined(DIRLIGHT)))
// based on node ifdef(float) SIMPLE_SHADOW (type:ifdef(float), id:13)
float ifdef11 = sampleShadow(sShadowMap, var46);
#endif
#if (defined(SPOTLIGHT) && (!defined(SIMPLE_SHADOW) && !defined(DIRLIGHT)))
// based on node ifdef(float) SIMPLE_SHADOW (type:ifdef(float), id:13)
float ifdef11 = ifdef12;
#endif
#if ((defined(VSM_SHADOW) && (!defined(SPOTLIGHT) && ((defined(SIMPLE_SHADOW) && ((defined(POINTLIGHT) && ((defined(PCF_SHADOW) && !defined(DIRLIGHT)) || (!defined(PCF_SHADOW) && !defined(DIRLIGHT)))) || (!defined(POINTLIGHT) && ((defined(PCF_SHADOW) && !defined(DIRLIGHT)) || (!defined(PCF_SHADOW) && !defined(DIRLIGHT)))))) || (!defined(SIMPLE_SHADOW) && ((defined(POINTLIGHT) && ((defined(PCF_SHADOW) && !defined(DIRLIGHT)) || (!defined(PCF_SHADOW) && !defined(DIRLIGHT)))) || (!defined(POINTLIGHT) && ((defined(PCF_SHADOW) && !defined(DIRLIGHT)) || (!defined(PCF_SHADOW) && !defined(DIRLIGHT))))))))) || (!defined(VSM_SHADOW) && (!defined(SPOTLIGHT) && ((defined(SIMPLE_SHADOW) && ((defined(POINTLIGHT) && ((defined(PCF_SHADOW) && !defined(DIRLIGHT)) || (!defined(PCF_SHADOW) && !defined(DIRLIGHT)))) || (!defined(POINTLIGHT) && ((defined(PCF_SHADOW) && !defined(DIRLIGHT)) || (!defined(PCF_SHADOW) && !defined(DIRLIGHT)))))) || (!defined(SIMPLE_SHADOW) && ((defined(POINTLIGHT) && (defined(PCF_SHADOW) && !defined(DIRLIGHT))) || (!defined(POINTLIGHT) && (defined(PCF_SHADOW) && !defined(DIRLIGHT)))))))))
// based on node get Varying11  (type:getVarying, id:0)
vec3 var62 = vVarying11;
// based on node break vec4 to vec3, float  (type:breakVec4toVec3Float, id:13)
vec3 var21 = textureCube(sFaceSelectCubeMap, var62).xyz;
// based on node textureCube(samplerCube,vec3)  (type:textureCube(samplerCube,vec3), id:13)
vec4 var22 = textureCube(sIndirectionCubeMap, (var62 + ((var21 * var62) * 0.00390625)));
// based on node per pixel vec4  (type:perPixelVec4, id:13)
vec4 var24 = cShadowCubeAdjust;
// based on node break vec4 to vec2, vec2  (type:breakVec4toVec2Vec2, id:13)
vec2 var77 = var24.zw;
// based on node break vec4 to vec2, vec2  (type:breakVec4toVec2Vec2, id:13)
vec2 var76 = var22.zw;
// based on node per pixel vec4  (type:perPixelVec4, id:13)
vec4 var56 = vec4(((var22.xy * var24.xy) + vec2((var77.x + (var76.x * 0.5)), (var77.y + var76.y))), vec2((vVarying12 + (vVarying25 / abs(dot(var21, var62)))), 1.0));
#endif
#if ((defined(VSM_SHADOW) && (!defined(SPOTLIGHT) && (!defined(SIMPLE_SHADOW) && ((defined(PCF_SHADOW) && !defined(DIRLIGHT)) || (!defined(PCF_SHADOW) && !defined(DIRLIGHT)))))) || (!defined(VSM_SHADOW) && (!defined(SPOTLIGHT) && (!defined(SIMPLE_SHADOW) && (defined(PCF_SHADOW) && !defined(DIRLIGHT))))))
// based on node break vec4  (type:breakVec4, id:13)
float var52 = var56.x;
// based on node break vec4  (type:breakVec4, id:13)
float var85 = var56.y;
// based on node break vec4  (type:breakVec4, id:13)
float var86 = var56.z;
// based on node break vec4  (type:breakVec4, id:13)
float var87 = var56.w;
#endif
#if (!defined(SPOTLIGHT) && (!defined(SIMPLE_SHADOW) && (defined(POINTLIGHT) && (defined(PCF_SHADOW) && !defined(DIRLIGHT)))))
// based on node ifdef(vec2) POINTLIGHT (type:ifdef(vec2), id:13)
vec2 ifdef17 = (var36 * var56.w);
#endif
#if (!defined(SPOTLIGHT) && (!defined(SIMPLE_SHADOW) && (!defined(POINTLIGHT) && (defined(PCF_SHADOW) && !defined(DIRLIGHT)))))
// based on node ifdef(vec2) POINTLIGHT (type:ifdef(vec2), id:13)
vec2 ifdef17 = var36;
#endif
#if (!defined(SPOTLIGHT) && (!defined(SIMPLE_SHADOW) && (defined(PCF_SHADOW) && !defined(DIRLIGHT))))
// based on node ifdef(vec2)  (type:ifdef(vec2), id:13)
vec2 var53 = ifdef17;
// based on node float+float  (type:float+float, id:13)
float var54 = (var52 + var53.x);
// based on node float+float  (type:float+float, id:13)
float var55 = (var53.y + var85);
#endif
#if (defined(VSM_SHADOW) && (!defined(SPOTLIGHT) && (!defined(SIMPLE_SHADOW) && (!defined(PCF_SHADOW) && !defined(DIRLIGHT)))))
// based on node float/float  (type:float/float, id:13)
float var58 = (var86 / var87);
// based on node sampleVSMShadow  (type:sampleVSMShadow(shadowMap,vec2), id:13)
vec2 var57 = texture2D(sShadowMap, (vec2(var52, var85) / var87)).rg;
// based on node break vec2  (type:breakVec2, id:13)
float var71 = var57.x;
// based on node max(float,float)  (type:max(float,float), id:13)
float var73 = max((var57.y - (var71 * var71)), var16);
// based on node float-float  (type:float-float, id:13)
float var74 = (var58 - var71);
// based on node ifdef(float) VSM_SHADOW (type:ifdef(float), id:13)
float ifdef18 = max(float((var58 <= var71)), clamp((((var73 / (var73 + (var74 * var74))) - var61) / var60), var17, 1.0));
#endif
#if (!defined(VSM_SHADOW) && (!defined(SPOTLIGHT) && (!defined(SIMPLE_SHADOW) && (!defined(PCF_SHADOW) && !defined(DIRLIGHT)))))
// based on node ifdef(float) VSM_SHADOW (type:ifdef(float), id:13)
float ifdef18 = 1.0;
#endif
#if (!defined(SPOTLIGHT) && (!defined(SIMPLE_SHADOW) && (defined(PCF_SHADOW) && !defined(DIRLIGHT))))
// based on node ifdef(float) PCF_SHADOW (type:ifdef(float), id:13)
float ifdef16 = ((sampleShadow(sShadowMap, vec4(var52, var85, var86, var87)) + sampleShadow(sShadowMap, vec4(var54, var85, var86, var87))) + (sampleShadow(sShadowMap, vec4(var52, var55, var86, var87)) + sampleShadow(sShadowMap, vec4(var54, var55, var86, var87))));
#endif
#if (!defined(SPOTLIGHT) && (!defined(SIMPLE_SHADOW) && (!defined(PCF_SHADOW) && !defined(DIRLIGHT))))
// based on node ifdef(float) PCF_SHADOW (type:ifdef(float), id:13)
float ifdef16 = ifdef18;
#endif
#if (!defined(SPOTLIGHT) && (defined(SIMPLE_SHADOW) && !defined(DIRLIGHT)))
// based on node ifdef(float) SIMPLE_SHADOW (type:ifdef(float), id:13)
float ifdef15 = sampleShadow(sShadowMap, var56);
#endif
#if (!defined(SPOTLIGHT) && (!defined(SIMPLE_SHADOW) && !defined(DIRLIGHT)))
// based on node ifdef(float) SIMPLE_SHADOW (type:ifdef(float), id:13)
float ifdef15 = ifdef16;
#endif
#if (defined(SPOTLIGHT) && !defined(DIRLIGHT))
// based on node ifdef(float) SPOTLIGHT (type:ifdef(float), id:13)
float ifdef10 = (var78 + (var32 * ifdef11));
#endif
#if (!defined(SPOTLIGHT) && !defined(DIRLIGHT))
// based on node ifdef(float) SPOTLIGHT (type:ifdef(float), id:13)
float ifdef10 = (var78 + (var32 * ifdef15));
#endif
#if defined(DIRLIGHT)
// based on node ifdef(float) DIRLIGHT (type:ifdef(float), id:13)
float ifdef3 = min(((var78 + (var32 * ifdef4)) + max(((var19 - vVarying17) * vVarying26), var17)), 1.0);
#endif
#if !defined(DIRLIGHT)
// based on node ifdef(float) DIRLIGHT (type:ifdef(float), id:13)
float ifdef3 = ifdef10;
#endif
#if defined(SHADOW)
// based on node ifdef(float) SHADOW (type:ifdef(float), id:13)
float ifdef2 = ifdef3;
#endif
#if !defined(SHADOW)
// based on node ifdef(float) SHADOW (type:ifdef(float), id:13)
float ifdef2 = 1.0;
#endif
// based on node dot(vec3,vec3)  (type:dot(vec3,vec3), id:13)
float var12 = dot(var4, var9);
#if defined(TRANSLUCENT)
// based on node abs(float)  (type:abs(float), id:13)
float var13 = abs(var12);
#endif
#if !defined(TRANSLUCENT)
// based on node max(float,float)  (type:max(float,float), id:13)
float var11 = max(var12, 0.0);
#endif
#if (defined(TRANSLUCENT) && defined(DIRLIGHT))
// based on node ifdef(float) TRANSLUCENT (type:ifdef(float), id:13)
float ifdef20 = var13;
#endif
#if (!defined(TRANSLUCENT) && defined(DIRLIGHT))
// based on node ifdef(float) TRANSLUCENT (type:ifdef(float), id:13)
float ifdef20 = var11;
#endif
#if ((defined(TRANSLUCENT) && !defined(DIRLIGHT)) || (!defined(TRANSLUCENT) && !defined(DIRLIGHT)))
// based on node break vec4  (type:breakVec4, id:13)
float var10 = texture2D(sLightRampMap, vec2(var8, 0.0)).x;
#endif
#if (defined(TRANSLUCENT) && !defined(DIRLIGHT))
// based on node ifdef(float) TRANSLUCENT (type:ifdef(float), id:13)
float ifdef21 = (var13 * var10);
#endif
#if (!defined(TRANSLUCENT) && !defined(DIRLIGHT))
// based on node ifdef(float) TRANSLUCENT (type:ifdef(float), id:13)
float ifdef21 = (var11 * var10);
#endif
#if defined(DIRLIGHT)
// based on node ifdef(float) DIRLIGHT (type:ifdef(float), id:13)
float ifdef19 = ifdef20;
#endif
#if !defined(DIRLIGHT)
// based on node ifdef(float) DIRLIGHT (type:ifdef(float), id:13)
float ifdef19 = ifdef21;
#endif
gl_FragColor = (vec4((vVarying6 + ((cMatEnvMapColor * textureCube(sZoneCubeMap, reflect(vVarying7, var72))) + cMatEmissiveColor).xyz), vVarying22) + ((cMatDiffColor + vec4((vVarying2 * (pow(max(dot(normalize((vVarying10 + var9)), var4), var17), vVarying21) * vVarying5)), var17)) * (ifdef2 * ifdef19)));

}
#endif
// ==================================== LIGHTPASS ====================================
#elif defined(LIGHTPASS)
#if !defined(GLSL)
#define GLSL
#endif
#if defined(DX11)
#undef DX11
#endif

// ------------------- Vertex Shader ---------------

#if defined(DIRLIGHT) && (!defined(GL_ES) || defined(WEBGL))
    #define NUMCASCADES 4
#else
    #define NUMCASCADES 1
#endif

#ifdef COMPILEVS

// Silence GLSL 150 deprecation warnings
#ifdef GL3
#define attribute in
#define varying out
#endif

#if defined(SKINNED)
attribute vec4 iBlendWeights;
attribute vec4 iBlendIndices;
#endif
#if (!defined(SKINNED) && defined(INSTANCED))
attribute vec4 iTexCoord4;
attribute vec4 iTexCoord5;
attribute vec4 iTexCoord6;
#endif
attribute vec4 iPos;
attribute vec3 iNormal;
uniform vec4 cMatSpecColor;
uniform mat4 cModel;
uniform vec4 cLightColor;
uniform vec4 cSkinMatrices[MAXBONES*3];
uniform vec3 cCameraPosPS;
uniform mat4 cViewProj;
uniform vec4 cDepthMode;
uniform vec4 cLightOffsetScale;
uniform mat4 cLightMatrices[4];
uniform vec4 cShadowSplits;
uniform vec4 cNormalOffsetScale;
uniform vec4 cShadowDepthFade;
uniform vec4 cLightPos;
uniform vec3 cLightDir;
uniform vec2 cVSMShadowParams;
uniform vec4 cClipPlane;
varying vec3 vVarying9;
varying vec3 vVarying4;
varying float vVarying20;
varying float vVarying19;
varying float vVarying18;
varying float vVarying17;
varying vec3 vVarying3;
varying float vVarying24;
varying vec4 vVarying14;
varying float vVarying21;
varying vec4 vVarying11;
varying float vVarying15;
varying float vVarying7;
varying float vVarying22;
varying vec4 vVarying12;
varying vec3 vVarying8;
varying vec4 vVarying16;
varying vec3 vVarying1;
varying float vVarying23;
varying vec4 vVarying13;
varying vec3 vVarying2;
varying float vVarying5;
varying float vVarying6;
varying float vVarying10;

attribute float iObjectIndex;


// --- GetNormalMatrix ---

mat3 GetNormalMatrix(mat4 modelMatrix)
{
    return mat3(modelMatrix[0].xyz, modelMatrix[1].xyz, modelMatrix[2].xyz);
}



void VS()
{
#if (!defined(SKINNED) && defined(INSTANCED))
// based on node ifdef(mat4x3) INSTANCED (type:ifdef(mat4x3), id:8)
mat4 ifdef4 = mat4(iTexCoord4, iTexCoord5, iTexCoord6, vec4(0.0, 0.0, 0.0, 1.0));
#endif
#if (!defined(SKINNED) && !defined(INSTANCED))
// based on node ifdef(mat4x3) INSTANCED (type:ifdef(mat4x3), id:8)
mat4 ifdef4 = cModel;
#endif
#if defined(SKINNED)
// based on node ifdef(mat4x3) SKINNED (type:ifdef(mat4x3), id:8)
mat4 ifdef3 = (((mat4(cSkinMatrices[ivec4(iBlendIndices).x*3], cSkinMatrices[ivec4(iBlendIndices).x*3+1],cSkinMatrices[ivec4(iBlendIndices).x*3+2], vec4(0.0, 0.0, 0.0, 1.0)) * iBlendWeights.x) + (mat4(cSkinMatrices[ivec4(iBlendIndices).y*3], cSkinMatrices[ivec4(iBlendIndices).y*3+1],cSkinMatrices[ivec4(iBlendIndices).y*3+2], vec4(0.0, 0.0, 0.0, 1.0)) * iBlendWeights.y)) + ((mat4(cSkinMatrices[ivec4(iBlendIndices).z*3], cSkinMatrices[ivec4(iBlendIndices).z*3+1],cSkinMatrices[ivec4(iBlendIndices).z*3+2], vec4(0.0, 0.0, 0.0, 1.0)) * iBlendWeights.z) + (mat4(cSkinMatrices[ivec4(iBlendIndices).w*3], cSkinMatrices[ivec4(iBlendIndices).w*3+1],cSkinMatrices[ivec4(iBlendIndices).w*3+2], vec4(0.0, 0.0, 0.0, 1.0)) * iBlendWeights.w)));
#endif
#if !defined(SKINNED)
// based on node ifdef(mat4x3) SKINNED (type:ifdef(mat4x3), id:8)
mat4 ifdef3 = ifdef4;
#endif
// based on node ifdef(mat4x3)  (type:ifdef(mat4x3), id:8)
mat4 var4 = ifdef3;
// based on node vec4*mat4x3  (type:vec4*mat4x3, id:8)
vec3 var1 = ((iPos * var4)).xyz;
// based on node vec4(vec3,float)  (type:makeVec4fromVec3Float, id:13)
vec4 var14 = vec4(var1, 1.0);
#if ((defined(SPOTLIGHT) && defined(NORMALOFFSET)) || (!defined(SPOTLIGHT) && (defined(NORMALOFFSET) || (!defined(NORMALOFFSET) && !defined(DIRLIGHT)))))
// based on node break vec4 to vec3, float  (type:breakVec4toVec3Float, id:13)
vec3 var23 = var14.xyz;
#endif
// based on node vec3*mat3  (type:vec3*mat3, id:9)
vec3 var2 = (iNormal * GetNormalMatrix(var4));
#if ((defined(SPOTLIGHT) && (defined(NORMALOFFSET) && !defined(DIRLIGHT))) || (!defined(SPOTLIGHT) && ((defined(NORMALOFFSET) && !defined(DIRLIGHT)) || (!defined(NORMALOFFSET) && !defined(DIRLIGHT)))))
// based on node break vec4 to vec3, float  (type:breakVec4toVec3Float, id:13)
vec3 var28 = cLightPos.xyz;
#endif
#if ((defined(SPOTLIGHT) && (defined(NORMALOFFSET) && defined(DIRLIGHT))) || (!defined(SPOTLIGHT) && (defined(NORMALOFFSET) && defined(DIRLIGHT))))
// based on node ifdef(vec3) DIRLIGHT (type:ifdef(vec3), id:13)
vec3 ifdef5 = cLightDir;
#endif
#if (defined(SPOTLIGHT) && (defined(NORMALOFFSET) && !defined(DIRLIGHT)))
// based on node ifdef(vec3) DIRLIGHT (type:ifdef(vec3), id:13)
vec3 ifdef5 = normalize((var28 - var23));
#endif
#if ((defined(SPOTLIGHT) && defined(NORMALOFFSET)) || (!defined(SPOTLIGHT) && (defined(NORMALOFFSET) && defined(DIRLIGHT))))
// based on node clamp(float,float,float)  (type:clamp(float,float,float), id:13)
float var59 = clamp((1.0 - dot(var2, ifdef5)), (0.0), 1.0);
// based on node break vec4 to vec3, float  (type:breakVec4toVec3Float, id:13)
float var86 = var14.w;
// based on node ifdef(vec4) NORMALOFFSET (type:ifdef(vec4), id:13)
vec4 ifdef2 = vec4((var23 + (var2 * (var59 * cNormalOffsetScale.x))), var86);
#endif
#if ((defined(SPOTLIGHT) && !defined(NORMALOFFSET)) || (!defined(SPOTLIGHT) && (!defined(NORMALOFFSET) && defined(DIRLIGHT))))
// based on node ifdef(vec4) NORMALOFFSET (type:ifdef(vec4), id:13)
vec4 ifdef2 = var14;
#endif
#if (defined(SPOTLIGHT) || (!defined(SPOTLIGHT) && defined(DIRLIGHT)))
// based on node ifdef(vec4)  (type:ifdef(vec4), id:13)
vec4 var69 = ifdef2;
// based on node vec4*mat4  (type:vec4*mat4, id:13)
vec4 var51 = (var69 * cLightMatrices[0]);
#endif
#if (!defined(SPOTLIGHT) && !defined(DIRLIGHT))
// based on node vec4(vec3,float)  (type:makeVec4fromVec3Float, id:13)
vec4 var27 = vec4((var23 - var28), 1.0);
#endif
#if (defined(SPOTLIGHT) && !defined(DIRLIGHT))
// based on node ifdef(vec4) SPOTLIGHT (type:ifdef(vec4), id:13)
vec4 ifdef6 = var51;
#endif
#if (!defined(SPOTLIGHT) && !defined(DIRLIGHT))
// based on node ifdef(vec4) SPOTLIGHT (type:ifdef(vec4), id:13)
vec4 ifdef6 = var27;
#endif
#if defined(DIRLIGHT)
// based on node ifdef(vec4) DIRLIGHT (type:ifdef(vec4), id:13)
vec4 ifdef1 = var51;
#endif
#if !defined(DIRLIGHT)
// based on node ifdef(vec4) DIRLIGHT (type:ifdef(vec4), id:13)
vec4 ifdef1 = ifdef6;
#endif
// based on node break vec4 to vec3, float  (type:breakVec4toVec3Float, id:13)
vec3 var20 = ifdef1.xyz;
vVarying9 = var20;
vVarying4 = var2;
vVarying20 = cShadowSplits.y;
// based on node MatSpecColor  (type:parameter(color), id:3)
vec4 var0 = cMatSpecColor;
vVarying19 = var0.w;
// based on node break vec2  (type:breakVec2, id:13)
float var87 = cVSMShadowParams.y;
// based on node float-float  (type:float-float, id:13)
float var73 = (1.0 - var87);
vVarying18 = var73;
// based on node break vec2  (type:breakVec2, id:13)
float var63 = cVSMShadowParams.x;
vVarying17 = var63;
vVarying3 = var1;
vVarying24 = var87;
#if ((defined(SPOTLIGHT) && defined(NORMALOFFSET)) || (!defined(SPOTLIGHT) && (defined(NORMALOFFSET) && defined(DIRLIGHT))))
// based on node ifdef(vec4) NORMALOFFSET (type:ifdef(vec4), id:13)
vec4 ifdef8 = vec4((var23 + (var2 * (var59 * cLightOffsetScale.w))), var86);
#endif
#if ((defined(SPOTLIGHT) && !defined(NORMALOFFSET)) || (!defined(SPOTLIGHT) && (!defined(NORMALOFFSET) && defined(DIRLIGHT))))
// based on node ifdef(vec4) NORMALOFFSET (type:ifdef(vec4), id:13)
vec4 ifdef8 = var14;
#endif
#if (defined(SPOTLIGHT) || (!defined(SPOTLIGHT) && defined(DIRLIGHT)))
// based on node vec4*mat4  (type:vec4*mat4, id:13)
vec4 var31 = (ifdef8 * cLightMatrices[3]);
#endif
#if (defined(SPOTLIGHT) && !defined(DIRLIGHT))
// based on node ifdef(vec4) SPOTLIGHT (type:ifdef(vec4), id:13)
vec4 ifdef9 = var31;
#endif
#if (!defined(SPOTLIGHT) && !defined(DIRLIGHT))
// based on node ifdef(vec4) SPOTLIGHT (type:ifdef(vec4), id:13)
vec4 ifdef9 = var27;
#endif
#if defined(DIRLIGHT)
// based on node ifdef(vec4) DIRLIGHT (type:ifdef(vec4), id:13)
vec4 ifdef7 = var31;
#endif
#if !defined(DIRLIGHT)
// based on node ifdef(vec4) DIRLIGHT (type:ifdef(vec4), id:13)
vec4 ifdef7 = ifdef9;
#endif
vVarying14 = ifdef7;
vVarying21 = cShadowSplits.z;
#if ((defined(SPOTLIGHT) && defined(NORMALOFFSET)) || (!defined(SPOTLIGHT) && (defined(NORMALOFFSET) && defined(DIRLIGHT))))
// based on node ifdef(vec4) NORMALOFFSET (type:ifdef(vec4), id:13)
vec4 ifdef11 = vec4((var23 + (var2 * (var59 * cLightOffsetScale.x))), var86);
#endif
#if ((defined(SPOTLIGHT) && !defined(NORMALOFFSET)) || (!defined(SPOTLIGHT) && (!defined(NORMALOFFSET) && defined(DIRLIGHT))))
// based on node ifdef(vec4) NORMALOFFSET (type:ifdef(vec4), id:13)
vec4 ifdef11 = var14;
#endif
#if (defined(SPOTLIGHT) || (!defined(SPOTLIGHT) && defined(DIRLIGHT)))
// based on node vec4*mat4  (type:vec4*mat4, id:13)
vec4 var26 = (ifdef11 * cLightMatrices[(0)]);
#endif
#if (defined(SPOTLIGHT) && !defined(DIRLIGHT))
// based on node ifdef(vec4) SPOTLIGHT (type:ifdef(vec4), id:13)
vec4 ifdef12 = var26;
#endif
#if (!defined(SPOTLIGHT) && !defined(DIRLIGHT))
// based on node ifdef(vec4) SPOTLIGHT (type:ifdef(vec4), id:13)
vec4 ifdef12 = var27;
#endif
#if defined(DIRLIGHT)
// based on node ifdef(vec4) DIRLIGHT (type:ifdef(vec4), id:13)
vec4 ifdef10 = var26;
#endif
#if !defined(DIRLIGHT)
// based on node ifdef(vec4) DIRLIGHT (type:ifdef(vec4), id:13)
vec4 ifdef10 = ifdef12;
#endif
// based on node ifdef(vec4)  (type:ifdef(vec4), id:13)
vec4 var25 = ifdef10;
vVarying11 = var25;
vVarying15 = cShadowDepthFade.z;
vVarying7 = cShadowSplits.x;
vVarying22 = cShadowDepthFade.y;
#if ((defined(SPOTLIGHT) && defined(NORMALOFFSET)) || (!defined(SPOTLIGHT) && (defined(NORMALOFFSET) && defined(DIRLIGHT))))
// based on node ifdef(vec4) NORMALOFFSET (type:ifdef(vec4), id:13)
vec4 ifdef14 = vec4((var23 + (var2 * (var59 * cLightOffsetScale.y))), var86);
#endif
#if ((defined(SPOTLIGHT) && !defined(NORMALOFFSET)) || (!defined(SPOTLIGHT) && (!defined(NORMALOFFSET) && defined(DIRLIGHT))))
// based on node ifdef(vec4) NORMALOFFSET (type:ifdef(vec4), id:13)
vec4 ifdef14 = var14;
#endif
#if (defined(SPOTLIGHT) || (!defined(SPOTLIGHT) && defined(DIRLIGHT)))
// based on node lightMatrices[int]  (type:lightMatrices[int], id:13)
mat4 var18 = cLightMatrices[1];
// based on node vec4*mat4  (type:vec4*mat4, id:13)
vec4 var29 = (ifdef14 * var18);
#endif
#if (defined(SPOTLIGHT) && !defined(DIRLIGHT))
// based on node ifdef(vec4) SPOTLIGHT (type:ifdef(vec4), id:13)
vec4 ifdef15 = var29;
#endif
#if (!defined(SPOTLIGHT) && !defined(DIRLIGHT))
// based on node ifdef(vec4) SPOTLIGHT (type:ifdef(vec4), id:13)
vec4 ifdef15 = var27;
#endif
#if defined(DIRLIGHT)
// based on node ifdef(vec4) DIRLIGHT (type:ifdef(vec4), id:13)
vec4 ifdef13 = var29;
#endif
#if !defined(DIRLIGHT)
// based on node ifdef(vec4) DIRLIGHT (type:ifdef(vec4), id:13)
vec4 ifdef13 = ifdef15;
#endif
vVarying12 = ifdef13;
vVarying8 = normalize((cCameraPosPS - var1));
#if (defined(SPOTLIGHT) || (!defined(SPOTLIGHT) && defined(DIRLIGHT)))
// based on node vec4*mat4  (type:vec4*mat4, id:13)
vec4 var50 = (var69 * var18);
#endif
#if (defined(SPOTLIGHT) && !defined(DIRLIGHT))
// based on node ifdef(vec4) SPOTLIGHT (type:ifdef(vec4), id:13)
vec4 ifdef17 = var50;
#endif
#if (!defined(SPOTLIGHT) && !defined(DIRLIGHT))
// based on node ifdef(vec4) SPOTLIGHT (type:ifdef(vec4), id:13)
vec4 ifdef17 = var27;
#endif
#if defined(DIRLIGHT)
// based on node ifdef(vec4) DIRLIGHT (type:ifdef(vec4), id:13)
vec4 ifdef16 = var50;
#endif
#if !defined(DIRLIGHT)
// based on node ifdef(vec4) DIRLIGHT (type:ifdef(vec4), id:13)
vec4 ifdef16 = ifdef17;
#endif
vVarying16 = ifdef16;
vVarying1 = (vec3(0, 6, 0) - var1);
vVarying23 = cShadowDepthFade.w;
#if ((defined(SPOTLIGHT) && defined(NORMALOFFSET)) || (!defined(SPOTLIGHT) && (defined(NORMALOFFSET) && defined(DIRLIGHT))))
// based on node ifdef(vec4) NORMALOFFSET (type:ifdef(vec4), id:13)
vec4 ifdef19 = vec4((var23 + (var2 * (var59 * cLightOffsetScale.z))), var86);
#endif
#if ((defined(SPOTLIGHT) && !defined(NORMALOFFSET)) || (!defined(SPOTLIGHT) && (!defined(NORMALOFFSET) && defined(DIRLIGHT))))
// based on node ifdef(vec4) NORMALOFFSET (type:ifdef(vec4), id:13)
vec4 ifdef19 = var14;
#endif
#if (defined(SPOTLIGHT) || (!defined(SPOTLIGHT) && defined(DIRLIGHT)))
// based on node vec4*mat4  (type:vec4*mat4, id:13)
vec4 var30 = (ifdef19 * cLightMatrices[2]);
#endif
#if (defined(SPOTLIGHT) && !defined(DIRLIGHT))
// based on node ifdef(vec4) SPOTLIGHT (type:ifdef(vec4), id:13)
vec4 ifdef20 = var30;
#endif
#if (!defined(SPOTLIGHT) && !defined(DIRLIGHT))
// based on node ifdef(vec4) SPOTLIGHT (type:ifdef(vec4), id:13)
vec4 ifdef20 = var27;
#endif
#if defined(DIRLIGHT)
// based on node ifdef(vec4) DIRLIGHT (type:ifdef(vec4), id:13)
vec4 ifdef18 = var30;
#endif
#if !defined(DIRLIGHT)
// based on node ifdef(vec4) DIRLIGHT (type:ifdef(vec4), id:13)
vec4 ifdef18 = ifdef20;
#endif
vVarying13 = ifdef18;
vVarying2 = var0.xyz;
vVarying5 = cLightColor.w;
// based on node vec4*mat4  (type:vec4*mat4, id:13)
vec4 var15 = (vec4(var1, 1) * cViewProj);
vVarying6 = dot(var15.zw, cDepthMode.zw);
vVarying10 = cShadowDepthFade.x;
vec4 ret =  var15;


    // While getting the clip coordinate, also automatically set gl_ClipVertex for user clip planes
    #if !defined(GL_ES) && !defined(GL3)
       gl_ClipVertex = ret;
    #elif defined(GL3)
       gl_ClipDistance[0] = dot(cClipPlane, ret);
    #endif
    gl_Position = ret;
}

#else
// ------------------- Pixel Shader ---------------

uniform vec4 cMatDiffColor;
uniform vec3 cLightDirPS;
uniform vec4 cLightPosPS;
uniform vec4 cShadowCubeAdjust;
uniform vec2 cShadowIntensity;
uniform vec2 cShadowMapInvSize;
#if ((defined(TRANSLUCENT) && !defined(DIRLIGHT)) || (!defined(TRANSLUCENT) && !defined(DIRLIGHT)))
uniform sampler2D sLightRampMap;
#endif
#if ((defined(VSM_SHADOW) && (!defined(SPOTLIGHT) && ((defined(SIMPLE_SHADOW) && ((defined(POINTLIGHT) && ((defined(PCF_SHADOW) && !defined(DIRLIGHT)) || (!defined(PCF_SHADOW) && !defined(DIRLIGHT)))) || (!defined(POINTLIGHT) && ((defined(PCF_SHADOW) && !defined(DIRLIGHT)) || (!defined(PCF_SHADOW) && !defined(DIRLIGHT)))))) || (!defined(SIMPLE_SHADOW) && ((defined(POINTLIGHT) && ((defined(PCF_SHADOW) && !defined(DIRLIGHT)) || (!defined(PCF_SHADOW) && !defined(DIRLIGHT)))) || (!defined(POINTLIGHT) && ((defined(PCF_SHADOW) && !defined(DIRLIGHT)) || (!defined(PCF_SHADOW) && !defined(DIRLIGHT))))))))) || (!defined(VSM_SHADOW) && (!defined(SPOTLIGHT) && ((defined(SIMPLE_SHADOW) && ((defined(POINTLIGHT) && ((defined(PCF_SHADOW) && !defined(DIRLIGHT)) || (!defined(PCF_SHADOW) && !defined(DIRLIGHT)))) || (!defined(POINTLIGHT) && ((defined(PCF_SHADOW) && !defined(DIRLIGHT)) || (!defined(PCF_SHADOW) && !defined(DIRLIGHT)))))) || (!defined(SIMPLE_SHADOW) && ((defined(POINTLIGHT) && (defined(PCF_SHADOW) && !defined(DIRLIGHT))) || (!defined(POINTLIGHT) && (defined(PCF_SHADOW) && !defined(DIRLIGHT)))))))))
uniform samplerCube sFaceSelectCubeMap;
uniform samplerCube sIndirectionCubeMap;
#endif
#if (defined(VSM_SHADOW) || (!defined(VSM_SHADOW) && ((defined(SPOTLIGHT) && (defined(SIMPLE_SHADOW) || (!defined(SIMPLE_SHADOW) && defined(PCF_SHADOW)))) || (!defined(SPOTLIGHT) && (defined(SIMPLE_SHADOW) || (!defined(SIMPLE_SHADOW) && defined(PCF_SHADOW)))))))

#ifndef GL_ES
    #ifdef VSM_SHADOW
        uniform sampler2D sShadowMap;
    #else
        uniform sampler2DShadow sShadowMap;
    #endif
#else
    uniform highp sampler2D sShadowMap;
#endif
	
#endif
varying float vVarying5;
varying vec3 vVarying1;
#if ((defined(TRANSLUCENT) && !defined(DIRLIGHT)) || (!defined(TRANSLUCENT) && !defined(DIRLIGHT)))
varying vec3 vVarying3;
#endif
varying vec3 vVarying2;
#if ((defined(VSM_SHADOW) && (!defined(SPOTLIGHT) && ((defined(SIMPLE_SHADOW) && ((defined(POINTLIGHT) && ((defined(PCF_SHADOW) && !defined(DIRLIGHT)) || (!defined(PCF_SHADOW) && !defined(DIRLIGHT)))) || (!defined(POINTLIGHT) && ((defined(PCF_SHADOW) && !defined(DIRLIGHT)) || (!defined(PCF_SHADOW) && !defined(DIRLIGHT)))))) || (!defined(SIMPLE_SHADOW) && ((defined(POINTLIGHT) && ((defined(PCF_SHADOW) && !defined(DIRLIGHT)) || (!defined(PCF_SHADOW) && !defined(DIRLIGHT)))) || (!defined(POINTLIGHT) && ((defined(PCF_SHADOW) && !defined(DIRLIGHT)) || (!defined(PCF_SHADOW) && !defined(DIRLIGHT))))))))) || (!defined(VSM_SHADOW) && (!defined(SPOTLIGHT) && ((defined(SIMPLE_SHADOW) && ((defined(POINTLIGHT) && ((defined(PCF_SHADOW) && !defined(DIRLIGHT)) || (!defined(PCF_SHADOW) && !defined(DIRLIGHT)))) || (!defined(POINTLIGHT) && ((defined(PCF_SHADOW) && !defined(DIRLIGHT)) || (!defined(PCF_SHADOW) && !defined(DIRLIGHT)))))) || (!defined(SIMPLE_SHADOW) && ((defined(POINTLIGHT) && (defined(PCF_SHADOW) && !defined(DIRLIGHT))) || (!defined(POINTLIGHT) && (defined(PCF_SHADOW) && !defined(DIRLIGHT)))))))))
varying vec3 vVarying9;
#endif
varying vec3 vVarying4;
#if (!defined(WEBGL) && !defined(GL_ES))
varying float vVarying20;
#endif
varying float vVarying19;
#if (defined(VSM_SHADOW) && ((defined(SPOTLIGHT) && (!defined(SIMPLE_SHADOW) && !defined(PCF_SHADOW))) || (!defined(SPOTLIGHT) && (!defined(SIMPLE_SHADOW) && !defined(PCF_SHADOW)))))
varying float vVarying18;
varying float vVarying17;
#endif
#if (!defined(WEBGL) && !defined(GL_ES))
varying vec4 vVarying14;
#endif
#if defined(DIRLIGHT)
varying float vVarying23;
#endif
#if (defined(VSM_SHADOW) && ((defined(SPOTLIGHT) && (!defined(SIMPLE_SHADOW) && !defined(PCF_SHADOW))) || (!defined(SPOTLIGHT) && (!defined(SIMPLE_SHADOW) && !defined(PCF_SHADOW)))))
varying float vVarying24;
#endif
#if (!defined(WEBGL) && !defined(GL_ES))
varying vec4 vVarying13;
#endif
#if ((defined(WEBGL) && ((defined(GL_ES) && defined(DIRLIGHT)) || (!defined(GL_ES) && defined(DIRLIGHT)))) || (!defined(WEBGL) && ((defined(GL_ES) && defined(DIRLIGHT)) || !defined(GL_ES))))
varying float vVarying6;
#endif
#if (!defined(WEBGL) && !defined(GL_ES))
varying float vVarying21;
#endif
varying vec4 vVarying11;
#if defined(DIRLIGHT)
varying float vVarying15;
#endif
#if (!defined(WEBGL) && !defined(GL_ES))
varying float vVarying7;
#endif
#if ((defined(VSM_SHADOW) && (!defined(SPOTLIGHT) && ((defined(SIMPLE_SHADOW) && ((defined(POINTLIGHT) && ((defined(PCF_SHADOW) && !defined(DIRLIGHT)) || (!defined(PCF_SHADOW) && !defined(DIRLIGHT)))) || (!defined(POINTLIGHT) && ((defined(PCF_SHADOW) && !defined(DIRLIGHT)) || (!defined(PCF_SHADOW) && !defined(DIRLIGHT)))))) || (!defined(SIMPLE_SHADOW) && ((defined(POINTLIGHT) && ((defined(PCF_SHADOW) && !defined(DIRLIGHT)) || (!defined(PCF_SHADOW) && !defined(DIRLIGHT)))) || (!defined(POINTLIGHT) && ((defined(PCF_SHADOW) && !defined(DIRLIGHT)) || (!defined(PCF_SHADOW) && !defined(DIRLIGHT))))))))) || (!defined(VSM_SHADOW) && (!defined(SPOTLIGHT) && ((defined(SIMPLE_SHADOW) && ((defined(POINTLIGHT) && ((defined(PCF_SHADOW) && !defined(DIRLIGHT)) || (!defined(PCF_SHADOW) && !defined(DIRLIGHT)))) || (!defined(POINTLIGHT) && ((defined(PCF_SHADOW) && !defined(DIRLIGHT)) || (!defined(PCF_SHADOW) && !defined(DIRLIGHT)))))) || (!defined(SIMPLE_SHADOW) && ((defined(POINTLIGHT) && (defined(PCF_SHADOW) && !defined(DIRLIGHT))) || (!defined(POINTLIGHT) && (defined(PCF_SHADOW) && !defined(DIRLIGHT)))))))))
varying float vVarying22;
#endif
#if (!defined(WEBGL) && !defined(GL_ES))
varying vec4 vVarying12;
#endif
varying vec3 vVarying8;
#if ((defined(VSM_SHADOW) && (defined(SPOTLIGHT) && ((defined(SIMPLE_SHADOW) && ((defined(POINTLIGHT) && ((defined(PCF_SHADOW) && !defined(DIRLIGHT)) || (!defined(PCF_SHADOW) && !defined(DIRLIGHT)))) || (!defined(POINTLIGHT) && ((defined(PCF_SHADOW) && !defined(DIRLIGHT)) || (!defined(PCF_SHADOW) && !defined(DIRLIGHT)))))) || (!defined(SIMPLE_SHADOW) && ((defined(POINTLIGHT) && ((defined(PCF_SHADOW) && !defined(DIRLIGHT)) || (!defined(PCF_SHADOW) && !defined(DIRLIGHT)))) || (!defined(POINTLIGHT) && ((defined(PCF_SHADOW) && !defined(DIRLIGHT)) || (!defined(PCF_SHADOW) && !defined(DIRLIGHT))))))))) || (!defined(VSM_SHADOW) && (defined(SPOTLIGHT) && ((defined(SIMPLE_SHADOW) && ((defined(POINTLIGHT) && ((defined(PCF_SHADOW) && !defined(DIRLIGHT)) || (!defined(PCF_SHADOW) && !defined(DIRLIGHT)))) || (!defined(POINTLIGHT) && ((defined(PCF_SHADOW) && !defined(DIRLIGHT)) || (!defined(PCF_SHADOW) && !defined(DIRLIGHT)))))) || (!defined(SIMPLE_SHADOW) && ((defined(POINTLIGHT) && (defined(PCF_SHADOW) && !defined(DIRLIGHT))) || (!defined(POINTLIGHT) && (defined(PCF_SHADOW) && !defined(DIRLIGHT)))))))))
varying vec4 vVarying16;
#endif
#if ((defined(VSM_SHADOW) && (!defined(SPOTLIGHT) && ((defined(SIMPLE_SHADOW) && ((defined(POINTLIGHT) && ((defined(PCF_SHADOW) && !defined(DIRLIGHT)) || (!defined(PCF_SHADOW) && !defined(DIRLIGHT)))) || (!defined(POINTLIGHT) && ((defined(PCF_SHADOW) && !defined(DIRLIGHT)) || (!defined(PCF_SHADOW) && !defined(DIRLIGHT)))))) || (!defined(SIMPLE_SHADOW) && ((defined(POINTLIGHT) && ((defined(PCF_SHADOW) && !defined(DIRLIGHT)) || (!defined(PCF_SHADOW) && !defined(DIRLIGHT)))) || (!defined(POINTLIGHT) && ((defined(PCF_SHADOW) && !defined(DIRLIGHT)) || (!defined(PCF_SHADOW) && !defined(DIRLIGHT))))))))) || (!defined(VSM_SHADOW) && (!defined(SPOTLIGHT) && ((defined(SIMPLE_SHADOW) && ((defined(POINTLIGHT) && ((defined(PCF_SHADOW) && !defined(DIRLIGHT)) || (!defined(PCF_SHADOW) && !defined(DIRLIGHT)))) || (!defined(POINTLIGHT) && ((defined(PCF_SHADOW) && !defined(DIRLIGHT)) || (!defined(PCF_SHADOW) && !defined(DIRLIGHT)))))) || (!defined(SIMPLE_SHADOW) && ((defined(POINTLIGHT) && (defined(PCF_SHADOW) && !defined(DIRLIGHT))) || (!defined(POINTLIGHT) && (defined(PCF_SHADOW) && !defined(DIRLIGHT)))))))))
varying float vVarying10;

#endif


void PS()
{
// based on node float  (type:default, id:0)
float var61 = (0.0);
if (bool(int(clamp(sign(vVarying1.y), var61, 1)))) discard;
#if ((defined(TRANSLUCENT) && !defined(DIRLIGHT)) || (!defined(TRANSLUCENT) && !defined(DIRLIGHT)))
// based on node per pixel vec4  (type:perPixelVec4, id:13)
vec4 var5 = cLightPosPS;
// based on node vec3*float  (type:vec3*float, id:13)
vec3 var6 = ((var5.xyz - vVarying3) * var5.w);
// based on node length(vec3)  (type:length(vec3), id:13)
float var7 = length(var6);
#endif
#if defined(DIRLIGHT)
// based on node ifdef(vec3) DIRLIGHT (type:ifdef(vec3), id:13)
vec3 ifdef1 = cLightDirPS;
#endif
#if !defined(DIRLIGHT)
// based on node ifdef(vec3) DIRLIGHT (type:ifdef(vec3), id:13)
vec3 ifdef1 = (var6 / var7);
#endif
// based on node ifdef(vec3)  (type:ifdef(vec3), id:13)
vec3 var8 = ifdef1;
// based on node normalize(vec3)  (type:normalize(vec3), id:13)
vec3 var3 = normalize(vVarying4);
// based on node per pixel vec2  (type:perPixelVec2, id:13)
vec2 var35 = cShadowIntensity;
// based on node break vec2  (type:breakVec2, id:13)
float var76 = var35.y;
// based on node break vec2  (type:breakVec2, id:13)
float var33 = var35.x;
// based on node get Varying11  (type:getVarying, id:0)
vec4 var60 = vVarying11;
#if ((defined(WEBGL) && ((defined(GL_ES) && defined(DIRLIGHT)) || (!defined(GL_ES) && defined(DIRLIGHT)))) || (!defined(WEBGL) && ((defined(GL_ES) && defined(DIRLIGHT)) || !defined(GL_ES))))
// based on node per pixel float  (type:perPixelFloat, id:13)
float var19 = vVarying6;
#endif
#if (defined(WEBGL) && !defined(GL_ES))
// based on node ifdef(vec4) WEBGL (type:ifdef(vec4), id:13)
vec4 ifdef6 = var60;
#endif
#if (!defined(WEBGL) && !defined(GL_ES))
// based on node ifdef(vec4) WEBGL (type:ifdef(vec4), id:13)
vec4 ifdef6 = (((var19 < vVarying7))?(var60):((((var19 < vVarying20))?(vVarying12):((((var19 < vVarying21))?(vVarying13):(vVarying14))))));
#endif
#if defined(GL_ES)
// based on node ifdef(vec4) GL_ES (type:ifdef(vec4), id:13)
vec4 ifdef5 = var60;
#endif
#if !defined(GL_ES)
// based on node ifdef(vec4) GL_ES (type:ifdef(vec4), id:13)
vec4 ifdef5 = ifdef6;
#endif
#if ((defined(VSM_SHADOW) && ((defined(SIMPLE_SHADOW) && ((defined(POINTLIGHT) && ((defined(PCF_SHADOW) && defined(DIRLIGHT)) || (!defined(PCF_SHADOW) && defined(DIRLIGHT)))) || (!defined(POINTLIGHT) && ((defined(PCF_SHADOW) && defined(DIRLIGHT)) || (!defined(PCF_SHADOW) && defined(DIRLIGHT)))))) || (!defined(SIMPLE_SHADOW) && ((defined(POINTLIGHT) && ((defined(PCF_SHADOW) && defined(DIRLIGHT)) || (!defined(PCF_SHADOW) && defined(DIRLIGHT)))) || (!defined(POINTLIGHT) && ((defined(PCF_SHADOW) && defined(DIRLIGHT)) || (!defined(PCF_SHADOW) && defined(DIRLIGHT)))))))) || (!defined(VSM_SHADOW) && ((defined(SIMPLE_SHADOW) && ((defined(POINTLIGHT) && ((defined(PCF_SHADOW) && defined(DIRLIGHT)) || (!defined(PCF_SHADOW) && defined(DIRLIGHT)))) || (!defined(POINTLIGHT) && ((defined(PCF_SHADOW) && defined(DIRLIGHT)) || (!defined(PCF_SHADOW) && defined(DIRLIGHT)))))) || (!defined(SIMPLE_SHADOW) && ((defined(POINTLIGHT) && (defined(PCF_SHADOW) && defined(DIRLIGHT))) || (!defined(POINTLIGHT) && (defined(PCF_SHADOW) && defined(DIRLIGHT))))))))
// based on node per pixel vec4  (type:perPixelVec4, id:13)
vec4 var40 = ifdef5;
#endif
#if ((defined(VSM_SHADOW) && (!defined(SIMPLE_SHADOW) && ((defined(PCF_SHADOW) && defined(DIRLIGHT)) || (!defined(PCF_SHADOW) && defined(DIRLIGHT))))) || (!defined(VSM_SHADOW) && (!defined(SIMPLE_SHADOW) && (defined(PCF_SHADOW) && defined(DIRLIGHT)))))
// based on node break vec4  (type:breakVec4, id:13)
float var34 = var40.x;
// based on node break vec4  (type:breakVec4, id:13)
float var77 = var40.y;
// based on node break vec4  (type:breakVec4, id:13)
float var78 = var40.z;
// based on node break vec4  (type:breakVec4, id:13)
float var79 = var40.w;
#endif
#if ((defined(SPOTLIGHT) && (!defined(SIMPLE_SHADOW) && ((defined(POINTLIGHT) && defined(PCF_SHADOW)) || (!defined(POINTLIGHT) && defined(PCF_SHADOW))))) || (!defined(SPOTLIGHT) && (!defined(SIMPLE_SHADOW) && ((defined(POINTLIGHT) && defined(PCF_SHADOW)) || (!defined(POINTLIGHT) && defined(PCF_SHADOW))))))
// based on node per pixel vec2  (type:perPixelVec2, id:13)
vec2 var37 = cShadowMapInvSize;
#endif
#if (!defined(SIMPLE_SHADOW) && (defined(POINTLIGHT) && (defined(PCF_SHADOW) && defined(DIRLIGHT))))
// based on node ifdef(vec2) POINTLIGHT (type:ifdef(vec2), id:13)
vec2 ifdef8 = (var37 * var40.w);
#endif
#if (!defined(SIMPLE_SHADOW) && (!defined(POINTLIGHT) && (defined(PCF_SHADOW) && defined(DIRLIGHT))))
// based on node ifdef(vec2) POINTLIGHT (type:ifdef(vec2), id:13)
vec2 ifdef8 = var37;
#endif
#if (!defined(SIMPLE_SHADOW) && (defined(PCF_SHADOW) && defined(DIRLIGHT)))
// based on node ifdef(vec2)  (type:ifdef(vec2), id:13)
vec2 var36 = ifdef8;
// based on node float+float  (type:float+float, id:13)
float var38 = (var34 + var36.x);
// based on node float+float  (type:float+float, id:13)
float var39 = (var36.y + var77);
#endif
#if (defined(VSM_SHADOW) && (!defined(SIMPLE_SHADOW) && (!defined(PCF_SHADOW) && defined(DIRLIGHT))))
// based on node float/float  (type:float/float, id:13)
float var42 = (var78 / var79);
// based on node sampleVSMShadow  (type:sampleVSMShadow(shadowMap,vec2), id:13)
vec2 var41 = texture2D(sShadowMap, (vec2(var34, var77) / var79)).rg;
// based on node break vec2  (type:breakVec2, id:13)
float var62 = var41.x;
#endif
#if (defined(VSM_SHADOW) && ((defined(SPOTLIGHT) && (!defined(SIMPLE_SHADOW) && !defined(PCF_SHADOW))) || (!defined(SPOTLIGHT) && (!defined(SIMPLE_SHADOW) && !defined(PCF_SHADOW)))))
// based on node get Varying17  (type:getVarying, id:0)
float var17 = vVarying17;
#endif
#if (defined(VSM_SHADOW) && (!defined(SIMPLE_SHADOW) && (!defined(PCF_SHADOW) && defined(DIRLIGHT))))
// based on node max(float,float)  (type:max(float,float), id:13)
float var65 = max((var41.y - (var62 * var62)), var17);
// based on node float-float  (type:float-float, id:13)
float var66 = (var42 - var62);
#endif
#if (defined(VSM_SHADOW) && ((defined(SPOTLIGHT) && (!defined(SIMPLE_SHADOW) && !defined(PCF_SHADOW))) || (!defined(SPOTLIGHT) && (!defined(SIMPLE_SHADOW) && !defined(PCF_SHADOW)))))
// based on node get Varying24  (type:getVarying, id:0)
float var32 = vVarying24;
// based on node get Varying18  (type:getVarying, id:0)
float var16 = vVarying18;
#endif
#if (defined(VSM_SHADOW) && (!defined(SIMPLE_SHADOW) && (!defined(PCF_SHADOW) && defined(DIRLIGHT))))
// based on node ifdef(float) VSM_SHADOW (type:ifdef(float), id:13)
float ifdef9 = max(float((var42 <= var62)), clamp((((var65 / (var65 + (var66 * var66))) - var32) / var16), var61, 1.0));
#endif
#if (!defined(VSM_SHADOW) && (!defined(SIMPLE_SHADOW) && (!defined(PCF_SHADOW) && defined(DIRLIGHT))))
// based on node ifdef(float) VSM_SHADOW (type:ifdef(float), id:13)
float ifdef9 = 1.0;
#endif
#if (!defined(SIMPLE_SHADOW) && (defined(PCF_SHADOW) && defined(DIRLIGHT)))
// based on node ifdef(float) PCF_SHADOW (type:ifdef(float), id:13)
float ifdef7 = ((sampleShadow(sShadowMap, vec4(var34, var77, var78, var79)) + sampleShadow(sShadowMap, vec4(var38, var77, var78, var79))) + (sampleShadow(sShadowMap, vec4(var34, var39, var78, var79)) + sampleShadow(sShadowMap, vec4(var38, var39, var78, var79))));
#endif
#if (!defined(SIMPLE_SHADOW) && (!defined(PCF_SHADOW) && defined(DIRLIGHT)))
// based on node ifdef(float) PCF_SHADOW (type:ifdef(float), id:13)
float ifdef7 = ifdef9;
#endif
#if (defined(SIMPLE_SHADOW) && defined(DIRLIGHT))
// based on node ifdef(float) SIMPLE_SHADOW (type:ifdef(float), id:13)
float ifdef4 = sampleShadow(sShadowMap, var40);
#endif
#if (!defined(SIMPLE_SHADOW) && defined(DIRLIGHT))
// based on node ifdef(float) SIMPLE_SHADOW (type:ifdef(float), id:13)
float ifdef4 = ifdef7;
#endif
#if ((defined(VSM_SHADOW) && (defined(SPOTLIGHT) && ((defined(SIMPLE_SHADOW) && ((defined(POINTLIGHT) && ((defined(PCF_SHADOW) && !defined(DIRLIGHT)) || (!defined(PCF_SHADOW) && !defined(DIRLIGHT)))) || (!defined(POINTLIGHT) && ((defined(PCF_SHADOW) && !defined(DIRLIGHT)) || (!defined(PCF_SHADOW) && !defined(DIRLIGHT)))))) || (!defined(SIMPLE_SHADOW) && ((defined(POINTLIGHT) && ((defined(PCF_SHADOW) && !defined(DIRLIGHT)) || (!defined(PCF_SHADOW) && !defined(DIRLIGHT)))) || (!defined(POINTLIGHT) && ((defined(PCF_SHADOW) && !defined(DIRLIGHT)) || (!defined(PCF_SHADOW) && !defined(DIRLIGHT))))))))) || (!defined(VSM_SHADOW) && (defined(SPOTLIGHT) && ((defined(SIMPLE_SHADOW) && ((defined(POINTLIGHT) && ((defined(PCF_SHADOW) && !defined(DIRLIGHT)) || (!defined(PCF_SHADOW) && !defined(DIRLIGHT)))) || (!defined(POINTLIGHT) && ((defined(PCF_SHADOW) && !defined(DIRLIGHT)) || (!defined(PCF_SHADOW) && !defined(DIRLIGHT)))))) || (!defined(SIMPLE_SHADOW) && ((defined(POINTLIGHT) && (defined(PCF_SHADOW) && !defined(DIRLIGHT))) || (!defined(POINTLIGHT) && (defined(PCF_SHADOW) && !defined(DIRLIGHT)))))))))
// based on node per pixel vec4  (type:perPixelVec4, id:13)
vec4 var47 = vVarying16;
#endif
#if ((defined(VSM_SHADOW) && (defined(SPOTLIGHT) && (!defined(SIMPLE_SHADOW) && ((defined(PCF_SHADOW) && !defined(DIRLIGHT)) || (!defined(PCF_SHADOW) && !defined(DIRLIGHT)))))) || (!defined(VSM_SHADOW) && (defined(SPOTLIGHT) && (!defined(SIMPLE_SHADOW) && (defined(PCF_SHADOW) && !defined(DIRLIGHT))))))
// based on node break vec4  (type:breakVec4, id:13)
float var43 = var47.x;
// based on node break vec4  (type:breakVec4, id:13)
float var80 = var47.y;
// based on node break vec4  (type:breakVec4, id:13)
float var81 = var47.z;
// based on node break vec4  (type:breakVec4, id:13)
float var82 = var47.w;
#endif
#if (defined(SPOTLIGHT) && (!defined(SIMPLE_SHADOW) && (defined(POINTLIGHT) && (defined(PCF_SHADOW) && !defined(DIRLIGHT)))))
// based on node ifdef(vec2) POINTLIGHT (type:ifdef(vec2), id:13)
vec2 ifdef13 = (var37 * var47.w);
#endif
#if (defined(SPOTLIGHT) && (!defined(SIMPLE_SHADOW) && (!defined(POINTLIGHT) && (defined(PCF_SHADOW) && !defined(DIRLIGHT)))))
// based on node ifdef(vec2) POINTLIGHT (type:ifdef(vec2), id:13)
vec2 ifdef13 = var37;
#endif
#if (defined(SPOTLIGHT) && (!defined(SIMPLE_SHADOW) && (defined(PCF_SHADOW) && !defined(DIRLIGHT))))
// based on node ifdef(vec2)  (type:ifdef(vec2), id:13)
vec2 var44 = ifdef13;
// based on node float+float  (type:float+float, id:13)
float var45 = (var43 + var44.x);
// based on node float+float  (type:float+float, id:13)
float var46 = (var44.y + var80);
#endif
#if (defined(VSM_SHADOW) && (defined(SPOTLIGHT) && (!defined(SIMPLE_SHADOW) && (!defined(PCF_SHADOW) && !defined(DIRLIGHT)))))
// based on node float/float  (type:float/float, id:13)
float var49 = (var81 / var82);
// based on node sampleVSMShadow  (type:sampleVSMShadow(shadowMap,vec2), id:13)
vec2 var48 = texture2D(sShadowMap, (vec2(var43, var80) / var82)).rg;
// based on node break vec2  (type:breakVec2, id:13)
float var64 = var48.x;
// based on node max(float,float)  (type:max(float,float), id:13)
float var67 = max((var48.y - (var64 * var64)), var17);
// based on node float-float  (type:float-float, id:13)
float var68 = (var49 - var64);
// based on node ifdef(float) VSM_SHADOW (type:ifdef(float), id:13)
float ifdef14 = max(float((var49 <= var64)), clamp((((var67 / (var67 + (var68 * var68))) - var32) / var16), var61, 1.0));
#endif
#if (!defined(VSM_SHADOW) && (defined(SPOTLIGHT) && (!defined(SIMPLE_SHADOW) && (!defined(PCF_SHADOW) && !defined(DIRLIGHT)))))
// based on node ifdef(float) VSM_SHADOW (type:ifdef(float), id:13)
float ifdef14 = 1.0;
#endif
#if (defined(SPOTLIGHT) && (!defined(SIMPLE_SHADOW) && (defined(PCF_SHADOW) && !defined(DIRLIGHT))))
// based on node ifdef(float) PCF_SHADOW (type:ifdef(float), id:13)
float ifdef12 = ((sampleShadow(sShadowMap, vec4(var43, var80, var81, var82)) + sampleShadow(sShadowMap, vec4(var45, var80, var81, var82))) + (sampleShadow(sShadowMap, vec4(var43, var46, var81, var82)) + sampleShadow(sShadowMap, vec4(var45, var46, var81, var82))));
#endif
#if (defined(SPOTLIGHT) && (!defined(SIMPLE_SHADOW) && (!defined(PCF_SHADOW) && !defined(DIRLIGHT))))
// based on node ifdef(float) PCF_SHADOW (type:ifdef(float), id:13)
float ifdef12 = ifdef14;
#endif
#if (defined(SPOTLIGHT) && (defined(SIMPLE_SHADOW) && !defined(DIRLIGHT)))
// based on node ifdef(float) SIMPLE_SHADOW (type:ifdef(float), id:13)
float ifdef11 = sampleShadow(sShadowMap, var47);
#endif
#if (defined(SPOTLIGHT) && (!defined(SIMPLE_SHADOW) && !defined(DIRLIGHT)))
// based on node ifdef(float) SIMPLE_SHADOW (type:ifdef(float), id:13)
float ifdef11 = ifdef12;
#endif
#if ((defined(VSM_SHADOW) && (!defined(SPOTLIGHT) && ((defined(SIMPLE_SHADOW) && ((defined(POINTLIGHT) && ((defined(PCF_SHADOW) && !defined(DIRLIGHT)) || (!defined(PCF_SHADOW) && !defined(DIRLIGHT)))) || (!defined(POINTLIGHT) && ((defined(PCF_SHADOW) && !defined(DIRLIGHT)) || (!defined(PCF_SHADOW) && !defined(DIRLIGHT)))))) || (!defined(SIMPLE_SHADOW) && ((defined(POINTLIGHT) && ((defined(PCF_SHADOW) && !defined(DIRLIGHT)) || (!defined(PCF_SHADOW) && !defined(DIRLIGHT)))) || (!defined(POINTLIGHT) && ((defined(PCF_SHADOW) && !defined(DIRLIGHT)) || (!defined(PCF_SHADOW) && !defined(DIRLIGHT))))))))) || (!defined(VSM_SHADOW) && (!defined(SPOTLIGHT) && ((defined(SIMPLE_SHADOW) && ((defined(POINTLIGHT) && ((defined(PCF_SHADOW) && !defined(DIRLIGHT)) || (!defined(PCF_SHADOW) && !defined(DIRLIGHT)))) || (!defined(POINTLIGHT) && ((defined(PCF_SHADOW) && !defined(DIRLIGHT)) || (!defined(PCF_SHADOW) && !defined(DIRLIGHT)))))) || (!defined(SIMPLE_SHADOW) && ((defined(POINTLIGHT) && (defined(PCF_SHADOW) && !defined(DIRLIGHT))) || (!defined(POINTLIGHT) && (defined(PCF_SHADOW) && !defined(DIRLIGHT)))))))))
// based on node get Varying9  (type:getVarying, id:0)
vec3 var10 = vVarying9;
// based on node break vec4 to vec3, float  (type:breakVec4toVec3Float, id:13)
vec3 var21 = textureCube(sFaceSelectCubeMap, var10).xyz;
// based on node textureCube(samplerCube,vec3)  (type:textureCube(samplerCube,vec3), id:13)
vec4 var22 = textureCube(sIndirectionCubeMap, (var10 + ((var21 * var10) * 0.00390625)));
// based on node per pixel vec4  (type:perPixelVec4, id:13)
vec4 var24 = cShadowCubeAdjust;
// based on node break vec4 to vec2, vec2  (type:breakVec4toVec2Vec2, id:13)
vec2 var75 = var24.zw;
// based on node break vec4 to vec2, vec2  (type:breakVec4toVec2Vec2, id:13)
vec2 var74 = var22.zw;
// based on node per pixel vec4  (type:perPixelVec4, id:13)
vec4 var56 = vec4(((var22.xy * var24.xy) + vec2((var75.x + (var74.x * 0.5)), (var75.y + var74.y))), vec2((vVarying10 + (vVarying22 / abs(dot(var21, var10)))), 1.0));
#endif
#if ((defined(VSM_SHADOW) && (!defined(SPOTLIGHT) && (!defined(SIMPLE_SHADOW) && ((defined(PCF_SHADOW) && !defined(DIRLIGHT)) || (!defined(PCF_SHADOW) && !defined(DIRLIGHT)))))) || (!defined(VSM_SHADOW) && (!defined(SPOTLIGHT) && (!defined(SIMPLE_SHADOW) && (defined(PCF_SHADOW) && !defined(DIRLIGHT))))))
// based on node break vec4  (type:breakVec4, id:13)
float var52 = var56.x;
// based on node break vec4  (type:breakVec4, id:13)
float var83 = var56.y;
// based on node break vec4  (type:breakVec4, id:13)
float var84 = var56.z;
// based on node break vec4  (type:breakVec4, id:13)
float var85 = var56.w;
#endif
#if (!defined(SPOTLIGHT) && (!defined(SIMPLE_SHADOW) && (defined(POINTLIGHT) && (defined(PCF_SHADOW) && !defined(DIRLIGHT)))))
// based on node ifdef(vec2) POINTLIGHT (type:ifdef(vec2), id:13)
vec2 ifdef17 = (var37 * var56.w);
#endif
#if (!defined(SPOTLIGHT) && (!defined(SIMPLE_SHADOW) && (!defined(POINTLIGHT) && (defined(PCF_SHADOW) && !defined(DIRLIGHT)))))
// based on node ifdef(vec2) POINTLIGHT (type:ifdef(vec2), id:13)
vec2 ifdef17 = var37;
#endif
#if (!defined(SPOTLIGHT) && (!defined(SIMPLE_SHADOW) && (defined(PCF_SHADOW) && !defined(DIRLIGHT))))
// based on node ifdef(vec2)  (type:ifdef(vec2), id:13)
vec2 var53 = ifdef17;
// based on node float+float  (type:float+float, id:13)
float var54 = (var52 + var53.x);
// based on node float+float  (type:float+float, id:13)
float var55 = (var53.y + var83);
#endif
#if (defined(VSM_SHADOW) && (!defined(SPOTLIGHT) && (!defined(SIMPLE_SHADOW) && (!defined(PCF_SHADOW) && !defined(DIRLIGHT)))))
// based on node float/float  (type:float/float, id:13)
float var58 = (var84 / var85);
// based on node sampleVSMShadow  (type:sampleVSMShadow(shadowMap,vec2), id:13)
vec2 var57 = texture2D(sShadowMap, (vec2(var52, var83) / var85)).rg;
// based on node break vec2  (type:breakVec2, id:13)
float var70 = var57.x;
// based on node max(float,float)  (type:max(float,float), id:13)
float var71 = max((var57.y - (var70 * var70)), var17);
// based on node float-float  (type:float-float, id:13)
float var72 = (var58 - var70);
// based on node ifdef(float) VSM_SHADOW (type:ifdef(float), id:13)
float ifdef18 = max(float((var58 <= var70)), clamp((((var71 / (var71 + (var72 * var72))) - var32) / var16), var61, 1.0));
#endif
#if (!defined(VSM_SHADOW) && (!defined(SPOTLIGHT) && (!defined(SIMPLE_SHADOW) && (!defined(PCF_SHADOW) && !defined(DIRLIGHT)))))
// based on node ifdef(float) VSM_SHADOW (type:ifdef(float), id:13)
float ifdef18 = 1.0;
#endif
#if (!defined(SPOTLIGHT) && (!defined(SIMPLE_SHADOW) && (defined(PCF_SHADOW) && !defined(DIRLIGHT))))
// based on node ifdef(float) PCF_SHADOW (type:ifdef(float), id:13)
float ifdef16 = ((sampleShadow(sShadowMap, vec4(var52, var83, var84, var85)) + sampleShadow(sShadowMap, vec4(var54, var83, var84, var85))) + (sampleShadow(sShadowMap, vec4(var52, var55, var84, var85)) + sampleShadow(sShadowMap, vec4(var54, var55, var84, var85))));
#endif
#if (!defined(SPOTLIGHT) && (!defined(SIMPLE_SHADOW) && (!defined(PCF_SHADOW) && !defined(DIRLIGHT))))
// based on node ifdef(float) PCF_SHADOW (type:ifdef(float), id:13)
float ifdef16 = ifdef18;
#endif
#if (!defined(SPOTLIGHT) && (defined(SIMPLE_SHADOW) && !defined(DIRLIGHT)))
// based on node ifdef(float) SIMPLE_SHADOW (type:ifdef(float), id:13)
float ifdef15 = sampleShadow(sShadowMap, var56);
#endif
#if (!defined(SPOTLIGHT) && (!defined(SIMPLE_SHADOW) && !defined(DIRLIGHT)))
// based on node ifdef(float) SIMPLE_SHADOW (type:ifdef(float), id:13)
float ifdef15 = ifdef16;
#endif
#if (defined(SPOTLIGHT) && !defined(DIRLIGHT))
// based on node ifdef(float) SPOTLIGHT (type:ifdef(float), id:13)
float ifdef10 = (var76 + (var33 * ifdef11));
#endif
#if (!defined(SPOTLIGHT) && !defined(DIRLIGHT))
// based on node ifdef(float) SPOTLIGHT (type:ifdef(float), id:13)
float ifdef10 = (var76 + (var33 * ifdef15));
#endif
#if defined(DIRLIGHT)
// based on node ifdef(float) DIRLIGHT (type:ifdef(float), id:13)
float ifdef3 = min(((var76 + (var33 * ifdef4)) + max(((var19 - vVarying15) * vVarying23), var61)), 1.0);
#endif
#if !defined(DIRLIGHT)
// based on node ifdef(float) DIRLIGHT (type:ifdef(float), id:13)
float ifdef3 = ifdef10;
#endif
#if defined(SHADOW)
// based on node ifdef(float) SHADOW (type:ifdef(float), id:13)
float ifdef2 = ifdef3;
#endif
#if !defined(SHADOW)
// based on node ifdef(float) SHADOW (type:ifdef(float), id:13)
float ifdef2 = 1.0;
#endif
// based on node dot(vec3,vec3)  (type:dot(vec3,vec3), id:13)
float var12 = dot(var3, var8);
#if defined(TRANSLUCENT)
// based on node abs(float)  (type:abs(float), id:13)
float var13 = abs(var12);
#endif
#if !defined(TRANSLUCENT)
// based on node max(float,float)  (type:max(float,float), id:13)
float var11 = max(var12, 0.0);
#endif
#if (defined(TRANSLUCENT) && defined(DIRLIGHT))
// based on node ifdef(float) TRANSLUCENT (type:ifdef(float), id:13)
float ifdef20 = var13;
#endif
#if (!defined(TRANSLUCENT) && defined(DIRLIGHT))
// based on node ifdef(float) TRANSLUCENT (type:ifdef(float), id:13)
float ifdef20 = var11;
#endif
#if ((defined(TRANSLUCENT) && !defined(DIRLIGHT)) || (!defined(TRANSLUCENT) && !defined(DIRLIGHT)))
// based on node break vec4  (type:breakVec4, id:13)
float var9 = texture2D(sLightRampMap, vec2(var7, 0.0)).x;
#endif
#if (defined(TRANSLUCENT) && !defined(DIRLIGHT))
// based on node ifdef(float) TRANSLUCENT (type:ifdef(float), id:13)
float ifdef21 = (var13 * var9);
#endif
#if (!defined(TRANSLUCENT) && !defined(DIRLIGHT))
// based on node ifdef(float) TRANSLUCENT (type:ifdef(float), id:13)
float ifdef21 = (var11 * var9);
#endif
#if defined(DIRLIGHT)
// based on node ifdef(float) DIRLIGHT (type:ifdef(float), id:13)
float ifdef19 = ifdef20;
#endif
#if !defined(DIRLIGHT)
// based on node ifdef(float) DIRLIGHT (type:ifdef(float), id:13)
float ifdef19 = ifdef21;
#endif
gl_FragColor = ((cMatDiffColor + vec4((vVarying2 * (pow(max(dot(normalize((vVarying8 + var8)), var3), var61), vVarying19) * vVarying5)), var61)) * (ifdef2 * ifdef19));

}
#endif
// ==================================== BASEPASS ====================================
#elif defined(BASEPASS)
#if !defined(GLSL)
#define GLSL
#endif
#if defined(DX11)
#undef DX11
#endif

// ------------------- Vertex Shader ---------------

#if defined(DIRLIGHT) && (!defined(GL_ES) || defined(WEBGL))
    #define NUMCASCADES 4
#else
    #define NUMCASCADES 1
#endif

#ifdef COMPILEVS

// Silence GLSL 150 deprecation warnings
#ifdef GL3
#define attribute in
#define varying out
#endif

#if defined(SKINNED)
attribute vec4 iBlendWeights;
attribute vec4 iBlendIndices;
#endif
#if (!defined(SKINNED) && defined(INSTANCED))
attribute vec4 iTexCoord4;
attribute vec4 iTexCoord5;
attribute vec4 iTexCoord6;
#endif
attribute vec4 iPos;
attribute vec3 iNormal;
uniform vec4 cMatDiffColor;
uniform mat4 cModel;
uniform vec4 cAmbientColor;
uniform vec3 cCameraPos;
uniform vec4 cSkinMatrices[MAXBONES*3];
uniform mat4 cViewProj;
uniform vec4 cClipPlane;
varying vec3 vVarying1;
varying float vVarying5;
varying vec3 vVarying4;
varying vec3 vVarying3;
varying vec3 vVarying2;

attribute float iObjectIndex;


// --- GetNormalMatrix ---

mat3 GetNormalMatrix(mat4 modelMatrix)
{
    return mat3(modelMatrix[0].xyz, modelMatrix[1].xyz, modelMatrix[2].xyz);
}



void VS()
{
#if (!defined(SKINNED) && defined(INSTANCED))
// based on node ifdef(mat4x3) INSTANCED (type:ifdef(mat4x3), id:8)
mat4 ifdef2 = mat4(iTexCoord4, iTexCoord5, iTexCoord6, vec4(0.0, 0.0, 0.0, 1.0));
#endif
#if (!defined(SKINNED) && !defined(INSTANCED))
// based on node ifdef(mat4x3) INSTANCED (type:ifdef(mat4x3), id:8)
mat4 ifdef2 = cModel;
#endif
#if defined(SKINNED)
// based on node ifdef(mat4x3) SKINNED (type:ifdef(mat4x3), id:8)
mat4 ifdef1 = (((mat4(cSkinMatrices[ivec4(iBlendIndices).x*3], cSkinMatrices[ivec4(iBlendIndices).x*3+1],cSkinMatrices[ivec4(iBlendIndices).x*3+2], vec4(0.0, 0.0, 0.0, 1.0)) * iBlendWeights.x) + (mat4(cSkinMatrices[ivec4(iBlendIndices).y*3], cSkinMatrices[ivec4(iBlendIndices).y*3+1],cSkinMatrices[ivec4(iBlendIndices).y*3+2], vec4(0.0, 0.0, 0.0, 1.0)) * iBlendWeights.y)) + ((mat4(cSkinMatrices[ivec4(iBlendIndices).z*3], cSkinMatrices[ivec4(iBlendIndices).z*3+1],cSkinMatrices[ivec4(iBlendIndices).z*3+2], vec4(0.0, 0.0, 0.0, 1.0)) * iBlendWeights.z) + (mat4(cSkinMatrices[ivec4(iBlendIndices).w*3], cSkinMatrices[ivec4(iBlendIndices).w*3+1],cSkinMatrices[ivec4(iBlendIndices).w*3+2], vec4(0.0, 0.0, 0.0, 1.0)) * iBlendWeights.w)));
#endif
#if !defined(SKINNED)
// based on node ifdef(mat4x3) SKINNED (type:ifdef(mat4x3), id:8)
mat4 ifdef1 = ifdef2;
#endif
// based on node ifdef(mat4x3)  (type:ifdef(mat4x3), id:8)
mat4 var2 = ifdef1;
// based on node vec4*mat4x3  (type:vec4*mat4x3, id:8)
vec3 var0 = ((iPos * var2)).xyz;
vVarying1 = (vec3(0, 6, 0) - var0);
// based on node vec4*vec4  (type:vec4*vec4, id:13)
vec4 var1 = (cMatDiffColor * vec4(1.000, 0.998, 1.000, 1.000));
vVarying5 = var1.w;
vVarying4 = (var0 - cCameraPos);
vVarying3 = (cAmbientColor.xyz * var1.xyz);
vVarying2 = (iNormal * GetNormalMatrix(var2));
vec4 ret =  (vec4(var0, 1) * cViewProj);


    // While getting the clip coordinate, also automatically set gl_ClipVertex for user clip planes
    #if !defined(GL_ES) && !defined(GL3)
       gl_ClipVertex = ret;
    #elif defined(GL3)
       gl_ClipDistance[0] = dot(cClipPlane, ret);
    #endif
    gl_Position = ret;
}

#else
// ------------------- Pixel Shader ---------------

uniform vec4 cMatEmissiveColor;
uniform vec4 cMatEnvMapColor;
uniform samplerCube sZoneCubeMap;
varying float vVarying5;
varying vec3 vVarying4;
varying vec3 vVarying3;
varying vec3 vVarying2;
varying vec3 vVarying1;



void PS()
{
if (bool(int(clamp(sign(vVarying1.y), (0.0), 1)))) discard;
gl_FragColor = vec4((vVarying3 + ((cMatEnvMapColor * textureCube(sZoneCubeMap, reflect(vVarying4, vVarying2))) + cMatEmissiveColor).xyz), vVarying5);

}
#endif
#elif
#ifdef COMPILEVS

attribute vec4 iPos;
uniform mat4 cModel;
uniform mat4 cViewProj;
uniform vec4 cClipPlane;

void VS()
{
	mat4 var1 = cModel;
	vec4 ret =  (vec4((iPos * var1).xyz, 1.0) * cViewProj);

    // While getting the clip coordinate, also automatically set gl_ClipVertex for user clip planes
    #if !defined(GL_ES) && !defined(GL3)
       gl_ClipVertex = ret;
    #elif defined(GL3)
       gl_ClipDistance[0] = dot(cClipPlane, ret);
    #endif
    gl_Position = ret;
}

#else
// ------------------- Pixel Shader ---------------

void PS()
{
    gl_FragColor = vec4(1.0, 0.0, 0.0, 0.5);
}
#endif
#endif
