123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186 |
- precision mediump float;
- // Attributes
- attribute vec3 position;
- attribute vec3 normal;
- #ifdef UV1
- attribute vec2 uv;
- #endif
- #ifdef UV2
- attribute vec2 uv2;
- #endif
- #ifdef VERTEXCOLOR
- attribute vec4 color;
- #endif
- #if NUM_BONE_INFLUENCERS > 0
- uniform mat4 mBones[BonesPerMesh];
- attribute vec4 matricesIndices;
- attribute vec4 matricesWeights;
- #if NUM_BONE_INFLUENCERS > 4
- attribute vec4 matricesIndicesExtra;
- attribute vec4 matricesWeightsExtra;
- #endif
- #endif
- // Uniforms
- uniform mat4 world;
- uniform mat4 view;
- uniform mat4 viewProjection;
- #ifdef ALBEDO
- varying vec2 vAlbedoUV;
- uniform mat4 albedoMatrix;
- uniform vec2 vAlbedoInfos;
- #endif
- #ifdef AMBIENT
- varying vec2 vAmbientUV;
- uniform mat4 ambientMatrix;
- uniform vec2 vAmbientInfos;
- #endif
- #ifdef OPACITY
- varying vec2 vOpacityUV;
- uniform mat4 opacityMatrix;
- uniform vec2 vOpacityInfos;
- #endif
- #ifdef EMISSIVE
- varying vec2 vEmissiveUV;
- uniform vec2 vEmissiveInfos;
- uniform mat4 emissiveMatrix;
- #endif
- #if defined(REFLECTIVITY)
- varying vec2 vReflectivityUV;
- uniform vec2 vReflectivityInfos;
- uniform mat4 reflectivityMatrix;
- #endif
- // Output
- varying vec3 vPositionW;
- varying vec3 vNormalW;
- #ifdef VERTEXCOLOR
- varying vec4 vColor;
- #endif
- #ifdef CLIPPLANE
- uniform vec4 vClipPlane;
- varying float fClipDistance;
- #endif
- void main(void) {
- mat4 finalWorld = world;
- #if NUM_BONE_INFLUENCERS > 0
- mat4 influence;
- influence = mBones[int(matricesIndices[0])] * matricesWeights[0];
- #if NUM_BONE_INFLUENCERS > 1
- influence += mBones[int(matricesIndices[1])] * matricesWeights[1];
- #endif
- #if NUM_BONE_INFLUENCERS > 2
- influence += mBones[int(matricesIndices[2])] * matricesWeights[2];
- #endif
- #if NUM_BONE_INFLUENCERS > 3
- influence += mBones[int(matricesIndices[3])] * matricesWeights[3];
- #endif
- #if NUM_BONE_INFLUENCERS > 4
- influence += mBones[int(matricesIndicesExtra[0])] * matricesWeightsExtra[0];
- #endif
- #if NUM_BONE_INFLUENCERS > 5
- influence += mBones[int(matricesIndicesExtra[1])] * matricesWeightsExtra[1];
- #endif
- #if NUM_BONE_INFLUENCERS > 6
- influence += mBones[int(matricesIndicesExtra[2])] * matricesWeightsExtra[2];
- #endif
- #if NUM_BONE_INFLUENCERS > 7
- influence += mBones[int(matricesIndicesExtra[3])] * matricesWeightsExtra[3];
- #endif
- finalWorld = finalWorld * influence;
- #endif
- gl_Position = viewProjection * finalWorld * vec4(position, 1.0);
- vec4 worldPos = finalWorld * vec4(position, 1.0);
- vPositionW = vec3(worldPos);
- vNormalW = normalize(vec3(finalWorld * vec4(normal, 0.0)));
- // Texture coordinates
- #ifndef UV1
- vec2 uv = vec2(0., 0.);
- #endif
- #ifndef UV2
- vec2 uv2 = vec2(0., 0.);
- #endif
- #ifdef ALBEDO
- if (vAlbedoInfos.x == 0.)
- {
- vAlbedoUV = vec2(albedoMatrix * vec4(uv, 1.0, 0.0));
- }
- else
- {
- vAlbedoUV = vec2(albedoMatrix * vec4(uv2, 1.0, 0.0));
- }
- #endif
- #ifdef AMBIENT
- if (vAmbientInfos.x == 0.)
- {
- vAmbientUV = vec2(ambientMatrix * vec4(uv, 1.0, 0.0));
- }
- else
- {
- vAmbientUV = vec2(ambientMatrix * vec4(uv2, 1.0, 0.0));
- }
- #endif
- #ifdef OPACITY
- if (vOpacityInfos.x == 0.)
- {
- vOpacityUV = vec2(opacityMatrix * vec4(uv, 1.0, 0.0));
- }
- else
- {
- vOpacityUV = vec2(opacityMatrix * vec4(uv2, 1.0, 0.0));
- }
- #endif
- #ifdef EMISSIVE
- if (vEmissiveInfos.x == 0.)
- {
- vEmissiveUV = vec2(emissiveMatrix * vec4(uv, 1.0, 0.0));
- }
- else
- {
- vEmissiveUV = vec2(emissiveMatrix * vec4(uv2, 1.0, 0.0));
- }
- #endif
- #if defined(REFLECTIVITY)
- if (vReflectivityInfos.x == 0.)
- {
- vReflectivityUV = vec2(reflectivityMatrix * vec4(uv, 1.0, 0.0));
- }
- else
- {
- vReflectivityUV = vec2(reflectivityMatrix * vec4(uv2, 1.0, 0.0));
- }
- #endif
- // Clip plane
- #ifdef CLIPPLANE
- fClipDistance = dot(worldPos, vClipPlane);
- #endif
- // Vertex color
- #ifdef VERTEXCOLOR
- vColor = color;
- #endif
- }
|