com.bladecoder.engine.shading.cel.vertex.glsl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of blade-engine Show documentation
Show all versions of blade-engine Show documentation
Classic point and click adventure game engine
#if defined(diffuseTextureFlag) || defined(specularTextureFlag)
#define textureFlag
#endif
#if defined(specularTextureFlag) || defined(specularColorFlag)
#define specularFlag
#endif
#if defined(specularFlag) || defined(fogFlag)
#define cameraPositionFlag
#endif
attribute vec3 a_position;
uniform mat4 u_projViewTrans;
#if defined(colorFlag)
varying vec4 v_color;
attribute vec4 a_color;
#endif // colorFlag
#ifdef normalFlag
attribute vec3 a_normal;
uniform mat3 u_normalMatrix;
varying vec3 v_normal;
#endif // normalFlag
#ifdef textureFlag
attribute vec2 a_texCoord0;
varying vec2 v_texCoords0;
#endif // textureFlag
#ifdef boneWeight0Flag
#define boneWeightsFlag
attribute vec2 a_boneWeight0;
#endif //boneWeight0Flag
#ifdef boneWeight1Flag
#ifndef boneWeightsFlag
#define boneWeightsFlag
#endif
attribute vec2 a_boneWeight1;
#endif //boneWeight1Flag
#ifdef boneWeight2Flag
#ifndef boneWeightsFlag
#define boneWeightsFlag
#endif
attribute vec2 a_boneWeight2;
#endif //boneWeight2Flag
#ifdef boneWeight3Flag
#ifndef boneWeightsFlag
#define boneWeightsFlag
#endif
attribute vec2 a_boneWeight3;
#endif //boneWeight3Flag
#ifdef boneWeight4Flag
#ifndef boneWeightsFlag
#define boneWeightsFlag
#endif
attribute vec2 a_boneWeight4;
#endif //boneWeight4Flag
#ifdef boneWeight5Flag
#ifndef boneWeightsFlag
#define boneWeightsFlag
#endif
attribute vec2 a_boneWeight5;
#endif //boneWeight5Flag
#ifdef boneWeight6Flag
#ifndef boneWeightsFlag
#define boneWeightsFlag
#endif
attribute vec2 a_boneWeight6;
#endif //boneWeight6Flag
#ifdef boneWeight7Flag
#ifndef boneWeightsFlag
#define boneWeightsFlag
#endif
attribute vec2 a_boneWeight7;
#endif //boneWeight7Flag
#if defined(numBones) && defined(boneWeightsFlag)
#if (numBones > 0)
#define skinningFlag
#endif
#endif
uniform mat4 u_worldTrans;
#if defined(numBones)
#if numBones > 0
uniform mat4 u_bones[numBones];
#endif //numBones
#endif
#ifdef lightingFlag
varying vec3 v_lightDiffuse;
#ifdef ambientLightFlag
uniform vec3 u_ambientLight;
#endif // ambientLightFlag
#ifdef cameraPositionFlag
uniform vec4 u_cameraPosition;
#endif // cameraPositionFlag
#if defined(numPointLights) && (numPointLights > 0)
struct PointLight
{
vec3 color;
vec3 position;
};
uniform PointLight u_pointLights[numPointLights];
#endif // numPointLights
#if defined(ambientLightFlag)
#define ambientFlag
#endif //ambientFlag
#ifdef shadowMapFlag
uniform mat4 u_shadowMapProjViewTrans;
varying vec3 v_shadowMapUv;
#define separateAmbientFlag
#endif //shadowMapFlag
#if defined(ambientFlag) && defined(separateAmbientFlag)
varying vec3 v_ambientLight;
#endif //separateAmbientFlag
#endif // lightingFlag
void main() {
#ifdef textureFlag
v_texCoords0 = a_texCoord0;
#endif // textureFlag
#if defined(colorFlag)
v_color = a_color;
#endif // colorFlag
#ifdef skinningFlag
mat4 skinning = mat4(0.0);
#ifdef boneWeight0Flag
skinning += (a_boneWeight0.y) * u_bones[int(a_boneWeight0.x)];
#endif //boneWeight0Flag
#ifdef boneWeight1Flag
skinning += (a_boneWeight1.y) * u_bones[int(a_boneWeight1.x)];
#endif //boneWeight1Flag
#ifdef boneWeight2Flag
skinning += (a_boneWeight2.y) * u_bones[int(a_boneWeight2.x)];
#endif //boneWeight2Flag
#ifdef boneWeight3Flag
skinning += (a_boneWeight3.y) * u_bones[int(a_boneWeight3.x)];
#endif //boneWeight3Flag
#ifdef boneWeight4Flag
skinning += (a_boneWeight4.y) * u_bones[int(a_boneWeight4.x)];
#endif //boneWeight4Flag
#ifdef boneWeight5Flag
skinning += (a_boneWeight5.y) * u_bones[int(a_boneWeight5.x)];
#endif //boneWeight5Flag
#ifdef boneWeight6Flag
skinning += (a_boneWeight6.y) * u_bones[int(a_boneWeight6.x)];
#endif //boneWeight6Flag
#ifdef boneWeight7Flag
skinning += (a_boneWeight7.y) * u_bones[int(a_boneWeight7.x)];
#endif //boneWeight7Flag
#endif //skinningFlag
#ifdef skinningFlag
vec4 pos = u_worldTrans * skinning * vec4(a_position, 1.0);
#else
vec4 pos = u_worldTrans * vec4(a_position, 1.0);
#endif
gl_Position = u_projViewTrans * pos;
#ifdef shadowMapFlag
vec4 spos = u_shadowMapProjViewTrans * pos;
v_shadowMapUv.xy = (spos.xy / spos.w) * 0.5 + 0.5;
v_shadowMapUv.z = min(spos.z * 0.5 + 0.5, 0.998);
#endif //shadowMapFlag
#if defined(normalFlag)
#if defined(skinningFlag)
vec3 normal = normalize((u_worldTrans * skinning * vec4(a_normal, 0.0)).xyz);
#else
vec3 normal = normalize(u_normalMatrix * a_normal);
#endif
v_normal = normal;
#endif // normalFlag
#ifdef lightingFlag
#ifdef ambientFlag
#ifdef separateAmbientFlag
v_ambientLight = ambientLight;
v_lightDiffuse = vec3(0.0);
#else
v_lightDiffuse = ambientLight;
#endif //separateAmbientFlag
#else
v_lightDiffuse = vec3(1.0);
#endif //ambientFlag
#if defined(numPointLights) && (numPointLights > 0) && defined(normalFlag)
v_lightDiffuse = normalize(u_pointLights[0].position) ;
#endif // numPointLights
#endif // lightingFlag
}