12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- precision highp float;
- // Constants
- uniform vec3 vEyePosition;
- uniform vec4 vDiffuseColor;
- // Input
- varying vec3 vPositionW;
- #ifdef NORMAL
- varying vec3 vNormalW;
- #endif
- #ifdef VERTEXCOLOR
- varying vec4 vColor;
- #endif
- // Lights
- #include<light0FragmentDeclaration>
- #include<light1FragmentDeclaration>
- #include<light2FragmentDeclaration>
- #include<light3FragmentDeclaration>
- #include<lightsFragmentFunctions>
- #include<shadowsFragmentFunctions>
- // Samplers
- #ifdef DIFFUSE
- varying vec2 vDiffuseUV;
- uniform sampler2D diffuseSampler;
- uniform vec2 vDiffuseInfos;
- #endif
- #include<clipPlaneFragmentDeclaration>
- // Fog
- #include<fogFragmentDeclaration>
- void main(void) {
- #include<clipPlaneFragment>
- vec3 viewDirectionW = normalize(vEyePosition - vPositionW);
- // Base color
- vec4 baseColor = vec4(1., 1., 1., 1.);
- vec3 diffuseColor = vDiffuseColor.rgb;
- // Alpha
- float alpha = vDiffuseColor.a;
- #ifdef DIFFUSE
- baseColor = texture2D(diffuseSampler, vDiffuseUV);
- #ifdef ALPHATEST
- if (baseColor.a < 0.4)
- discard;
- #endif
- baseColor.rgb *= vDiffuseInfos.y;
- #endif
- #ifdef VERTEXCOLOR
- baseColor.rgb *= vColor.rgb;
- #endif
- // Normal
- #ifdef NORMAL
- vec3 normalW = normalize(vNormalW);
- #else
- vec3 normalW = vec3(1.0, 1.0, 1.0);
- #endif
- // Lighting
- vec3 diffuseBase = vec3(0., 0., 0.);
- float shadow = 1.;
- float glossiness = 0.;
-
- #include<light0Fragment>
- #include<light1Fragment>
- #include<light2Fragment>
- #include<light3Fragment>
- #ifdef VERTEXALPHA
- alpha *= vColor.a;
- #endif
- vec3 finalDiffuse = clamp(diffuseBase * diffuseColor, 0.0, 1.0) * baseColor.rgb;
- // Composition
- vec4 color = vec4(finalDiffuse, alpha);
- #include<fogFragment>
- gl_FragColor = color;
- }
|