|
@@ -1,226 +0,0 @@
|
|
|
-#define MAP_PROJECTION 4.
|
|
|
-
|
|
|
-// Constants
|
|
|
-uniform vec3 vEyePosition;
|
|
|
-uniform vec3 vAmbientColor;
|
|
|
-uniform vec4 vDiffuseColor;
|
|
|
-#ifdef SPECULARTERM
|
|
|
-uniform vec4 vSpecularColor;
|
|
|
-#endif
|
|
|
-uniform vec3 vEmissiveColor;
|
|
|
-
|
|
|
-// Input
|
|
|
-varying vec3 vPositionW;
|
|
|
-varying vec3 vNormalW;
|
|
|
-
|
|
|
-#ifdef VERTEXCOLOR
|
|
|
-varying vec4 vColor;
|
|
|
-#endif
|
|
|
-
|
|
|
-// Lights
|
|
|
-#include<lightFragmentDeclaration>[0..3]
|
|
|
-
|
|
|
-#include<lightsFragmentFunctions>
|
|
|
-#include<shadowsFragmentFunctions>
|
|
|
-
|
|
|
-// Samplers
|
|
|
-#ifdef DIFFUSE
|
|
|
-varying vec2 vDiffuseUV;
|
|
|
-uniform sampler2D diffuseSampler;
|
|
|
-uniform vec2 vDiffuseInfos;
|
|
|
-#endif
|
|
|
-
|
|
|
-#ifdef AMBIENT
|
|
|
-varying vec2 vAmbientUV;
|
|
|
-uniform sampler2D ambientSampler;
|
|
|
-uniform vec2 vAmbientInfos;
|
|
|
-#endif
|
|
|
-
|
|
|
-#ifdef OPACITY
|
|
|
-varying vec2 vOpacityUV;
|
|
|
-uniform sampler2D opacitySampler;
|
|
|
-uniform vec2 vOpacityInfos;
|
|
|
-#endif
|
|
|
-
|
|
|
-#ifdef REFLECTION
|
|
|
-varying vec3 vReflectionUVW;
|
|
|
-#ifdef REFLECTIONMAP_3D
|
|
|
-uniform samplerCube reflectionCubeSampler;
|
|
|
-#else
|
|
|
-uniform sampler2D reflection2DSampler;
|
|
|
-#endif
|
|
|
-uniform vec2 vReflectionInfos;
|
|
|
-#endif
|
|
|
-
|
|
|
-#ifdef EMISSIVE
|
|
|
-varying vec2 vEmissiveUV;
|
|
|
-uniform vec2 vEmissiveInfos;
|
|
|
-uniform sampler2D emissiveSampler;
|
|
|
-#endif
|
|
|
-
|
|
|
-#if defined(SPECULAR) && defined(SPECULARTERM)
|
|
|
-varying vec2 vSpecularUV;
|
|
|
-uniform vec2 vSpecularInfos;
|
|
|
-uniform sampler2D specularSampler;
|
|
|
-#endif
|
|
|
-
|
|
|
-// Fresnel
|
|
|
-#include<fresnelFunction>
|
|
|
-
|
|
|
-#ifdef DIFFUSEFRESNEL
|
|
|
-uniform vec4 diffuseLeftColor;
|
|
|
-uniform vec4 diffuseRightColor;
|
|
|
-#endif
|
|
|
-
|
|
|
-#ifdef OPACITYFRESNEL
|
|
|
-uniform vec4 opacityParts;
|
|
|
-#endif
|
|
|
-
|
|
|
-#ifdef REFLECTIONFRESNEL
|
|
|
-uniform vec4 reflectionLeftColor;
|
|
|
-uniform vec4 reflectionRightColor;
|
|
|
-#endif
|
|
|
-
|
|
|
-#ifdef EMISSIVEFRESNEL
|
|
|
-uniform vec4 emissiveLeftColor;
|
|
|
-uniform vec4 emissiveRightColor;
|
|
|
-#endif
|
|
|
-
|
|
|
-#include<clipPlaneFragmentDeclaration>
|
|
|
-#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;
|
|
|
-
|
|
|
-#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
|
|
|
-
|
|
|
- // Bump
|
|
|
- vec3 normalW = normalize(vNormalW);
|
|
|
-
|
|
|
- // Ambient color
|
|
|
- vec3 baseAmbientColor = vec3(1., 1., 1.);
|
|
|
-
|
|
|
-#ifdef AMBIENT
|
|
|
- baseAmbientColor = texture2D(ambientSampler, vAmbientUV).rgb * vAmbientInfos.y;
|
|
|
-#endif
|
|
|
-
|
|
|
- // Lighting
|
|
|
- vec3 diffuseBase = vec3(0., 0., 0.);
|
|
|
- lightingInfo info;
|
|
|
- float glossiness = 0.;
|
|
|
-#ifdef SPECULARTERM
|
|
|
- vec3 specularBase = vec3(0., 0., 0.);
|
|
|
- glossiness = vSpecularColor.a;
|
|
|
-#endif
|
|
|
- float shadow = 1.;
|
|
|
-
|
|
|
-#include<lightFragment>[0..3]
|
|
|
-
|
|
|
- // Reflection
|
|
|
- vec3 reflectionColor = vec3(0., 0., 0.);
|
|
|
-
|
|
|
-#ifdef REFLECTION
|
|
|
-#ifdef REFLECTIONMAP_3D
|
|
|
- reflectionColor = textureCube(reflectionCubeSampler, vReflectionUVW).rgb * vReflectionInfos.x;
|
|
|
-#else
|
|
|
- vec2 coords = vReflectionUVW.xy;
|
|
|
-
|
|
|
-#ifdef REFLECTIONMAP_PROJECTION
|
|
|
- coords /= vReflectionUVW.z;
|
|
|
-#endif
|
|
|
-
|
|
|
- coords.y = 1.0 - coords.y;
|
|
|
-
|
|
|
- reflectionColor = texture2D(reflection2DSampler, coords).rgb * vReflectionInfos.x;
|
|
|
-#endif
|
|
|
-
|
|
|
-#ifdef REFLECTIONFRESNEL
|
|
|
- float reflectionFresnelTerm = computeFresnelTerm(viewDirectionW, normalW, reflectionRightColor.a, reflectionLeftColor.a);
|
|
|
-
|
|
|
- reflectionColor *= reflectionLeftColor.rgb * (1.0 - reflectionFresnelTerm) + reflectionFresnelTerm * reflectionRightColor.rgb;
|
|
|
-#endif
|
|
|
-#endif
|
|
|
-
|
|
|
- // Alpha
|
|
|
- float alpha = vDiffuseColor.a;
|
|
|
-
|
|
|
-#ifdef OPACITY
|
|
|
- vec4 opacityMap = texture2D(opacitySampler, vOpacityUV);
|
|
|
-#ifdef OPACITYRGB
|
|
|
- opacityMap.rgb = opacityMap.rgb * vec3(0.3, 0.59, 0.11);
|
|
|
- alpha *= (opacityMap.x + opacityMap.y + opacityMap.z)* vOpacityInfos.y;
|
|
|
-#else
|
|
|
- alpha *= opacityMap.a * vOpacityInfos.y;
|
|
|
-#endif
|
|
|
-#endif
|
|
|
-
|
|
|
-#ifdef VERTEXALPHA
|
|
|
- alpha *= vColor.a;
|
|
|
-#endif
|
|
|
-
|
|
|
-#ifdef OPACITYFRESNEL
|
|
|
- float opacityFresnelTerm = computeFresnelTerm(viewDirectionW, normalW, opacityParts.z, opacityParts.w);
|
|
|
-
|
|
|
- alpha += opacityParts.x * (1.0 - opacityFresnelTerm) + opacityFresnelTerm * opacityParts.y;
|
|
|
-#endif
|
|
|
-
|
|
|
- // Emissive
|
|
|
- vec3 emissiveColor = vEmissiveColor;
|
|
|
-#ifdef EMISSIVE
|
|
|
- emissiveColor += texture2D(emissiveSampler, vEmissiveUV).rgb * vEmissiveInfos.y;
|
|
|
-#endif
|
|
|
-
|
|
|
-#ifdef EMISSIVEFRESNEL
|
|
|
- float emissiveFresnelTerm = computeFresnelTerm(viewDirectionW, normalW, emissiveRightColor.a, emissiveLeftColor.a);
|
|
|
-
|
|
|
- emissiveColor *= emissiveLeftColor.rgb * (1.0 - emissiveFresnelTerm) + emissiveFresnelTerm * emissiveRightColor.rgb;
|
|
|
-#endif
|
|
|
-
|
|
|
- // Specular map
|
|
|
-#ifdef SPECULARTERM
|
|
|
- vec3 specularColor = vSpecularColor.rgb;
|
|
|
-#ifdef SPECULAR
|
|
|
- specularColor = texture2D(specularSampler, vSpecularUV).rgb * vSpecularInfos.y;
|
|
|
-#endif
|
|
|
-#endif
|
|
|
-
|
|
|
- // Fresnel
|
|
|
-#ifdef DIFFUSEFRESNEL
|
|
|
- float diffuseFresnelTerm = computeFresnelTerm(viewDirectionW, normalW, diffuseRightColor.a, diffuseLeftColor.a);
|
|
|
-
|
|
|
- diffuseBase *= diffuseLeftColor.rgb * (1.0 - diffuseFresnelTerm) + diffuseFresnelTerm * diffuseRightColor.rgb;
|
|
|
-#endif
|
|
|
-
|
|
|
- // Composition
|
|
|
- vec3 finalDiffuse = clamp(diffuseBase * diffuseColor + emissiveColor + vAmbientColor, 0.0, 1.0) * baseColor.rgb;
|
|
|
-#ifdef SPECULARTERM
|
|
|
- vec3 finalSpecular = specularBase * specularColor;
|
|
|
-#else
|
|
|
- vec3 finalSpecular = vec3(0.0);
|
|
|
-#endif
|
|
|
-
|
|
|
- vec4 color = vec4(finalDiffuse * baseAmbientColor + finalSpecular + reflectionColor, alpha);
|
|
|
-
|
|
|
-#include<fogFragment>
|
|
|
-
|
|
|
- gl_FragColor = color;
|
|
|
-}
|