
#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

attribute vec4 iPos;
#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 vec3 iNormal;
uniform vec3 cPortalOrigin;
uniform vec3 cPortalForward;
uniform vec4 cMatSpecColor;
uniform mat4 cModel;
uniform vec3 cCameraPos;
uniform vec4 cSkinMatrices[MAXBONES*3];
uniform mat4 cViewProj;
uniform vec4 cDepthMode;
uniform vec4 cClipPlane;
varying vec3 vVarying2;
varying vec3 vVarying3;
varying vec3 vVarying1;
varying float vVarying8;
varying vec3 vVarying7;
varying float vVarying6;
varying float vVarying5;
varying mat3 vVarying4;
varying float vVarying9;

attribute float iObjectIndex;


// --- GetNormalMatrix ---

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



void VS()
{
// based on node normalize(vec3)  (type:normalize(vec3), id:31)
vec3 var2 = normalize(normalize(cPortalForward));
vVarying2 = var2;
// based on node vec3-vec3  (type:vec3-vec3, id:76)
vec3 var4 = (cCameraPos - vec3(0.0, 0.0, 0.0));
vVarying3 = var4;
#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 var11 = ifdef1;
// based on node vec4*mat4x3  (type:vec4*mat4x3, id:8)
vec3 var10 = ((iPos * var11)).xyz;
vVarying1 = (var10 - vec3(0.0, 0.0, 0.0));
vVarying8 = (cMatSpecColor.w / 255.0);
vVarying7 = (iNormal * GetNormalMatrix(var11));
// based on node PortalOrigin  (type:parameter(vec3), id:156)
vec3 var1 = cPortalOrigin;
// based on node cross(vec3,vec3)  (type:cross(vec3,vec3), id:33)
vec3 var0 = cross(var2, normalize(vec3(1.0, 0.0, 0.0)));
// based on node mat3(vec3,vec3,vec3)  (type:mat3(vec3,vec3,vec3), id:70)
mat3 var5 = mat3(normalize(cross(var0, var2)), normalize(var0), var2);
vVarying6 = step((0.0), ((var4 - var1) * var5).z);
vVarying5 = dot((var1 - var4), var2);
vVarying4 = var5;
// based on node vec4*mat4  (type:vec4*mat4, id:208)
vec4 var18 = (vec4(var10, 1) * cViewProj);
vVarying9 = dot(var18.zw, cDepthMode.zw);
vec4 ret =  var18;


    // 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 float cPortalRadius;
uniform vec3 cPortalOrigin;
varying vec3 vVarying3;
varying float vVarying8;
varying vec3 vVarying1;
varying vec3 vVarying7;
varying float vVarying6;
varying float vVarying5;
varying mat3 vVarying4;
varying vec3 vVarying2;
varying float vVarying9;



void PS()
{
// based on node float  (type:default, id:0)
float var19 = (0.0);
// based on node per pixel vec3  (type:perPixelVec3, id:150)
vec3 var8 = vVarying1;
// based on node PortalOrigin  (type:parameter(vec3), id:156)
vec3 var13 = cPortalOrigin;
// based on node step(float,float)  (type:step(float,float), id:202)
float var6 = step(var19, ((var8 - var13) * vVarying4).z);
// based on node get Varying3  (type:getVarying, id:0)
vec3 var3 = vVarying3;
// based on node normalize(vec3)  (type:normalize(vec3), id:130)
vec3 var7 = normalize((var8 - var3));
// based on node step(float,float)  (type:step(float,float), id:196)
float var9 = step(cPortalRadius, distance(var13, ((var7 * (vVarying5 / dot(vVarying2, var7))) + var3)));
if (!(bool(mix(min(var6, var9), max(var6, (1.0 - var9)), vVarying6)))) discard;
// based on node per pixel float  (type:perPixelFloat, id:208)
float var12 = vVarying9;
#if !defined(GL3)
// based on node float*float  (type:float*float, id:208)
float var14 = (var12 * 255.0);
// based on node floor(float)  (type:floor(float), id:208)
float var15 = floor(var14);
// based on node float*float  (type:float*float, id:208)
float var16 = ((var14 - var15) * 255.0);
// based on node floor(float)  (type:floor(float), id:208)
float var17 = floor(var16);
#endif
#if defined(GL3)
// based on node ifdef(vec3) GL3 (type:ifdef(vec3), id:208)
vec3 ifdef1 = vec3(var12, var19, var19);
#endif
#if !defined(GL3)
// based on node ifdef(vec3) GL3 (type:ifdef(vec3), id:208)
vec3 ifdef1 = vec3((var15 * 0.0039215686274509803921568627451), (var17 * 0.0039215686274509803921568627451), (var16 - var17));
#endif
gl_FragData[1] = vec4(ifdef1, var19);
gl_FragData[0] = vec4(((normalize(vVarying7) * 0.5) + vec3(0.5, 0.5, 0.5)), vVarying8);

}
#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

attribute vec4 iPos;
#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 vec3 iNormal;
uniform vec3 cPortalOrigin;
uniform vec4 cMatDiffColor;
uniform vec3 cPortalForward;
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 vVarying2;
varying vec3 vVarying3;
varying vec3 vVarying1;
varying vec3 vVarying8;
varying vec3 vVarying7;
varying float vVarying13;
varying float vVarying6;
varying float vVarying5;
varying mat3 vVarying4;
varying float vVarying12;
varying vec4 vVarying11;
varying float vVarying10;
varying vec3 vVarying9;

attribute float iObjectIndex;


// --- GetNormalMatrix ---

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



void VS()
{
// based on node normalize(vec3)  (type:normalize(vec3), id:31)
vec3 var2 = normalize(normalize(cPortalForward));
vVarying2 = var2;
// based on node vec3-vec3  (type:vec3-vec3, id:76)
vec3 var4 = (cCameraPos - vec3(0.0, 0.0, 0.0));
vVarying3 = var4;
#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 var12 = ifdef1;
// based on node vec4*mat4x3  (type:vec4*mat4x3, id:8)
vec3 var10 = ((iPos * var12)).xyz;
vVarying1 = (var10 - vec3(0.0, 0.0, 0.0));
// based on node vec4  (type:default, id:0)
vec4 var21 = vec4(0.0,0.0,0.0,0.0);
vVarying8 = (cAmbientColor.xyz * var21.xyz);
// based on node vec3*mat3  (type:vec3*mat3, id:9)
vec3 var11 = (iNormal * GetNormalMatrix(var12));
vVarying7 = var11;
vVarying13 = var21.w;
// based on node PortalOrigin  (type:parameter(vec3), id:156)
vec3 var1 = cPortalOrigin;
// based on node cross(vec3,vec3)  (type:cross(vec3,vec3), id:33)
vec3 var0 = cross(var2, normalize(vec3(1.0, 0.0, 0.0)));
// based on node mat3(vec3,vec3,vec3)  (type:mat3(vec3,vec3,vec3), id:70)
mat3 var5 = mat3(normalize(cross(var0, var2)), normalize(var0), var2);
vVarying6 = step((0.0), ((var4 - var1) * var5).z);
vVarying5 = dot((var1 - var4), var2);
vVarying4 = var5;
// based on node vec4*mat4  (type:vec4*mat4, id:208)
vec4 var19 = (vec4(var10, 1) * cViewProj);
vVarying12 = dot(var19.zw, cDepthMode.zw);
// based on node break vec4 to vec3, float  (type:breakVec4toVec3Float, id:208)
float var23 = cMatSpecColor.w;
vVarying11 = vec4(cMatDiffColor.xyz, var23);
vVarying10 = (var23 / 255.0);
vVarying9 = (var10 - cCameraPos);
vec4 ret =  var19;


    // 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 float cPortalRadius;
uniform vec4 cMatEmissiveColor;
uniform vec4 cMatEnvMapColor;
uniform vec3 cPortalOrigin;
uniform samplerCube sZoneCubeMap;
varying vec3 vVarying3;
varying vec3 vVarying8;
varying vec3 vVarying1;
varying float vVarying13;
varying vec3 vVarying7;
varying float vVarying6;
varying float vVarying5;
varying mat3 vVarying4;
varying vec3 vVarying2;
varying vec4 vVarying11;
varying float vVarying12;
varying float vVarying10;
varying vec3 vVarying9;



void PS()
{
// based on node float  (type:default, id:0)
float var22 = (0.0);
// based on node per pixel vec3  (type:perPixelVec3, id:150)
vec3 var8 = vVarying1;
// based on node PortalOrigin  (type:parameter(vec3), id:156)
vec3 var14 = cPortalOrigin;
// based on node step(float,float)  (type:step(float,float), id:202)
float var6 = step(var22, ((var8 - var14) * vVarying4).z);
// based on node get Varying3  (type:getVarying, id:0)
vec3 var3 = vVarying3;
// based on node normalize(vec3)  (type:normalize(vec3), id:130)
vec3 var7 = normalize((var8 - var3));
// based on node step(float,float)  (type:step(float,float), id:196)
float var9 = step(cPortalRadius, distance(var14, ((var7 * (vVarying5 / dot(vVarying2, var7))) + var3)));
if (!(bool(mix(min(var6, var9), max(var6, (1.0 - var9)), vVarying6)))) discard;
// based on node get Varying7  (type:getVarying, id:0)
vec3 var20 = vVarying7;
gl_FragData[0] = vec4(vec4((vVarying8 + ((cMatEnvMapColor * textureCube(sZoneCubeMap, reflect(vVarying9, var20))) + cMatEmissiveColor).xyz), vVarying13).xyz, 1.0);
gl_FragData[1] = vVarying11;
gl_FragData[2] = vec4(((normalize(var20) * 0.5) + vec3(0.5, 0.5, 0.5)), vVarying10);
// based on node per pixel float  (type:perPixelFloat, id:208)
float var13 = vVarying12;
#if !defined(GL3)
// based on node float*float  (type:float*float, id:208)
float var15 = (var13 * 255.0);
// based on node floor(float)  (type:floor(float), id:208)
float var16 = floor(var15);
// based on node float*float  (type:float*float, id:208)
float var17 = ((var15 - var16) * 255.0);
// based on node floor(float)  (type:floor(float), id:208)
float var18 = floor(var17);
#endif
#if defined(GL3)
// based on node ifdef(vec3) GL3 (type:ifdef(vec3), id:208)
vec3 ifdef1 = vec3(var13, var22, var22);
#endif
#if !defined(GL3)
// based on node ifdef(vec3) GL3 (type:ifdef(vec3), id:208)
vec3 ifdef1 = vec3((var16 * 0.0039215686274509803921568627451), (var18 * 0.0039215686274509803921568627451), (var17 - var18));
#endif
gl_FragData[3] = vec4(ifdef1, var22);

}
#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

attribute vec4 iPos;
#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
uniform vec3 cPortalOrigin;
uniform vec3 cPortalForward;
uniform mat4 cModel;
uniform vec3 cCameraPos;
uniform vec4 cSkinMatrices[MAXBONES*3];
uniform mat4 cViewProj;
uniform vec4 cClipPlane;
varying vec3 vVarying3;
varying vec3 vVarying1;
varying vec3 vVarying2;
varying mat3 vVarying4;
varying float vVarying5;
varying vec2 vVarying7;
varying float vVarying6;

attribute float iObjectIndex;




void VS()
{
// based on node vec3-vec3  (type:vec3-vec3, id:76)
vec3 var3 = (cCameraPos - vec3(0.0, 0.0, 0.0));
vVarying3 = var3;
#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 var10 = ((iPos * ifdef1)).xyz;
vVarying1 = (var10 - vec3(0.0, 0.0, 0.0));
// based on node normalize(vec3)  (type:normalize(vec3), id:31)
vec3 var2 = normalize(normalize(cPortalForward));
vVarying2 = var2;
// based on node cross(vec3,vec3)  (type:cross(vec3,vec3), id:33)
vec3 var0 = cross(var2, normalize(vec3(1.0, 0.0, 0.0)));
// based on node mat3(vec3,vec3,vec3)  (type:mat3(vec3,vec3,vec3), id:70)
mat3 var4 = mat3(normalize(cross(var0, var2)), normalize(var0), var2);
vVarying4 = var4;
// based on node PortalOrigin  (type:parameter(vec3), id:156)
vec3 var1 = cPortalOrigin;
vVarying5 = dot((var1 - var3), var2);
// based on node vec4*mat4  (type:vec4*mat4, id:208)
vec4 var11 = (vec4(var10, 1) * cViewProj);
vVarying7 = var11.zw;
vVarying6 = step((0.0), ((var3 - var1) * var4).z);
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 float cPortalRadius;
uniform vec3 cPortalOrigin;
varying mat3 vVarying4;
varying vec3 vVarying2;
varying vec3 vVarying1;
varying float vVarying6;
varying vec2 vVarying7;
varying float vVarying5;
varying vec3 vVarying3;



void PS()
{
// based on node per pixel vec3  (type:perPixelVec3, id:150)
vec3 var8 = vVarying1;
// based on node PortalOrigin  (type:parameter(vec3), id:156)
vec3 var5 = cPortalOrigin;
// based on node step(float,float)  (type:step(float,float), id:202)
float var6 = step((0.0), ((var8 - var5) * vVarying4).z);
// based on node get Varying3  (type:getVarying, id:0)
vec3 var12 = vVarying3;
// based on node normalize(vec3)  (type:normalize(vec3), id:130)
vec3 var7 = normalize((var8 - var12));
// based on node step(float,float)  (type:step(float,float), id:196)
float var9 = step(cPortalRadius, distance(var5, ((var7 * (vVarying5 / dot(vVarying2, var7))) + var12)));
if (!(bool(mix(min(var6, var9), max(var6, (1.0 - var9)), vVarying6)))) discard;
    #ifdef VSM_SHADOW
        float depth = vVarying7.x / vVarying7.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

attribute vec4 iPos;
#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 vec3 iNormal;
uniform vec3 cPortalOrigin;
uniform vec3 cPortalForward;
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 vVarying17;
varying vec3 vVarying5;
varying mat3 vVarying4;
varying float vVarying30;
varying vec3 vVarying16;
varying vec3 vVarying12;
varying vec3 vVarying9;
varying float vVarying22;
varying vec4 vVarying21;
varying vec4 vVarying20;
varying vec4 vVarying19;
varying vec3 vVarying8;
varying float vVarying25;
varying float vVarying26;
varying float vVarying27;
varying vec4 vVarying18;
varying vec4 vVarying23;
varying float vVarying10;
varying float vVarying13;
varying float vVarying31;
varying float vVarying6;
varying float vVarying14;
varying float vVarying32;
varying float vVarying24;
varying float vVarying7;
varying vec3 vVarying11;
varying vec3 vVarying15;
varying vec3 vVarying1;
varying vec3 vVarying2;
varying vec3 vVarying3;
varying float vVarying28;
varying float vVarying29;

attribute float iObjectIndex;


// --- GetNormalMatrix ---

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



void VS()
{
vVarying17 = cShadowDepthFade.x;
// based on node MatSpecColor  (type:parameter(color), id:232)
vec4 var9 = cMatSpecColor;
vVarying5 = var9.xyz;
// based on node normalize(vec3)  (type:normalize(vec3), id:31)
vec3 var2 = normalize(normalize(cPortalForward));
// based on node cross(vec3,vec3)  (type:cross(vec3,vec3), id:33)
vec3 var0 = cross(var2, normalize(vec3(1.0, 0.0, 0.0)));
// based on node mat3(vec3,vec3,vec3)  (type:mat3(vec3,vec3,vec3), id:70)
mat3 var4 = mat3(normalize(cross(var0, var2)), normalize(var0), var2);
vVarying4 = var4;
vVarying30 = cShadowDepthFade.y;
#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 var13 = ifdef3;
// based on node vec4*mat4x3  (type:vec4*mat4x3, id:8)
vec3 var10 = ((iPos * var13)).xyz;
// based on node vec4(vec3,float)  (type:makeVec4fromVec3Float, id:208)
vec4 var25 = vec4(var10, 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:208)
vec3 var33 = var25.xyz;
#endif
// based on node vec3*mat3  (type:vec3*mat3, id:9)
vec3 var11 = (iNormal * GetNormalMatrix(var13));
#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:208)
vec3 var38 = 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:208)
vec3 ifdef5 = cLightDir;
#endif
#if (defined(SPOTLIGHT) && (defined(NORMALOFFSET) && !defined(DIRLIGHT)))
// based on node ifdef(vec3) DIRLIGHT (type:ifdef(vec3), id:208)
vec3 ifdef5 = normalize((var38 - var33));
#endif
// based on node float  (type:default, id:0)
float var72 = (0.0);
#if ((defined(SPOTLIGHT) && defined(NORMALOFFSET)) || (!defined(SPOTLIGHT) && (defined(NORMALOFFSET) && defined(DIRLIGHT))))
// based on node clamp(float,float,float)  (type:clamp(float,float,float), id:208)
float var69 = clamp((1.0 - dot(var11, ifdef5)), var72, 1.0);
// based on node break vec4 to vec3, float  (type:breakVec4toVec3Float, id:208)
float var100 = var25.w;
// based on node ifdef(vec4) NORMALOFFSET (type:ifdef(vec4), id:208)
vec4 ifdef2 = vec4((var33 + (var11 * (var69 * cNormalOffsetScale.x))), var100);
#endif
#if ((defined(SPOTLIGHT) && !defined(NORMALOFFSET)) || (!defined(SPOTLIGHT) && (!defined(NORMALOFFSET) && defined(DIRLIGHT))))
// based on node ifdef(vec4) NORMALOFFSET (type:ifdef(vec4), id:208)
vec4 ifdef2 = var25;
#endif
#if (defined(SPOTLIGHT) || (!defined(SPOTLIGHT) && defined(DIRLIGHT)))
// based on node ifdef(vec4)  (type:ifdef(vec4), id:208)
vec4 var80 = ifdef2;
// based on node vec4*mat4  (type:vec4*mat4, id:208)
vec4 var61 = (var80 * cLightMatrices[0]);
#endif
#if (!defined(SPOTLIGHT) && !defined(DIRLIGHT))
// based on node vec4(vec3,float)  (type:makeVec4fromVec3Float, id:208)
vec4 var37 = vec4((var33 - var38), 1.0);
#endif
#if (defined(SPOTLIGHT) && !defined(DIRLIGHT))
// based on node ifdef(vec4) SPOTLIGHT (type:ifdef(vec4), id:208)
vec4 ifdef6 = var61;
#endif
#if (!defined(SPOTLIGHT) && !defined(DIRLIGHT))
// based on node ifdef(vec4) SPOTLIGHT (type:ifdef(vec4), id:208)
vec4 ifdef6 = var37;
#endif
#if defined(DIRLIGHT)
// based on node ifdef(vec4) DIRLIGHT (type:ifdef(vec4), id:208)
vec4 ifdef1 = var61;
#endif
#if !defined(DIRLIGHT)
// based on node ifdef(vec4) DIRLIGHT (type:ifdef(vec4), id:208)
vec4 ifdef1 = ifdef6;
#endif
// based on node break vec4 to vec3, float  (type:breakVec4toVec3Float, id:208)
vec3 var30 = ifdef1.xyz;
vVarying16 = var30;
vVarying12 = (var10 - cCameraPos);
vVarying9 = var11;
vVarying22 = cShadowDepthFade.z;
#if ((defined(SPOTLIGHT) && defined(NORMALOFFSET)) || (!defined(SPOTLIGHT) && (defined(NORMALOFFSET) && defined(DIRLIGHT))))
// based on node ifdef(vec4) NORMALOFFSET (type:ifdef(vec4), id:208)
vec4 ifdef8 = vec4((var33 + (var11 * (var69 * cLightOffsetScale.w))), var100);
#endif
#if ((defined(SPOTLIGHT) && !defined(NORMALOFFSET)) || (!defined(SPOTLIGHT) && (!defined(NORMALOFFSET) && defined(DIRLIGHT))))
// based on node ifdef(vec4) NORMALOFFSET (type:ifdef(vec4), id:208)
vec4 ifdef8 = var25;
#endif
#if (defined(SPOTLIGHT) || (!defined(SPOTLIGHT) && defined(DIRLIGHT)))
// based on node vec4*mat4  (type:vec4*mat4, id:208)
vec4 var42 = (ifdef8 * cLightMatrices[3]);
#endif
#if (defined(SPOTLIGHT) && !defined(DIRLIGHT))
// based on node ifdef(vec4) SPOTLIGHT (type:ifdef(vec4), id:208)
vec4 ifdef9 = var42;
#endif
#if (!defined(SPOTLIGHT) && !defined(DIRLIGHT))
// based on node ifdef(vec4) SPOTLIGHT (type:ifdef(vec4), id:208)
vec4 ifdef9 = var37;
#endif
#if defined(DIRLIGHT)
// based on node ifdef(vec4) DIRLIGHT (type:ifdef(vec4), id:208)
vec4 ifdef7 = var42;
#endif
#if !defined(DIRLIGHT)
// based on node ifdef(vec4) DIRLIGHT (type:ifdef(vec4), id:208)
vec4 ifdef7 = ifdef9;
#endif
vVarying21 = ifdef7;
#if ((defined(SPOTLIGHT) && defined(NORMALOFFSET)) || (!defined(SPOTLIGHT) && (defined(NORMALOFFSET) && defined(DIRLIGHT))))
// based on node ifdef(vec4) NORMALOFFSET (type:ifdef(vec4), id:208)
vec4 ifdef11 = vec4((var33 + (var11 * (var69 * cLightOffsetScale.z))), var100);
#endif
#if ((defined(SPOTLIGHT) && !defined(NORMALOFFSET)) || (!defined(SPOTLIGHT) && (!defined(NORMALOFFSET) && defined(DIRLIGHT))))
// based on node ifdef(vec4) NORMALOFFSET (type:ifdef(vec4), id:208)
vec4 ifdef11 = var25;
#endif
#if (defined(SPOTLIGHT) || (!defined(SPOTLIGHT) && defined(DIRLIGHT)))
// based on node vec4*mat4  (type:vec4*mat4, id:208)
vec4 var40 = (ifdef11 * cLightMatrices[2]);
#endif
#if (defined(SPOTLIGHT) && !defined(DIRLIGHT))
// based on node ifdef(vec4) SPOTLIGHT (type:ifdef(vec4), id:208)
vec4 ifdef12 = var40;
#endif
#if (!defined(SPOTLIGHT) && !defined(DIRLIGHT))
// based on node ifdef(vec4) SPOTLIGHT (type:ifdef(vec4), id:208)
vec4 ifdef12 = var37;
#endif
#if defined(DIRLIGHT)
// based on node ifdef(vec4) DIRLIGHT (type:ifdef(vec4), id:208)
vec4 ifdef10 = var40;
#endif
#if !defined(DIRLIGHT)
// based on node ifdef(vec4) DIRLIGHT (type:ifdef(vec4), id:208)
vec4 ifdef10 = ifdef12;
#endif
vVarying20 = ifdef10;
#if ((defined(SPOTLIGHT) && defined(NORMALOFFSET)) || (!defined(SPOTLIGHT) && (defined(NORMALOFFSET) && defined(DIRLIGHT))))
// based on node ifdef(vec4) NORMALOFFSET (type:ifdef(vec4), id:208)
vec4 ifdef14 = vec4((var33 + (var11 * (var69 * cLightOffsetScale.y))), var100);
#endif
#if ((defined(SPOTLIGHT) && !defined(NORMALOFFSET)) || (!defined(SPOTLIGHT) && (!defined(NORMALOFFSET) && defined(DIRLIGHT))))
// based on node ifdef(vec4) NORMALOFFSET (type:ifdef(vec4), id:208)
vec4 ifdef14 = var25;
#endif
#if (defined(SPOTLIGHT) || (!defined(SPOTLIGHT) && defined(DIRLIGHT)))
// based on node lightMatrices[int]  (type:lightMatrices[int], id:208)
mat4 var27 = cLightMatrices[1];
// based on node vec4*mat4  (type:vec4*mat4, id:208)
vec4 var39 = (ifdef14 * var27);
#endif
#if (defined(SPOTLIGHT) && !defined(DIRLIGHT))
// based on node ifdef(vec4) SPOTLIGHT (type:ifdef(vec4), id:208)
vec4 ifdef15 = var39;
#endif
#if (!defined(SPOTLIGHT) && !defined(DIRLIGHT))
// based on node ifdef(vec4) SPOTLIGHT (type:ifdef(vec4), id:208)
vec4 ifdef15 = var37;
#endif
#if defined(DIRLIGHT)
// based on node ifdef(vec4) DIRLIGHT (type:ifdef(vec4), id:208)
vec4 ifdef13 = var39;
#endif
#if !defined(DIRLIGHT)
// based on node ifdef(vec4) DIRLIGHT (type:ifdef(vec4), id:208)
vec4 ifdef13 = ifdef15;
#endif
vVarying19 = ifdef13;
vVarying8 = var10;
// based on node break vec2  (type:breakVec2, id:208)
float var101 = cVSMShadowParams.y;
// based on node float-float  (type:float-float, id:208)
float var87 = (1.0 - var101);
vVarying25 = var87;
vVarying26 = var9.w;
// based on node vec4  (type:default, id:0)
vec4 var70 = vec4(0.0,0.0,0.0,0.0);
vVarying27 = var70.w;
#if ((defined(SPOTLIGHT) && defined(NORMALOFFSET)) || (!defined(SPOTLIGHT) && (defined(NORMALOFFSET) && defined(DIRLIGHT))))
// based on node ifdef(vec4) NORMALOFFSET (type:ifdef(vec4), id:208)
vec4 ifdef17 = vec4((var33 + (var11 * (var69 * cLightOffsetScale.x))), var100);
#endif
#if ((defined(SPOTLIGHT) && !defined(NORMALOFFSET)) || (!defined(SPOTLIGHT) && (!defined(NORMALOFFSET) && defined(DIRLIGHT))))
// based on node ifdef(vec4) NORMALOFFSET (type:ifdef(vec4), id:208)
vec4 ifdef17 = var25;
#endif
#if (defined(SPOTLIGHT) || (!defined(SPOTLIGHT) && defined(DIRLIGHT)))
// based on node vec4*mat4  (type:vec4*mat4, id:208)
vec4 var36 = (ifdef17 * cLightMatrices[(0)]);
#endif
#if (defined(SPOTLIGHT) && !defined(DIRLIGHT))
// based on node ifdef(vec4) SPOTLIGHT (type:ifdef(vec4), id:208)
vec4 ifdef18 = var36;
#endif
#if (!defined(SPOTLIGHT) && !defined(DIRLIGHT))
// based on node ifdef(vec4) SPOTLIGHT (type:ifdef(vec4), id:208)
vec4 ifdef18 = var37;
#endif
#if defined(DIRLIGHT)
// based on node ifdef(vec4) DIRLIGHT (type:ifdef(vec4), id:208)
vec4 ifdef16 = var36;
#endif
#if !defined(DIRLIGHT)
// based on node ifdef(vec4) DIRLIGHT (type:ifdef(vec4), id:208)
vec4 ifdef16 = ifdef18;
#endif
// based on node ifdef(vec4)  (type:ifdef(vec4), id:208)
vec4 var35 = ifdef16;
vVarying18 = var35;
#if (defined(SPOTLIGHT) || (!defined(SPOTLIGHT) && defined(DIRLIGHT)))
// based on node vec4*mat4  (type:vec4*mat4, id:208)
vec4 var60 = (var80 * var27);
#endif
#if (defined(SPOTLIGHT) && !defined(DIRLIGHT))
// based on node ifdef(vec4) SPOTLIGHT (type:ifdef(vec4), id:208)
vec4 ifdef20 = var60;
#endif
#if (!defined(SPOTLIGHT) && !defined(DIRLIGHT))
// based on node ifdef(vec4) SPOTLIGHT (type:ifdef(vec4), id:208)
vec4 ifdef20 = var37;
#endif
#if defined(DIRLIGHT)
// based on node ifdef(vec4) DIRLIGHT (type:ifdef(vec4), id:208)
vec4 ifdef19 = var60;
#endif
#if !defined(DIRLIGHT)
// based on node ifdef(vec4) DIRLIGHT (type:ifdef(vec4), id:208)
vec4 ifdef19 = ifdef20;
#endif
vVarying23 = ifdef19;
vVarying10 = cLightColor.w;
// based on node vec4*mat4  (type:vec4*mat4, id:208)
vec4 var26 = (vec4(var10, 1) * cViewProj);
vVarying13 = dot(var26.zw, cDepthMode.zw);
vVarying31 = cShadowDepthFade.w;
// based on node PortalOrigin  (type:parameter(vec3), id:156)
vec3 var1 = cPortalOrigin;
// based on node vec3-vec3  (type:vec3-vec3, id:76)
vec3 var3 = (cCameraPos - vec3(0.0, 0.0, 0.0));
vVarying6 = dot((var1 - var3), var2);
vVarying14 = cShadowSplits.x;
vVarying32 = var101;
// based on node break vec2  (type:breakVec2, id:208)
float var74 = cVSMShadowParams.x;
vVarying24 = var74;
vVarying7 = step(var72, ((var3 - var1) * var4).z);
vVarying11 = (cAmbientColor.xyz * var70.xyz);
vVarying15 = normalize((cCameraPosPS - var10));
vVarying1 = (var10 - vec3(0.0, 0.0, 0.0));
vVarying2 = var2;
vVarying3 = var3;
vVarying28 = cShadowSplits.y;
vVarying29 = cShadowSplits.z;
vec4 ret =  var26;


    // 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 float cPortalRadius;
uniform vec4 cMatEmissiveColor;
uniform vec4 cMatEnvMapColor;
uniform vec3 cLightDirPS;
uniform vec4 cLightPosPS;
uniform vec4 cShadowCubeAdjust;
uniform vec2 cShadowIntensity;
uniform vec2 cShadowMapInvSize;
uniform vec3 cPortalOrigin;
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
varying mat3 vVarying4;
varying vec3 vVarying15;
varying vec3 vVarying2;
#if ((defined(TRANSLUCENT) && !defined(DIRLIGHT)) || (!defined(TRANSLUCENT) && !defined(DIRLIGHT)))
varying vec3 vVarying8;
#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 vVarying30;
#endif
varying vec3 vVarying3;
varying float vVarying27;
#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 vVarying16;
#endif
varying vec3 vVarying12;
varying vec3 vVarying9;
#if defined(DIRLIGHT)
varying float vVarying22;
#endif
#if (!defined(WEBGL) && !defined(GL_ES))
varying vec4 vVarying21;
varying vec4 vVarying20;
varying vec4 vVarying19;
#endif
varying vec4 vVarying18;
#if (defined(VSM_SHADOW) && ((defined(SPOTLIGHT) && (!defined(SIMPLE_SHADOW) && !defined(PCF_SHADOW))) || (!defined(SPOTLIGHT) && (!defined(SIMPLE_SHADOW) && !defined(PCF_SHADOW)))))
varying float vVarying25;
#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 vVarying17;
#endif
varying float vVarying26;
varying vec3 vVarying5;
#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 vVarying23;
#endif
varying float vVarying10;
#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 vVarying13;
#endif
#if defined(DIRLIGHT)
varying float vVarying31;
#endif
varying float vVarying6;
#if (!defined(WEBGL) && !defined(GL_ES))
varying float vVarying14;
#endif
#if (defined(VSM_SHADOW) && ((defined(SPOTLIGHT) && (!defined(SIMPLE_SHADOW) && !defined(PCF_SHADOW))) || (!defined(SPOTLIGHT) && (!defined(SIMPLE_SHADOW) && !defined(PCF_SHADOW)))))
varying float vVarying32;
varying float vVarying24;
#endif
varying float vVarying7;
varying vec3 vVarying11;
varying vec3 vVarying1;
#if (!defined(WEBGL) && !defined(GL_ES))
varying float vVarying28;
varying float vVarying29;

#endif


void PS()
{
// based on node float  (type:default, id:0)
float var71 = (0.0);
// based on node per pixel vec3  (type:perPixelVec3, id:150)
vec3 var7 = vVarying1;
// based on node PortalOrigin  (type:parameter(vec3), id:156)
vec3 var82 = cPortalOrigin;
// based on node step(float,float)  (type:step(float,float), id:202)
float var5 = step(var71, ((var7 - var82) * vVarying4).z);
// based on node get Varying3  (type:getVarying, id:0)
vec3 var18 = vVarying3;
// based on node normalize(vec3)  (type:normalize(vec3), id:130)
vec3 var6 = normalize((var7 - var18));
// based on node step(float,float)  (type:step(float,float), id:196)
float var8 = step(cPortalRadius, distance(var82, ((var6 * (vVarying6 / dot(vVarying2, var6))) + var18)));
if (!(bool(mix(min(var5, var8), max(var5, (1.0 - var8)), vVarying7)))) discard;
// based on node get Varying9  (type:getVarying, id:0)
vec3 var21 = vVarying9;
#if ((defined(TRANSLUCENT) && !defined(DIRLIGHT)) || (!defined(TRANSLUCENT) && !defined(DIRLIGHT)))
// based on node per pixel vec4  (type:perPixelVec4, id:208)
vec4 var14 = cLightPosPS;
// based on node vec3*float  (type:vec3*float, id:208)
vec3 var15 = ((var14.xyz - vVarying8) * var14.w);
// based on node length(vec3)  (type:length(vec3), id:208)
float var16 = length(var15);
#endif
#if defined(DIRLIGHT)
// based on node ifdef(vec3) DIRLIGHT (type:ifdef(vec3), id:208)
vec3 ifdef1 = cLightDirPS;
#endif
#if !defined(DIRLIGHT)
// based on node ifdef(vec3) DIRLIGHT (type:ifdef(vec3), id:208)
vec3 ifdef1 = (var15 / var16);
#endif
// based on node ifdef(vec3)  (type:ifdef(vec3), id:208)
vec3 var17 = ifdef1;
// based on node normalize(vec3)  (type:normalize(vec3), id:208)
vec3 var12 = normalize(var21);
// based on node per pixel vec2  (type:perPixelVec2, id:208)
vec2 var45 = cShadowIntensity;
// based on node break vec2  (type:breakVec2, id:208)
float var90 = var45.y;
// based on node break vec2  (type:breakVec2, id:208)
float var43 = var45.x;
// based on node get Varying18  (type:getVarying, id:0)
vec4 var29 = vVarying18;
#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:208)
float var28 = vVarying13;
#endif
#if (defined(WEBGL) && !defined(GL_ES))
// based on node ifdef(vec4) WEBGL (type:ifdef(vec4), id:208)
vec4 ifdef6 = var29;
#endif
#if (!defined(WEBGL) && !defined(GL_ES))
// based on node ifdef(vec4) WEBGL (type:ifdef(vec4), id:208)
vec4 ifdef6 = (((var28 < vVarying14))?(var29):((((var28 < vVarying28))?(vVarying19):((((var28 < vVarying29))?(vVarying20):(vVarying21))))));
#endif
#if defined(GL_ES)
// based on node ifdef(vec4) GL_ES (type:ifdef(vec4), id:208)
vec4 ifdef5 = var29;
#endif
#if !defined(GL_ES)
// based on node ifdef(vec4) GL_ES (type:ifdef(vec4), id:208)
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:208)
vec4 var50 = 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:208)
float var44 = var50.x;
// based on node break vec4  (type:breakVec4, id:208)
float var91 = var50.y;
// based on node break vec4  (type:breakVec4, id:208)
float var92 = var50.z;
// based on node break vec4  (type:breakVec4, id:208)
float var93 = var50.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:208)
vec2 var47 = cShadowMapInvSize;
#endif
#if (!defined(SIMPLE_SHADOW) && (defined(POINTLIGHT) && (defined(PCF_SHADOW) && defined(DIRLIGHT))))
// based on node ifdef(vec2) POINTLIGHT (type:ifdef(vec2), id:208)
vec2 ifdef8 = (var47 * var50.w);
#endif
#if (!defined(SIMPLE_SHADOW) && (!defined(POINTLIGHT) && (defined(PCF_SHADOW) && defined(DIRLIGHT))))
// based on node ifdef(vec2) POINTLIGHT (type:ifdef(vec2), id:208)
vec2 ifdef8 = var47;
#endif
#if (!defined(SIMPLE_SHADOW) && (defined(PCF_SHADOW) && defined(DIRLIGHT)))
// based on node ifdef(vec2)  (type:ifdef(vec2), id:208)
vec2 var46 = ifdef8;
// based on node float+float  (type:float+float, id:208)
float var48 = (var44 + var46.x);
// based on node float+float  (type:float+float, id:208)
float var49 = (var46.y + var91);
#endif
#if (defined(VSM_SHADOW) && (!defined(SIMPLE_SHADOW) && (!defined(PCF_SHADOW) && defined(DIRLIGHT))))
// based on node float/float  (type:float/float, id:208)
float var52 = (var92 / var93);
// based on node sampleVSMShadow  (type:sampleVSMShadow(shadowMap,vec2), id:208)
vec2 var51 = texture2D(sShadowMap, (vec2(var44, var91) / var93)).rg;
// based on node break vec2  (type:breakVec2, id:208)
float var73 = var51.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 Varying24  (type:getVarying, id:0)
float var83 = vVarying24;
#endif
#if (defined(VSM_SHADOW) && (!defined(SIMPLE_SHADOW) && (!defined(PCF_SHADOW) && defined(DIRLIGHT))))
// based on node max(float,float)  (type:max(float,float), id:208)
float var76 = max((var51.y - (var73 * var73)), var83);
// based on node float-float  (type:float-float, id:208)
float var77 = (var52 - var73);
#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 Varying32  (type:getVarying, id:0)
float var81 = vVarying32;
// based on node get Varying25  (type:getVarying, id:0)
float var41 = vVarying25;
#endif
#if (defined(VSM_SHADOW) && (!defined(SIMPLE_SHADOW) && (!defined(PCF_SHADOW) && defined(DIRLIGHT))))
// based on node ifdef(float) VSM_SHADOW (type:ifdef(float), id:208)
float ifdef9 = max(float((var52 <= var73)), clamp((((var76 / (var76 + (var77 * var77))) - var81) / var41), var71, 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:208)
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:208)
float ifdef7 = ((sampleShadow(sShadowMap, vec4(var44, var91, var92, var93)) + sampleShadow(sShadowMap, vec4(var48, var91, var92, var93))) + (sampleShadow(sShadowMap, vec4(var44, var49, var92, var93)) + sampleShadow(sShadowMap, vec4(var48, var49, var92, var93))));
#endif
#if (!defined(SIMPLE_SHADOW) && (!defined(PCF_SHADOW) && defined(DIRLIGHT)))
// based on node ifdef(float) PCF_SHADOW (type:ifdef(float), id:208)
float ifdef7 = ifdef9;
#endif
#if (defined(SIMPLE_SHADOW) && defined(DIRLIGHT))
// based on node ifdef(float) SIMPLE_SHADOW (type:ifdef(float), id:208)
float ifdef4 = sampleShadow(sShadowMap, var50);
#endif
#if (!defined(SIMPLE_SHADOW) && defined(DIRLIGHT))
// based on node ifdef(float) SIMPLE_SHADOW (type:ifdef(float), id:208)
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:208)
vec4 var57 = vVarying23;
#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:208)
float var53 = var57.x;
// based on node break vec4  (type:breakVec4, id:208)
float var94 = var57.y;
// based on node break vec4  (type:breakVec4, id:208)
float var95 = var57.z;
// based on node break vec4  (type:breakVec4, id:208)
float var96 = var57.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:208)
vec2 ifdef13 = (var47 * var57.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:208)
vec2 ifdef13 = var47;
#endif
#if (defined(SPOTLIGHT) && (!defined(SIMPLE_SHADOW) && (defined(PCF_SHADOW) && !defined(DIRLIGHT))))
// based on node ifdef(vec2)  (type:ifdef(vec2), id:208)
vec2 var54 = ifdef13;
// based on node float+float  (type:float+float, id:208)
float var55 = (var53 + var54.x);
// based on node float+float  (type:float+float, id:208)
float var56 = (var54.y + var94);
#endif
#if (defined(VSM_SHADOW) && (defined(SPOTLIGHT) && (!defined(SIMPLE_SHADOW) && (!defined(PCF_SHADOW) && !defined(DIRLIGHT)))))
// based on node float/float  (type:float/float, id:208)
float var59 = (var95 / var96);
// based on node sampleVSMShadow  (type:sampleVSMShadow(shadowMap,vec2), id:208)
vec2 var58 = texture2D(sShadowMap, (vec2(var53, var94) / var96)).rg;
// based on node break vec2  (type:breakVec2, id:208)
float var75 = var58.x;
// based on node max(float,float)  (type:max(float,float), id:208)
float var78 = max((var58.y - (var75 * var75)), var83);
// based on node float-float  (type:float-float, id:208)
float var79 = (var59 - var75);
// based on node ifdef(float) VSM_SHADOW (type:ifdef(float), id:208)
float ifdef14 = max(float((var59 <= var75)), clamp((((var78 / (var78 + (var79 * var79))) - var81) / var41), var71, 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:208)
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:208)
float ifdef12 = ((sampleShadow(sShadowMap, vec4(var53, var94, var95, var96)) + sampleShadow(sShadowMap, vec4(var55, var94, var95, var96))) + (sampleShadow(sShadowMap, vec4(var53, var56, var95, var96)) + sampleShadow(sShadowMap, vec4(var55, var56, var95, var96))));
#endif
#if (defined(SPOTLIGHT) && (!defined(SIMPLE_SHADOW) && (!defined(PCF_SHADOW) && !defined(DIRLIGHT))))
// based on node ifdef(float) PCF_SHADOW (type:ifdef(float), id:208)
float ifdef12 = ifdef14;
#endif
#if (defined(SPOTLIGHT) && (defined(SIMPLE_SHADOW) && !defined(DIRLIGHT)))
// based on node ifdef(float) SIMPLE_SHADOW (type:ifdef(float), id:208)
float ifdef11 = sampleShadow(sShadowMap, var57);
#endif
#if (defined(SPOTLIGHT) && (!defined(SIMPLE_SHADOW) && !defined(DIRLIGHT)))
// based on node ifdef(float) SIMPLE_SHADOW (type:ifdef(float), id:208)
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 Varying16  (type:getVarying, id:0)
vec3 var20 = vVarying16;
// based on node break vec4 to vec3, float  (type:breakVec4toVec3Float, id:208)
vec3 var31 = textureCube(sFaceSelectCubeMap, var20).xyz;
// based on node textureCube(samplerCube,vec3)  (type:textureCube(samplerCube,vec3), id:208)
vec4 var32 = textureCube(sIndirectionCubeMap, (var20 + ((var31 * var20) * 0.00390625)));
// based on node per pixel vec4  (type:perPixelVec4, id:208)
vec4 var34 = cShadowCubeAdjust;
// based on node break vec4 to vec2, vec2  (type:breakVec4toVec2Vec2, id:208)
vec2 var89 = var34.zw;
// based on node break vec4 to vec2, vec2  (type:breakVec4toVec2Vec2, id:208)
vec2 var88 = var32.zw;
// based on node per pixel vec4  (type:perPixelVec4, id:208)
vec4 var66 = vec4(((var32.xy * var34.xy) + vec2((var89.x + (var88.x * 0.5)), (var89.y + var88.y))), vec2((vVarying17 + (vVarying30 / abs(dot(var31, var20)))), 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:208)
float var62 = var66.x;
// based on node break vec4  (type:breakVec4, id:208)
float var97 = var66.y;
// based on node break vec4  (type:breakVec4, id:208)
float var98 = var66.z;
// based on node break vec4  (type:breakVec4, id:208)
float var99 = var66.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:208)
vec2 ifdef17 = (var47 * var66.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:208)
vec2 ifdef17 = var47;
#endif
#if (!defined(SPOTLIGHT) && (!defined(SIMPLE_SHADOW) && (defined(PCF_SHADOW) && !defined(DIRLIGHT))))
// based on node ifdef(vec2)  (type:ifdef(vec2), id:208)
vec2 var63 = ifdef17;
// based on node float+float  (type:float+float, id:208)
float var64 = (var62 + var63.x);
// based on node float+float  (type:float+float, id:208)
float var65 = (var63.y + var97);
#endif
#if (defined(VSM_SHADOW) && (!defined(SPOTLIGHT) && (!defined(SIMPLE_SHADOW) && (!defined(PCF_SHADOW) && !defined(DIRLIGHT)))))
// based on node float/float  (type:float/float, id:208)
float var68 = (var98 / var99);
// based on node sampleVSMShadow  (type:sampleVSMShadow(shadowMap,vec2), id:208)
vec2 var67 = texture2D(sShadowMap, (vec2(var62, var97) / var99)).rg;
// based on node break vec2  (type:breakVec2, id:208)
float var84 = var67.x;
// based on node max(float,float)  (type:max(float,float), id:208)
float var85 = max((var67.y - (var84 * var84)), var83);
// based on node float-float  (type:float-float, id:208)
float var86 = (var68 - var84);
// based on node ifdef(float) VSM_SHADOW (type:ifdef(float), id:208)
float ifdef18 = max(float((var68 <= var84)), clamp((((var85 / (var85 + (var86 * var86))) - var81) / var41), var71, 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:208)
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:208)
float ifdef16 = ((sampleShadow(sShadowMap, vec4(var62, var97, var98, var99)) + sampleShadow(sShadowMap, vec4(var64, var97, var98, var99))) + (sampleShadow(sShadowMap, vec4(var62, var65, var98, var99)) + sampleShadow(sShadowMap, vec4(var64, var65, var98, var99))));
#endif
#if (!defined(SPOTLIGHT) && (!defined(SIMPLE_SHADOW) && (!defined(PCF_SHADOW) && !defined(DIRLIGHT))))
// based on node ifdef(float) PCF_SHADOW (type:ifdef(float), id:208)
float ifdef16 = ifdef18;
#endif
#if (!defined(SPOTLIGHT) && (defined(SIMPLE_SHADOW) && !defined(DIRLIGHT)))
// based on node ifdef(float) SIMPLE_SHADOW (type:ifdef(float), id:208)
float ifdef15 = sampleShadow(sShadowMap, var66);
#endif
#if (!defined(SPOTLIGHT) && (!defined(SIMPLE_SHADOW) && !defined(DIRLIGHT)))
// based on node ifdef(float) SIMPLE_SHADOW (type:ifdef(float), id:208)
float ifdef15 = ifdef16;
#endif
#if (defined(SPOTLIGHT) && !defined(DIRLIGHT))
// based on node ifdef(float) SPOTLIGHT (type:ifdef(float), id:208)
float ifdef10 = (var90 + (var43 * ifdef11));
#endif
#if (!defined(SPOTLIGHT) && !defined(DIRLIGHT))
// based on node ifdef(float) SPOTLIGHT (type:ifdef(float), id:208)
float ifdef10 = (var90 + (var43 * ifdef15));
#endif
#if defined(DIRLIGHT)
// based on node ifdef(float) DIRLIGHT (type:ifdef(float), id:208)
float ifdef3 = min(((var90 + (var43 * ifdef4)) + max(((var28 - vVarying22) * vVarying31), var71)), 1.0);
#endif
#if !defined(DIRLIGHT)
// based on node ifdef(float) DIRLIGHT (type:ifdef(float), id:208)
float ifdef3 = ifdef10;
#endif
#if defined(SHADOW)
// based on node ifdef(float) SHADOW (type:ifdef(float), id:208)
float ifdef2 = ifdef3;
#endif
#if !defined(SHADOW)
// based on node ifdef(float) SHADOW (type:ifdef(float), id:208)
float ifdef2 = 1.0;
#endif
// based on node dot(vec3,vec3)  (type:dot(vec3,vec3), id:208)
float var23 = dot(var12, var17);
#if defined(TRANSLUCENT)
// based on node abs(float)  (type:abs(float), id:208)
float var24 = abs(var23);
#endif
#if !defined(TRANSLUCENT)
// based on node max(float,float)  (type:max(float,float), id:208)
float var22 = max(var23, 0.0);
#endif
#if (defined(TRANSLUCENT) && defined(DIRLIGHT))
// based on node ifdef(float) TRANSLUCENT (type:ifdef(float), id:208)
float ifdef20 = var24;
#endif
#if (!defined(TRANSLUCENT) && defined(DIRLIGHT))
// based on node ifdef(float) TRANSLUCENT (type:ifdef(float), id:208)
float ifdef20 = var22;
#endif
#if ((defined(TRANSLUCENT) && !defined(DIRLIGHT)) || (!defined(TRANSLUCENT) && !defined(DIRLIGHT)))
// based on node break vec4  (type:breakVec4, id:208)
float var19 = texture2D(sLightRampMap, vec2(var16, 0.0)).x;
#endif
#if (defined(TRANSLUCENT) && !defined(DIRLIGHT))
// based on node ifdef(float) TRANSLUCENT (type:ifdef(float), id:208)
float ifdef21 = (var24 * var19);
#endif
#if (!defined(TRANSLUCENT) && !defined(DIRLIGHT))
// based on node ifdef(float) TRANSLUCENT (type:ifdef(float), id:208)
float ifdef21 = (var22 * var19);
#endif
#if defined(DIRLIGHT)
// based on node ifdef(float) DIRLIGHT (type:ifdef(float), id:208)
float ifdef19 = ifdef20;
#endif
#if !defined(DIRLIGHT)
// based on node ifdef(float) DIRLIGHT (type:ifdef(float), id:208)
float ifdef19 = ifdef21;
#endif
gl_FragColor = (vec4((vVarying11 + ((cMatEnvMapColor * textureCube(sZoneCubeMap, reflect(vVarying12, var21))) + cMatEmissiveColor).xyz), vVarying27) + ((cMatDiffColor + vec4((vVarying5 * (pow(max(dot(normalize((vVarying15 + var17)), var12), var71), vVarying26) * vVarying10)), var71)) * (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

attribute vec4 iPos;
#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 vec3 iNormal;
uniform vec3 cPortalOrigin;
uniform vec3 cPortalForward;
uniform vec4 cMatSpecColor;
uniform mat4 cModel;
uniform vec4 cLightColor;
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 vec4 vVarying17;
varying vec3 vVarying5;
varying mat3 vVarying4;
varying vec4 vVarying16;
varying float vVarying12;
varying vec3 vVarying9;
varying float vVarying22;
varying vec4 vVarying21;
varying float vVarying20;
varying vec4 vVarying19;
varying vec3 vVarying8;
varying float vVarying25;
varying float vVarying26;
varying float vVarying27;
varying vec4 vVarying18;
varying float vVarying10;
varying vec3 vVarying13;
varying float vVarying23;
varying float vVarying6;
varying vec3 vVarying14;
varying float vVarying24;
varying float vVarying7;
varying float vVarying11;
varying float vVarying15;
varying vec3 vVarying1;
varying vec3 vVarying2;
varying vec3 vVarying3;
varying float vVarying28;
varying float vVarying29;

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 var13 = ifdef3;
// based on node vec4*mat4x3  (type:vec4*mat4x3, id:8)
vec3 var10 = ((iPos * var13)).xyz;
// based on node vec4(vec3,float)  (type:makeVec4fromVec3Float, id:208)
vec4 var24 = vec4(var10, 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:208)
vec3 var32 = var24.xyz;
#endif
// based on node vec3*mat3  (type:vec3*mat3, id:9)
vec3 var11 = (iNormal * GetNormalMatrix(var13));
#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:208)
vec3 var37 = 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:208)
vec3 ifdef5 = cLightDir;
#endif
#if (defined(SPOTLIGHT) && (defined(NORMALOFFSET) && !defined(DIRLIGHT)))
// based on node ifdef(vec3) DIRLIGHT (type:ifdef(vec3), id:208)
vec3 ifdef5 = normalize((var37 - var32));
#endif
// based on node float  (type:default, id:0)
float var70 = (0.0);
#if ((defined(SPOTLIGHT) && defined(NORMALOFFSET)) || (!defined(SPOTLIGHT) && (defined(NORMALOFFSET) && defined(DIRLIGHT))))
// based on node clamp(float,float,float)  (type:clamp(float,float,float), id:208)
float var67 = clamp((1.0 - dot(var11, ifdef5)), var70, 1.0);
// based on node break vec4 to vec3, float  (type:breakVec4toVec3Float, id:208)
float var98 = var24.w;
// based on node ifdef(vec4) NORMALOFFSET (type:ifdef(vec4), id:208)
vec4 ifdef2 = vec4((var32 + (var11 * (var67 * cLightOffsetScale.y))), var98);
#endif
#if ((defined(SPOTLIGHT) && !defined(NORMALOFFSET)) || (!defined(SPOTLIGHT) && (!defined(NORMALOFFSET) && defined(DIRLIGHT))))
// based on node ifdef(vec4) NORMALOFFSET (type:ifdef(vec4), id:208)
vec4 ifdef2 = var24;
#endif
#if (defined(SPOTLIGHT) || (!defined(SPOTLIGHT) && defined(DIRLIGHT)))
// based on node lightMatrices[int]  (type:lightMatrices[int], id:208)
mat4 var27 = cLightMatrices[1];
// based on node vec4*mat4  (type:vec4*mat4, id:208)
vec4 var38 = (ifdef2 * var27);
#endif
#if (!defined(SPOTLIGHT) && !defined(DIRLIGHT))
// based on node vec4(vec3,float)  (type:makeVec4fromVec3Float, id:208)
vec4 var36 = vec4((var32 - var37), 1.0);
#endif
#if (defined(SPOTLIGHT) && !defined(DIRLIGHT))
// based on node ifdef(vec4) SPOTLIGHT (type:ifdef(vec4), id:208)
vec4 ifdef6 = var38;
#endif
#if (!defined(SPOTLIGHT) && !defined(DIRLIGHT))
// based on node ifdef(vec4) SPOTLIGHT (type:ifdef(vec4), id:208)
vec4 ifdef6 = var36;
#endif
#if defined(DIRLIGHT)
// based on node ifdef(vec4) DIRLIGHT (type:ifdef(vec4), id:208)
vec4 ifdef1 = var38;
#endif
#if !defined(DIRLIGHT)
// based on node ifdef(vec4) DIRLIGHT (type:ifdef(vec4), id:208)
vec4 ifdef1 = ifdef6;
#endif
vVarying17 = ifdef1;
// based on node MatSpecColor  (type:parameter(color), id:232)
vec4 var9 = cMatSpecColor;
vVarying5 = var9.xyz;
// based on node normalize(vec3)  (type:normalize(vec3), id:31)
vec3 var2 = normalize(normalize(cPortalForward));
// based on node cross(vec3,vec3)  (type:cross(vec3,vec3), id:33)
vec3 var0 = cross(var2, normalize(vec3(1.0, 0.0, 0.0)));
// based on node mat3(vec3,vec3,vec3)  (type:mat3(vec3,vec3,vec3), id:70)
mat3 var4 = mat3(normalize(cross(var0, var2)), normalize(var0), var2);
vVarying4 = var4;
#if ((defined(SPOTLIGHT) && defined(NORMALOFFSET)) || (!defined(SPOTLIGHT) && (defined(NORMALOFFSET) && defined(DIRLIGHT))))
// based on node ifdef(vec4) NORMALOFFSET (type:ifdef(vec4), id:208)
vec4 ifdef8 = vec4((var32 + (var11 * (var67 * cLightOffsetScale.x))), var98);
#endif
#if ((defined(SPOTLIGHT) && !defined(NORMALOFFSET)) || (!defined(SPOTLIGHT) && (!defined(NORMALOFFSET) && defined(DIRLIGHT))))
// based on node ifdef(vec4) NORMALOFFSET (type:ifdef(vec4), id:208)
vec4 ifdef8 = var24;
#endif
#if (defined(SPOTLIGHT) || (!defined(SPOTLIGHT) && defined(DIRLIGHT)))
// based on node vec4*mat4  (type:vec4*mat4, id:208)
vec4 var35 = (ifdef8 * cLightMatrices[(0)]);
#endif
#if (defined(SPOTLIGHT) && !defined(DIRLIGHT))
// based on node ifdef(vec4) SPOTLIGHT (type:ifdef(vec4), id:208)
vec4 ifdef9 = var35;
#endif
#if (!defined(SPOTLIGHT) && !defined(DIRLIGHT))
// based on node ifdef(vec4) SPOTLIGHT (type:ifdef(vec4), id:208)
vec4 ifdef9 = var36;
#endif
#if defined(DIRLIGHT)
// based on node ifdef(vec4) DIRLIGHT (type:ifdef(vec4), id:208)
vec4 ifdef7 = var35;
#endif
#if !defined(DIRLIGHT)
// based on node ifdef(vec4) DIRLIGHT (type:ifdef(vec4), id:208)
vec4 ifdef7 = ifdef9;
#endif
// based on node ifdef(vec4)  (type:ifdef(vec4), id:208)
vec4 var34 = ifdef7;
vVarying16 = var34;
vVarying12 = cShadowSplits.x;
vVarying9 = var11;
// based on node break vec2  (type:breakVec2, id:208)
float var72 = cVSMShadowParams.x;
vVarying22 = var72;
#if ((defined(SPOTLIGHT) && defined(NORMALOFFSET)) || (!defined(SPOTLIGHT) && (defined(NORMALOFFSET) && defined(DIRLIGHT))))
// based on node ifdef(vec4) NORMALOFFSET (type:ifdef(vec4), id:208)
vec4 ifdef11 = vec4((var32 + (var11 * (var67 * cNormalOffsetScale.x))), var98);
#endif
#if ((defined(SPOTLIGHT) && !defined(NORMALOFFSET)) || (!defined(SPOTLIGHT) && (!defined(NORMALOFFSET) && defined(DIRLIGHT))))
// based on node ifdef(vec4) NORMALOFFSET (type:ifdef(vec4), id:208)
vec4 ifdef11 = var24;
#endif
#if (defined(SPOTLIGHT) || (!defined(SPOTLIGHT) && defined(DIRLIGHT)))
// based on node ifdef(vec4)  (type:ifdef(vec4), id:208)
vec4 var78 = ifdef11;
// based on node vec4*mat4  (type:vec4*mat4, id:208)
vec4 var58 = (var78 * var27);
#endif
#if (defined(SPOTLIGHT) && !defined(DIRLIGHT))
// based on node ifdef(vec4) SPOTLIGHT (type:ifdef(vec4), id:208)
vec4 ifdef12 = var58;
#endif
#if (!defined(SPOTLIGHT) && !defined(DIRLIGHT))
// based on node ifdef(vec4) SPOTLIGHT (type:ifdef(vec4), id:208)
vec4 ifdef12 = var36;
#endif
#if defined(DIRLIGHT)
// based on node ifdef(vec4) DIRLIGHT (type:ifdef(vec4), id:208)
vec4 ifdef10 = var58;
#endif
#if !defined(DIRLIGHT)
// based on node ifdef(vec4) DIRLIGHT (type:ifdef(vec4), id:208)
vec4 ifdef10 = ifdef12;
#endif
vVarying21 = ifdef10;
vVarying20 = cShadowDepthFade.z;
#if ((defined(SPOTLIGHT) && defined(NORMALOFFSET)) || (!defined(SPOTLIGHT) && (defined(NORMALOFFSET) && defined(DIRLIGHT))))
// based on node ifdef(vec4) NORMALOFFSET (type:ifdef(vec4), id:208)
vec4 ifdef14 = vec4((var32 + (var11 * (var67 * cLightOffsetScale.w))), var98);
#endif
#if ((defined(SPOTLIGHT) && !defined(NORMALOFFSET)) || (!defined(SPOTLIGHT) && (!defined(NORMALOFFSET) && defined(DIRLIGHT))))
// based on node ifdef(vec4) NORMALOFFSET (type:ifdef(vec4), id:208)
vec4 ifdef14 = var24;
#endif
#if (defined(SPOTLIGHT) || (!defined(SPOTLIGHT) && defined(DIRLIGHT)))
// based on node vec4*mat4  (type:vec4*mat4, id:208)
vec4 var40 = (ifdef14 * cLightMatrices[3]);
#endif
#if (defined(SPOTLIGHT) && !defined(DIRLIGHT))
// based on node ifdef(vec4) SPOTLIGHT (type:ifdef(vec4), id:208)
vec4 ifdef15 = var40;
#endif
#if (!defined(SPOTLIGHT) && !defined(DIRLIGHT))
// based on node ifdef(vec4) SPOTLIGHT (type:ifdef(vec4), id:208)
vec4 ifdef15 = var36;
#endif
#if defined(DIRLIGHT)
// based on node ifdef(vec4) DIRLIGHT (type:ifdef(vec4), id:208)
vec4 ifdef13 = var40;
#endif
#if !defined(DIRLIGHT)
// based on node ifdef(vec4) DIRLIGHT (type:ifdef(vec4), id:208)
vec4 ifdef13 = ifdef15;
#endif
vVarying19 = ifdef13;
vVarying8 = var10;
vVarying25 = cShadowSplits.y;
vVarying26 = cShadowSplits.z;
vVarying27 = cShadowDepthFade.y;
#if ((defined(SPOTLIGHT) && defined(NORMALOFFSET)) || (!defined(SPOTLIGHT) && (defined(NORMALOFFSET) && defined(DIRLIGHT))))
// based on node ifdef(vec4) NORMALOFFSET (type:ifdef(vec4), id:208)
vec4 ifdef17 = vec4((var32 + (var11 * (var67 * cLightOffsetScale.z))), var98);
#endif
#if ((defined(SPOTLIGHT) && !defined(NORMALOFFSET)) || (!defined(SPOTLIGHT) && (!defined(NORMALOFFSET) && defined(DIRLIGHT))))
// based on node ifdef(vec4) NORMALOFFSET (type:ifdef(vec4), id:208)
vec4 ifdef17 = var24;
#endif
#if (defined(SPOTLIGHT) || (!defined(SPOTLIGHT) && defined(DIRLIGHT)))
// based on node vec4*mat4  (type:vec4*mat4, id:208)
vec4 var39 = (ifdef17 * cLightMatrices[2]);
#endif
#if (defined(SPOTLIGHT) && !defined(DIRLIGHT))
// based on node ifdef(vec4) SPOTLIGHT (type:ifdef(vec4), id:208)
vec4 ifdef18 = var39;
#endif
#if (!defined(SPOTLIGHT) && !defined(DIRLIGHT))
// based on node ifdef(vec4) SPOTLIGHT (type:ifdef(vec4), id:208)
vec4 ifdef18 = var36;
#endif
#if defined(DIRLIGHT)
// based on node ifdef(vec4) DIRLIGHT (type:ifdef(vec4), id:208)
vec4 ifdef16 = var39;
#endif
#if !defined(DIRLIGHT)
// based on node ifdef(vec4) DIRLIGHT (type:ifdef(vec4), id:208)
vec4 ifdef16 = ifdef18;
#endif
vVarying18 = ifdef16;
vVarying10 = cLightColor.w;
vVarying13 = normalize((cCameraPosPS - var10));
// based on node break vec2  (type:breakVec2, id:208)
float var99 = cVSMShadowParams.y;
// based on node float-float  (type:float-float, id:208)
float var84 = (1.0 - var99);
vVarying23 = var84;
// based on node PortalOrigin  (type:parameter(vec3), id:156)
vec3 var1 = cPortalOrigin;
// based on node vec3-vec3  (type:vec3-vec3, id:76)
vec3 var3 = (cCameraPos - vec3(0.0, 0.0, 0.0));
vVarying6 = dot((var1 - var3), var2);
#if (defined(SPOTLIGHT) || (!defined(SPOTLIGHT) && defined(DIRLIGHT)))
// based on node vec4*mat4  (type:vec4*mat4, id:208)
vec4 var59 = (var78 * cLightMatrices[0]);
#endif
#if (defined(SPOTLIGHT) && !defined(DIRLIGHT))
// based on node ifdef(vec4) SPOTLIGHT (type:ifdef(vec4), id:208)
vec4 ifdef20 = var59;
#endif
#if (!defined(SPOTLIGHT) && !defined(DIRLIGHT))
// based on node ifdef(vec4) SPOTLIGHT (type:ifdef(vec4), id:208)
vec4 ifdef20 = var36;
#endif
#if defined(DIRLIGHT)
// based on node ifdef(vec4) DIRLIGHT (type:ifdef(vec4), id:208)
vec4 ifdef19 = var59;
#endif
#if !defined(DIRLIGHT)
// based on node ifdef(vec4) DIRLIGHT (type:ifdef(vec4), id:208)
vec4 ifdef19 = ifdef20;
#endif
// based on node break vec4 to vec3, float  (type:breakVec4toVec3Float, id:208)
vec3 var29 = ifdef19.xyz;
vVarying14 = var29;
vVarying24 = var9.w;
vVarying7 = step(var70, ((var3 - var1) * var4).z);
// based on node vec4*mat4  (type:vec4*mat4, id:208)
vec4 var25 = (vec4(var10, 1) * cViewProj);
vVarying11 = dot(var25.zw, cDepthMode.zw);
vVarying15 = cShadowDepthFade.x;
vVarying1 = (var10 - vec3(0.0, 0.0, 0.0));
vVarying2 = var2;
vVarying3 = var3;
vVarying28 = cShadowDepthFade.w;
vVarying29 = var99;
vec4 ret =  var25;


    // 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 float cPortalRadius;
uniform vec3 cLightDirPS;
uniform vec4 cLightPosPS;
uniform vec4 cShadowCubeAdjust;
uniform vec2 cShadowIntensity;
uniform vec2 cShadowMapInvSize;
uniform vec3 cPortalOrigin;
#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 mat3 vVarying4;
#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 vVarying15;
#endif
varying vec3 vVarying2;
#if ((defined(TRANSLUCENT) && !defined(DIRLIGHT)) || (!defined(TRANSLUCENT) && !defined(DIRLIGHT)))
varying vec3 vVarying8;
#endif
varying vec3 vVarying3;
#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 vVarying27;
#endif
varying vec4 vVarying16;
#if (!defined(WEBGL) && !defined(GL_ES))
varying float vVarying12;
#endif
varying vec3 vVarying9;
#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 vVarying21;
#endif
#if defined(DIRLIGHT)
varying float vVarying20;
#endif
#if (!defined(WEBGL) && !defined(GL_ES))
varying vec4 vVarying19;
varying vec4 vVarying18;
varying float vVarying25;
varying vec4 vVarying17;
varying float vVarying26;
#endif
#if (defined(VSM_SHADOW) && ((defined(SPOTLIGHT) && (!defined(SIMPLE_SHADOW) && !defined(PCF_SHADOW))) || (!defined(SPOTLIGHT) && (!defined(SIMPLE_SHADOW) && !defined(PCF_SHADOW)))))
varying float vVarying22;
#endif
varying vec3 vVarying5;
varying float vVarying10;
varying vec3 vVarying13;
#if (defined(VSM_SHADOW) && ((defined(SPOTLIGHT) && (!defined(SIMPLE_SHADOW) && !defined(PCF_SHADOW))) || (!defined(SPOTLIGHT) && (!defined(SIMPLE_SHADOW) && !defined(PCF_SHADOW)))))
varying float vVarying23;
#endif
varying float vVarying6;
#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 vVarying14;
#endif
varying float vVarying24;
varying float vVarying7;
#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 vVarying11;
#endif
varying vec3 vVarying1;
#if defined(DIRLIGHT)
varying float vVarying28;
#endif
#if (defined(VSM_SHADOW) && ((defined(SPOTLIGHT) && (!defined(SIMPLE_SHADOW) && !defined(PCF_SHADOW))) || (!defined(SPOTLIGHT) && (!defined(SIMPLE_SHADOW) && !defined(PCF_SHADOW)))))
varying float vVarying29;

#endif


void PS()
{
// based on node float  (type:default, id:0)
float var26 = (0.0);
// based on node per pixel vec3  (type:perPixelVec3, id:150)
vec3 var7 = vVarying1;
// based on node PortalOrigin  (type:parameter(vec3), id:156)
vec3 var80 = cPortalOrigin;
// based on node step(float,float)  (type:step(float,float), id:202)
float var5 = step(var26, ((var7 - var80) * vVarying4).z);
// based on node get Varying3  (type:getVarying, id:0)
vec3 var18 = vVarying3;
// based on node normalize(vec3)  (type:normalize(vec3), id:130)
vec3 var6 = normalize((var7 - var18));
// based on node step(float,float)  (type:step(float,float), id:196)
float var8 = step(cPortalRadius, distance(var80, ((var6 * (vVarying6 / dot(vVarying2, var6))) + var18)));
if (!(bool(mix(min(var5, var8), max(var5, (1.0 - var8)), vVarying7)))) discard;
#if ((defined(TRANSLUCENT) && !defined(DIRLIGHT)) || (!defined(TRANSLUCENT) && !defined(DIRLIGHT)))
// based on node per pixel vec4  (type:perPixelVec4, id:208)
vec4 var14 = cLightPosPS;
// based on node vec3*float  (type:vec3*float, id:208)
vec3 var15 = ((var14.xyz - vVarying8) * var14.w);
// based on node length(vec3)  (type:length(vec3), id:208)
float var16 = length(var15);
#endif
#if defined(DIRLIGHT)
// based on node ifdef(vec3) DIRLIGHT (type:ifdef(vec3), id:208)
vec3 ifdef1 = cLightDirPS;
#endif
#if !defined(DIRLIGHT)
// based on node ifdef(vec3) DIRLIGHT (type:ifdef(vec3), id:208)
vec3 ifdef1 = (var15 / var16);
#endif
// based on node ifdef(vec3)  (type:ifdef(vec3), id:208)
vec3 var17 = ifdef1;
// based on node normalize(vec3)  (type:normalize(vec3), id:208)
vec3 var12 = normalize(vVarying9);
// based on node per pixel vec2  (type:perPixelVec2, id:208)
vec2 var43 = cShadowIntensity;
// based on node break vec2  (type:breakVec2, id:208)
float var88 = var43.y;
// based on node break vec2  (type:breakVec2, id:208)
float var41 = var43.x;
// based on node get Varying16  (type:getVarying, id:0)
vec4 var20 = vVarying16;
#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:208)
float var28 = vVarying11;
#endif
#if (defined(WEBGL) && !defined(GL_ES))
// based on node ifdef(vec4) WEBGL (type:ifdef(vec4), id:208)
vec4 ifdef6 = var20;
#endif
#if (!defined(WEBGL) && !defined(GL_ES))
// based on node ifdef(vec4) WEBGL (type:ifdef(vec4), id:208)
vec4 ifdef6 = (((var28 < vVarying12))?(var20):((((var28 < vVarying25))?(vVarying17):((((var28 < vVarying26))?(vVarying18):(vVarying19))))));
#endif
#if defined(GL_ES)
// based on node ifdef(vec4) GL_ES (type:ifdef(vec4), id:208)
vec4 ifdef5 = var20;
#endif
#if !defined(GL_ES)
// based on node ifdef(vec4) GL_ES (type:ifdef(vec4), id:208)
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:208)
vec4 var48 = 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:208)
float var42 = var48.x;
// based on node break vec4  (type:breakVec4, id:208)
float var89 = var48.y;
// based on node break vec4  (type:breakVec4, id:208)
float var90 = var48.z;
// based on node break vec4  (type:breakVec4, id:208)
float var91 = var48.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:208)
vec2 var45 = cShadowMapInvSize;
#endif
#if (!defined(SIMPLE_SHADOW) && (defined(POINTLIGHT) && (defined(PCF_SHADOW) && defined(DIRLIGHT))))
// based on node ifdef(vec2) POINTLIGHT (type:ifdef(vec2), id:208)
vec2 ifdef8 = (var45 * var48.w);
#endif
#if (!defined(SIMPLE_SHADOW) && (!defined(POINTLIGHT) && (defined(PCF_SHADOW) && defined(DIRLIGHT))))
// based on node ifdef(vec2) POINTLIGHT (type:ifdef(vec2), id:208)
vec2 ifdef8 = var45;
#endif
#if (!defined(SIMPLE_SHADOW) && (defined(PCF_SHADOW) && defined(DIRLIGHT)))
// based on node ifdef(vec2)  (type:ifdef(vec2), id:208)
vec2 var44 = ifdef8;
// based on node float+float  (type:float+float, id:208)
float var46 = (var42 + var44.x);
// based on node float+float  (type:float+float, id:208)
float var47 = (var44.y + var89);
#endif
#if (defined(VSM_SHADOW) && (!defined(SIMPLE_SHADOW) && (!defined(PCF_SHADOW) && defined(DIRLIGHT))))
// based on node float/float  (type:float/float, id:208)
float var50 = (var90 / var91);
// based on node sampleVSMShadow  (type:sampleVSMShadow(shadowMap,vec2), id:208)
vec2 var49 = texture2D(sShadowMap, (vec2(var42, var89) / var91)).rg;
// based on node break vec2  (type:breakVec2, id:208)
float var71 = var49.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 Varying22  (type:getVarying, id:0)
float var68 = vVarying22;
#endif
#if (defined(VSM_SHADOW) && (!defined(SIMPLE_SHADOW) && (!defined(PCF_SHADOW) && defined(DIRLIGHT))))
// based on node max(float,float)  (type:max(float,float), id:208)
float var74 = max((var49.y - (var71 * var71)), var68);
// based on node float-float  (type:float-float, id:208)
float var75 = (var50 - var71);
#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 Varying29  (type:getVarying, id:0)
float var85 = vVarying29;
// based on node get Varying23  (type:getVarying, id:0)
float var69 = vVarying23;
#endif
#if (defined(VSM_SHADOW) && (!defined(SIMPLE_SHADOW) && (!defined(PCF_SHADOW) && defined(DIRLIGHT))))
// based on node ifdef(float) VSM_SHADOW (type:ifdef(float), id:208)
float ifdef9 = max(float((var50 <= var71)), clamp((((var74 / (var74 + (var75 * var75))) - var85) / var69), var26, 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:208)
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:208)
float ifdef7 = ((sampleShadow(sShadowMap, vec4(var42, var89, var90, var91)) + sampleShadow(sShadowMap, vec4(var46, var89, var90, var91))) + (sampleShadow(sShadowMap, vec4(var42, var47, var90, var91)) + sampleShadow(sShadowMap, vec4(var46, var47, var90, var91))));
#endif
#if (!defined(SIMPLE_SHADOW) && (!defined(PCF_SHADOW) && defined(DIRLIGHT)))
// based on node ifdef(float) PCF_SHADOW (type:ifdef(float), id:208)
float ifdef7 = ifdef9;
#endif
#if (defined(SIMPLE_SHADOW) && defined(DIRLIGHT))
// based on node ifdef(float) SIMPLE_SHADOW (type:ifdef(float), id:208)
float ifdef4 = sampleShadow(sShadowMap, var48);
#endif
#if (!defined(SIMPLE_SHADOW) && defined(DIRLIGHT))
// based on node ifdef(float) SIMPLE_SHADOW (type:ifdef(float), id:208)
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:208)
vec4 var55 = vVarying21;
#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:208)
float var51 = var55.x;
// based on node break vec4  (type:breakVec4, id:208)
float var92 = var55.y;
// based on node break vec4  (type:breakVec4, id:208)
float var93 = var55.z;
// based on node break vec4  (type:breakVec4, id:208)
float var94 = var55.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:208)
vec2 ifdef13 = (var45 * var55.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:208)
vec2 ifdef13 = var45;
#endif
#if (defined(SPOTLIGHT) && (!defined(SIMPLE_SHADOW) && (defined(PCF_SHADOW) && !defined(DIRLIGHT))))
// based on node ifdef(vec2)  (type:ifdef(vec2), id:208)
vec2 var52 = ifdef13;
// based on node float+float  (type:float+float, id:208)
float var53 = (var51 + var52.x);
// based on node float+float  (type:float+float, id:208)
float var54 = (var52.y + var92);
#endif
#if (defined(VSM_SHADOW) && (defined(SPOTLIGHT) && (!defined(SIMPLE_SHADOW) && (!defined(PCF_SHADOW) && !defined(DIRLIGHT)))))
// based on node float/float  (type:float/float, id:208)
float var57 = (var93 / var94);
// based on node sampleVSMShadow  (type:sampleVSMShadow(shadowMap,vec2), id:208)
vec2 var56 = texture2D(sShadowMap, (vec2(var51, var92) / var94)).rg;
// based on node break vec2  (type:breakVec2, id:208)
float var73 = var56.x;
// based on node max(float,float)  (type:max(float,float), id:208)
float var76 = max((var56.y - (var73 * var73)), var68);
// based on node float-float  (type:float-float, id:208)
float var77 = (var57 - var73);
// based on node ifdef(float) VSM_SHADOW (type:ifdef(float), id:208)
float ifdef14 = max(float((var57 <= var73)), clamp((((var76 / (var76 + (var77 * var77))) - var85) / var69), var26, 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:208)
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:208)
float ifdef12 = ((sampleShadow(sShadowMap, vec4(var51, var92, var93, var94)) + sampleShadow(sShadowMap, vec4(var53, var92, var93, var94))) + (sampleShadow(sShadowMap, vec4(var51, var54, var93, var94)) + sampleShadow(sShadowMap, vec4(var53, var54, var93, var94))));
#endif
#if (defined(SPOTLIGHT) && (!defined(SIMPLE_SHADOW) && (!defined(PCF_SHADOW) && !defined(DIRLIGHT))))
// based on node ifdef(float) PCF_SHADOW (type:ifdef(float), id:208)
float ifdef12 = ifdef14;
#endif
#if (defined(SPOTLIGHT) && (defined(SIMPLE_SHADOW) && !defined(DIRLIGHT)))
// based on node ifdef(float) SIMPLE_SHADOW (type:ifdef(float), id:208)
float ifdef11 = sampleShadow(sShadowMap, var55);
#endif
#if (defined(SPOTLIGHT) && (!defined(SIMPLE_SHADOW) && !defined(DIRLIGHT)))
// based on node ifdef(float) SIMPLE_SHADOW (type:ifdef(float), id:208)
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 Varying14  (type:getVarying, id:0)
vec3 var79 = vVarying14;
// based on node break vec4 to vec3, float  (type:breakVec4toVec3Float, id:208)
vec3 var30 = textureCube(sFaceSelectCubeMap, var79).xyz;
// based on node textureCube(samplerCube,vec3)  (type:textureCube(samplerCube,vec3), id:208)
vec4 var31 = textureCube(sIndirectionCubeMap, (var79 + ((var30 * var79) * 0.00390625)));
// based on node per pixel vec4  (type:perPixelVec4, id:208)
vec4 var33 = cShadowCubeAdjust;
// based on node break vec4 to vec2, vec2  (type:breakVec4toVec2Vec2, id:208)
vec2 var87 = var33.zw;
// based on node break vec4 to vec2, vec2  (type:breakVec4toVec2Vec2, id:208)
vec2 var86 = var31.zw;
// based on node per pixel vec4  (type:perPixelVec4, id:208)
vec4 var64 = vec4(((var31.xy * var33.xy) + vec2((var87.x + (var86.x * 0.5)), (var87.y + var86.y))), vec2((vVarying15 + (vVarying27 / abs(dot(var30, var79)))), 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:208)
float var60 = var64.x;
// based on node break vec4  (type:breakVec4, id:208)
float var95 = var64.y;
// based on node break vec4  (type:breakVec4, id:208)
float var96 = var64.z;
// based on node break vec4  (type:breakVec4, id:208)
float var97 = var64.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:208)
vec2 ifdef17 = (var45 * var64.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:208)
vec2 ifdef17 = var45;
#endif
#if (!defined(SPOTLIGHT) && (!defined(SIMPLE_SHADOW) && (defined(PCF_SHADOW) && !defined(DIRLIGHT))))
// based on node ifdef(vec2)  (type:ifdef(vec2), id:208)
vec2 var61 = ifdef17;
// based on node float+float  (type:float+float, id:208)
float var62 = (var60 + var61.x);
// based on node float+float  (type:float+float, id:208)
float var63 = (var61.y + var95);
#endif
#if (defined(VSM_SHADOW) && (!defined(SPOTLIGHT) && (!defined(SIMPLE_SHADOW) && (!defined(PCF_SHADOW) && !defined(DIRLIGHT)))))
// based on node float/float  (type:float/float, id:208)
float var66 = (var96 / var97);
// based on node sampleVSMShadow  (type:sampleVSMShadow(shadowMap,vec2), id:208)
vec2 var65 = texture2D(sShadowMap, (vec2(var60, var95) / var97)).rg;
// based on node break vec2  (type:breakVec2, id:208)
float var81 = var65.x;
// based on node max(float,float)  (type:max(float,float), id:208)
float var82 = max((var65.y - (var81 * var81)), var68);
// based on node float-float  (type:float-float, id:208)
float var83 = (var66 - var81);
// based on node ifdef(float) VSM_SHADOW (type:ifdef(float), id:208)
float ifdef18 = max(float((var66 <= var81)), clamp((((var82 / (var82 + (var83 * var83))) - var85) / var69), var26, 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:208)
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:208)
float ifdef16 = ((sampleShadow(sShadowMap, vec4(var60, var95, var96, var97)) + sampleShadow(sShadowMap, vec4(var62, var95, var96, var97))) + (sampleShadow(sShadowMap, vec4(var60, var63, var96, var97)) + sampleShadow(sShadowMap, vec4(var62, var63, var96, var97))));
#endif
#if (!defined(SPOTLIGHT) && (!defined(SIMPLE_SHADOW) && (!defined(PCF_SHADOW) && !defined(DIRLIGHT))))
// based on node ifdef(float) PCF_SHADOW (type:ifdef(float), id:208)
float ifdef16 = ifdef18;
#endif
#if (!defined(SPOTLIGHT) && (defined(SIMPLE_SHADOW) && !defined(DIRLIGHT)))
// based on node ifdef(float) SIMPLE_SHADOW (type:ifdef(float), id:208)
float ifdef15 = sampleShadow(sShadowMap, var64);
#endif
#if (!defined(SPOTLIGHT) && (!defined(SIMPLE_SHADOW) && !defined(DIRLIGHT)))
// based on node ifdef(float) SIMPLE_SHADOW (type:ifdef(float), id:208)
float ifdef15 = ifdef16;
#endif
#if (defined(SPOTLIGHT) && !defined(DIRLIGHT))
// based on node ifdef(float) SPOTLIGHT (type:ifdef(float), id:208)
float ifdef10 = (var88 + (var41 * ifdef11));
#endif
#if (!defined(SPOTLIGHT) && !defined(DIRLIGHT))
// based on node ifdef(float) SPOTLIGHT (type:ifdef(float), id:208)
float ifdef10 = (var88 + (var41 * ifdef15));
#endif
#if defined(DIRLIGHT)
// based on node ifdef(float) DIRLIGHT (type:ifdef(float), id:208)
float ifdef3 = min(((var88 + (var41 * ifdef4)) + max(((var28 - vVarying20) * vVarying28), var26)), 1.0);
#endif
#if !defined(DIRLIGHT)
// based on node ifdef(float) DIRLIGHT (type:ifdef(float), id:208)
float ifdef3 = ifdef10;
#endif
#if defined(SHADOW)
// based on node ifdef(float) SHADOW (type:ifdef(float), id:208)
float ifdef2 = ifdef3;
#endif
#if !defined(SHADOW)
// based on node ifdef(float) SHADOW (type:ifdef(float), id:208)
float ifdef2 = 1.0;
#endif
// based on node dot(vec3,vec3)  (type:dot(vec3,vec3), id:208)
float var22 = dot(var12, var17);
#if defined(TRANSLUCENT)
// based on node abs(float)  (type:abs(float), id:208)
float var23 = abs(var22);
#endif
#if !defined(TRANSLUCENT)
// based on node max(float,float)  (type:max(float,float), id:208)
float var21 = max(var22, 0.0);
#endif
#if (defined(TRANSLUCENT) && defined(DIRLIGHT))
// based on node ifdef(float) TRANSLUCENT (type:ifdef(float), id:208)
float ifdef20 = var23;
#endif
#if (!defined(TRANSLUCENT) && defined(DIRLIGHT))
// based on node ifdef(float) TRANSLUCENT (type:ifdef(float), id:208)
float ifdef20 = var21;
#endif
#if ((defined(TRANSLUCENT) && !defined(DIRLIGHT)) || (!defined(TRANSLUCENT) && !defined(DIRLIGHT)))
// based on node break vec4  (type:breakVec4, id:208)
float var19 = texture2D(sLightRampMap, vec2(var16, 0.0)).x;
#endif
#if (defined(TRANSLUCENT) && !defined(DIRLIGHT))
// based on node ifdef(float) TRANSLUCENT (type:ifdef(float), id:208)
float ifdef21 = (var23 * var19);
#endif
#if (!defined(TRANSLUCENT) && !defined(DIRLIGHT))
// based on node ifdef(float) TRANSLUCENT (type:ifdef(float), id:208)
float ifdef21 = (var21 * var19);
#endif
#if defined(DIRLIGHT)
// based on node ifdef(float) DIRLIGHT (type:ifdef(float), id:208)
float ifdef19 = ifdef20;
#endif
#if !defined(DIRLIGHT)
// based on node ifdef(float) DIRLIGHT (type:ifdef(float), id:208)
float ifdef19 = ifdef21;
#endif
gl_FragColor = ((cMatDiffColor + vec4((vVarying5 * (pow(max(dot(normalize((vVarying13 + var17)), var12), var26), vVarying24) * vVarying10)), var26)) * (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

attribute vec4 iPos;
#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 vec3 iNormal;
uniform vec3 cPortalOrigin;
uniform vec3 cPortalForward;
uniform mat4 cModel;
uniform vec4 cAmbientColor;
uniform vec3 cCameraPos;
uniform vec4 cSkinMatrices[MAXBONES*3];
uniform mat4 cViewProj;
uniform vec4 cClipPlane;
varying vec3 vVarying2;
varying vec3 vVarying3;
varying vec3 vVarying1;
varying vec3 vVarying8;
varying vec3 vVarying7;
varying float vVarying6;
varying float vVarying5;
varying mat3 vVarying4;
varying float vVarying10;
varying vec3 vVarying9;

attribute float iObjectIndex;


// --- GetNormalMatrix ---

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



void VS()
{
// based on node normalize(vec3)  (type:normalize(vec3), id:31)
vec3 var2 = normalize(normalize(cPortalForward));
vVarying2 = var2;
// based on node vec3-vec3  (type:vec3-vec3, id:76)
vec3 var4 = (cCameraPos - vec3(0.0, 0.0, 0.0));
vVarying3 = var4;
#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 var11 = ifdef1;
// based on node vec4*mat4x3  (type:vec4*mat4x3, id:8)
vec3 var10 = ((iPos * var11)).xyz;
vVarying1 = (var10 - vec3(0.0, 0.0, 0.0));
// based on node vec4  (type:default, id:0)
vec4 var13 = vec4(0.0,0.0,0.0,0.0);
vVarying8 = (cAmbientColor.xyz * var13.xyz);
vVarying7 = (iNormal * GetNormalMatrix(var11));
// based on node PortalOrigin  (type:parameter(vec3), id:156)
vec3 var1 = cPortalOrigin;
// based on node cross(vec3,vec3)  (type:cross(vec3,vec3), id:33)
vec3 var0 = cross(var2, normalize(vec3(1.0, 0.0, 0.0)));
// based on node mat3(vec3,vec3,vec3)  (type:mat3(vec3,vec3,vec3), id:70)
mat3 var5 = mat3(normalize(cross(var0, var2)), normalize(var0), var2);
vVarying6 = step((0.0), ((var4 - var1) * var5).z);
vVarying5 = dot((var1 - var4), var2);
vVarying4 = var5;
vVarying10 = var13.w;
vVarying9 = (var10 - cCameraPos);
vec4 ret =  (vec4(var10, 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 float cPortalRadius;
uniform vec4 cMatEmissiveColor;
uniform vec4 cMatEnvMapColor;
uniform vec3 cPortalOrigin;
uniform samplerCube sZoneCubeMap;
varying vec3 vVarying3;
varying vec3 vVarying8;
varying vec3 vVarying1;
varying vec3 vVarying7;
varying float vVarying6;
varying float vVarying5;
varying mat3 vVarying4;
varying vec3 vVarying2;
varying float vVarying10;
varying vec3 vVarying9;



void PS()
{
// based on node per pixel vec3  (type:perPixelVec3, id:150)
vec3 var8 = vVarying1;
// based on node PortalOrigin  (type:parameter(vec3), id:156)
vec3 var12 = cPortalOrigin;
// based on node step(float,float)  (type:step(float,float), id:202)
float var6 = step((0.0), ((var8 - var12) * vVarying4).z);
// based on node get Varying3  (type:getVarying, id:0)
vec3 var3 = vVarying3;
// based on node normalize(vec3)  (type:normalize(vec3), id:130)
vec3 var7 = normalize((var8 - var3));
// based on node step(float,float)  (type:step(float,float), id:196)
float var9 = step(cPortalRadius, distance(var12, ((var7 * (vVarying5 / dot(vVarying2, var7))) + var3)));
if (!(bool(mix(min(var6, var9), max(var6, (1.0 - var9)), vVarying6)))) discard;
gl_FragColor = vec4((vVarying8 + ((cMatEnvMapColor * textureCube(sZoneCubeMap, reflect(vVarying9, vVarying7))) + cMatEmissiveColor).xyz), vVarying10);

}
#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
