playcanvas 1.51.0 → 1.51.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/playcanvas-extras.js +1 -1
- package/build/playcanvas.dbg.js +51 -54
- package/build/playcanvas.js +51 -52
- package/build/playcanvas.min.js +2 -2
- package/build/playcanvas.mjs +51 -52
- package/build/playcanvas.prf.js +51 -52
- package/package.json +1 -1
- package/scripts/parsers/vox-parser.js +1 -1
package/build/playcanvas.dbg.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* PlayCanvas Engine v1.51.
|
|
3
|
+
* PlayCanvas Engine v1.51.4 revision e91904d1b (DEBUG PROFILER)
|
|
4
4
|
* Copyright 2011-2021 PlayCanvas Ltd. All rights reserved.
|
|
5
5
|
*/
|
|
6
6
|
(function (global, factory) {
|
|
@@ -634,8 +634,8 @@
|
|
|
634
634
|
return result;
|
|
635
635
|
}();
|
|
636
636
|
|
|
637
|
-
var version = "1.51.
|
|
638
|
-
var revision = "
|
|
637
|
+
var version = "1.51.4";
|
|
638
|
+
var revision = "e91904d1b";
|
|
639
639
|
var config = {};
|
|
640
640
|
var common = {};
|
|
641
641
|
var apps = {};
|
|
@@ -6356,7 +6356,7 @@
|
|
|
6356
6356
|
|
|
6357
6357
|
var reflectionCubePS = "uniform samplerCube texture_cubeMap;\nuniform float material_reflectivity;\n\nvec3 calcReflection(vec3 tReflDirW, float tGlossiness) {\n\tvec3 lookupVec = fixSeams(cubeMapProject(tReflDirW));\n\tlookupVec.x *= -1.0;\n\treturn $DECODE(textureCube(texture_cubeMap, lookupVec));\n}\n\nvoid addReflection() { \n\tdReflection += vec4(calcReflection(dReflDirW, dGlossiness), material_reflectivity);\n}\n";
|
|
6358
6358
|
|
|
6359
|
-
var reflectionEnvPS = "#ifndef ENV_ATLAS\n#define ENV_ATLAS\nuniform sampler2D texture_envAtlas;\n#endif\nuniform float material_reflectivity;\n\n// calculate mip level for shiny reflection given equirect coords uv.\nfloat shinyMipLevel(vec2 uv) {\n\tvec2 dx = dFdx(uv);\n\tvec2 dy = dFdy(uv);\n\n\t// calculate second dF at 180 degrees\n\tvec2 uv2 = vec2(fract(uv.x + 0.5), uv.y);\n\tvec2 dx2 = dFdx(uv2);\n\tvec2 dy2 = dFdy(uv2);\n\n\t// calculate min of both sets of dF to handle discontinuity at the azim edge\n\tfloat maxd = min(max(dot(dx, dx), dot(dy, dy)), max(dot(dx2, dx2), dot(dy2, dy2)));\n\n\treturn clamp(0.5 * log2(maxd), 0.0,
|
|
6359
|
+
var reflectionEnvPS = "#ifndef ENV_ATLAS\n#define ENV_ATLAS\nuniform sampler2D texture_envAtlas;\n#endif\nuniform float material_reflectivity;\n\n// calculate mip level for shiny reflection given equirect coords uv.\nfloat shinyMipLevel(vec2 uv) {\n\tvec2 dx = dFdx(uv);\n\tvec2 dy = dFdy(uv);\n\n\t// calculate second dF at 180 degrees\n\tvec2 uv2 = vec2(fract(uv.x + 0.5), uv.y);\n\tvec2 dx2 = dFdx(uv2);\n\tvec2 dy2 = dFdy(uv2);\n\n\t// calculate min of both sets of dF to handle discontinuity at the azim edge\n\tfloat maxd = min(max(dot(dx, dx), dot(dy, dy)), max(dot(dx2, dx2), dot(dy2, dy2)));\n\n\treturn clamp(0.5 * log2(maxd) - 1.0, 0.0, 6.0);\n}\n\nvec3 calcReflection(vec3 tReflDirW, float tGlossiness) {\n\tvec3 dir = cubeMapProject(tReflDirW) * vec3(-1.0, 1.0, 1.0);\n\tvec2 uv = toSphericalUv(dir);\n\n\t// calculate roughness level\n\tfloat level = saturate(1.0 - tGlossiness) * 5.0;\n\tfloat ilevel = floor(level);\n\n\tvec2 uv0, uv1;\n\tfloat weight;\n\tif (ilevel == 0.0) {\n\t\t// accessing the shiny (top level) reflection - perform manual mipmap lookup\n\t\tfloat level2 = shinyMipLevel(uv * atlasSize);\n\t\tfloat ilevel2 = floor(level2);\n\t\tuv0 = mapMip(uv, ilevel2);\n\t\tuv1 = mapMip(uv, ilevel2 + 1.0);\n\t\tweight = level2 - ilevel2;\n\t} else {\n\t\t// accessing rough reflection - just sample the same part twice\n\t\tuv0 = uv1 = mapRoughnessUv(uv, ilevel);\n\t\tweight = 0.0;\n\t}\n\n\tvec3 linearA = $DECODE(texture2D(texture_envAtlas, uv0));\n\tvec3 linearB = $DECODE(texture2D(texture_envAtlas, uv1));\n\tvec3 linear0 = mix(linearA, linearB, weight);\n\tvec3 linear1 = $DECODE(texture2D(texture_envAtlas, mapRoughnessUv(uv, ilevel + 1.0)));\n\n\treturn processEnvironment(mix(linear0, linear1, level - ilevel));\n}\n\nvoid addReflection() { \n\tdReflection += vec4(calcReflection(dReflDirW, dGlossiness), material_reflectivity);\n}\n";
|
|
6360
6360
|
|
|
6361
6361
|
var reflectionSpherePS = "#ifndef VIEWMATRIX\n#define VIEWMATRIX\nuniform mat4 matrix_view;\n#endif\nuniform sampler2D texture_sphereMap;\nuniform float material_reflectivity;\n\nvec3 calcReflection(vec3 tReflDirW, float tGlossiness) {\n\tvec3 reflDirV = (mat3(matrix_view) * tReflDirW).xyz;\n\n\tfloat m = 2.0 * sqrt( dot(reflDirV.xy, reflDirV.xy) + (reflDirV.z+1.0)*(reflDirV.z+1.0) );\n\tvec2 sphereMapUv = reflDirV.xy / m + 0.5;\n\n\treturn $DECODE(texture2D(texture_sphereMap, sphereMapUv));\n}\n\nvoid addReflection() { \n\tdReflection += vec4(calcReflection(dReflDirW, dGlossiness), material_reflectivity);\n}\n";
|
|
6362
6362
|
|
|
@@ -6364,7 +6364,7 @@
|
|
|
6364
6364
|
|
|
6365
6365
|
var refractionPS = "uniform float material_refraction, material_refractionIndex;\n\nvec3 refract2(vec3 viewVec, vec3 Normal, float IOR) {\n\tfloat vn = dot(viewVec, Normal);\n\tfloat k = 1.0 - IOR * IOR * (1.0 - vn * vn);\n\tvec3 refrVec = IOR * viewVec - (IOR * vn + sqrt(k)) * Normal;\n\treturn refrVec;\n}\n\nvoid addRefraction() {\n\t// use same reflection code with refraction vector\n\tvec3 tmp = dReflDirW;\n\tvec4 tmp2 = dReflection;\n\tdReflection = vec4(0.0);\n\tdReflDirW = refract2(-dViewDirW, dNormalW, material_refractionIndex);\n\n\taddReflection();\n\n\tdDiffuseLight = mix(dDiffuseLight, dReflection.rgb * dAlbedo, material_refraction);\n\tdReflDirW = tmp;\n\tdReflection = tmp2;\n}\n";
|
|
6366
6366
|
|
|
6367
|
-
var reprojectPS = "// This shader requires the following #DEFINEs:\n//\n// PROCESS_FUNC - must be one of reproject, prefilter\n// DECODE_FUNC - must be one of decodeRGBM, decodeRGBE, decodeGamma or decodeLinear\n// ENCODE_FUNC - must be one of encodeRGBM, encodeRGBE, encideGamma or encodeLinear\n// SOURCE_FUNC - must be one of sampleCubemap, sampleEquirect, sampleOctahedral\n// TARGET_FUNC - must be one of getDirectionCubemap, getDirectionEquirect, getDirectionOctahedral\n//\n// When filtering:\n// NUM_SAMPLES - number of samples\n//\n// SUPPORTS_TEXLOD - whether supports texlod is supported\n\nvarying vec2 vUv0;\n\n// source\nuniform sampler2D sourceTex;\nuniform samplerCube sourceCube;\n\n// samples\nuniform sampler2D samplesTex;\nuniform vec2 samplesTexInverseSize;\n\n// params:\n// x - target cubemap face 0..6\n// y - specular power (when prefiltering)\n// z - source cubemap seam scale (0 to disable)\n// w - target cubemap size for seam calc (0 to disable)\nuniform vec4 params;\n\n// params2:\n// x - target image total pixels\n// y - source cubemap size\nuniform
|
|
6367
|
+
var reprojectPS = "// This shader requires the following #DEFINEs:\n//\n// PROCESS_FUNC - must be one of reproject, prefilter\n// DECODE_FUNC - must be one of decodeRGBM, decodeRGBE, decodeGamma or decodeLinear\n// ENCODE_FUNC - must be one of encodeRGBM, encodeRGBE, encideGamma or encodeLinear\n// SOURCE_FUNC - must be one of sampleCubemap, sampleEquirect, sampleOctahedral\n// TARGET_FUNC - must be one of getDirectionCubemap, getDirectionEquirect, getDirectionOctahedral\n//\n// When filtering:\n// NUM_SAMPLES - number of samples\n//\n// SUPPORTS_TEXLOD - whether supports texlod is supported\n\nvarying vec2 vUv0;\n\n// source\nuniform sampler2D sourceTex;\nuniform samplerCube sourceCube;\n\n// samples\nuniform sampler2D samplesTex;\nuniform vec2 samplesTexInverseSize;\n\n// params:\n// x - target cubemap face 0..6\n// y - specular power (when prefiltering)\n// z - source cubemap seam scale (0 to disable)\n// w - target cubemap size for seam calc (0 to disable)\nuniform vec4 params;\n\n// params2:\n// x - target image total pixels\n// y - source cubemap size\nuniform vec2 params2;\n\nfloat targetFace() { return params.x; }\nfloat specularPower() { return params.y; }\nfloat sourceCubeSeamScale() { return params.z; }\nfloat targetCubeSeamScale() { return params.w; }\n\nfloat targetTotalPixels() { return params2.x; }\nfloat sourceTotalPixels() { return params2.y; }\n\nfloat PI = 3.141592653589793;\n\nfloat saturate(float x) {\n\treturn clamp(x, 0.0, 1.0);\n}\n\n//-- supported codings\n\nvec3 decodeLinear(vec4 source) {\n\treturn source.rgb;\n}\n\nvec4 encodeLinear(vec3 source) {\n\treturn vec4(source, 1.0);\n}\n\nvec3 decodeGamma(vec4 source) {\n\treturn pow(source.xyz, vec3(2.2));\n}\n\nvec4 encodeGamma(vec3 source) {\n\treturn vec4(pow(source + 0.0000001, vec3(1.0 / 2.2)), 1.0);\n}\n\nvec3 decodeRGBM(vec4 rgbm) {\n\tvec3 color = (8.0 * rgbm.a) * rgbm.rgb;\n\treturn color * color;\n}\n\nvec4 encodeRGBM(vec3 source) { // modified RGBM\n\tvec4 result;\n\tresult.rgb = pow(source.rgb, vec3(0.5));\n\tresult.rgb *= 1.0 / 8.0;\n\n\tresult.a = saturate( max( max( result.r, result.g ), max( result.b, 1.0 / 255.0 ) ) );\n\tresult.a = ceil(result.a * 255.0) / 255.0;\n\n\tresult.rgb /= result.a;\n\treturn result;\n}\n\nvec3 decodeRGBE(vec4 source) {\n\tif (source.a == 0.0) {\n\t\treturn vec3(0.0, 0.0, 0.0);\n\t} else {\n\t\treturn source.xyz * pow(2.0, source.w * 255.0 - 128.0);\n\t}\n}\n\nvec4 encodeRGBE(vec3 source) {\n\tfloat maxVal = max(source.x, max(source.y, source.z));\n\tif (maxVal < 1e-32) {\n\t\treturn vec4(0, 0, 0, 0);\n\t} else {\n\t\tfloat e = ceil(log2(maxVal));\n\t\treturn vec4(source / pow(2.0, e), (e + 128.0) / 255.0);\n\t}\n}\n\n//-- supported projections\n\nvec3 modifySeams(vec3 dir, float scale) {\n\tvec3 adir = abs(dir);\n\tfloat M = max(max(adir.x, adir.y), adir.z);\n\treturn dir / M * vec3(\n\t\tadir.x == M ? 1.0 : scale,\n\t\tadir.y == M ? 1.0 : scale,\n\t\tadir.z == M ? 1.0 : scale\n\t);\n}\n\nvec2 toSpherical(vec3 dir) {\n\treturn vec2(dir.xz == vec2(0.0) ? 0.0 : atan(dir.x, dir.z), asin(dir.y));\n}\n\nvec3 fromSpherical(vec2 uv) {\n\treturn vec3(cos(uv.y) * sin(uv.x),\n\t\t\t\tsin(uv.y),\n\t\t\t\tcos(uv.y) * cos(uv.x));\n}\n\nvec3 getDirectionEquirect() {\n\treturn fromSpherical((vec2(vUv0.x, 1.0 - vUv0.y) * 2.0 - 1.0) * vec2(PI, PI * 0.5));\n}\n\nvec4 sampleEquirect(vec2 sph) {\n\tvec2 uv = sph / vec2(PI * 2.0, PI) + 0.5;\n\treturn texture2D(sourceTex, vec2(uv.x, 1.0 - uv.y));\n}\n\nvec4 sampleEquirect(vec3 dir) {\n\treturn sampleEquirect(toSpherical(dir));\n}\n\nvec4 sampleCubemap(vec3 dir) {\n\treturn textureCube(sourceCube, modifySeams(dir, 1.0 - sourceCubeSeamScale()));\n}\n\nvec4 sampleCubemap(vec2 sph) {\n\treturn sampleCubemap(fromSpherical(sph));\n}\n\nvec4 sampleEquirect(vec2 sph, float mipLevel) {\n\tvec2 uv = sph / vec2(PI * 2.0, PI) + 0.5;\n#ifdef SUPPORTS_TEXLOD\n\treturn texture2DLodEXT(sourceTex, vec2(uv.x, 1.0 - uv.y), mipLevel);\n#else\n\treturn texture2D(sourceTex, vec2(uv.x, 1.0 - uv.y));\n#endif\n}\n\nvec4 sampleEquirect(vec3 dir, float mipLevel) {\n\treturn sampleEquirect(toSpherical(dir), mipLevel);\n}\n\nvec4 sampleCubemap(vec3 dir, float mipLevel) {\n#ifdef SUPPORTS_TEXLOD\n\treturn textureCubeLodEXT(sourceCube, modifySeams(dir, 1.0 - exp2(mipLevel) * sourceCubeSeamScale()), mipLevel);\n#else\n\treturn textureCube(sourceCube, modifySeams(dir, 1.0 - exp2(mipLevel) * sourceCubeSeamScale()));\n#endif\n}\n\nvec4 sampleCubemap(vec2 sph, float mipLevel) {\n\treturn sampleCubemap(fromSpherical(sph), mipLevel);\n}\n\n// octahedral code, based on http://jcgt.org/published/0003/02/01\n// \"Survey of Efficient Representations for Independent Unit Vectors\" by Cigolle, Donow, Evangelakos, Mara, McGuire, Meyer\n\nfloat signNotZero(float k){\n\treturn(k >= 0.0) ? 1.0 : -1.0;\n}\n\nvec2 signNotZero(vec2 v) {\n\treturn vec2(signNotZero(v.x), signNotZero(v.y));\n}\n\n// Returns a unit vector. Argument o is an octahedral vector packed via octEncode, on the [-1, +1] square\nvec3 octDecode(vec2 o) {\n\tvec3 v = vec3(o.x, 1.0 - abs(o.x) - abs(o.y), o.y);\n\tif (v.y < 0.0) {\n\t\tv.xz = (1.0 - abs(v.zx)) * signNotZero(v.xz);\n\t}\n\treturn normalize(v);\n}\n\nvec3 getDirectionOctahedral() {\n\treturn octDecode(vec2(vUv0.x, 1.0 - vUv0.y) * 2.0 - 1.0);\n}\n\n// Assumes that v is a unit vector. The result is an octahedral vector on the [-1, +1] square\nvec2 octEncode(in vec3 v) {\n\tfloat l1norm = abs(v.x) + abs(v.y) + abs(v.z);\n\tvec2 result = v.xz * (1.0 / l1norm);\n\tif (v.y < 0.0) {\n\t\tresult = (1.0 - abs(result.yx)) * signNotZero(result.xy);\n\t}\n\treturn result;\n}\n\nvec4 sampleOctahedral(vec3 dir) {\n\tvec2 uv = octEncode(dir) * 0.5 + 0.5;\n\treturn texture2D(sourceTex, vec2(uv.x, 1.0 - uv.y));\n}\n\nvec4 sampleOctahedral(vec2 sph) {\n\treturn sampleOctahedral(fromSpherical(sph));\n}\n\nvec4 sampleOctahedral(vec3 dir, float mipLevel) {\n\tvec2 uv = octEncode(dir) * 0.5 + 0.5;\n#ifdef SUPPORTS_TEXLOD\n\treturn texture2DLodEXT(sourceTex, vec2(uv.x, 1.0 - uv.y), mipLevel);\n#else\n\treturn texture2D(sourceTex, vec2(uv.x, 1.0 - uv.y));\n#endif\n}\n\nvec4 sampleOctahedral(vec2 sph, float mipLevel) {\n\treturn sampleOctahedral(fromSpherical(sph), mipLevel);\n}\n\n/////////////////////////////////////////////////////////////////////\n\nvec3 getDirectionCubemap() {\n\tvec2 st = vUv0 * 2.0 - 1.0;\n\tfloat face = targetFace();\n\n\tvec3 vec;\n\tif (face == 0.0) {\n\t\tvec = vec3(1, -st.y, -st.x);\n\t} else if (face == 1.0) {\n\t\tvec = vec3(-1, -st.y, st.x);\n\t} else if (face == 2.0) {\n\t\tvec = vec3(st.x, 1, st.y);\n\t} else if (face == 3.0) {\n\t\tvec = vec3(st.x, -1, -st.y);\n\t} else if (face == 4.0) {\n\t\tvec = vec3(st.x, -st.y, 1);\n\t} else {\n\t\tvec = vec3(-st.x, -st.y, -1);\n\t}\n\n\treturn normalize(modifySeams(vec, 1.0 / (1.0 - targetCubeSeamScale())));\n}\n\nmat3 matrixFromVector(vec3 n) { // frisvad\n\tfloat a = 1.0 / (1.0 + n.z);\n\tfloat b = -n.x * n.y * a;\n\tvec3 b1 = vec3(1.0 - n.x * n.x * a, b, -n.x);\n\tvec3 b2 = vec3(b, 1.0 - n.y * n.y * a, -n.y);\n\treturn mat3(b1, b2, n);\n}\n\nmat3 matrixFromVectorSlow(vec3 n) {\n\tvec3 up = (1.0 - abs(n.y) <= 0.0000001) ? vec3(0.0, 0.0, n.y > 0.0 ? 1.0 : -1.0) : vec3(0.0, 1.0, 0.0);\n\tvec3 x = normalize(cross(up, n));\n\tvec3 y = cross(n, x);\n\treturn mat3(x, y, n);\n}\n\nvec4 reproject() {\n\tif (NUM_SAMPLES <= 1) {\n\t\t// single sample\n\t\treturn ENCODE_FUNC(DECODE_FUNC(SOURCE_FUNC(TARGET_FUNC())));\n\t} else {\n\t\t// multi sample\n\t\tvec2 sph = toSpherical(TARGET_FUNC());\n\t\tvec2 sphu = dFdx(sph);\n\t\tvec2 sphv = dFdy(sph);\n\n\t\t// TODO: check this declartion works on old old devices.\n\t\t// might need to be placed globally or be made a #define\n\t\tconst float NUM_SAMPLES_SQRT = sqrt(float(NUM_SAMPLES));\n\n\t\tvec3 result = vec3(0.0);\n\t\tfor (float u = 0.0; u < NUM_SAMPLES_SQRT; ++u) {\n\t\t\tfor (float v = 0.0; v < NUM_SAMPLES_SQRT; ++v) {\n\t\t\t\tresult += DECODE_FUNC(SOURCE_FUNC(sph +\n\t\t\t\t\t\t\t\t\t\t\t\t sphu * (u / NUM_SAMPLES_SQRT - 0.5) +\n\t\t\t\t\t\t\t\t\t\t\t\t sphv * (v / NUM_SAMPLES_SQRT - 0.5)));\n\t\t\t}\n\t\t}\n\t\treturn ENCODE_FUNC(result / (NUM_SAMPLES_SQRT * NUM_SAMPLES_SQRT));\n\t}\n}\n\nvec4 unpackFloat = vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0);\n\nvoid unpackSample(int i, out vec3 L, out float mipLevel) {\n\tfloat u = (float(i * 4) + 0.5) * samplesTexInverseSize.x;\n\tfloat v = (floor(u) + 0.5) * samplesTexInverseSize.y;\n\n\tvec4 raw;\n\traw.x = dot(texture2D(samplesTex, vec2(u, v)), unpackFloat); u += samplesTexInverseSize.x;\n\traw.y = dot(texture2D(samplesTex, vec2(u, v)), unpackFloat); u += samplesTexInverseSize.x;\n\traw.z = dot(texture2D(samplesTex, vec2(u, v)), unpackFloat); u += samplesTexInverseSize.x;\n\traw.w = dot(texture2D(samplesTex, vec2(u, v)), unpackFloat);\n\n\tL.xyz = raw.xyz * 2.0 - 1.0;\n\tmipLevel = raw.w * 8.0;\n}\n\n// convolve an environment given pre-generated samples\nvec4 prefilterSamples() {\n\t// construct vector space given target direction\n\tmat3 vecSpace = matrixFromVectorSlow(TARGET_FUNC());\n\n\tvec3 L;\n\tfloat mipLevel;\n\n\tvec3 result = vec3(0.0);\n\tfloat totalWeight = 0.0;\n\tfor (int i = 0; i < NUM_SAMPLES; ++i) {\n\t\tunpackSample(i, L, mipLevel);\n\t\tresult += DECODE_FUNC(SOURCE_FUNC(vecSpace * L, mipLevel)) * L.z;\n\t\ttotalWeight += L.z;\n\t}\n\n\treturn ENCODE_FUNC(result / totalWeight);\n}\n\n// unweighted version of prefilterSamples\nvec4 prefilterSamplesUnweighted() {\n\t// construct vector space given target direction\n\tmat3 vecSpace = matrixFromVectorSlow(TARGET_FUNC());\n\n\tvec3 L;\n\tfloat mipLevel;\n\n\tvec3 result = vec3(0.0);\n\tfloat totalWeight = 0.0;\n\tfor (int i = 0; i < NUM_SAMPLES; ++i) {\n\t\tunpackSample(i, L, mipLevel);\n\t\tresult += DECODE_FUNC(SOURCE_FUNC(vecSpace * L, mipLevel));\n\t}\n\n\treturn ENCODE_FUNC(result / float(NUM_SAMPLES));\n}\n\nvoid main(void) {\n\tgl_FragColor = PROCESS_FUNC();\n}\n";
|
|
6368
6368
|
|
|
6369
6369
|
var rgbmPS = "vec3 texture2DRGBM(sampler2D tex, vec2 uv) {\n\treturn decodeRGBM(texture2D(tex, uv));\n}\n\nvec3 textureCubeRGBM(samplerCube tex, vec3 uvw) {\n\treturn decodeRGBM(textureCube(tex, uvw));\n}\n";
|
|
6370
6370
|
|
|
@@ -10496,11 +10496,11 @@
|
|
|
10496
10496
|
code += options.packedNormal ? chunks.normalXYPS : chunks.normalXYZPS;
|
|
10497
10497
|
|
|
10498
10498
|
if (!options.hasTangents) {
|
|
10499
|
-
var
|
|
10499
|
+
var baseName = options.normalMap ? "normalMap" : "clearCoatNormalMap";
|
|
10500
10500
|
|
|
10501
|
-
var
|
|
10501
|
+
var uv = this._getUvSourceExpression(baseName + "Transform", baseName + "Uv", options);
|
|
10502
10502
|
|
|
10503
|
-
tbn = tbn.replace(/\$UV/g,
|
|
10503
|
+
tbn = tbn.replace(/\$UV/g, uv);
|
|
10504
10504
|
}
|
|
10505
10505
|
|
|
10506
10506
|
code += tbn;
|
|
@@ -11452,7 +11452,7 @@
|
|
|
11452
11452
|
var packSamplesTex = function packSamplesTex(device, name, samples) {
|
|
11453
11453
|
var numSamples = samples.length;
|
|
11454
11454
|
var w = Math.min(numSamples, 512);
|
|
11455
|
-
var h = Math.
|
|
11455
|
+
var h = Math.ceil(numSamples / w);
|
|
11456
11456
|
var data = new Uint8ClampedArray(w * h * 4);
|
|
11457
11457
|
var off = 0;
|
|
11458
11458
|
|
|
@@ -11584,8 +11584,8 @@
|
|
|
11584
11584
|
uvModParam.setValue([1, 1, 0, 0]);
|
|
11585
11585
|
}
|
|
11586
11586
|
|
|
11587
|
-
var params = [0, specularPower,
|
|
11588
|
-
var params2 = [target.width * target.height * (target.cubemap ? 6 : 1), source.width * source.height * (source.cubemap ? 6 : 1)
|
|
11587
|
+
var params = [0, specularPower, source.fixCubemapSeams ? 1.0 / source.width : 0.0, target.fixCubemapSeams ? 1.0 / target.width : 0.0];
|
|
11588
|
+
var params2 = [target.width * target.height * (target.cubemap ? 6 : 1), source.width * source.height * (source.cubemap ? 6 : 1)];
|
|
11589
11589
|
|
|
11590
11590
|
if (processFunc.startsWith('prefilterSamples')) {
|
|
11591
11591
|
var sourceTotalPixels = source.width * source.height * (source.cubemap ? 6 : 1);
|
|
@@ -11651,29 +11651,6 @@
|
|
|
11651
11651
|
});
|
|
11652
11652
|
};
|
|
11653
11653
|
|
|
11654
|
-
var generateMipmaps = function generateMipmaps(target) {
|
|
11655
|
-
var device = target.device;
|
|
11656
|
-
Debug.pushGpuMarker(device, "genMipmaps");
|
|
11657
|
-
var result = new Texture(device, {
|
|
11658
|
-
name: target.name + '-mipmaps',
|
|
11659
|
-
cubemap: target.cubemap,
|
|
11660
|
-
width: target.width,
|
|
11661
|
-
height: target.height,
|
|
11662
|
-
format: target.format,
|
|
11663
|
-
type: target.type,
|
|
11664
|
-
addressU: target.addressU,
|
|
11665
|
-
addressV: target.addressV,
|
|
11666
|
-
fixCubemapSeams: target.fixCubemapSeams,
|
|
11667
|
-
mipmaps: true
|
|
11668
|
-
});
|
|
11669
|
-
reprojectTexture(target, result, {
|
|
11670
|
-
numSamples: 1
|
|
11671
|
-
});
|
|
11672
|
-
target.destroy();
|
|
11673
|
-
Debug.popGpuMarker(device);
|
|
11674
|
-
return result;
|
|
11675
|
-
};
|
|
11676
|
-
|
|
11677
11654
|
var EnvLighting = function () {
|
|
11678
11655
|
function EnvLighting() {}
|
|
11679
11656
|
|
|
@@ -11691,12 +11668,24 @@
|
|
|
11691
11668
|
EnvLighting.generateLightingSource = function generateLightingSource(source) {
|
|
11692
11669
|
var device = source.device;
|
|
11693
11670
|
Debug.pushGpuMarker(device, "genLightingSource");
|
|
11694
|
-
var
|
|
11671
|
+
var format = lightingSourcePixelFormat(device);
|
|
11672
|
+
var result = new Texture(device, {
|
|
11673
|
+
name: "lighting-source",
|
|
11674
|
+
cubemap: true,
|
|
11675
|
+
width: 128,
|
|
11676
|
+
height: 128,
|
|
11677
|
+
format: format,
|
|
11678
|
+
type: format === PIXELFORMAT_R8_G8_B8_A8 ? TEXTURETYPE_RGBM : TEXTURETYPE_DEFAULT,
|
|
11679
|
+
addressU: ADDRESS_CLAMP_TO_EDGE,
|
|
11680
|
+
addressV: ADDRESS_CLAMP_TO_EDGE,
|
|
11681
|
+
fixCubemapSeams: false,
|
|
11682
|
+
mipmaps: true
|
|
11683
|
+
});
|
|
11695
11684
|
reprojectTexture(source, result, {
|
|
11696
11685
|
numSamples: source.mipmaps ? 1 : 1024
|
|
11697
11686
|
});
|
|
11698
11687
|
Debug.popGpuMarker(device);
|
|
11699
|
-
return
|
|
11688
|
+
return result;
|
|
11700
11689
|
};
|
|
11701
11690
|
|
|
11702
11691
|
EnvLighting.generateAtlas = function generateAtlas(source, options) {
|
|
@@ -49423,8 +49412,15 @@
|
|
|
49423
49412
|
|
|
49424
49413
|
if (this._imageReference.hasComponent('element')) {
|
|
49425
49414
|
this._isApplyingSprite = true;
|
|
49426
|
-
|
|
49427
|
-
this._imageReference.entity.element.
|
|
49415
|
+
|
|
49416
|
+
if (this._imageReference.entity.element.spriteAsset !== spriteAsset) {
|
|
49417
|
+
this._imageReference.entity.element.spriteAsset = spriteAsset;
|
|
49418
|
+
}
|
|
49419
|
+
|
|
49420
|
+
if (this._imageReference.entity.element.spriteFrame !== spriteFrame) {
|
|
49421
|
+
this._imageReference.entity.element.spriteFrame = spriteFrame;
|
|
49422
|
+
}
|
|
49423
|
+
|
|
49428
49424
|
this._isApplyingSprite = false;
|
|
49429
49425
|
}
|
|
49430
49426
|
};
|
|
@@ -49440,25 +49436,26 @@
|
|
|
49440
49436
|
};
|
|
49441
49437
|
|
|
49442
49438
|
_proto._applyTintImmediately = function _applyTintImmediately(tintColor) {
|
|
49443
|
-
if (this._imageReference.hasComponent('element')
|
|
49444
|
-
|
|
49445
|
-
|
|
49446
|
-
|
|
49447
|
-
|
|
49448
|
-
|
|
49439
|
+
if (!tintColor || !this._imageReference.hasComponent('element')) return;
|
|
49440
|
+
var color3 = toColor3(tintColor);
|
|
49441
|
+
this._isApplyingTint = true;
|
|
49442
|
+
if (!color3.equals(this._imageReference.entity.element.color)) this._imageReference.entity.element.color = color3;
|
|
49443
|
+
if (this._imageReference.entity.element.opacity != tintColor.a) this._imageReference.entity.element.opacity = tintColor.a;
|
|
49444
|
+
this._isApplyingTint = false;
|
|
49449
49445
|
};
|
|
49450
49446
|
|
|
49451
49447
|
_proto._applyTintWithTween = function _applyTintWithTween(tintColor) {
|
|
49452
|
-
if (this._imageReference.hasComponent('element')
|
|
49453
|
-
|
|
49454
|
-
|
|
49455
|
-
|
|
49456
|
-
|
|
49457
|
-
|
|
49458
|
-
|
|
49459
|
-
|
|
49460
|
-
|
|
49461
|
-
|
|
49448
|
+
if (!tintColor || !this._imageReference.hasComponent('element')) return;
|
|
49449
|
+
var color3 = toColor3(tintColor);
|
|
49450
|
+
var color = this._imageReference.entity.element.color;
|
|
49451
|
+
var opacity = this._imageReference.entity.element.opacity;
|
|
49452
|
+
if (color3.equals(color) && tintColor.a == opacity) return;
|
|
49453
|
+
this._tweenInfo = {
|
|
49454
|
+
startTime: now(),
|
|
49455
|
+
from: new Color(color.r, color.g, color.b, opacity),
|
|
49456
|
+
to: tintColor.clone(),
|
|
49457
|
+
lerpColor: new Color()
|
|
49458
|
+
};
|
|
49462
49459
|
};
|
|
49463
49460
|
|
|
49464
49461
|
_proto._updateTintTween = function _updateTintTween() {
|
package/build/playcanvas.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* PlayCanvas Engine v1.51.
|
|
3
|
+
* PlayCanvas Engine v1.51.4 revision e91904d1b
|
|
4
4
|
* Copyright 2011-2021 PlayCanvas Ltd. All rights reserved.
|
|
5
5
|
*/
|
|
6
6
|
(function (global, factory) {
|
|
@@ -634,8 +634,8 @@
|
|
|
634
634
|
return result;
|
|
635
635
|
}();
|
|
636
636
|
|
|
637
|
-
var version = "1.51.
|
|
638
|
-
var revision = "
|
|
637
|
+
var version = "1.51.4";
|
|
638
|
+
var revision = "e91904d1b";
|
|
639
639
|
var config = {};
|
|
640
640
|
var common = {};
|
|
641
641
|
var apps = {};
|
|
@@ -6286,7 +6286,7 @@
|
|
|
6286
6286
|
|
|
6287
6287
|
var reflectionCubePS = "uniform samplerCube texture_cubeMap;\nuniform float material_reflectivity;\nvec3 calcReflection(vec3 tReflDirW, float tGlossiness) {\n\tvec3 lookupVec = fixSeams(cubeMapProject(tReflDirW));\n\tlookupVec.x *= -1.0;\n\treturn $DECODE(textureCube(texture_cubeMap, lookupVec));\n}\nvoid addReflection() {\n\tdReflection += vec4(calcReflection(dReflDirW, dGlossiness), material_reflectivity);\n}\n";
|
|
6288
6288
|
|
|
6289
|
-
var reflectionEnvPS = "#ifndef ENV_ATLAS\n#define ENV_ATLAS\nuniform sampler2D texture_envAtlas;\n#endif\nuniform float material_reflectivity;\nfloat shinyMipLevel(vec2 uv) {\n\tvec2 dx = dFdx(uv);\n\tvec2 dy = dFdy(uv);\n\tvec2 uv2 = vec2(fract(uv.x + 0.5), uv.y);\n\tvec2 dx2 = dFdx(uv2);\n\tvec2 dy2 = dFdy(uv2);\n\tfloat maxd = min(max(dot(dx, dx), dot(dy, dy)), max(dot(dx2, dx2), dot(dy2, dy2)));\n\treturn clamp(0.5 * log2(maxd), 0.0,
|
|
6289
|
+
var reflectionEnvPS = "#ifndef ENV_ATLAS\n#define ENV_ATLAS\nuniform sampler2D texture_envAtlas;\n#endif\nuniform float material_reflectivity;\nfloat shinyMipLevel(vec2 uv) {\n\tvec2 dx = dFdx(uv);\n\tvec2 dy = dFdy(uv);\n\tvec2 uv2 = vec2(fract(uv.x + 0.5), uv.y);\n\tvec2 dx2 = dFdx(uv2);\n\tvec2 dy2 = dFdy(uv2);\n\tfloat maxd = min(max(dot(dx, dx), dot(dy, dy)), max(dot(dx2, dx2), dot(dy2, dy2)));\n\treturn clamp(0.5 * log2(maxd) - 1.0, 0.0, 6.0);\n}\nvec3 calcReflection(vec3 tReflDirW, float tGlossiness) {\n\tvec3 dir = cubeMapProject(tReflDirW) * vec3(-1.0, 1.0, 1.0);\n\tvec2 uv = toSphericalUv(dir);\n\tfloat level = saturate(1.0 - tGlossiness) * 5.0;\n\tfloat ilevel = floor(level);\n\tvec2 uv0, uv1;\n\tfloat weight;\n\tif (ilevel == 0.0) {\n\t\tfloat level2 = shinyMipLevel(uv * atlasSize);\n\t\tfloat ilevel2 = floor(level2);\n\t\tuv0 = mapMip(uv, ilevel2);\n\t\tuv1 = mapMip(uv, ilevel2 + 1.0);\n\t\tweight = level2 - ilevel2;\n\t} else {\n\t\tuv0 = uv1 = mapRoughnessUv(uv, ilevel);\n\t\tweight = 0.0;\n\t}\n\tvec3 linearA = $DECODE(texture2D(texture_envAtlas, uv0));\n\tvec3 linearB = $DECODE(texture2D(texture_envAtlas, uv1));\n\tvec3 linear0 = mix(linearA, linearB, weight);\n\tvec3 linear1 = $DECODE(texture2D(texture_envAtlas, mapRoughnessUv(uv, ilevel + 1.0)));\n\treturn processEnvironment(mix(linear0, linear1, level - ilevel));\n}\nvoid addReflection() {\n\tdReflection += vec4(calcReflection(dReflDirW, dGlossiness), material_reflectivity);\n}\n";
|
|
6290
6290
|
|
|
6291
6291
|
var reflectionSpherePS = "#ifndef VIEWMATRIX\n#define VIEWMATRIX\nuniform mat4 matrix_view;\n#endif\nuniform sampler2D texture_sphereMap;\nuniform float material_reflectivity;\nvec3 calcReflection(vec3 tReflDirW, float tGlossiness) {\n\tvec3 reflDirV = (mat3(matrix_view) * tReflDirW).xyz;\n\tfloat m = 2.0 * sqrt( dot(reflDirV.xy, reflDirV.xy) + (reflDirV.z+1.0)*(reflDirV.z+1.0) );\n\tvec2 sphereMapUv = reflDirV.xy / m + 0.5;\n\treturn $DECODE(texture2D(texture_sphereMap, sphereMapUv));\n}\nvoid addReflection() {\n\tdReflection += vec4(calcReflection(dReflDirW, dGlossiness), material_reflectivity);\n}\n";
|
|
6292
6292
|
|
|
@@ -6294,7 +6294,7 @@
|
|
|
6294
6294
|
|
|
6295
6295
|
var refractionPS = "uniform float material_refraction, material_refractionIndex;\nvec3 refract2(vec3 viewVec, vec3 Normal, float IOR) {\n\tfloat vn = dot(viewVec, Normal);\n\tfloat k = 1.0 - IOR * IOR * (1.0 - vn * vn);\n\tvec3 refrVec = IOR * viewVec - (IOR * vn + sqrt(k)) * Normal;\n\treturn refrVec;\n}\nvoid addRefraction() {\n\tvec3 tmp = dReflDirW;\n\tvec4 tmp2 = dReflection;\n\tdReflection = vec4(0.0);\n\tdReflDirW = refract2(-dViewDirW, dNormalW, material_refractionIndex);\n\taddReflection();\n\tdDiffuseLight = mix(dDiffuseLight, dReflection.rgb * dAlbedo, material_refraction);\n\tdReflDirW = tmp;\n\tdReflection = tmp2;\n}\n";
|
|
6296
6296
|
|
|
6297
|
-
var reprojectPS = "\nvarying vec2 vUv0;\nuniform sampler2D sourceTex;\nuniform samplerCube sourceCube;\nuniform sampler2D samplesTex;\nuniform vec2 samplesTexInverseSize;\nuniform vec4 params;\nuniform
|
|
6297
|
+
var reprojectPS = "\nvarying vec2 vUv0;\nuniform sampler2D sourceTex;\nuniform samplerCube sourceCube;\nuniform sampler2D samplesTex;\nuniform vec2 samplesTexInverseSize;\nuniform vec4 params;\nuniform vec2 params2;\nfloat targetFace() { return params.x; }\nfloat specularPower() { return params.y; }\nfloat sourceCubeSeamScale() { return params.z; }\nfloat targetCubeSeamScale() { return params.w; }\nfloat targetTotalPixels() { return params2.x; }\nfloat sourceTotalPixels() { return params2.y; }\nfloat PI = 3.141592653589793;\nfloat saturate(float x) {\n\treturn clamp(x, 0.0, 1.0);\n}\nvec3 decodeLinear(vec4 source) {\n\treturn source.rgb;\n}\nvec4 encodeLinear(vec3 source) {\n\treturn vec4(source, 1.0);\n}\nvec3 decodeGamma(vec4 source) {\n\treturn pow(source.xyz, vec3(2.2));\n}\nvec4 encodeGamma(vec3 source) {\n\treturn vec4(pow(source + 0.0000001, vec3(1.0 / 2.2)), 1.0);\n}\nvec3 decodeRGBM(vec4 rgbm) {\n\tvec3 color = (8.0 * rgbm.a) * rgbm.rgb;\n\treturn color * color;\n}\nvec4 encodeRGBM(vec3 source) {\n\tvec4 result;\n\tresult.rgb = pow(source.rgb, vec3(0.5));\n\tresult.rgb *= 1.0 / 8.0;\n\tresult.a = saturate( max( max( result.r, result.g ), max( result.b, 1.0 / 255.0 ) ) );\n\tresult.a = ceil(result.a * 255.0) / 255.0;\n\tresult.rgb /= result.a;\n\treturn result;\n}\nvec3 decodeRGBE(vec4 source) {\n\tif (source.a == 0.0) {\n\t\treturn vec3(0.0, 0.0, 0.0);\n\t} else {\n\t\treturn source.xyz * pow(2.0, source.w * 255.0 - 128.0);\n\t}\n}\nvec4 encodeRGBE(vec3 source) {\n\tfloat maxVal = max(source.x, max(source.y, source.z));\n\tif (maxVal < 1e-32) {\n\t\treturn vec4(0, 0, 0, 0);\n\t} else {\n\t\tfloat e = ceil(log2(maxVal));\n\t\treturn vec4(source / pow(2.0, e), (e + 128.0) / 255.0);\n\t}\n}\nvec3 modifySeams(vec3 dir, float scale) {\n\tvec3 adir = abs(dir);\n\tfloat M = max(max(adir.x, adir.y), adir.z);\n\treturn dir / M * vec3(\n\t\tadir.x == M ? 1.0 : scale,\n\t\tadir.y == M ? 1.0 : scale,\n\t\tadir.z == M ? 1.0 : scale\n\t);\n}\nvec2 toSpherical(vec3 dir) {\n\treturn vec2(dir.xz == vec2(0.0) ? 0.0 : atan(dir.x, dir.z), asin(dir.y));\n}\nvec3 fromSpherical(vec2 uv) {\n\treturn vec3(cos(uv.y) * sin(uv.x),\n\t\t\t\tsin(uv.y),\n\t\t\t\tcos(uv.y) * cos(uv.x));\n}\nvec3 getDirectionEquirect() {\n\treturn fromSpherical((vec2(vUv0.x, 1.0 - vUv0.y) * 2.0 - 1.0) * vec2(PI, PI * 0.5));\n}\nvec4 sampleEquirect(vec2 sph) {\n\tvec2 uv = sph / vec2(PI * 2.0, PI) + 0.5;\n\treturn texture2D(sourceTex, vec2(uv.x, 1.0 - uv.y));\n}\nvec4 sampleEquirect(vec3 dir) {\n\treturn sampleEquirect(toSpherical(dir));\n}\nvec4 sampleCubemap(vec3 dir) {\n\treturn textureCube(sourceCube, modifySeams(dir, 1.0 - sourceCubeSeamScale()));\n}\nvec4 sampleCubemap(vec2 sph) {\n\treturn sampleCubemap(fromSpherical(sph));\n}\nvec4 sampleEquirect(vec2 sph, float mipLevel) {\n\tvec2 uv = sph / vec2(PI * 2.0, PI) + 0.5;\n#ifdef SUPPORTS_TEXLOD\n\treturn texture2DLodEXT(sourceTex, vec2(uv.x, 1.0 - uv.y), mipLevel);\n#else\n\treturn texture2D(sourceTex, vec2(uv.x, 1.0 - uv.y));\n#endif\n}\nvec4 sampleEquirect(vec3 dir, float mipLevel) {\n\treturn sampleEquirect(toSpherical(dir), mipLevel);\n}\nvec4 sampleCubemap(vec3 dir, float mipLevel) {\n#ifdef SUPPORTS_TEXLOD\n\treturn textureCubeLodEXT(sourceCube, modifySeams(dir, 1.0 - exp2(mipLevel) * sourceCubeSeamScale()), mipLevel);\n#else\n\treturn textureCube(sourceCube, modifySeams(dir, 1.0 - exp2(mipLevel) * sourceCubeSeamScale()));\n#endif\n}\nvec4 sampleCubemap(vec2 sph, float mipLevel) {\n\treturn sampleCubemap(fromSpherical(sph), mipLevel);\n}\nfloat signNotZero(float k){\n\treturn(k >= 0.0) ? 1.0 : -1.0;\n}\nvec2 signNotZero(vec2 v) {\n\treturn vec2(signNotZero(v.x), signNotZero(v.y));\n}\nvec3 octDecode(vec2 o) {\n\tvec3 v = vec3(o.x, 1.0 - abs(o.x) - abs(o.y), o.y);\n\tif (v.y < 0.0) {\n\t\tv.xz = (1.0 - abs(v.zx)) * signNotZero(v.xz);\n\t}\n\treturn normalize(v);\n}\nvec3 getDirectionOctahedral() {\n\treturn octDecode(vec2(vUv0.x, 1.0 - vUv0.y) * 2.0 - 1.0);\n}\nvec2 octEncode(in vec3 v) {\n\tfloat l1norm = abs(v.x) + abs(v.y) + abs(v.z);\n\tvec2 result = v.xz * (1.0 / l1norm);\n\tif (v.y < 0.0) {\n\t\tresult = (1.0 - abs(result.yx)) * signNotZero(result.xy);\n\t}\n\treturn result;\n}\nvec4 sampleOctahedral(vec3 dir) {\n\tvec2 uv = octEncode(dir) * 0.5 + 0.5;\n\treturn texture2D(sourceTex, vec2(uv.x, 1.0 - uv.y));\n}\nvec4 sampleOctahedral(vec2 sph) {\n\treturn sampleOctahedral(fromSpherical(sph));\n}\nvec4 sampleOctahedral(vec3 dir, float mipLevel) {\n\tvec2 uv = octEncode(dir) * 0.5 + 0.5;\n#ifdef SUPPORTS_TEXLOD\n\treturn texture2DLodEXT(sourceTex, vec2(uv.x, 1.0 - uv.y), mipLevel);\n#else\n\treturn texture2D(sourceTex, vec2(uv.x, 1.0 - uv.y));\n#endif\n}\nvec4 sampleOctahedral(vec2 sph, float mipLevel) {\n\treturn sampleOctahedral(fromSpherical(sph), mipLevel);\n}\nvec3 getDirectionCubemap() {\n\tvec2 st = vUv0 * 2.0 - 1.0;\n\tfloat face = targetFace();\n\tvec3 vec;\n\tif (face == 0.0) {\n\t\tvec = vec3(1, -st.y, -st.x);\n\t} else if (face == 1.0) {\n\t\tvec = vec3(-1, -st.y, st.x);\n\t} else if (face == 2.0) {\n\t\tvec = vec3(st.x, 1, st.y);\n\t} else if (face == 3.0) {\n\t\tvec = vec3(st.x, -1, -st.y);\n\t} else if (face == 4.0) {\n\t\tvec = vec3(st.x, -st.y, 1);\n\t} else {\n\t\tvec = vec3(-st.x, -st.y, -1);\n\t}\n\treturn normalize(modifySeams(vec, 1.0 / (1.0 - targetCubeSeamScale())));\n}\nmat3 matrixFromVector(vec3 n) {\n\tfloat a = 1.0 / (1.0 + n.z);\n\tfloat b = -n.x * n.y * a;\n\tvec3 b1 = vec3(1.0 - n.x * n.x * a, b, -n.x);\n\tvec3 b2 = vec3(b, 1.0 - n.y * n.y * a, -n.y);\n\treturn mat3(b1, b2, n);\n}\nmat3 matrixFromVectorSlow(vec3 n) {\n\tvec3 up = (1.0 - abs(n.y) <= 0.0000001) ? vec3(0.0, 0.0, n.y > 0.0 ? 1.0 : -1.0) : vec3(0.0, 1.0, 0.0);\n\tvec3 x = normalize(cross(up, n));\n\tvec3 y = cross(n, x);\n\treturn mat3(x, y, n);\n}\nvec4 reproject() {\n\tif (NUM_SAMPLES <= 1) {\n\t\treturn ENCODE_FUNC(DECODE_FUNC(SOURCE_FUNC(TARGET_FUNC())));\n\t} else {\n\t\tvec2 sph = toSpherical(TARGET_FUNC());\n\t\tvec2 sphu = dFdx(sph);\n\t\tvec2 sphv = dFdy(sph);\n\t\tconst float NUM_SAMPLES_SQRT = sqrt(float(NUM_SAMPLES));\n\t\tvec3 result = vec3(0.0);\n\t\tfor (float u = 0.0; u < NUM_SAMPLES_SQRT; ++u) {\n\t\t\tfor (float v = 0.0; v < NUM_SAMPLES_SQRT; ++v) {\n\t\t\t\tresult += DECODE_FUNC(SOURCE_FUNC(sph +\n\t\t\t\t\t\t\t\t\t\t\t\t sphu * (u / NUM_SAMPLES_SQRT - 0.5) +\n\t\t\t\t\t\t\t\t\t\t\t\t sphv * (v / NUM_SAMPLES_SQRT - 0.5)));\n\t\t\t}\n\t\t}\n\t\treturn ENCODE_FUNC(result / (NUM_SAMPLES_SQRT * NUM_SAMPLES_SQRT));\n\t}\n}\nvec4 unpackFloat = vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0);\nvoid unpackSample(int i, out vec3 L, out float mipLevel) {\n\tfloat u = (float(i * 4) + 0.5) * samplesTexInverseSize.x;\n\tfloat v = (floor(u) + 0.5) * samplesTexInverseSize.y;\n\tvec4 raw;\n\traw.x = dot(texture2D(samplesTex, vec2(u, v)), unpackFloat); u += samplesTexInverseSize.x;\n\traw.y = dot(texture2D(samplesTex, vec2(u, v)), unpackFloat); u += samplesTexInverseSize.x;\n\traw.z = dot(texture2D(samplesTex, vec2(u, v)), unpackFloat); u += samplesTexInverseSize.x;\n\traw.w = dot(texture2D(samplesTex, vec2(u, v)), unpackFloat);\n\tL.xyz = raw.xyz * 2.0 - 1.0;\n\tmipLevel = raw.w * 8.0;\n}\nvec4 prefilterSamples() {\n\tmat3 vecSpace = matrixFromVectorSlow(TARGET_FUNC());\n\tvec3 L;\n\tfloat mipLevel;\n\tvec3 result = vec3(0.0);\n\tfloat totalWeight = 0.0;\n\tfor (int i = 0; i < NUM_SAMPLES; ++i) {\n\t\tunpackSample(i, L, mipLevel);\n\t\tresult += DECODE_FUNC(SOURCE_FUNC(vecSpace * L, mipLevel)) * L.z;\n\t\ttotalWeight += L.z;\n\t}\n\treturn ENCODE_FUNC(result / totalWeight);\n}\nvec4 prefilterSamplesUnweighted() {\n\tmat3 vecSpace = matrixFromVectorSlow(TARGET_FUNC());\n\tvec3 L;\n\tfloat mipLevel;\n\tvec3 result = vec3(0.0);\n\tfloat totalWeight = 0.0;\n\tfor (int i = 0; i < NUM_SAMPLES; ++i) {\n\t\tunpackSample(i, L, mipLevel);\n\t\tresult += DECODE_FUNC(SOURCE_FUNC(vecSpace * L, mipLevel));\n\t}\n\treturn ENCODE_FUNC(result / float(NUM_SAMPLES));\n}\nvoid main(void) {\n\tgl_FragColor = PROCESS_FUNC();\n}\n";
|
|
6298
6298
|
|
|
6299
6299
|
var rgbmPS = "vec3 texture2DRGBM(sampler2D tex, vec2 uv) {\n\treturn decodeRGBM(texture2D(tex, uv));\n}\nvec3 textureCubeRGBM(samplerCube tex, vec3 uvw) {\n\treturn decodeRGBM(textureCube(tex, uvw));\n}\n";
|
|
6300
6300
|
|
|
@@ -10395,11 +10395,11 @@
|
|
|
10395
10395
|
code += options.packedNormal ? chunks.normalXYPS : chunks.normalXYZPS;
|
|
10396
10396
|
|
|
10397
10397
|
if (!options.hasTangents) {
|
|
10398
|
-
var
|
|
10398
|
+
var baseName = options.normalMap ? "normalMap" : "clearCoatNormalMap";
|
|
10399
10399
|
|
|
10400
|
-
var
|
|
10400
|
+
var uv = this._getUvSourceExpression(baseName + "Transform", baseName + "Uv", options);
|
|
10401
10401
|
|
|
10402
|
-
tbn = tbn.replace(/\$UV/g,
|
|
10402
|
+
tbn = tbn.replace(/\$UV/g, uv);
|
|
10403
10403
|
}
|
|
10404
10404
|
|
|
10405
10405
|
code += tbn;
|
|
@@ -11351,7 +11351,7 @@
|
|
|
11351
11351
|
var packSamplesTex = function packSamplesTex(device, name, samples) {
|
|
11352
11352
|
var numSamples = samples.length;
|
|
11353
11353
|
var w = Math.min(numSamples, 512);
|
|
11354
|
-
var h = Math.
|
|
11354
|
+
var h = Math.ceil(numSamples / w);
|
|
11355
11355
|
var data = new Uint8ClampedArray(w * h * 4);
|
|
11356
11356
|
var off = 0;
|
|
11357
11357
|
|
|
@@ -11480,8 +11480,8 @@
|
|
|
11480
11480
|
uvModParam.setValue([1, 1, 0, 0]);
|
|
11481
11481
|
}
|
|
11482
11482
|
|
|
11483
|
-
var params = [0, specularPower,
|
|
11484
|
-
var params2 = [target.width * target.height * (target.cubemap ? 6 : 1), source.width * source.height * (source.cubemap ? 6 : 1)
|
|
11483
|
+
var params = [0, specularPower, source.fixCubemapSeams ? 1.0 / source.width : 0.0, target.fixCubemapSeams ? 1.0 / target.width : 0.0];
|
|
11484
|
+
var params2 = [target.width * target.height * (target.cubemap ? 6 : 1), source.width * source.height * (source.cubemap ? 6 : 1)];
|
|
11485
11485
|
|
|
11486
11486
|
if (processFunc.startsWith('prefilterSamples')) {
|
|
11487
11487
|
var sourceTotalPixels = source.width * source.height * (source.cubemap ? 6 : 1);
|
|
@@ -11545,27 +11545,6 @@
|
|
|
11545
11545
|
});
|
|
11546
11546
|
};
|
|
11547
11547
|
|
|
11548
|
-
var generateMipmaps = function generateMipmaps(target) {
|
|
11549
|
-
var device = target.device;
|
|
11550
|
-
var result = new Texture(device, {
|
|
11551
|
-
name: target.name + '-mipmaps',
|
|
11552
|
-
cubemap: target.cubemap,
|
|
11553
|
-
width: target.width,
|
|
11554
|
-
height: target.height,
|
|
11555
|
-
format: target.format,
|
|
11556
|
-
type: target.type,
|
|
11557
|
-
addressU: target.addressU,
|
|
11558
|
-
addressV: target.addressV,
|
|
11559
|
-
fixCubemapSeams: target.fixCubemapSeams,
|
|
11560
|
-
mipmaps: true
|
|
11561
|
-
});
|
|
11562
|
-
reprojectTexture(target, result, {
|
|
11563
|
-
numSamples: 1
|
|
11564
|
-
});
|
|
11565
|
-
target.destroy();
|
|
11566
|
-
return result;
|
|
11567
|
-
};
|
|
11568
|
-
|
|
11569
11548
|
var EnvLighting = function () {
|
|
11570
11549
|
function EnvLighting() {}
|
|
11571
11550
|
|
|
@@ -11580,11 +11559,23 @@
|
|
|
11580
11559
|
|
|
11581
11560
|
EnvLighting.generateLightingSource = function generateLightingSource(source) {
|
|
11582
11561
|
var device = source.device;
|
|
11583
|
-
var
|
|
11562
|
+
var format = lightingSourcePixelFormat(device);
|
|
11563
|
+
var result = new Texture(device, {
|
|
11564
|
+
name: "lighting-source",
|
|
11565
|
+
cubemap: true,
|
|
11566
|
+
width: 128,
|
|
11567
|
+
height: 128,
|
|
11568
|
+
format: format,
|
|
11569
|
+
type: format === PIXELFORMAT_R8_G8_B8_A8 ? TEXTURETYPE_RGBM : TEXTURETYPE_DEFAULT,
|
|
11570
|
+
addressU: ADDRESS_CLAMP_TO_EDGE,
|
|
11571
|
+
addressV: ADDRESS_CLAMP_TO_EDGE,
|
|
11572
|
+
fixCubemapSeams: false,
|
|
11573
|
+
mipmaps: true
|
|
11574
|
+
});
|
|
11584
11575
|
reprojectTexture(source, result, {
|
|
11585
11576
|
numSamples: source.mipmaps ? 1 : 1024
|
|
11586
11577
|
});
|
|
11587
|
-
return
|
|
11578
|
+
return result;
|
|
11588
11579
|
};
|
|
11589
11580
|
|
|
11590
11581
|
EnvLighting.generateAtlas = function generateAtlas(source, options) {
|
|
@@ -48850,8 +48841,15 @@
|
|
|
48850
48841
|
|
|
48851
48842
|
if (this._imageReference.hasComponent('element')) {
|
|
48852
48843
|
this._isApplyingSprite = true;
|
|
48853
|
-
|
|
48854
|
-
this._imageReference.entity.element.
|
|
48844
|
+
|
|
48845
|
+
if (this._imageReference.entity.element.spriteAsset !== spriteAsset) {
|
|
48846
|
+
this._imageReference.entity.element.spriteAsset = spriteAsset;
|
|
48847
|
+
}
|
|
48848
|
+
|
|
48849
|
+
if (this._imageReference.entity.element.spriteFrame !== spriteFrame) {
|
|
48850
|
+
this._imageReference.entity.element.spriteFrame = spriteFrame;
|
|
48851
|
+
}
|
|
48852
|
+
|
|
48855
48853
|
this._isApplyingSprite = false;
|
|
48856
48854
|
}
|
|
48857
48855
|
};
|
|
@@ -48867,25 +48865,26 @@
|
|
|
48867
48865
|
};
|
|
48868
48866
|
|
|
48869
48867
|
_proto._applyTintImmediately = function _applyTintImmediately(tintColor) {
|
|
48870
|
-
if (this._imageReference.hasComponent('element')
|
|
48871
|
-
|
|
48872
|
-
|
|
48873
|
-
|
|
48874
|
-
|
|
48875
|
-
|
|
48868
|
+
if (!tintColor || !this._imageReference.hasComponent('element')) return;
|
|
48869
|
+
var color3 = toColor3(tintColor);
|
|
48870
|
+
this._isApplyingTint = true;
|
|
48871
|
+
if (!color3.equals(this._imageReference.entity.element.color)) this._imageReference.entity.element.color = color3;
|
|
48872
|
+
if (this._imageReference.entity.element.opacity != tintColor.a) this._imageReference.entity.element.opacity = tintColor.a;
|
|
48873
|
+
this._isApplyingTint = false;
|
|
48876
48874
|
};
|
|
48877
48875
|
|
|
48878
48876
|
_proto._applyTintWithTween = function _applyTintWithTween(tintColor) {
|
|
48879
|
-
if (this._imageReference.hasComponent('element')
|
|
48880
|
-
|
|
48881
|
-
|
|
48882
|
-
|
|
48883
|
-
|
|
48884
|
-
|
|
48885
|
-
|
|
48886
|
-
|
|
48887
|
-
|
|
48888
|
-
|
|
48877
|
+
if (!tintColor || !this._imageReference.hasComponent('element')) return;
|
|
48878
|
+
var color3 = toColor3(tintColor);
|
|
48879
|
+
var color = this._imageReference.entity.element.color;
|
|
48880
|
+
var opacity = this._imageReference.entity.element.opacity;
|
|
48881
|
+
if (color3.equals(color) && tintColor.a == opacity) return;
|
|
48882
|
+
this._tweenInfo = {
|
|
48883
|
+
startTime: now(),
|
|
48884
|
+
from: new Color(color.r, color.g, color.b, opacity),
|
|
48885
|
+
to: tintColor.clone(),
|
|
48886
|
+
lerpColor: new Color()
|
|
48887
|
+
};
|
|
48889
48888
|
};
|
|
48890
48889
|
|
|
48891
48890
|
_proto._updateTintTween = function _updateTintTween() {
|