|
@@ -97,6 +97,7 @@
|
|
|
isCompressed: boolean;
|
|
|
dxgiFormat: number;
|
|
|
textureType: number;
|
|
|
+ sphericalPolynomial?: SphericalPolynomial;
|
|
|
};
|
|
|
|
|
|
export class DDSTools {
|
|
@@ -371,7 +372,11 @@
|
|
|
return byteArray;
|
|
|
}
|
|
|
|
|
|
- public static UploadDDSLevels(engine: Engine, gl: WebGLRenderingContext, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex = -1, currentFace?: number): void {
|
|
|
+ public static UploadDDSLevels(engine: Engine, gl: WebGLRenderingContext, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex = -1, currentFace?: number) {
|
|
|
+ var sphericalPolynomialFaces:Nullable<Array<ArrayBufferView>> = null;
|
|
|
+ if(info.sphericalPolynomial){
|
|
|
+ sphericalPolynomialFaces = new Array<ArrayBufferView>();
|
|
|
+ }
|
|
|
var ext = engine.getCaps().s3tc;
|
|
|
|
|
|
var header = new Int32Array(arrayBuffer, 0, headerLengthInt);
|
|
@@ -482,9 +487,15 @@
|
|
|
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 = Engine.TEXTURETYPE_UNSIGNED_INT;
|
|
@@ -494,14 +505,23 @@
|
|
|
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 = 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));
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -545,6 +565,20 @@
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
+ if(sphericalPolynomialFaces){
|
|
|
+ info.sphericalPolynomial = 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: Engine.TEXTUREFORMAT_RGBA,
|
|
|
+ type: Engine.TEXTURETYPE_FLOAT,
|
|
|
+ gammaSpace: false,
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|