{ "blur_h.fs" : "precision highp float;\n\nuniform vec4 blurWeights0;\nuniform vec4 blurWeights1;\nuniform vec2 texelSize;\nuniform sampler2D sourceMap;\n\nvarying vec2 vUV;\n\nvoid main(void)\n{\n vec4 sum = vec4(0.0);\n\n sum += texture2D(sourceMap, vec2(vUV.x - 6.0*texelSize.x, vUV.y)) * blurWeights1.z;\n sum += texture2D(sourceMap, vec2(vUV.x - 5.0*texelSize.x, vUV.y)) * blurWeights1.y;\n sum += texture2D(sourceMap, vec2(vUV.x - 4.0*texelSize.x, vUV.y)) * blurWeights1.x;\n sum += texture2D(sourceMap, vec2(vUV.x - 3.0*texelSize.x, vUV.y)) * blurWeights0.w;\n sum += texture2D(sourceMap, vec2(vUV.x - 2.0*texelSize.x, vUV.y)) * blurWeights0.z;\n sum += texture2D(sourceMap, vec2(vUV.x - texelSize.x, vUV.y)) * blurWeights0.y;\n sum += texture2D(sourceMap, vUV) * blurWeights0.x;\n sum += texture2D(sourceMap, vec2(vUV.x + texelSize.x, vUV.y)) * blurWeights0.y;\n sum += texture2D(sourceMap, vec2(vUV.x + 2.0*texelSize.x, vUV.y)) * blurWeights0.z;\n sum += texture2D(sourceMap, vec2(vUV.x + 3.0*texelSize.x, vUV.y)) * blurWeights0.w;\n sum += texture2D(sourceMap, vec2(vUV.x + 4.0*texelSize.x, vUV.y)) * blurWeights1.x;\n sum += texture2D(sourceMap, vec2(vUV.x + 5.0*texelSize.x, vUV.y)) * blurWeights1.y;\n sum += texture2D(sourceMap, vec2(vUV.x + 6.0*texelSize.x, vUV.y)) * blurWeights1.z;\n\n gl_FragColor = vec4(sum.rgb, 1.0);\n}\n", "blur_v.fs" : "precision highp float;\n\nuniform vec4 blurWeights0;\nuniform vec4 blurWeights1;\nuniform vec2 texelSize;\nuniform sampler2D sourceMap;\n\nvarying vec2 vUV;\n\nvoid main(void)\n{\n vec4 sum = vec4(0.0);\n\n sum += texture2D(sourceMap, vec2(vUV.x, vUV.y - 6.0*texelSize.y)) * blurWeights1.z;\n sum += texture2D(sourceMap, vec2(vUV.x, vUV.y - 5.0*texelSize.y)) * blurWeights1.y;\n sum += texture2D(sourceMap, vec2(vUV.x, vUV.y - 4.0*texelSize.y)) * blurWeights1.x;\n sum += texture2D(sourceMap, vec2(vUV.x, vUV.y - 3.0*texelSize.y)) * blurWeights0.w;\n sum += texture2D(sourceMap, vec2(vUV.x, vUV.y - 2.0*texelSize.y)) * blurWeights0.z;\n sum += texture2D(sourceMap, vec2(vUV.x, vUV.y - texelSize.y)) * blurWeights0.y;\n sum += texture2D(sourceMap, vUV) * blurWeights0.x;\n sum += texture2D(sourceMap, vec2(vUV.x, vUV.y + texelSize.y)) * blurWeights0.y;\n sum += texture2D(sourceMap, vec2(vUV.x, vUV.y + 2.0*texelSize.y)) * blurWeights0.z;\n sum += texture2D(sourceMap, vec2(vUV.x, vUV.y + 3.0*texelSize.y)) * blurWeights0.w;\n sum += texture2D(sourceMap, vec2(vUV.x, vUV.y + 4.0*texelSize.y)) * blurWeights1.x;\n sum += texture2D(sourceMap, vec2(vUV.x, vUV.y + 5.0*texelSize.y)) * blurWeights1.y;\n sum += texture2D(sourceMap, vec2(vUV.x, vUV.y + 6.0*texelSize.y)) * blurWeights1.z;\n\n gl_FragColor = vec4(sum.rgb, 1.0);\n}\n", "bright.fs" : "precision highp float;\n\nuniform float brightThreshold;\nuniform float brightScale;\nuniform vec2 texelSize;\nuniform sampler2D sourceMap;\n\nvarying vec2 vUV;\n\nvec3 getBrightValue(vec2 uv)\n{\n\tvec3 sample = texture2D(sourceMap, uv).rgb;\n\tfloat luminance = max(sample.r, max(sample.g, sample.b));\n\treturn sample * max(luminance - brightThreshold, 0.0) * (1.0 / (1.0 - brightThreshold)) * brightScale;\n}\n\nvoid main(void)\n{\n\tvec3 average = vec3(0.0);\n\taverage += getBrightValue(vec2(vUV + vec2(-1.5, -1.5) * texelSize));\n\taverage += getBrightValue(vec2(vUV + vec2(-0.5, -1.5) * texelSize));\n\taverage += getBrightValue(vec2(vUV + vec2( 0.5, -1.5) * texelSize));\n\taverage += getBrightValue(vec2(vUV + vec2( 1.5, -1.5) * texelSize));\n\taverage += getBrightValue(vec2(vUV + vec2(-1.5, -0.5) * texelSize));\n\taverage += getBrightValue(vec2(vUV + vec2(-0.5, -0.5) * texelSize));\n\taverage += getBrightValue(vec2(vUV + vec2( 0.5, -0.5) * texelSize));\n\taverage += getBrightValue(vec2(vUV + vec2( 1.5, -0.5) * texelSize));\n\taverage += getBrightValue(vec2(vUV + vec2(-1.5, 0.5) * texelSize));\n\taverage += getBrightValue(vec2(vUV + vec2(-0.5, 0.5) * texelSize));\n\taverage += getBrightValue(vec2(vUV + vec2( 0.5, 0.5) * texelSize));\n\taverage += getBrightValue(vec2(vUV + vec2( 1.5, 0.5) * texelSize));\n\taverage += getBrightValue(vec2(vUV + vec2(-1.5, 1.5) * texelSize));\n\taverage += getBrightValue(vec2(vUV + vec2(-0.5, 1.5) * texelSize));\n\taverage += getBrightValue(vec2(vUV + vec2( 0.5, 1.5) * texelSize));\n\taverage += getBrightValue(vec2(vUV + vec2( 1.5, 1.5) * texelSize));\n\tgl_FragColor = vec4(average * 0.0625, 1.0);\n}\n", "color.fs" : "precision highp float;\n\nuniform vec4 color;\n\nvarying float vLambert;\n\nvoid main()\n{\n gl_FragColor = vec4(color.rgb * vLambert, color.a);\n}\n", "color.vs" : "precision highp float;\n\nattribute vec3 lxPosition;\nattribute vec3 lxNormal;\n\nuniform mat4 mxVP;\nuniform mat4 mxW;\nuniform vec3 lightDir;\n\nvarying float vLambert;\n\nvoid main()\n{\n vec4 worldPos = mxW * vec4(lxPosition, 1.0);\n gl_Position = mxVP * worldPos;\n vec3 vNormal = normalize(mat3(mxW[0].xyz, mxW[1].xyz, mxW[2].xyz) * lxNormal);\n vLambert = clamp(dot(vNormal, normalize(lightDir)), 0.0, 1.0);\n}\n", "combine.fs" : "precision highp float;\n\nuniform float sourceIntensity;\nuniform vec2 sourceTexelSize;\nuniform sampler2D sourceMap;\nuniform sampler2D bloomMap;\n\nvarying vec2 vUV;\n\nvoid main(void)\n{\n\tvec3 srcColor = texture2D(sourceMap, vec2(vUV)).rgb;\n\tvec3 bloomColor = texture2D(bloomMap, vUV).rgb;\n\tgl_FragColor = vec4(srcColor * sourceIntensity + bloomColor, 1.0);\n}\n", "debug.fs" : "precision highp float;\n\nvarying vec4 vColor;\n\nvoid main()\n{\n gl_FragColor = vColor;\n}\n", "debug.vs" : "precision highp float;\n\nattribute vec3 lxPosition;\n\nuniform mat4 mxVP;\nuniform vec4 color;\n\nvarying vec4 vColor;\n\nvoid main()\n{\n gl_Position = mxVP * vec4(lxPosition, 1.0);\n vColor = color;\n}\n", "default.fs" : "precision highp float;\n\nuniform sampler2D colorMap;\n\nvarying vec2 vUV;\nvarying float vLambert;\n\nvoid main()\n{\n vec4 color = texture2D(colorMap, vUV);\n if( color.a < 0.5 ){ discard; };\n gl_FragColor = vec4(color.rgb * vLambert, 1.0);\n}\n", "default.vs" : "precision highp float;\n\nattribute vec3 lxPosition;\nattribute vec3 lxNormal;\nattribute vec2 lxUV0;\n\nuniform mat4 mxVP;\nuniform mat4 mxW;\nuniform vec3 lightDir;\nuniform vec3 viewPos;\n\nvarying vec2 vUV;\nvarying float vLambert;\n\nvoid main()\n{\n vec4 worldPos = mxW * vec4(lxPosition, 1.0);\n gl_Position = mxVP * worldPos;\n vec3 vNormal = normalize(mat3(mxW[0].xyz, mxW[1].xyz, mxW[2].xyz) * lxNormal);\n vUV = lxUV0;\n vLambert = clamp(dot(vNormal, normalize(lightDir)), 0.0, 1.0);\n}\n", "glass.fs" : "precision highp float;\n\n#ifdef SHADOWS\nuniform sampler2D shadowMap;\n#endif\n#ifdef AO_MAP\nuniform sampler2D aoMap;\n#endif\nuniform samplerCube ambientCube;\nuniform samplerCube reflectionMap;\n\n#ifdef SHADOWS\nvarying vec4 vPositionTLP;\n#endif\nvarying vec3 vNormal;\nvarying vec4 vLightDir;\nvarying vec4 vViewDir;\nvarying vec3 vFresnel;\nvarying vec4 vColor;\n#ifdef AO_MAP\nvarying vec2 vUV;\n#endif\n\nuniform float ambientIntensity;\nuniform float lightIntensity;\n#ifdef SHADOWS\nuniform vec2 shadowMapSize;\nuniform vec2 shadowMapTexelSize;\n#endif\n\n#ifdef SHADOWS\nfloat rgbaToFloat(vec4 value)\n{\n\tconst vec4 shifts = vec4(1.0 / (256.0 * 256.0 * 256.0), 1.0 / (256.0 * 256.0), 1.0 / 256.0, 1);\n\treturn dot(value, shifts);\n}\n\nfloat fetchShadowMap(vec2 uv, float depth)\n{\n\tvec4 terms;\n\tterms.x = float(rgbaToFloat(texture2D(shadowMap, uv)) > depth);\n\tterms.y = float(rgbaToFloat(texture2D(shadowMap, uv + vec2(shadowMapTexelSize.x, 0))) > depth);\n\tterms.z = float(rgbaToFloat(texture2D(shadowMap, uv + vec2(0, shadowMapTexelSize.y))) > depth);\n\tterms.w = float(rgbaToFloat(texture2D(shadowMap, uv + shadowMapTexelSize)) > depth);\n\n\tvec2 lerps = fract(uv * shadowMapSize);\n\tvec2 firstLerp = mix(terms.xz, terms.yw, lerps.x);\n\treturn mix(firstLerp.x, firstLerp.y, lerps.y);\n}\n\nfloat calcShadowTerm(vec4 positionTLP)\n{\n\tconst float depthBias = 0.004;\n\n\tvec2 uv = positionTLP.xy / positionTLP.w;\n\tfloat depth = (positionTLP.z - depthBias) / positionTLP.w;\n\n\tvec3 result;\n\tresult.x = fetchShadowMap(uv + vec2(-0.7904286, -0.2801397) * shadowMapTexelSize, depth);\n\tresult.y = fetchShadowMap(uv + vec2(0.1648042, 0.5930318) * shadowMapTexelSize, depth);\n\tresult.z = fetchShadowMap(uv + vec2(0.4335592, -0.6467823) * shadowMapTexelSize, depth);\n\treturn dot(result, vec3(0.333));\n}\n#endif\n\nvoid main()\n{\n vec3 normal = normalize(vNormal);\n vec3 lightDir = normalize(vLightDir.xyz);\n vec3 viewDir = normalize(vViewDir.xyz);\n vec3 vReflect = normalize(reflect(viewDir, normal));\n\n\tvec3 refection = textureCube(reflectionMap, vReflect).rgb;\n float fresnel = vFresnel.x + (1.0 - vFresnel.x) * pow(1.0 + dot(viewDir, normalize(vReflect - viewDir)), vFresnel.y);\n vec3 albedo = mix(vColor.rgb, refection, fresnel * vFresnel.z);\n#ifdef AO_MAP\n\talbedo *= texture2D(aoMap, vUV).rgb;\n#endif\n\n\tfloat shadowTerm = 1.0;\n#ifdef SHADOWS\n\tshadowTerm = calcShadowTerm(vPositionTLP);\n#endif\n vec3 ambient = (textureCube(ambientCube, normal).rgb * 0.5 + 0.5) * ambientIntensity;\n\tfloat diffuse = clamp(dot(normal, lightDir), 0.0, 1.0) * lightIntensity * shadowTerm;\n float specular = pow(clamp(dot(vReflect, lightDir), 0.0, 1.0), vLightDir.w) * vViewDir.w * shadowTerm;\n\n gl_FragColor = vec4(albedo * (ambient + diffuse) + specular, vColor.a + specular);\n}\n", "glass.vs" : "precision highp float;\n\nattribute vec3 lxPosition;\nattribute vec3 lxNormal;\n#ifdef AO_MAP\nattribute vec2 lxUV1;\n#endif\n\n#ifdef SHADOWS\nuniform mat4 mxTLP;\n#endif\nuniform mat4 mxVP;\nuniform mat4 mxW;\nuniform float specularPower;\nuniform float specularIntensity;\nuniform float fresnelOffset;\nuniform float fresnelPower;\nuniform float reflectionIntensity;\nuniform vec3 lightDir;\nuniform vec3 viewPos;\nuniform vec4 color;\n\n#ifdef SHADOWS\nvarying vec4 vPositionTLP;\n#endif\nvarying vec3 vNormal;\nvarying vec4 vLightDir;\nvarying vec4 vViewDir;\nvarying vec3 vFresnel;\nvarying vec4 vColor;\n#ifdef AO_MAP\nvarying vec2 vUV;\n#endif\n\nvoid main()\n{\n vec4 worldPos = mxW * vec4(lxPosition, 1.0);\n gl_Position = mxVP * worldPos;\n#ifdef SHADOWS\n\tvPositionTLP = mxTLP * worldPos;\n#endif\n vNormal = mat3(mxW[0].xyz, mxW[1].xyz, mxW[2].xyz) * lxNormal;\n vLightDir.xyz = lightDir;\n vLightDir.w = specularPower;\n vViewDir.xyz = worldPos.xyz - viewPos;\n vViewDir.w = specularIntensity;\n vFresnel.x = fresnelOffset;\n vFresnel.y = fresnelPower;\n vFresnel.z = reflectionIntensity;\n vColor = color;\n#ifdef AO_MAP\n vUV = lxUV1;\n#endif\n}\n", "ground.fs" : "precision highp float;\n\n#ifdef SHADOWS\nuniform sampler2D shadowMap;\n#endif\n#ifdef AO_MAP\nuniform sampler2D aoMap;\n#endif\nuniform samplerCube ambientCube;\n#ifdef BLEND_MAP\nuniform sampler2D blendMap;\nuniform sampler2D layer0Map;\nuniform sampler2D layer1Map;\nuniform sampler2D layer2Map;\nuniform sampler2D layer3Map;\n#else\nuniform sampler2D colorMap;\n#endif\n#ifdef DETAIL_MAP\nuniform sampler2D detailMap;\n#ifdef NORMAL_MAP\nuniform sampler2D normalMap;\n#endif\n#endif\n\n#ifdef SHADOWS\nvarying vec4 vPositionTLP;\n#endif\nvarying vec3 vWorldNormal;\nvarying vec3 vLightDir;\nvarying vec4 vUV;\n\nuniform float ambientIntensity;\nuniform float lightIntensity;\n#ifdef SHADOWS\nuniform vec2 shadowMapSize;\nuniform vec2 shadowMapTexelSize;\n#endif\n#ifdef DETAIL_MAP\nuniform float detailScale;\n#endif\n#ifdef BLEND_MAP\nuniform float layersScale;\n#endif\n\n#ifdef SHADOWS\nfloat rgbaToFloat(vec4 value)\n{\n\tconst vec4 shifts = vec4(1.0 / (256.0 * 256.0 * 256.0), 1.0 / (256.0 * 256.0), 1.0 / 256.0, 1);\n\treturn dot(value, shifts);\n}\n\nfloat fetchShadowMap(vec2 uv, float depth)\n{\n\tvec4 terms;\n\tterms.x = float(rgbaToFloat(texture2D(shadowMap, uv)) > depth);\n\tterms.y = float(rgbaToFloat(texture2D(shadowMap, uv + vec2(shadowMapTexelSize.x, 0))) > depth);\n\tterms.z = float(rgbaToFloat(texture2D(shadowMap, uv + vec2(0, shadowMapTexelSize.y))) > depth);\n\tterms.w = float(rgbaToFloat(texture2D(shadowMap, uv + shadowMapTexelSize)) > depth);\n\n\tvec2 lerps = fract(uv * shadowMapSize);\n\tvec2 firstLerp = mix(terms.xz, terms.yw, lerps.x);\n\treturn mix(firstLerp.x, firstLerp.y, lerps.y);\n}\n\nfloat calcShadowTerm(vec4 positionTLP)\n{\n\tconst float depthBias = 0.002;\n\n\tvec2 uv = positionTLP.xy / positionTLP.w;\n\tfloat depth = (positionTLP.z - depthBias) / positionTLP.w;\n\n\tvec3 result;\n\tresult.x = fetchShadowMap(uv + vec2(-0.7904286, -0.2801397) * shadowMapTexelSize, depth);\n\tresult.y = fetchShadowMap(uv + vec2(0.1648042, 0.5930318) * shadowMapTexelSize, depth);\n\tresult.z = fetchShadowMap(uv + vec2(0.4335592, -0.6467823) * shadowMapTexelSize, depth);\n\treturn dot(result, vec3(0.333));\n}\n#endif\n\nvoid main()\n{\n vec3 worldNormal = normalize(vWorldNormal);\n\tvec3 normal = worldNormal;\n vec3 lightDir = normalize(vLightDir);\n\n#ifdef BLEND_MAP\n vec2 layerUV = vUV.xy * layersScale;\n\tvec4 blendFactors = normalize(texture2D(blendMap, vUV.xy));\n\tvec3 albedo = texture2D(layer0Map, layerUV).rgb * blendFactors.r + texture2D(layer1Map, layerUV).rgb *\n\t\tblendFactors.g + texture2D(layer2Map, layerUV).rgb * blendFactors.b + texture2D(layer3Map, layerUV).rgb * blendFactors.a;\n#else\n vec3 albedo = texture2D(colorMap, vUV.xy).rgb;\n#endif\n#ifdef AO_MAP\n\talbedo *= texture2D(aoMap, vUV.zw).rgb;\n#endif\n#ifdef DETAIL_MAP\n vec2 detailUV = vUV.xy * detailScale;\n\talbedo *= texture2D(detailMap, detailUV).rgb * 2.0;\n#ifdef NORMAL_MAP\n normal = texture2D(normalMap, detailUV).rgb * 2.0 - 1.0;\n#endif\n#endif\n\n\tfloat shadowTerm = 1.0;\n#ifdef SHADOWS\n\tshadowTerm = calcShadowTerm(vPositionTLP);\n#endif\n vec3 ambient = (textureCube(ambientCube, worldNormal).rgb * 0.5 + 0.5) * ambientIntensity;\n\tfloat diffuse = clamp(dot(normal, lightDir), 0.0, 1.0) * lightIntensity * shadowTerm;\n\n gl_FragColor = vec4(albedo * (ambient + diffuse), 1.0);\n}\n", "ground.vs" : "precision highp float;\n\nattribute vec3 lxPosition;\nattribute vec3 lxNormal;\n#ifdef NORMAL_MAP\nattribute vec3 lxTangent0;\n#endif\nattribute vec2 lxUV0;\n#ifdef AO_MAP\nattribute vec2 lxUV1;\n#endif\n\n#ifdef SHADOWS\nuniform mat4 mxTLP;\n#endif\nuniform mat4 mxVP;\nuniform mat4 mxW;\nuniform vec3 lightDir;\n\n#ifdef SHADOWS\nvarying vec4 vPositionTLP;\n#endif\nvarying vec3 vWorldNormal;\nvarying vec3 vLightDir;\nvarying vec4 vUV;\n\nvoid main()\n{\n vec4 worldPos = mxW * vec4(lxPosition, 1.0);\n gl_Position = mxVP * worldPos;\n#ifdef SHADOWS\n\tvPositionTLP = mxTLP * worldPos;\n#endif\n\n vWorldNormal = mat3(mxW[0].xyz, mxW[1].xyz, mxW[2].xyz) * lxNormal;\n#ifdef NORMAL_MAP\n vec3 n = normalize(vWorldNormal);\n vec3 t = normalize(mat3(mxW[0].xyz, mxW[1].xyz, mxW[2].xyz) * lxTangent0);\n vec3 b = cross(t, n);\n#endif\n\n\tvLightDir = lightDir;\n#ifdef NORMAL_MAP\n vLightDir.x = dot(lightDir, t);\n vLightDir.y = dot(lightDir, b);\n vLightDir.z = dot(lightDir, n);\n#endif\n\n vUV.xy = lxUV0;\n#ifdef AO_MAP\n vUV.zw = lxUV1;\n#endif\n}\n", "pano.fs" : "precision highp float;\n\nuniform sampler2D colorMap;\n\nvarying vec2 vUV;\n\nvoid main()\n{\n gl_FragColor = vec4(texture2D(colorMap, vUV).xyz, 1.0);\n}\n", "pano.vs" : "precision highp float;\n\nattribute vec3 lxPosition;\nattribute vec2 lxUV0;\n\nuniform mat4 mxVP;\nuniform mat4 mxW;\n\nvarying vec2 vUV;\n\nvoid main()\n{\n vec4 worldPos = mxW * vec4(lxPosition, 1.0);\n gl_Position = mxVP * worldPos;\n vUV = lxUV0;\n}\n", "quad.vs" : "precision highp float;\n\nattribute vec3 lxPosition;\n\nvarying vec2 vUV;\n\nvoid main()\n{\n gl_Position = vec4(lxPosition, 1.0);\n vUV = lxPosition.xy * 0.5 + 0.5;\n}\n", "resolve.fs" : "precision highp float;\n\nuniform vec2 sourceTexelSize;\nuniform sampler2D sourceMap;\n\nvarying vec2 vUV;\n\nvoid main(void)\n{\n\tvec3 average = vec3(0.0);\n\taverage += texture2D(sourceMap, vec2(vUV + vec2(-0.5, -0.5) * sourceTexelSize)).rgb;\n\taverage += texture2D(sourceMap, vec2(vUV + vec2( 0.5, -0.5) * sourceTexelSize)).rgb;\n\taverage += texture2D(sourceMap, vec2(vUV + vec2(-0.5, 0.5) * sourceTexelSize)).rgb;\n\taverage += texture2D(sourceMap, vec2(vUV + vec2( 0.5, 0.5) * sourceTexelSize)).rgb;\n\tgl_FragColor = vec4(average * 0.25, 1.0);\n}\n", "shadow.fs" : "precision highp float;\n\n#ifdef ALPHA_CUT\n#ifdef OPACITY_MAP\nuniform sampler2D opacityMap;\n#else\nuniform sampler2D colorMap;\n#endif\nuniform float shadowCutRef;\n\nvarying vec2 vUV;\n#endif\n\nvec4 floatToRGBA (float depth)\n{\n\tconst vec4 shift = vec4(256 * 256 * 256, 256 * 256, 256, 1.0);\n\tconst vec4 mask = vec4(0, 1.0 / 256.0, 1.0 / 256.0, 1.0 / 256.0);\n\tvec4 comp = fract(depth * shift);\n\tcomp -= comp.xxyz * mask;\n\treturn comp;\n}\n\nvoid main()\n{\n#ifdef ALPHA_CUT\n#ifdef OPACITY_MAP\n\tfloat alpha = texture2D(opacityMap, vUV).r;\n#else\n float alpha = texture2D(colorMap, vUV).a;\n#endif\n\tif (alpha < shadowCutRef) discard;\n#endif\n\tgl_FragColor = floatToRGBA(gl_FragCoord.z);\n}\n", "shadow.vs" : "precision highp float;\n\nattribute vec3 lxPosition;\n#ifdef ALPHA_CUT\nattribute vec2 lxUV0;\n#endif\n\nuniform mat4 mxVP;\nuniform mat4 mxW;\n\n#ifdef ALPHA_CUT\nvarying vec2 vUV;\n#endif\n\nvoid main()\n{\n\tgl_Position = mxVP * mxW * vec4(lxPosition, 1.0);\n#ifdef ALPHA_CUT\n\tvUV = lxUV0;\n#endif\n}\n", "sky.fs" : "precision highp float;\n\nuniform samplerCube colorMap;\n\nvarying vec3 vUV;\n\nvoid main()\n{\n gl_FragColor = vec4(textureCube(colorMap, normalize(vUV)).rgb, 1.0);\n}\n", "sky.vs" : "precision highp float;\n\nattribute vec3 lxPosition;\n\nuniform mat4 mxVP;\nuniform vec3 viewPos;\n\nvarying vec3 vUV;\n\nvoid main()\n{\n gl_Position = mxVP * vec4(lxPosition + viewPos, 1.0);\n gl_Position.z = gl_Position.w - 1e-5;\n vUV = lxPosition;\n}\n", "surface.fs" : "precision highp float;\n\n#ifdef HEIGHT_MAP\n#undef TANGENT_SPACE\n#define TANGENT_SPACE\n#endif\n#ifdef NORMAL_MAP\n#undef TANGENT_SPACE\n#define TANGENT_SPACE\n#endif\n\n#ifdef HEIGHT_PM\n#undef VIEW_DIR\n#define VIEW_DIR\n#endif\n#ifdef HEIGHT_POM\n#undef VIEW_DIR\n#define VIEW_DIR\n#endif\n#ifdef SPECULAR\n#undef VIEW_DIR\n#define VIEW_DIR\n#endif\n\n#ifdef ALPHA_CUT\n#undef USE_COLOR_VAR\n#define USE_COLOR_VAR\n#endif\n#ifdef COLOR\n#undef USE_COLOR_VAR\n#define USE_COLOR_VAR\n#endif\n\n#ifdef HEIGHT_PM\n#undef HEIGHT_MAP\n#define HEIGHT_MAP\n#endif\n#ifdef HEIGHT_POM\n#undef HEIGHT_MAP\n#define HEIGHT_MAP\n#endif\n\n#ifdef SPECULAR\n#undef REFLECT_VECTOR\n#define REFLECT_VECTOR\n#endif\n#ifdef REFLECTION\n#undef REFLECT_VECTOR\n#define REFLECT_VECTOR\n#endif\n\n#ifdef SHADOWS\nuniform sampler2D shadowMap;\n#endif\nuniform samplerCube ambientCube;\n#ifdef AO_MAP\nuniform sampler2D aoMap;\n#endif\n#ifdef COLOR_MAP\nuniform sampler2D colorMap;\n#endif\n#ifdef DETAIL_MAP\nuniform sampler2D detailMap;\n#endif\n#ifdef NORMAL_MAP\nuniform sampler2D normalMap;\n#endif\n#ifdef HEIGHT_MAP\nuniform sampler2D heightMap;\n#endif\n#ifdef SPECULAR_MAP\nuniform sampler2D specularMap;\n#endif\n#ifdef REFLECTION\nuniform samplerCube reflectionMap;\n#endif\n\nuniform float ambientIntensity;\nuniform float lightIntensity;\n#ifdef SHADOWS\nuniform vec2 shadowMapSize;\nuniform vec2 shadowMapTexelSize;\n#endif\n#ifdef REFLECTION\nuniform float fresnelOffset;\nuniform float fresnelPower;\nuniform float reflectionIntensity;\n#endif\n\n#ifdef SHADOWS\nvarying vec4 vPositionTLP;\n#endif\nvarying vec4 vNormal;\n#ifdef TANGENT_SPACE\n#ifdef REFLECTION\nvarying vec3 vInvT;\nvarying vec3 vInvB;\nvarying vec3 vInvN;\n#endif\n#endif\nvarying vec4 vLightDir;\n#ifdef VIEW_DIR\nvarying vec4 vViewDir;\n#endif\n#ifdef DETAIL_MAP\nvarying vec3 vDetail;\n#endif\nvarying vec4 vUV;\n#ifdef USE_COLOR_VAR\nvarying vec4 vColor;\n#endif\n\n#ifdef HEIGHT_PM\nvec2 calcPM(float parallaxScale, vec3 viewDir, vec2 uv, sampler2D heightMap)\n{\n\tconst float bias = 0.01;\n\tfloat height = parallaxScale * texture2D(heightMap, uv).r - bias;\n\treturn uv - min(height * viewDir.xy, vec2(bias));\n}\n#endif\n#ifdef HEIGHT_POM\nvec2 calcPOM(float parallaxScale, vec3 viewDir, vec2 vUV, sampler2D heightMap)\n{\n\tconst float numSteps = float(HEIGHT_POM_STEPS);\n\tfloat step = 1.0 / numSteps;\n\tvec2 duv = viewDir.xy * parallaxScale / (numSteps * viewDir.z);\n\tvec2 uv = vUV;\n\tfloat height = 1.0;\n\tfloat h = texture2D(heightMap, uv).r;\n\tfor (int i = 0; i < HEIGHT_POM_STEPS; i++)\n\t{\n\t if (h < height) {\n\t height -= step;\n\t uv -= duv;\n\t h = texture2D(heightMap, uv).r;\n\t }\n\t}\n\tvec2 prev = uv + duv;\n\tfloat hPrev = texture2D(heightMap, prev).r - (height + step);\n\tfloat hCur = h - height;\n\tfloat weight = hCur / (hCur - hPrev );\n\treturn weight * prev + (1.0 - weight) * uv;\n}\n#endif\n\n#ifdef SHADOWS\nfloat rgbaToFloat(vec4 value)\n{\n\tconst vec4 shifts = vec4(1.0 / (256.0 * 256.0 * 256.0), 1.0 / (256.0 * 256.0), 1.0 / 256.0, 1);\n\treturn dot(value, shifts);\n}\nfloat fetchShadowMap(vec2 uv, float depth)\n{\n\tvec4 terms;\n\tterms.x = float(rgbaToFloat(texture2D(shadowMap, uv)) > depth);\n\tterms.y = float(rgbaToFloat(texture2D(shadowMap, uv + vec2(shadowMapTexelSize.x, 0))) > depth);\n\tterms.z = float(rgbaToFloat(texture2D(shadowMap, uv + vec2(0, shadowMapTexelSize.y))) > depth);\n\tterms.w = float(rgbaToFloat(texture2D(shadowMap, uv + shadowMapTexelSize)) > depth);\n\n\tvec2 lerps = fract(uv * shadowMapSize);\n\tvec2 firstLerp = mix(terms.xz, terms.yw, lerps.x);\n\treturn mix(firstLerp.x, firstLerp.y, lerps.y);\n}\nfloat calcShadowTerm(vec4 positionTLP)\n{\n\tconst float depthBias = 0.004;\n\n\tvec2 uv = positionTLP.xy / positionTLP.w;\n\tfloat depth = (positionTLP.z - depthBias) / positionTLP.w;\n\n\tvec3 result;\n\tresult.x = fetchShadowMap(uv + vec2(-0.7904286, -0.2801397) * shadowMapTexelSize, depth);\n\tresult.y = fetchShadowMap(uv + vec2(0.1648042, 0.5930318) * shadowMapTexelSize, depth);\n\tresult.z = fetchShadowMap(uv + vec2(0.4335592, -0.6467823) * shadowMapTexelSize, depth);\n\treturn dot(result, vec3(0.333));\n}\n#endif\n\nvoid main()\n{\n vec3 normal = normalize(vNormal.xyz);\n vec3 lightDir = normalize(vLightDir.xyz);\n#ifdef VIEW_DIR\n vec3 viewDir = normalize(vViewDir.xyz);\n#endif\n\t\n\tvec2 uv = vUV.xy;\n#ifdef HEIGHT_PM\n\tuv = calcPM(vNormal.w, viewDir, uv, heightMap);\n#endif\n#ifdef HEIGHT_POM\n\tuv = calcPOM(vNormal.w, viewDir, uv, heightMap);\n#endif\n\t\n#ifdef NORMAL_MAP\n normal = texture2D(normalMap, uv).rgb * 2.0 - 1.0;\n#endif\n#ifdef REFLECT_VECTOR\n\tvec3 reflectVec = normalize(reflect(viewDir, normal));\n#endif\n\n\tvec4 albedo = vec4(1.0);\n#ifdef COLOR_MAP\n\talbedo = texture2D(colorMap, uv);\n#endif\n#ifdef COLOR\n\talbedo.rgb *= vColor.rgb;\n#endif\n#ifdef DETAIL_MAP\n\talbedo.rgb *= (texture2D(detailMap, uv * vDetail.xy) * vDetail.z);\n#endif\n#ifdef ALPHA_CUT\n\tif(albedo.a < vColor.a){ discard; };\n#endif\n#ifdef REFLECTION\n\tvec3 worldReflect = reflectVec;\n#ifdef TANGENT_SPACE\n\tworldReflect.x = dot(reflectVec, vInvT);\n worldReflect.y = dot(reflectVec, vInvB);\n worldReflect.z = dot(reflectVec, vInvN);\n#endif\n\tvec3 refection = textureCube(reflectionMap, worldReflect).rgb;\n float fresnel = fresnelOffset + (1.0 - fresnelOffset) * pow(1.0 + dot(viewDir, normalize(reflectVec - viewDir)), fresnelPower);\n albedo.rgb = mix(albedo.rgb, refection, fresnel * reflectionIntensity);\n#endif\n#ifdef AO_MAP\n\talbedo.rgb *= texture2D(aoMap, vUV.zw).rgb;\n#endif\n\t\n\tfloat shadowTerm = 1.0;\n#ifdef SHADOWS\n\tshadowTerm = calcShadowTerm(vPositionTLP);\n#endif\n vec3 ambient = (textureCube(ambientCube, normal).rgb * 0.5 + 0.5) * ambientIntensity;\n\tfloat diffuse = clamp(dot(normal, lightDir), 0.0, 1.0) * lightIntensity * shadowTerm;\n#ifdef SPECULAR\n\tfloat specIntensity = vViewDir.w;\n#ifdef SPECULAR_MAP\n\tspecIntensity *= texture2D(specularMap, uv).r;\n#endif\n\tfloat specular = pow(clamp(dot(reflectVec, lightDir), 0.0, 1.0), vLightDir.w) * specIntensity * shadowTerm;\n#endif\n\n\tvec3 result = albedo.rgb * (ambient + diffuse);\n#ifdef SPECULAR\n\tresult += specular;\n#endif\n\n gl_FragColor = vec4(result, 1.0);\n}\n", "surface.vs" : "precision highp float;\n\n#ifdef HEIGHT_MAP\n#undef TANGENT_SPACE\n#define TANGENT_SPACE\n#endif\n#ifdef NORMAL_MAP\n#undef TANGENT_SPACE\n#define TANGENT_SPACE\n#endif\n\n#ifdef HEIGHT_PM\n#undef VIEW_DIR\n#define VIEW_DIR\n#endif\n#ifdef HEIGHT_POM\n#undef VIEW_DIR\n#define VIEW_DIR\n#endif\n#ifdef SPECULAR\n#undef VIEW_DIR\n#define VIEW_DIR\n#endif\n#ifdef REFLECTION\n#undef VIEW_DIR\n#define VIEW_DIR\n#endif\n\n#ifdef HEIGHT_PM\n#undef PARALLAX_SCALE\n#define PARALLAX_SCALE\n#endif\n#ifdef HEIGHT_POM\n#undef PARALLAX_SCALE\n#define PARALLAX_SCALE\n#endif\n\n#ifdef ALPHA_CUT\n#undef USE_COLOR_VAR\n#define USE_COLOR_VAR\n#endif\n#ifdef COLOR\n#undef USE_COLOR_VAR\n#define USE_COLOR_VAR\n#endif\n\nattribute vec3 lxPosition;\nattribute vec3 lxNormal;\n#ifdef TANGENT_SPACE\nattribute vec3 lxTangent0;\n#endif\nattribute vec2 lxUV0;\n#ifdef AO_MAP\nattribute vec2 lxUV1;\n#endif\n\n#ifdef SHADOWS\nuniform mat4 mxTLP;\n#endif\nuniform mat4 mxVP;\nuniform mat4 mxW;\nuniform vec3 lightDir;\n#ifdef VIEW_DIR\nuniform vec3 viewPos;\n#endif\n#ifdef PARALLAX_SCALE\nuniform float parallaxScale;\n#endif\n#ifdef DETAIL_MAP\nuniform vec2 detailTileScale;\nuniform float detailIntensity;\n#endif\n#ifdef SPECULAR\nuniform float specularPower;\nuniform float specularIntensity;\n#endif\n#ifdef ALPHA_CUT\nuniform float alphaCutRef;\n#endif\n#ifdef COLOR\nuniform vec4 color;\n#endif\n\n#ifdef SHADOWS\nvarying vec4 vPositionTLP;\n#endif\nvarying vec4 vNormal;\n#ifdef TANGENT_SPACE\n#ifdef REFLECTION\nvarying vec3 vInvT;\nvarying vec3 vInvB;\nvarying vec3 vInvN;\n#endif\n#endif\nvarying vec4 vLightDir;\n#ifdef VIEW_DIR\nvarying vec4 vViewDir;\n#endif\n#ifdef DETAIL_MAP\nvarying vec3 vDetail;\n#endif\nvarying vec4 vUV;\n#ifdef USE_COLOR_VAR\nvarying vec4 vColor;\n#endif\n\nvoid main()\n{\n vec4 worldPos = mxW * vec4(lxPosition, 1.0);\n gl_Position = mxVP * worldPos;\n#ifdef SHADOWS\n\tvPositionTLP = mxTLP * worldPos;\n#endif\n \n\tvNormal.xyz = mat3(mxW[0].xyz, mxW[1].xyz, mxW[2].xyz) * lxNormal;\n\tvLightDir.xyz = lightDir;\n#ifdef VIEW_DIR\n vec3 viewDir = worldPos.xyz - viewPos;\n\tvViewDir.xyz = viewDir;\n#endif\n\n#ifdef TANGENT_SPACE\n vec3 n = normalize(vNormal.xyz);\n vec3 t = normalize(mat3(mxW[0].xyz, mxW[1].xyz, mxW[2].xyz) * lxTangent0);\n vec3 b = cross(t, n);\n\n vLightDir.x = dot(lightDir, t);\n vLightDir.y = dot(lightDir, b);\n vLightDir.z = dot(lightDir, n);\n#ifdef VIEW_DIR\n vViewDir.x = dot(viewDir, t);\n vViewDir.y = dot(viewDir, b);\n vViewDir.z = dot(viewDir, n);\n#endif\n#ifdef REFLECTION\n\tvInvT = vec3(t.x, b.x, n.x);\n\tvInvB = vec3(t.y, b.y, n.y);\n\tvInvN = vec3(t.z, b.z, n.z);\n#endif\n#endif\n\n#ifdef PARALLAX_SCALE\n\tvNormal.w = parallaxScale;\n#endif\n\n#ifdef DETAIL_MAP\n\tvDetail.xy = detailTileScale;\n\tvDetail.z = detailIntensity;\n#endif\n\n#ifdef SPECULAR\n vLightDir.w = specularPower;\n vViewDir.w = specularIntensity;\n#endif\n\n vUV.xy = lxUV0;\n#ifdef AO_MAP\n vUV.zw = lxUV1;\n#endif\n\n#ifdef COLOR\n\tvColor.rgb = color.rgb;\n#endif\n#ifdef ALPHA_CUT\n\tvColor.a = alphaCutRef;\n#endif\n}\n", "vegetation.fs" : "precision highp float;\n\n#ifdef SHADOWS\nuniform sampler2D shadowMap;\n#endif\nuniform samplerCube ambientCube;\nuniform sampler2D colorMap;\nuniform sampler2D opacityMap;\n\n#ifdef SHADOWS\nvarying vec4 vPositionTLP;\n#endif\nvarying vec2 vUV;\nvarying vec3 vNormal;\nvarying vec3 vLightDir;\n\nuniform float ambientIntensity;\nuniform float lightIntensity;\nuniform float alphaCutRef;\n#ifdef SHADOWS\nuniform vec2 shadowMapSize;\nuniform vec2 shadowMapTexelSize;\n\nfloat rgbaToFloat(vec4 value)\n{\n\tconst vec4 shifts = vec4(1.0 / (256.0 * 256.0 * 256.0), 1.0 / (256.0 * 256.0), 1.0 / 256.0, 1);\n\treturn dot(value, shifts);\n}\nfloat fetchShadowMap(vec2 uv, float depth)\n{\n\tvec4 terms;\n\tterms.x = float(rgbaToFloat(texture2D(shadowMap, uv)) > depth);\n\tterms.y = float(rgbaToFloat(texture2D(shadowMap, uv + vec2(shadowMapTexelSize.x, 0))) > depth);\n\tterms.z = float(rgbaToFloat(texture2D(shadowMap, uv + vec2(0, shadowMapTexelSize.y))) > depth);\n\tterms.w = float(rgbaToFloat(texture2D(shadowMap, uv + shadowMapTexelSize)) > depth);\n\n\tvec2 lerps = fract(uv * shadowMapSize);\n\tvec2 firstLerp = mix(terms.xz, terms.yw, lerps.x);\n\treturn mix(firstLerp.x, firstLerp.y, lerps.y);\n}\nfloat calcShadowTerm(vec4 positionTLP)\n{\n\tconst float depthBias = 0.004;\n\tvec2 uv = positionTLP.xy / positionTLP.w;\n\tfloat depth = (positionTLP.z - depthBias) / positionTLP.w;\n\treturn fetchShadowMap(uv, depth);\n}\n#endif\n\nvoid main()\n{\n\tvec3 normal = normalize(vNormal);\n\tvec3 lightDir = normalize(vLightDir.xyz);\n\n\tvec3 albedo = texture2D(colorMap, vUV).rgb;\n\tfloat opacity = texture2D(opacityMap, vUV).r;\n if( opacity < alphaCutRef ){ discard; };\n\n\tfloat shadowTerm = 1.0;\n#ifdef SHADOWS\n\tshadowTerm = calcShadowTerm(vPositionTLP);\n#endif\n vec3 ambient = (textureCube(ambientCube, normal).rgb * 0.5 + 0.5) * ambientIntensity;\n\tfloat diffuse = clamp(dot(normal, lightDir), 0.0, 1.0) * lightIntensity * shadowTerm;\n\n gl_FragColor = vec4(albedo * (ambient + diffuse), 1.0);\n}\n", "vegetation.vs" : "precision highp float;\n\nattribute vec3 lxPosition;\nattribute vec3 lxNormal;\nattribute vec2 lxUV0;\n\n#ifdef SHADOWS\nuniform mat4 mxTLP;\n#endif\nuniform mat4 mxVP;\nuniform mat4 mxW;\nuniform vec3 lightDir;\nuniform vec3 viewPos;\n\n#ifdef SHADOWS\nvarying vec4 vPositionTLP;\n#endif\nvarying vec2 vUV;\nvarying vec3 vNormal;\nvarying vec3 vLightDir;\n\nvoid main()\n{\n vec4 worldPos = mxW * vec4(lxPosition, 1.0);\n gl_Position = mxVP * worldPos;\n#ifdef SHADOWS\n\tvPositionTLP = mxTLP * worldPos;\n#endif\n vUV = lxUV0;\n\tvNormal = mat3(mxW[0].xyz, mxW[1].xyz, mxW[2].xyz) * lxNormal;\n vLightDir.xyz = normalize(lightDir);\n}\n", "vegetation_alpha.fs" : "precision highp float;\n\n#ifdef SHADOWS\nuniform sampler2D shadowMap;\n#endif\nuniform samplerCube ambientCube;\nuniform sampler2D colorMap;\nuniform sampler2D opacityMap;\n\n#ifdef SHADOWS\nvarying vec4 vPositionTLP;\n#endif\nvarying vec2 vUV;\nvarying vec3 vNormal;\nvarying vec3 vLightDir;\n\nuniform float ambientIntensity;\nuniform float lightIntensity;\nuniform float transparency;\n#ifdef SHADOWS\nuniform vec2 shadowMapSize;\nuniform vec2 shadowMapTexelSize;\n\nfloat rgbaToFloat(vec4 value)\n{\n\tconst vec4 shifts = vec4(1.0 / (256.0 * 256.0 * 256.0), 1.0 / (256.0 * 256.0), 1.0 / 256.0, 1);\n\treturn dot(value, shifts);\n}\nfloat fetchShadowMap(vec2 uv, float depth)\n{\n\tvec4 terms;\n\tterms.x = float(rgbaToFloat(texture2D(shadowMap, uv)) > depth);\n\tterms.y = float(rgbaToFloat(texture2D(shadowMap, uv + vec2(shadowMapTexelSize.x, 0))) > depth);\n\tterms.z = float(rgbaToFloat(texture2D(shadowMap, uv + vec2(0, shadowMapTexelSize.y))) > depth);\n\tterms.w = float(rgbaToFloat(texture2D(shadowMap, uv + shadowMapTexelSize)) > depth);\n\n\tvec2 lerps = fract(uv * shadowMapSize);\n\tvec2 firstLerp = mix(terms.xz, terms.yw, lerps.x);\n\treturn mix(firstLerp.x, firstLerp.y, lerps.y);\n}\nfloat calcShadowTerm(vec4 positionTLP)\n{\n\tconst float depthBias = 0.004;\n\tvec2 uv = positionTLP.xy / positionTLP.w;\n\tfloat depth = (positionTLP.z - depthBias) / positionTLP.w;\n\treturn fetchShadowMap(uv, depth);\n}\n#endif\n\nvoid main()\n{\n\tvec3 normal = normalize(vNormal);\n\tvec3 lightDir = normalize(vLightDir.xyz);\n\n\tvec3 albedo = texture2D(colorMap, vUV).rgb;\n\tfloat opacity = texture2D(opacityMap, vUV).r;\n\n\tfloat shadowTerm = 1.0;\n#ifdef SHADOWS\n\tshadowTerm = calcShadowTerm(vPositionTLP);\n#endif\n vec3 ambient = (textureCube(ambientCube, normal).rgb * 0.5 + 0.5) * ambientIntensity;\n\tfloat diffuse = clamp(dot(normal, lightDir), 0.0, 1.0) * lightIntensity * shadowTerm;\n\n gl_FragColor = vec4(albedo * (ambient + diffuse), opacity * transparency);\n}\n", "water.fs" : "precision highp float;\n\n#ifdef SHADOWS\nuniform sampler2D shadowMap;\n#endif\n#ifdef AO_MAP\nuniform sampler2D aoMap;\n#endif\nuniform samplerCube ambientCube;\nuniform sampler2D normalMap;\nuniform samplerCube reflectionMap;\n\n#ifdef SHADOWS\nvarying vec4 vPositionTLP;\n#endif\nvarying vec4 vUV;\n#ifdef AO_MAP\nvarying vec2 vAOUV;\n#endif\nvarying vec4 vLightDir;\nvarying vec4 vViewDir;\nvarying vec3 vFresnel;\nvarying vec4 vColor;\nvarying vec3 vSpecularColor;\n\nuniform float ambientIntensity;\nuniform float lightIntensity;\n#ifdef SHADOWS\nuniform vec2 shadowMapTexelSize;\nuniform vec2 shadowMapSize;\n\nfloat rgbaToFloat(vec4 value)\n{\n\tconst vec4 shifts = vec4(1.0 / (256.0 * 256.0 * 256.0), 1.0 / (256.0 * 256.0), 1.0 / 256.0, 1);\n\treturn dot(value, shifts);\n}\n\nfloat fetchShadowMap(vec2 uv, float depth)\n{\n\tvec4 terms;\n\tterms.x = float(rgbaToFloat(texture2D(shadowMap, uv)) > depth);\n\tterms.y = float(rgbaToFloat(texture2D(shadowMap, uv + vec2(shadowMapTexelSize.x, 0))) > depth);\n\tterms.z = float(rgbaToFloat(texture2D(shadowMap, uv + vec2(0, shadowMapTexelSize.y))) > depth);\n\tterms.w = float(rgbaToFloat(texture2D(shadowMap, uv + shadowMapTexelSize)) > depth);\n\n\tvec2 lerps = fract(uv * shadowMapSize);\n\tvec2 firstLerp = mix(terms.xz, terms.yw, lerps.x);\n\treturn mix(firstLerp.x, firstLerp.y, lerps.y);\n}\n\nfloat calcShadowTerm(vec4 positionTLP)\n{\n\tconst float depthBias = 0.002;\n\n\tvec2 uv = positionTLP.xy / positionTLP.w;\n\tfloat depth = (positionTLP.z - depthBias) / positionTLP.w;\n\n\tvec3 result;\n\tresult.x = fetchShadowMap(uv + vec2(-0.7904286, -0.2801397) * shadowMapTexelSize, depth);\n\tresult.y = fetchShadowMap(uv + vec2(0.1648042, 0.5930318) * shadowMapTexelSize, depth);\n\tresult.z = fetchShadowMap(uv + vec2(0.4335592, -0.6467823) * shadowMapTexelSize, depth);\n\treturn dot(result, vec3(0.333));\n}\n#endif\n\nvoid main()\n{\n vec3 viewDir = normalize(vViewDir.xyz);\n vec3 lightDir = normalize(vLightDir.xyz);\n vec3 n0 = normalize(texture2D(normalMap, vUV.xy).rbg * 2.0 - 1.0);\n vec3 n1 = normalize(texture2D(normalMap, vUV.zw).rbg * 2.0 - 1.0);\n vec3 normal = normalize(n0 + n1);\n vec3 vReflect = reflect(viewDir, normal);\n\n\tvec3 refection = textureCube(reflectionMap, vReflect).rgb;\n float fresnel = vFresnel.x + (1.0 - vFresnel.x) * pow(1.0 + dot(viewDir, normalize(vReflect - viewDir)), vFresnel.y);\n vec3 albedo = mix(vColor.rgb, refection, fresnel * vFresnel.z);\n#ifdef AO_MAP\n\talbedo *= texture2D(aoMap, vUV).rgb;\n#endif\n\n\tfloat shadowTerm = 1.0;\n#ifdef SHADOWS\n\tshadowTerm = calcShadowTerm(vPositionTLP);\n#endif\n vec3 ambient = (textureCube(ambientCube, normal).rgb * 0.5 + 0.5) * ambientIntensity;\n\tfloat diffuse = clamp(dot(normal, lightDir), 0.0, 1.0) * lightIntensity * shadowTerm;\n float specularCoeff = pow(clamp(dot(vReflect, lightDir), 0.0, 1.0), vLightDir.w) * vViewDir.w;\n\tvec3 specular = vSpecularColor * specularCoeff * shadowTerm;\n\n gl_FragColor = vec4(albedo * (ambient + diffuse) + specular, vColor.a + specularCoeff);\n}\n", "water.vs" : "precision highp float;\n\nattribute vec3 lxPosition;\nattribute vec3 lxNormal;\n#ifdef AO_MAP\nattribute vec2 lxUV1;\n#endif\n\n#ifdef SHADOWS\nuniform mat4 mxTLP;\n#endif\nuniform mat4 mxVP;\nuniform mat4 mxW;\nuniform float time;\nuniform float specularPower;\nuniform float specularIntensity;\nuniform vec4 specularColor;\nuniform float fresnelOffset;\nuniform float fresnelPower;\nuniform float reflectionIntensity;\nuniform vec2 speedFactors;\nuniform vec2 uvScales;\nuniform vec3 lightDir;\nuniform vec3 viewPos;\nuniform vec4 color;\n\n#ifdef SHADOWS\nvarying vec4 vPositionTLP;\n#endif\nvarying vec3 vNormal;\nvarying vec4 vUV;\n#ifdef AO_MAP\nvarying vec2 vAOUV;\n#endif\nvarying vec4 vLightDir;\nvarying vec4 vViewDir;\nvarying vec3 vFresnel;\nvarying vec4 vColor;\nvarying vec3 vSpecularColor;\n\nvoid main()\n{\n vec4 worldPos = mxW * vec4(lxPosition, 1.0);\n gl_Position = mxVP * worldPos;\n#ifdef SHADOWS\n\tvPositionTLP = mxTLP * worldPos;\n#endif\n\n vNormal = mat3(mxW[0].xyz, mxW[1].xyz, mxW[2].xyz) * lxNormal;\n\n vUV = lxPosition.xzxz;\n vUV.yw += speedFactors * time;\n vUV *= uvScales.xxyy;\n#ifdef AO_MAP\n vUV = lxUV1;\n#endif\n\n vLightDir.xyz = lightDir;\n vLightDir.w = specularPower;\n vViewDir.xyz = worldPos.xyz - viewPos;\n vViewDir.w = specularIntensity;\n\n vFresnel.x = fresnelOffset;\n vFresnel.y = fresnelPower;\n vFresnel.z = reflectionIntensity;\n\n vColor = color;\n vSpecularColor = specularColor.rgb;\n}\n" }