|
@@ -15364,6 +15364,9 @@ var BABYLON;
|
|
|
return;
|
|
|
}
|
|
|
var texture = loadData.texture;
|
|
|
+ if (loadData.info.sphericalPolynomial) {
|
|
|
+ texture._sphericalPolynomial = loadData.info.sphericalPolynomial;
|
|
|
+ }
|
|
|
texture._dataSource = BABYLON.InternalTexture.DATASOURCE_CUBEPREFILTERED;
|
|
|
texture._lodGenerationScale = scale;
|
|
|
texture._lodGenerationOffset = offset;
|
|
@@ -15420,7 +15423,7 @@ var BABYLON;
|
|
|
onLoad(texture);
|
|
|
}
|
|
|
};
|
|
|
- return this.createCubeTexture(rootUrl, scene, null, false, callback, onError, format, forcedExtension);
|
|
|
+ return this.createCubeTexture(rootUrl, scene, null, false, callback, onError, format, forcedExtension, true);
|
|
|
};
|
|
|
/**
|
|
|
* Creates a cube texture
|
|
@@ -15432,13 +15435,15 @@ var BABYLON;
|
|
|
* @param onError defines an optional callback raised if there is an issue to load the texture
|
|
|
* @param format defines the format of the data
|
|
|
* @param forcedExtension defines the extension to use to pick the right loader
|
|
|
+ * @param createPolynomials if a polynomial sphere should be created for the cube texture
|
|
|
* @returns the cube texture as an InternalTexture
|
|
|
*/
|
|
|
- Engine.prototype.createCubeTexture = function (rootUrl, scene, files, noMipmap, onLoad, onError, format, forcedExtension) {
|
|
|
+ Engine.prototype.createCubeTexture = function (rootUrl, scene, files, noMipmap, onLoad, onError, format, forcedExtension, createPolynomials) {
|
|
|
var _this = this;
|
|
|
if (onLoad === void 0) { onLoad = null; }
|
|
|
if (onError === void 0) { onError = null; }
|
|
|
if (forcedExtension === void 0) { forcedExtension = null; }
|
|
|
+ if (createPolynomials === void 0) { createPolynomials = false; }
|
|
|
var gl = this._gl;
|
|
|
var texture = new BABYLON.InternalTexture(this, BABYLON.InternalTexture.DATASOURCE_CUBE);
|
|
|
texture.isCube = true;
|
|
@@ -15509,6 +15514,9 @@ var BABYLON;
|
|
|
else {
|
|
|
this._loadFile(rootUrl, function (data) {
|
|
|
var info = BABYLON.DDSTools.GetDDSInfo(data);
|
|
|
+ if (createPolynomials) {
|
|
|
+ info.sphericalPolynomial = new BABYLON.SphericalPolynomial();
|
|
|
+ }
|
|
|
var loadMipmap = (info.isRGB || info.isLuminance || info.mipmapCount > 1) && !noMipmap;
|
|
|
_this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, texture, true);
|
|
|
gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, info.isCompressed ? 1 : 0);
|
|
@@ -28457,25 +28465,29 @@ var BABYLON;
|
|
|
* @param pbr defines if PBRMaterial must be used instead of StandardMaterial
|
|
|
* @param scale defines the overall scale of the skybox
|
|
|
* @param blur defines if blurring must be applied to the environment texture (works only with pbr === true)
|
|
|
+ * @param setGlobalEnvTexture defines a boolean indicating that scene.environmentTexture must match the current skybox texture (true by default)
|
|
|
* @returns a new mesh holding the sky box
|
|
|
*/
|
|
|
- Scene.prototype.createDefaultSkybox = function (environmentTexture, pbr, scale, blur) {
|
|
|
+ Scene.prototype.createDefaultSkybox = function (environmentTexture, pbr, scale, blur, setGlobalEnvTexture) {
|
|
|
if (pbr === void 0) { pbr = false; }
|
|
|
if (scale === void 0) { scale = 1000; }
|
|
|
if (blur === void 0) { blur = 0; }
|
|
|
- if (environmentTexture) {
|
|
|
- this.environmentTexture = environmentTexture;
|
|
|
- }
|
|
|
- if (!this.environmentTexture) {
|
|
|
+ if (setGlobalEnvTexture === void 0) { setGlobalEnvTexture = true; }
|
|
|
+ if (!environmentTexture) {
|
|
|
BABYLON.Tools.Warn("Can not create default skybox without environment texture.");
|
|
|
return null;
|
|
|
}
|
|
|
+ if (setGlobalEnvTexture) {
|
|
|
+ if (environmentTexture) {
|
|
|
+ this.environmentTexture = environmentTexture;
|
|
|
+ }
|
|
|
+ }
|
|
|
// Skybox
|
|
|
var hdrSkybox = BABYLON.Mesh.CreateBox("hdrSkyBox", scale, this);
|
|
|
if (pbr) {
|
|
|
var hdrSkyboxMaterial = new BABYLON.PBRMaterial("skyBox", this);
|
|
|
hdrSkyboxMaterial.backFaceCulling = false;
|
|
|
- hdrSkyboxMaterial.reflectionTexture = this.environmentTexture.clone();
|
|
|
+ hdrSkyboxMaterial.reflectionTexture = environmentTexture.clone();
|
|
|
if (hdrSkyboxMaterial.reflectionTexture) {
|
|
|
hdrSkyboxMaterial.reflectionTexture.coordinatesMode = BABYLON.Texture.SKYBOX_MODE;
|
|
|
}
|
|
@@ -28488,7 +28500,7 @@ var BABYLON;
|
|
|
else {
|
|
|
var skyboxMaterial = new BABYLON.StandardMaterial("skyBox", this);
|
|
|
skyboxMaterial.backFaceCulling = false;
|
|
|
- skyboxMaterial.reflectionTexture = this.environmentTexture.clone();
|
|
|
+ skyboxMaterial.reflectionTexture = environmentTexture.clone();
|
|
|
if (skyboxMaterial.reflectionTexture) {
|
|
|
skyboxMaterial.reflectionTexture.coordinatesMode = BABYLON.Texture.SKYBOX_MODE;
|
|
|
}
|
|
@@ -84740,6 +84752,10 @@ var BABYLON;
|
|
|
};
|
|
|
DDSTools.UploadDDSLevels = function (engine, gl, arrayBuffer, info, loadMipmaps, faces, lodIndex, currentFace) {
|
|
|
if (lodIndex === void 0) { lodIndex = -1; }
|
|
|
+ var sphericalPolynomialFaces = null;
|
|
|
+ if (info.sphericalPolynomial) {
|
|
|
+ sphericalPolynomialFaces = new Array();
|
|
|
+ }
|
|
|
var ext = engine.getCaps().s3tc;
|
|
|
var header = new Int32Array(arrayBuffer, 0, headerLengthInt);
|
|
|
var fourCC, width, height, dataLength = 0, dataOffset;
|
|
@@ -84833,9 +84849,15 @@ var BABYLON;
|
|
|
if (engine._badOS || engine._badDesktopOS || (!engine.getCaps().textureHalfFloat && !engine.getCaps().textureFloat)) { // Required because iOS has many issues with float and half float generation
|
|
|
if (bpp === 128) {
|
|
|
floatArray = DDSTools._GetFloatAsUIntRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i);
|
|
|
+ if (sphericalPolynomialFaces && i == 0) {
|
|
|
+ sphericalPolynomialFaces.push(DDSTools._GetFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i));
|
|
|
+ }
|
|
|
}
|
|
|
else if (bpp === 64) {
|
|
|
floatArray = DDSTools._GetHalfFloatAsUIntRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i);
|
|
|
+ if (sphericalPolynomialFaces && i == 0) {
|
|
|
+ sphericalPolynomialFaces.push(DDSTools._GetHalfFloatAsFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i));
|
|
|
+ }
|
|
|
}
|
|
|
info.textureType = BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT;
|
|
|
format = engine._getWebGLTextureType(info.textureType);
|
|
@@ -84844,15 +84866,24 @@ var BABYLON;
|
|
|
else {
|
|
|
if (bpp === 128) {
|
|
|
floatArray = DDSTools._GetFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i);
|
|
|
+ if (sphericalPolynomialFaces && i == 0) {
|
|
|
+ sphericalPolynomialFaces.push(floatArray);
|
|
|
+ }
|
|
|
}
|
|
|
else if (bpp === 64 && !engine.getCaps().textureHalfFloat) {
|
|
|
floatArray = DDSTools._GetHalfFloatAsFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i);
|
|
|
+ if (sphericalPolynomialFaces && i == 0) {
|
|
|
+ sphericalPolynomialFaces.push(floatArray);
|
|
|
+ }
|
|
|
info.textureType = BABYLON.Engine.TEXTURETYPE_FLOAT;
|
|
|
format = engine._getWebGLTextureType(info.textureType);
|
|
|
internalFormat = engine._getRGBABufferInternalSizedFormat(info.textureType);
|
|
|
}
|
|
|
else { // 64
|
|
|
floatArray = DDSTools._GetHalfFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i);
|
|
|
+ if (sphericalPolynomialFaces && i == 0) {
|
|
|
+ sphericalPolynomialFaces.push(DDSTools._GetHalfFloatAsFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i));
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
if (floatArray) {
|
|
@@ -84896,6 +84927,23 @@ var BABYLON;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
+ if (sphericalPolynomialFaces && sphericalPolynomialFaces.length > 0) {
|
|
|
+ info.sphericalPolynomial = BABYLON.CubeMapToSphericalPolynomialTools.ConvertCubeMapToSphericalPolynomial({
|
|
|
+ size: header[off_width],
|
|
|
+ right: sphericalPolynomialFaces[0],
|
|
|
+ left: sphericalPolynomialFaces[1],
|
|
|
+ up: sphericalPolynomialFaces[2],
|
|
|
+ down: sphericalPolynomialFaces[3],
|
|
|
+ front: sphericalPolynomialFaces[4],
|
|
|
+ back: sphericalPolynomialFaces[5],
|
|
|
+ format: BABYLON.Engine.TEXTUREFORMAT_RGBA,
|
|
|
+ type: BABYLON.Engine.TEXTURETYPE_FLOAT,
|
|
|
+ gammaSpace: false,
|
|
|
+ });
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ info.sphericalPolynomial = undefined;
|
|
|
+ }
|
|
|
};
|
|
|
DDSTools.StoreLODInAlphaChannel = false;
|
|
|
return DDSTools;
|