mirror of
https://gitlab.com/skysthelimit.dev/selenite.git
synced 2025-06-16 02:22:07 -05:00
Upload files to "semag/mind/assets/com/badlogic/gdx/graphics/g3d/shaders"
This commit is contained in:
parent
733152a451
commit
4522e5c303
@ -0,0 +1,188 @@
|
||||
#ifdef GL_ES
|
||||
#define LOWP lowp
|
||||
#define MED mediump
|
||||
#define HIGH highp
|
||||
precision mediump float;
|
||||
#else
|
||||
#define MED
|
||||
#define LOWP
|
||||
#define HIGH
|
||||
#endif
|
||||
|
||||
#if defined(specularTextureFlag) || defined(specularColorFlag)
|
||||
#define specularFlag
|
||||
#endif
|
||||
|
||||
#ifdef normalFlag
|
||||
varying vec3 v_normal;
|
||||
#endif //normalFlag
|
||||
|
||||
#if defined(colorFlag)
|
||||
varying vec4 v_color;
|
||||
#endif
|
||||
|
||||
#ifdef blendedFlag
|
||||
varying float v_opacity;
|
||||
#ifdef alphaTestFlag
|
||||
varying float v_alphaTest;
|
||||
#endif //alphaTestFlag
|
||||
#endif //blendedFlag
|
||||
|
||||
#if defined(diffuseTextureFlag) || defined(specularTextureFlag)
|
||||
#define textureFlag
|
||||
#endif
|
||||
|
||||
#ifdef diffuseTextureFlag
|
||||
varying MED vec2 v_diffuseUV;
|
||||
#endif
|
||||
|
||||
#ifdef specularTextureFlag
|
||||
varying MED vec2 v_specularUV;
|
||||
#endif
|
||||
|
||||
#ifdef diffuseColorFlag
|
||||
uniform vec4 u_diffuseColor;
|
||||
#endif
|
||||
|
||||
#ifdef diffuseTextureFlag
|
||||
uniform sampler2D u_diffuseTexture;
|
||||
#endif
|
||||
|
||||
#ifdef specularColorFlag
|
||||
uniform vec4 u_specularColor;
|
||||
#endif
|
||||
|
||||
#ifdef specularTextureFlag
|
||||
uniform sampler2D u_specularTexture;
|
||||
#endif
|
||||
|
||||
#ifdef normalTextureFlag
|
||||
uniform sampler2D u_normalTexture;
|
||||
#endif
|
||||
|
||||
#ifdef lightingFlag
|
||||
varying vec3 v_lightDiffuse;
|
||||
|
||||
#if defined(ambientLightFlag) || defined(ambientCubemapFlag) || defined(sphericalHarmonicsFlag)
|
||||
#define ambientFlag
|
||||
#endif //ambientFlag
|
||||
|
||||
#ifdef specularFlag
|
||||
varying vec3 v_lightSpecular;
|
||||
#endif //specularFlag
|
||||
|
||||
#ifdef shadowMapFlag
|
||||
uniform sampler2D u_shadowTexture;
|
||||
uniform float u_shadowPCFOffset;
|
||||
varying vec3 v_shadowMapUv;
|
||||
#define separateAmbientFlag
|
||||
|
||||
float getShadowness(vec2 offset)
|
||||
{
|
||||
const vec4 bitShifts = vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0);
|
||||
return step(v_shadowMapUv.z, dot(texture2D(u_shadowTexture, v_shadowMapUv.xy + offset), bitShifts));//+(1.0/255.0));
|
||||
}
|
||||
|
||||
float getShadow()
|
||||
{
|
||||
return (//getShadowness(vec2(0,0)) +
|
||||
getShadowness(vec2(u_shadowPCFOffset, u_shadowPCFOffset)) +
|
||||
getShadowness(vec2(-u_shadowPCFOffset, u_shadowPCFOffset)) +
|
||||
getShadowness(vec2(u_shadowPCFOffset, -u_shadowPCFOffset)) +
|
||||
getShadowness(vec2(-u_shadowPCFOffset, -u_shadowPCFOffset))) * 0.25;
|
||||
}
|
||||
#endif //shadowMapFlag
|
||||
|
||||
#if defined(ambientFlag) && defined(separateAmbientFlag)
|
||||
varying vec3 v_ambientLight;
|
||||
#endif //separateAmbientFlag
|
||||
|
||||
#endif //lightingFlag
|
||||
|
||||
#ifdef fogFlag
|
||||
uniform vec4 u_fogColor;
|
||||
varying float v_fog;
|
||||
#endif // fogFlag
|
||||
|
||||
void main() {
|
||||
#if defined(normalFlag)
|
||||
vec3 normal = v_normal;
|
||||
#endif // normalFlag
|
||||
|
||||
#if defined(diffuseTextureFlag) && defined(diffuseColorFlag) && defined(colorFlag)
|
||||
vec4 diffuse = texture2D(u_diffuseTexture, v_diffuseUV) * u_diffuseColor * v_color;
|
||||
#elif defined(diffuseTextureFlag) && defined(diffuseColorFlag)
|
||||
vec4 diffuse = texture2D(u_diffuseTexture, v_diffuseUV) * u_diffuseColor;
|
||||
#elif defined(diffuseTextureFlag) && defined(colorFlag)
|
||||
vec4 diffuse = texture2D(u_diffuseTexture, v_diffuseUV) * v_color;
|
||||
#elif defined(diffuseTextureFlag)
|
||||
vec4 diffuse = texture2D(u_diffuseTexture, v_diffuseUV);
|
||||
#elif defined(diffuseColorFlag) && defined(colorFlag)
|
||||
vec4 diffuse = u_diffuseColor * v_color;
|
||||
#elif defined(diffuseColorFlag)
|
||||
vec4 diffuse = u_diffuseColor;
|
||||
#elif defined(colorFlag)
|
||||
vec4 diffuse = v_color;
|
||||
#else
|
||||
vec4 diffuse = vec4(1.0);
|
||||
#endif
|
||||
|
||||
#if (!defined(lightingFlag))
|
||||
gl_FragColor.rgb = diffuse.rgb;
|
||||
#elif (!defined(specularFlag))
|
||||
#if defined(ambientFlag) && defined(separateAmbientFlag)
|
||||
#ifdef shadowMapFlag
|
||||
gl_FragColor.rgb = (diffuse.rgb * (v_ambientLight + getShadow() * v_lightDiffuse));
|
||||
//gl_FragColor.rgb = texture2D(u_shadowTexture, v_shadowMapUv.xy);
|
||||
#else
|
||||
gl_FragColor.rgb = (diffuse.rgb * (v_ambientLight + v_lightDiffuse));
|
||||
#endif //shadowMapFlag
|
||||
#else
|
||||
#ifdef shadowMapFlag
|
||||
gl_FragColor.rgb = getShadow() * (diffuse.rgb * v_lightDiffuse);
|
||||
#else
|
||||
gl_FragColor.rgb = (diffuse.rgb * v_lightDiffuse);
|
||||
#endif //shadowMapFlag
|
||||
#endif
|
||||
#else
|
||||
#if defined(specularTextureFlag) && defined(specularColorFlag)
|
||||
vec3 specular = texture2D(u_specularTexture, v_specularUV).rgb * u_specularColor.rgb * v_lightSpecular;
|
||||
#elif defined(specularTextureFlag)
|
||||
vec3 specular = texture2D(u_specularTexture, v_specularUV).rgb * v_lightSpecular;
|
||||
#elif defined(specularColorFlag)
|
||||
vec3 specular = u_specularColor.rgb * v_lightSpecular;
|
||||
#else
|
||||
vec3 specular = v_lightSpecular;
|
||||
#endif
|
||||
|
||||
#if defined(ambientFlag) && defined(separateAmbientFlag)
|
||||
#ifdef shadowMapFlag
|
||||
gl_FragColor.rgb = (diffuse.rgb * (getShadow() * v_lightDiffuse + v_ambientLight)) + specular;
|
||||
//gl_FragColor.rgb = texture2D(u_shadowTexture, v_shadowMapUv.xy);
|
||||
#else
|
||||
gl_FragColor.rgb = (diffuse.rgb * (v_lightDiffuse + v_ambientLight)) + specular;
|
||||
#endif //shadowMapFlag
|
||||
#else
|
||||
#ifdef shadowMapFlag
|
||||
gl_FragColor.rgb = getShadow() * ((diffuse.rgb * v_lightDiffuse) + specular);
|
||||
#else
|
||||
gl_FragColor.rgb = (diffuse.rgb * v_lightDiffuse) + specular;
|
||||
#endif //shadowMapFlag
|
||||
#endif
|
||||
#endif //lightingFlag
|
||||
|
||||
#ifdef fogFlag
|
||||
gl_FragColor.rgb = mix(gl_FragColor.rgb, u_fogColor.rgb, v_fog);
|
||||
#endif // end fogFlag
|
||||
|
||||
#ifdef blendedFlag
|
||||
gl_FragColor.a = diffuse.a * v_opacity;
|
||||
#ifdef alphaTestFlag
|
||||
if (gl_FragColor.a <= v_alphaTest)
|
||||
discard;
|
||||
#endif
|
||||
#else
|
||||
gl_FragColor.a = 1.0;
|
||||
#endif
|
||||
|
||||
}
|
@ -0,0 +1,336 @@
|
||||
#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;
|
||||
#endif // textureFlag
|
||||
|
||||
#ifdef diffuseTextureFlag
|
||||
uniform vec4 u_diffuseUVTransform;
|
||||
varying vec2 v_diffuseUV;
|
||||
#endif
|
||||
|
||||
#ifdef specularTextureFlag
|
||||
uniform vec4 u_specularUVTransform;
|
||||
varying vec2 v_specularUV;
|
||||
#endif
|
||||
|
||||
#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 shininessFlag
|
||||
uniform float u_shininess;
|
||||
#else
|
||||
const float u_shininess = 20.0;
|
||||
#endif // shininessFlag
|
||||
|
||||
#ifdef blendedFlag
|
||||
uniform float u_opacity;
|
||||
varying float v_opacity;
|
||||
|
||||
#ifdef alphaTestFlag
|
||||
uniform float u_alphaTest;
|
||||
varying float v_alphaTest;
|
||||
#endif //alphaTestFlag
|
||||
#endif // blendedFlag
|
||||
|
||||
#ifdef lightingFlag
|
||||
varying vec3 v_lightDiffuse;
|
||||
|
||||
#ifdef ambientLightFlag
|
||||
uniform vec3 u_ambientLight;
|
||||
#endif // ambientLightFlag
|
||||
|
||||
#ifdef ambientCubemapFlag
|
||||
uniform vec3 u_ambientCubemap[6];
|
||||
#endif // ambientCubemapFlag
|
||||
|
||||
#ifdef sphericalHarmonicsFlag
|
||||
uniform vec3 u_sphericalHarmonics[9];
|
||||
#endif //sphericalHarmonicsFlag
|
||||
|
||||
#ifdef specularFlag
|
||||
varying vec3 v_lightSpecular;
|
||||
#endif // specularFlag
|
||||
|
||||
#ifdef cameraPositionFlag
|
||||
uniform vec4 u_cameraPosition;
|
||||
#endif // cameraPositionFlag
|
||||
|
||||
#ifdef fogFlag
|
||||
varying float v_fog;
|
||||
#endif // fogFlag
|
||||
|
||||
|
||||
#if numDirectionalLights > 0
|
||||
struct DirectionalLight
|
||||
{
|
||||
vec3 color;
|
||||
vec3 direction;
|
||||
};
|
||||
uniform DirectionalLight u_dirLights[numDirectionalLights];
|
||||
#endif // numDirectionalLights
|
||||
|
||||
#if numPointLights > 0
|
||||
struct PointLight
|
||||
{
|
||||
vec3 color;
|
||||
vec3 position;
|
||||
};
|
||||
uniform PointLight u_pointLights[numPointLights];
|
||||
#endif // numPointLights
|
||||
|
||||
#if defined(ambientLightFlag) || defined(ambientCubemapFlag) || defined(sphericalHarmonicsFlag)
|
||||
#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 diffuseTextureFlag
|
||||
v_diffuseUV = u_diffuseUVTransform.xy + a_texCoord0 * u_diffuseUVTransform.zw;
|
||||
#endif //diffuseTextureFlag
|
||||
|
||||
#ifdef specularTextureFlag
|
||||
v_specularUV = u_specularUVTransform.xy + a_texCoord0 * u_specularUVTransform.zw;
|
||||
#endif //specularTextureFlag
|
||||
|
||||
#if defined(colorFlag)
|
||||
v_color = a_color;
|
||||
#endif // colorFlag
|
||||
|
||||
#ifdef blendedFlag
|
||||
v_opacity = u_opacity;
|
||||
#ifdef alphaTestFlag
|
||||
v_alphaTest = u_alphaTest;
|
||||
#endif //alphaTestFlag
|
||||
#endif // blendedFlag
|
||||
|
||||
#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.xyz = (spos.xyz / spos.w) * 0.5 + 0.5;
|
||||
v_shadowMapUv.z = min(v_shadowMapUv.z, 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 fogFlag
|
||||
vec3 flen = u_cameraPosition.xyz - pos.xyz;
|
||||
float fog = dot(flen, flen) * u_cameraPosition.w;
|
||||
v_fog = min(fog, 1.0);
|
||||
#endif
|
||||
|
||||
#ifdef lightingFlag
|
||||
#if defined(ambientLightFlag)
|
||||
vec3 ambientLight = u_ambientLight;
|
||||
#elif defined(ambientFlag)
|
||||
vec3 ambientLight = vec3(0.0);
|
||||
#endif
|
||||
|
||||
#ifdef ambientCubemapFlag
|
||||
vec3 squaredNormal = normal * normal;
|
||||
vec3 isPositive = step(0.0, normal);
|
||||
ambientLight += squaredNormal.x * mix(u_ambientCubemap[0], u_ambientCubemap[1], isPositive.x) +
|
||||
squaredNormal.y * mix(u_ambientCubemap[2], u_ambientCubemap[3], isPositive.y) +
|
||||
squaredNormal.z * mix(u_ambientCubemap[4], u_ambientCubemap[5], isPositive.z);
|
||||
#endif // ambientCubemapFlag
|
||||
|
||||
#ifdef sphericalHarmonicsFlag
|
||||
ambientLight += u_sphericalHarmonics[0];
|
||||
ambientLight += u_sphericalHarmonics[1] * normal.x;
|
||||
ambientLight += u_sphericalHarmonics[2] * normal.y;
|
||||
ambientLight += u_sphericalHarmonics[3] * normal.z;
|
||||
ambientLight += u_sphericalHarmonics[4] * (normal.x * normal.z);
|
||||
ambientLight += u_sphericalHarmonics[5] * (normal.z * normal.y);
|
||||
ambientLight += u_sphericalHarmonics[6] * (normal.y * normal.x);
|
||||
ambientLight += u_sphericalHarmonics[7] * (3.0 * normal.z * normal.z - 1.0);
|
||||
ambientLight += u_sphericalHarmonics[8] * (normal.x * normal.x - normal.y * normal.y);
|
||||
#endif // sphericalHarmonicsFlag
|
||||
|
||||
#ifdef ambientFlag
|
||||
#ifdef separateAmbientFlag
|
||||
v_ambientLight = ambientLight;
|
||||
v_lightDiffuse = vec3(0.0);
|
||||
#else
|
||||
v_lightDiffuse = ambientLight;
|
||||
#endif //separateAmbientFlag
|
||||
#else
|
||||
v_lightDiffuse = vec3(0.0);
|
||||
#endif //ambientFlag
|
||||
|
||||
|
||||
#ifdef specularFlag
|
||||
v_lightSpecular = vec3(0.0);
|
||||
vec3 viewVec = normalize(u_cameraPosition.xyz - pos.xyz);
|
||||
#endif // specularFlag
|
||||
|
||||
#if (numDirectionalLights > 0) && defined(normalFlag)
|
||||
for (int i = 0; i < numDirectionalLights; i++) {
|
||||
vec3 lightDir = -u_dirLights[i].direction;
|
||||
float NdotL = clamp(dot(normal, lightDir), 0.0, 1.0);
|
||||
vec3 value = u_dirLights[i].color * NdotL;
|
||||
v_lightDiffuse += value;
|
||||
#ifdef specularFlag
|
||||
float halfDotView = max(0.0, dot(normal, normalize(lightDir + viewVec)));
|
||||
v_lightSpecular += value * pow(halfDotView, u_shininess);
|
||||
#endif // specularFlag
|
||||
}
|
||||
#endif // numDirectionalLights
|
||||
|
||||
#if (numPointLights > 0) && defined(normalFlag)
|
||||
for (int i = 0; i < numPointLights; i++) {
|
||||
vec3 lightDir = u_pointLights[i].position - pos.xyz;
|
||||
float dist2 = dot(lightDir, lightDir);
|
||||
lightDir *= inversesqrt(dist2);
|
||||
float NdotL = clamp(dot(normal, lightDir), 0.0, 1.0);
|
||||
vec3 value = u_pointLights[i].color * (NdotL / (1.0 + dist2));
|
||||
v_lightDiffuse += value;
|
||||
#ifdef specularFlag
|
||||
float halfDotView = max(0.0, dot(normal, normalize(lightDir + viewVec)));
|
||||
v_lightSpecular += value * pow(halfDotView, u_shininess);
|
||||
#endif // specularFlag
|
||||
}
|
||||
#endif // numPointLights
|
||||
#endif // lightingFlag
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
#ifdef GL_ES
|
||||
#define LOWP lowp
|
||||
#define MED mediump
|
||||
#define HIGH highp
|
||||
precision mediump float;
|
||||
#else
|
||||
#define MED
|
||||
#define LOWP
|
||||
#define HIGH
|
||||
#endif
|
||||
|
||||
#if defined(diffuseTextureFlag) && defined(blendedFlag)
|
||||
#define blendedTextureFlag
|
||||
varying MED vec2 v_texCoords0;
|
||||
uniform sampler2D u_diffuseTexture;
|
||||
uniform float u_alphaTest;
|
||||
#endif
|
||||
|
||||
#ifdef PackedDepthFlag
|
||||
varying HIGH float v_depth;
|
||||
#endif //PackedDepthFlag
|
||||
|
||||
void main() {
|
||||
#ifdef blendedTextureFlag
|
||||
if (texture2D(u_diffuseTexture, v_texCoords0).a < u_alphaTest)
|
||||
discard;
|
||||
#endif // blendedTextureFlag
|
||||
|
||||
#ifdef PackedDepthFlag
|
||||
HIGH float depth = v_depth;
|
||||
const HIGH vec4 bias = vec4(1.0 / 255.0, 1.0 / 255.0, 1.0 / 255.0, 0.0);
|
||||
HIGH vec4 color = vec4(depth, fract(depth * 255.0), fract(depth * 65025.0), fract(depth * 16581375.0));
|
||||
gl_FragColor = color - (color.yzww * bias);
|
||||
#endif //PackedDepthFlag
|
||||
}
|
@ -0,0 +1,125 @@
|
||||
attribute vec3 a_position;
|
||||
uniform mat4 u_projViewWorldTrans;
|
||||
|
||||
#if defined(diffuseTextureFlag) && defined(blendedFlag)
|
||||
#define blendedTextureFlag
|
||||
attribute vec2 a_texCoord0;
|
||||
varying vec2 v_texCoords0;
|
||||
#endif
|
||||
|
||||
|
||||
#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
|
||||
|
||||
#if defined(numBones)
|
||||
#if numBones > 0
|
||||
uniform mat4 u_bones[numBones];
|
||||
#endif //numBones
|
||||
#endif
|
||||
|
||||
#ifdef PackedDepthFlag
|
||||
varying float v_depth;
|
||||
#endif //PackedDepthFlag
|
||||
|
||||
void main() {
|
||||
#ifdef blendedTextureFlag
|
||||
v_texCoords0 = a_texCoord0;
|
||||
#endif // blendedTextureFlag
|
||||
|
||||
#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_projViewWorldTrans * skinning * vec4(a_position, 1.0);
|
||||
#else
|
||||
vec4 pos = u_projViewWorldTrans * vec4(a_position, 1.0);
|
||||
#endif
|
||||
|
||||
#ifdef PackedDepthFlag
|
||||
v_depth = pos.z / pos.w * 0.5 + 0.5;
|
||||
#endif //PackedDepthFlag
|
||||
|
||||
gl_Position = pos;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user