
#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
uniform mat4 cViewProj;
uniform mat4 cModel;
uniform vec4 cSkinMatrices[MAXBONES*3];
uniform vec4 cClipPlane;
varying vec4 vVarying1;

attribute float iObjectIndex;




void VS()
{
vVarying1 = vec4((vec3(0.0,0.0,0.0) + vec3(0.5, 0.5, 0.5)), ((0.0) / 255.0));
#if (!defined(SKINNED) && defined(INSTANCED))
// based on node ifdef(mat4x3) INSTANCED (type:ifdef(mat4x3), id:0)
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:0)
mat4 ifdef2 = cModel;
#endif
#if defined(SKINNED)
// based on node ifdef(mat4x3) SKINNED (type:ifdef(mat4x3), id:0)
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:0)
mat4 ifdef1 = ifdef2;
vec4 ret =  (vec4(((iPos * ifdef1)).xyz, 1) * cViewProj);
#endif


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

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

varying vec4 vVarying1;



void PS()
{
// based on node float  (type:default, id:0)
float var5 = (0.0);
// based on node per pixel float  (type:perPixelFloat, id:22)
float var0 = var5;
#if !defined(GL3)
// based on node float*float  (type:float*float, id:22)
float var1 = (var0 * 255.0);
// based on node floor(float)  (type:floor(float), id:22)
float var2 = floor(var1);
// based on node float*float  (type:float*float, id:22)
float var3 = ((var1 - var2) * 255.0);
// based on node floor(float)  (type:floor(float), id:22)
float var4 = floor(var3);
#endif
#if defined(GL3)
// based on node ifdef(vec3) GL3 (type:ifdef(vec3), id:22)
vec3 ifdef1 = vec3(var0, var5, var5);
#endif
#if !defined(GL3)
// based on node ifdef(vec3) GL3 (type:ifdef(vec3), id:22)
vec3 ifdef1 = vec3((var2 * 0.0039215686274509803921568627451), (var4 * 0.0039215686274509803921568627451), (var3 - var4));
#endif
gl_FragData[1] = vec4(ifdef1, var5);
gl_FragData[0] = vVarying1;

}
#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
uniform mat4 cViewProj;
uniform mat4 cModel;
uniform vec4 cSkinMatrices[MAXBONES*3];
uniform vec4 cClipPlane;
varying vec4 vVarying3;
varying vec4 vVarying1;
varying vec4 vVarying2;

attribute float iObjectIndex;




void VS()
{
// based on node float  (type:default, id:0)
float var5 = (0.0);
vVarying3 = vec4(vec4(1.000, 1.000, 1.000, 0.000).xyz, var5);
vVarying1 = vec4(vec4(0.0,0.0,0.0,0.0).xyz, 1.0);
vVarying2 = vec4((vec3(0.0,0.0,0.0) + vec3(0.5, 0.5, 0.5)), (var5 / 255.0));
#if (!defined(SKINNED) && defined(INSTANCED))
// based on node ifdef(mat4x3) INSTANCED (type:ifdef(mat4x3), id:0)
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:0)
mat4 ifdef2 = cModel;
#endif
#if defined(SKINNED)
// based on node ifdef(mat4x3) SKINNED (type:ifdef(mat4x3), id:0)
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:0)
mat4 ifdef1 = ifdef2;
vec4 ret =  (vec4(((iPos * ifdef1)).xyz, 1) * cViewProj);
#endif


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

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

varying vec4 vVarying1;
varying vec4 vVarying2;
varying vec4 vVarying3;



void PS()
{
gl_FragData[0] = vVarying1;
gl_FragData[1] = vVarying3;
gl_FragData[2] = vVarying2;
// based on node float  (type:default, id:0)
float var6 = (0.0);
// based on node per pixel float  (type:perPixelFloat, id:22)
float var0 = var6;
#if !defined(GL3)
// based on node float*float  (type:float*float, id:22)
float var1 = (var0 * 255.0);
// based on node floor(float)  (type:floor(float), id:22)
float var2 = floor(var1);
// based on node float*float  (type:float*float, id:22)
float var3 = ((var1 - var2) * 255.0);
// based on node floor(float)  (type:floor(float), id:22)
float var4 = floor(var3);
#endif
#if defined(GL3)
// based on node ifdef(vec3) GL3 (type:ifdef(vec3), id:22)
vec3 ifdef1 = vec3(var0, var6, var6);
#endif
#if !defined(GL3)
// based on node ifdef(vec3) GL3 (type:ifdef(vec3), id:22)
vec3 ifdef1 = vec3((var2 * 0.0039215686274509803921568627451), (var4 * 0.0039215686274509803921568627451), (var3 - var4));
#endif
gl_FragData[3] = vec4(ifdef1, var6);

}
#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
uniform mat4 cViewProj;
uniform mat4 cModel;
uniform vec4 cSkinMatrices[MAXBONES*3];
uniform vec4 cClipPlane;

attribute float iObjectIndex;




void VS()
{
#if (!defined(SKINNED) && defined(INSTANCED))
// based on node ifdef(mat4x3) INSTANCED (type:ifdef(mat4x3), id:0)
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:0)
mat4 ifdef2 = cModel;
#endif
#if defined(SKINNED)
// based on node ifdef(mat4x3) SKINNED (type:ifdef(mat4x3), id:0)
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:0)
mat4 ifdef1 = ifdef2;
vec4 ret =  (vec4(((iPos * ifdef1)).xyz, 1) * cViewProj);
#endif


    // 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(0.0,0.0,0.0,0.0);

}
#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 mat4 cViewProj;
uniform mat4 cModel;
uniform vec4 cSkinMatrices[MAXBONES*3];
uniform vec4 cClipPlane;
varying vec2 vVarying1;

attribute float iObjectIndex;




void VS()
{
#if (!defined(SKINNED) && defined(INSTANCED))
// based on node ifdef(mat4x3) INSTANCED (type:ifdef(mat4x3), id:0)
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:0)
mat4 ifdef2 = cModel;
#endif
#if defined(SKINNED)
// based on node ifdef(mat4x3) SKINNED (type:ifdef(mat4x3), id:0)
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:0)
mat4 ifdef1 = ifdef2;
#endif
// based on node vec4*mat4  (type:vec4*mat4, id:0)
vec4 var0 = (vec4(((iPos * ifdef1)).xyz, 1) * cViewProj);
vVarying1 = var0.zw;
vec4 ret =  var0;


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

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

varying vec2 vVarying1;



void PS()
{
    #ifdef VSM_SHADOW
        float depth = vVarying1.x / vVarying1.y * 0.5 + 0.5;
        gl_FragColor = vec4(depth, depth * depth, 1.0, 1.0);
    #else
        gl_FragColor = vec4(1.0);
    #endif

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