Sebastien Vandenberghe 8 rokov pred
rodič
commit
09e99218f0

+ 14 - 27
materialsLibrary/src/legacyPBR/babylon.legacyPBRMaterial.ts

@@ -1331,33 +1331,20 @@ module BABYLON {
                             this._uniformBuffer.updateFloat2("vReflectionInfos", this.reflectionTexture.level, 0);
 
                             if (this._defines.USESPHERICALFROMREFLECTIONMAP) {
-                                this._effect.setFloat3("vSphericalX", (<HDRCubeTexture>this.reflectionTexture).sphericalPolynomial.x.x,
-                                    (<HDRCubeTexture>this.reflectionTexture).sphericalPolynomial.x.y,
-                                    (<HDRCubeTexture>this.reflectionTexture).sphericalPolynomial.x.z);
-                                this._effect.setFloat3("vSphericalY", (<HDRCubeTexture>this.reflectionTexture).sphericalPolynomial.y.x,
-                                    (<HDRCubeTexture>this.reflectionTexture).sphericalPolynomial.y.y,
-                                    (<HDRCubeTexture>this.reflectionTexture).sphericalPolynomial.y.z);
-                                this._effect.setFloat3("vSphericalZ", (<HDRCubeTexture>this.reflectionTexture).sphericalPolynomial.z.x,
-                                    (<HDRCubeTexture>this.reflectionTexture).sphericalPolynomial.z.y,
-                                    (<HDRCubeTexture>this.reflectionTexture).sphericalPolynomial.z.z);
-                                this._effect.setFloat3("vSphericalXX", (<HDRCubeTexture>this.reflectionTexture).sphericalPolynomial.xx.x,
-                                    (<HDRCubeTexture>this.reflectionTexture).sphericalPolynomial.xx.y,
-                                    (<HDRCubeTexture>this.reflectionTexture).sphericalPolynomial.xx.z);
-                                this._effect.setFloat3("vSphericalYY", (<HDRCubeTexture>this.reflectionTexture).sphericalPolynomial.yy.x,
-                                    (<HDRCubeTexture>this.reflectionTexture).sphericalPolynomial.yy.y,
-                                    (<HDRCubeTexture>this.reflectionTexture).sphericalPolynomial.yy.z);
-                                this._effect.setFloat3("vSphericalZZ", (<HDRCubeTexture>this.reflectionTexture).sphericalPolynomial.zz.x,
-                                    (<HDRCubeTexture>this.reflectionTexture).sphericalPolynomial.zz.y,
-                                    (<HDRCubeTexture>this.reflectionTexture).sphericalPolynomial.zz.z);
-                                this._effect.setFloat3("vSphericalXY", (<HDRCubeTexture>this.reflectionTexture).sphericalPolynomial.xy.x,
-                                    (<HDRCubeTexture>this.reflectionTexture).sphericalPolynomial.xy.y,
-                                    (<HDRCubeTexture>this.reflectionTexture).sphericalPolynomial.xy.z);
-                                this._effect.setFloat3("vSphericalYZ", (<HDRCubeTexture>this.reflectionTexture).sphericalPolynomial.yz.x,
-                                    (<HDRCubeTexture>this.reflectionTexture).sphericalPolynomial.yz.y,
-                                    (<HDRCubeTexture>this.reflectionTexture).sphericalPolynomial.yz.z);
-                                this._effect.setFloat3("vSphericalZX", (<HDRCubeTexture>this.reflectionTexture).sphericalPolynomial.zx.x,
-                                    (<HDRCubeTexture>this.reflectionTexture).sphericalPolynomial.zx.y,
-                                    (<HDRCubeTexture>this.reflectionTexture).sphericalPolynomial.zx.z);
+                                var polynomials = this.reflectionTexture.getSphericalPolynomial();
+                                this._effect.setFloat3("vSphericalX", polynomials.x.x, polynomials.x.y, polynomials.x.z);
+                                this._effect.setFloat3("vSphericalY", polynomials.y.x, polynomials.y.y, polynomials.y.z);
+                                this._effect.setFloat3("vSphericalZ", polynomials.z.x, polynomials.z.y, polynomials.z.z);
+                                this._effect.setFloat3("vSphericalXX_ZZ", polynomials.xx.x - polynomials.zz.x,
+                                    polynomials.xx.y - polynomials.zz.y,
+                                    polynomials.xx.z - polynomials.zz.z);
+                                this._effect.setFloat3("vSphericalYY_ZZ", polynomials.yy.x - polynomials.zz.x,
+                                    polynomials.yy.y - polynomials.zz.y,
+                                    polynomials.yy.z - polynomials.zz.z);
+                                this._effect.setFloat3("vSphericalZZ", polynomials.zz.x, polynomials.zz.y, polynomials.zz.z);
+                                this._effect.setFloat3("vSphericalXY", polynomials.xy.x, polynomials.xy.y, polynomials.xy.z);
+                                this._effect.setFloat3("vSphericalYZ", polynomials.yz.x, polynomials.yz.y, polynomials.yz.z);
+                                this._effect.setFloat3("vSphericalZX", polynomials.zx.x, polynomials.zx.y, polynomials.zx.z);
                             }
                         }
 

+ 6 - 6
src/Tools/HDR/babylon.cubemapToSphericalPolynomial.ts

@@ -43,12 +43,12 @@ module BABYLON.Internals {
             }
 
             var size = texture.getSize().width;
-            var right = texture.readPixels(0);
-            var left = texture.readPixels(1);
-            var up = texture.readPixels(2);
-            var down = texture.readPixels(3);
-            var front = texture.readPixels(4);
-            var back = texture.readPixels(5);
+            var right = <Float32Array>texture.readPixels(0);
+            var left = <Float32Array>texture.readPixels(1);
+            var up = <Float32Array>texture.readPixels(2);
+            var down = <Float32Array>texture.readPixels(3);
+            var front = <Float32Array>texture.readPixels(4);
+            var back = <Float32Array>texture.readPixels(5);
 
             var cubeInfo: CubeMapInfo = {
                 size,