Forráskód Böngészése

beginning material library compatibility (no port yet) and corrected vicious bug about scene UBO bind

Benjamin Guignabert 8 éve
szülő
commit
0b4333436b

A különbségek nem kerülnek megjelenítésre, a fájl túl nagy
+ 1 - 1
dist/preview release/babylon.core.js


A különbségek nem kerülnek megjelenítésre, a fájl túl nagy
+ 4177 - 4177
dist/preview release/babylon.d.ts


A különbségek nem kerülnek megjelenítésre, a fájl túl nagy
+ 1 - 1
dist/preview release/babylon.js


+ 4 - 2
dist/preview release/babylon.max.js

@@ -31135,7 +31135,9 @@ var BABYLON;
                     break;
                     break;
                 }
                 }
                 uniformsList.push("vLightData" + lightIndex, "vLightDiffuse" + lightIndex, "vLightSpecular" + lightIndex, "vLightDirection" + lightIndex, "vLightGround" + lightIndex, "lightMatrix" + lightIndex, "shadowsInfo" + lightIndex);
                 uniformsList.push("vLightData" + lightIndex, "vLightDiffuse" + lightIndex, "vLightSpecular" + lightIndex, "vLightDirection" + lightIndex, "vLightGround" + lightIndex, "lightMatrix" + lightIndex, "shadowsInfo" + lightIndex);
-                uniformBuffersList.push("Light" + lightIndex);
+                if (uniformBuffersList) {
+                    uniformBuffersList.push("Light" + lightIndex);
+                }
                 samplersList.push("shadowSampler" + lightIndex);
                 samplersList.push("shadowSampler" + lightIndex);
             }
             }
             if (defines["NUM_MORPH_INFLUENCERS"]) {
             if (defines["NUM_MORPH_INFLUENCERS"]) {
@@ -31240,7 +31242,7 @@ var BABYLON;
                 }
                 }
                 // Shadows
                 // Shadows
                 if (scene.shadowsEnabled) {
                 if (scene.shadowsEnabled) {
-                    depthValuesAlreadySet = this.BindLightShadow(light, scene, mesh, lightIndex, effect, depthValuesAlreadySet);
+                    depthValuesAlreadySet = this.BindLightShadow(light, scene, mesh, lightIndex, effect, depthValuesAlreadySet, disableUbo);
                 }
                 }
                 light._uniformBuffer.update();
                 light._uniformBuffer.update();
                 lightIndex++;
                 lightIndex++;

A különbségek nem kerülnek megjelenítésre, a fájl túl nagy
+ 4177 - 4177
dist/preview release/babylon.module.d.ts


A különbségek nem kerülnek megjelenítésre, a fájl túl nagy
+ 1 - 1
dist/preview release/babylon.noworker.js


+ 20 - 14
materialsLibrary/src/fire/babylon.fireMaterial.ts

@@ -146,20 +146,26 @@ module BABYLON {
                 
                 
                 var join = defines.toString();
                 var join = defines.toString();
                 subMesh.setEffect(scene.getEngine().createEffect(shaderName,
                 subMesh.setEffect(scene.getEngine().createEffect(shaderName,
-                    attribs,
-                    ["world", "view", "viewProjection", "vEyePosition",
-                        "vFogInfos", "vFogColor", "pointSize",
-                        "vDiffuseInfos", 
-                        "mBones",
-                        "vClipPlane", "diffuseMatrix",
-                        // Fire
-                        "time", "speed"
-                    ],
-                    ["diffuseSampler",
-                        // Fire
-                        "distortionSampler", "opacitySampler"
-                    ],
-                    join, fallbacks, this.onCompiled, this.onError), defines);
+                    <EffectCreationOptions>{
+                        attributes: attribs,
+                        uniformsNames: ["world", "view", "viewProjection", "vEyePosition",
+                                "vFogInfos", "vFogColor", "pointSize",
+                                "vDiffuseInfos", 
+                                "mBones",
+                                "vClipPlane", "diffuseMatrix",
+                                // Fire
+                                "time", "speed"
+                            ],
+                        uniformBuffersNames: [],
+                        samplers: ["diffuseSampler",
+                                // Fire
+                                "distortionSampler", "opacitySampler"
+                            ],
+                        defines: join,
+                        fallbacks: fallbacks,
+                        onCompiled: this.onCompiled,
+                        onError: this.onError
+                    }, engine), defines);
             }
             }
             
             
             if (!subMesh.effect.isReady()) {
             if (!subMesh.effect.isReady()) {

+ 1 - 1
materialsLibrary/src/fur/fur.fragment.fx

@@ -19,7 +19,7 @@ varying vec4 vColor;
 #endif
 #endif
 
 
 // Lights
 // Lights
-#include<lightFragmentDeclaration>[0..maxSimultaneousLights]
+#include<__decl__lightFragment>[0..maxSimultaneousLights]
 
 
 // Samplers
 // Samplers
 #ifdef DIFFUSE
 #ifdef DIFFUSE

+ 4 - 4
materialsLibrary/src/gradient/gradient.fragment.fx

@@ -23,10 +23,10 @@ varying vec4 vColor;
 
 
 // Lights
 // Lights
 
 
-#include<lightFragmentDeclaration>[0]
-#include<lightFragmentDeclaration>[1]
-#include<lightFragmentDeclaration>[2]
-#include<lightFragmentDeclaration>[3]
+#include<__decl__lightFragment>[0]
+#include<__decl__lightFragment>[1]
+#include<__decl__lightFragment>[2]
+#include<__decl__lightFragment>[3]
 
 
 
 
 #include<lightsFragmentFunctions>
 #include<lightsFragmentFunctions>

+ 4 - 4
materialsLibrary/src/lava/lava.fragment.fx

@@ -27,10 +27,10 @@ varying vec4 vColor;
 #endif
 #endif
 
 
 // Lights
 // Lights
-#include<lightFragmentDeclaration>[0]
-#include<lightFragmentDeclaration>[1]
-#include<lightFragmentDeclaration>[2]
-#include<lightFragmentDeclaration>[3]
+#include<__decl__lightFragment>[0]
+#include<__decl__lightFragment>[1]
+#include<__decl__lightFragment>[2]
+#include<__decl__lightFragment>[3]
 
 
 
 
 #include<lightsFragmentFunctions>
 #include<lightsFragmentFunctions>

+ 4 - 4
materialsLibrary/src/normal/normal.fragment.fx

@@ -16,10 +16,10 @@ varying vec4 vColor;
 #endif
 #endif
 
 
 // Lights
 // Lights
-#include<lightFragmentDeclaration>[0]
-#include<lightFragmentDeclaration>[1]
-#include<lightFragmentDeclaration>[2]
-#include<lightFragmentDeclaration>[3]
+#include<__decl__lightFragment>[0]
+#include<__decl__lightFragment>[1]
+#include<__decl__lightFragment>[2]
+#include<__decl__lightFragment>[3]
 
 
 
 
 #include<lightsFragmentFunctions>
 #include<lightsFragmentFunctions>

+ 21 - 5
materialsLibrary/src/simple/babylon.simpleMaterial.ts

@@ -159,12 +159,28 @@ module BABYLON {
                                 "vClipPlane", "diffuseMatrix", "depthValues"
                                 "vClipPlane", "diffuseMatrix", "depthValues"
                 ];
                 ];
                 var samplers = ["diffuseSampler"];
                 var samplers = ["diffuseSampler"];
-                    
-                MaterialHelper.PrepareUniformsAndSamplersList(uniforms, samplers, defines, this.maxSimultaneousLights);
-                
+                var uniformBuffers = [];
+
+                MaterialHelper.PrepareUniformsAndSamplersList(<EffectCreationOptions>{
+                    uniformsNames: uniforms, 
+                    uniformBuffersNames: uniformBuffers,
+                    samplers: samplers, 
+                    defines: defines, 
+                    maxSimultaneousLights: this.maxSimultaneousLights
+                });
                 subMesh.setEffect(scene.getEngine().createEffect(shaderName,
                 subMesh.setEffect(scene.getEngine().createEffect(shaderName,
-                    attribs, uniforms, samplers,
-                    join, fallbacks, this.onCompiled, this.onError, { maxSimultaneousLights: this._maxSimultaneousLights - 1 }), defines);
+                    <EffectCreationOptions>{
+                        attributes: attribs,
+                        uniformsNames: uniforms,
+                        uniformBuffersNames: uniformBuffers,
+                        samplers: samplers,
+                        defines: join,
+                        fallbacks: fallbacks,
+                        onCompiled: this.onCompiled,
+                        onError: this.onError,
+                        indexParameters: { maxSimultaneousLights: this._maxSimultaneousLights - 1 }
+                    }, engine), defines);
+
             }
             }
             if (!subMesh.effect.isReady()) {
             if (!subMesh.effect.isReady()) {
                 return false;
                 return false;

+ 1 - 1
materialsLibrary/src/simple/simple.fragment.fx

@@ -16,7 +16,7 @@ varying vec4 vColor;
 #endif
 #endif
 
 
 // Lights
 // Lights
-#include<lightFragmentDeclaration>[0..maxSimultaneousLights]
+#include<__decl__lightFragment>[0..maxSimultaneousLights]
 
 
 
 
 #include<lightsFragmentFunctions>
 #include<lightsFragmentFunctions>

+ 1 - 1
materialsLibrary/src/terrain/terrain.fragment.fx

@@ -20,7 +20,7 @@ varying vec4 vColor;
 #endif
 #endif
 
 
 // Lights
 // Lights
-#include<lightFragmentDeclaration>[0..maxSimultaneousLights]
+#include<__decl__lightFragment>[0..maxSimultaneousLights]
 
 
 // Samplers
 // Samplers
 #ifdef DIFFUSE
 #ifdef DIFFUSE

+ 1 - 1
materialsLibrary/src/triPlanar/triplanar.fragment.fx

@@ -16,7 +16,7 @@ varying vec4 vColor;
 #endif
 #endif
 
 
 // Lights
 // Lights
-#include<lightFragmentDeclaration>[0..maxSimultaneousLights]
+#include<__decl__lightFragment>[0..maxSimultaneousLights]
 
 
 // Samplers
 // Samplers
 #ifdef DIFFUSEX
 #ifdef DIFFUSEX

+ 21 - 5
materialsLibrary/src/water/babylon.waterMaterial.ts

@@ -340,12 +340,28 @@ module BABYLON {
                     // Water
                     // Water
                     "refractionSampler", "reflectionSampler"
                     "refractionSampler", "reflectionSampler"
                 ];
                 ];
-                
-                MaterialHelper.PrepareUniformsAndSamplersList(uniforms, samplers, defines, this.maxSimultaneousLights);
-                
+                var uniformBuffers = [];
+
+                MaterialHelper.PrepareUniformsAndSamplersList(<EffectCreationOptions>{
+                    uniformsNames: uniforms, 
+                    uniformBuffersNames: uniformBuffers,
+                    samplers: samplers, 
+                    defines: defines, 
+                    maxSimultaneousLights: this.maxSimultaneousLights
+                });
                 subMesh.setEffect(scene.getEngine().createEffect(shaderName,
                 subMesh.setEffect(scene.getEngine().createEffect(shaderName,
-                    attribs, uniforms, samplers,
-                    join, fallbacks, this.onCompiled, this.onError, { maxSimultaneousLights: this.maxSimultaneousLights }), defines);
+                    <EffectCreationOptions>{
+                        attributes: attribs,
+                        uniformsNames: uniforms,
+                        uniformBuffersNames: uniformBuffers,
+                        samplers: samplers,
+                        defines: join,
+                        fallbacks: fallbacks,
+                        onCompiled: this.onCompiled,
+                        onError: this.onError,
+                        indexParameters: { maxSimultaneousLights: this._maxSimultaneousLights }
+                    }, engine), defines);
+
             }
             }
             if (!subMesh.effect.isReady()) {
             if (!subMesh.effect.isReady()) {
                 return false;
                 return false;

+ 1 - 1
materialsLibrary/src/water/water.fragment.fx

@@ -24,7 +24,7 @@ varying vec4 vColor;
 #endif
 #endif
 
 
 // Lights
 // Lights
-#include<lightFragmentDeclaration>[0..maxSimultaneousLights]
+#include<__decl__lightFragment>[0..maxSimultaneousLights]
 
 
 #include<lightsFragmentFunctions>
 #include<lightsFragmentFunctions>
 #include<shadowsFragmentFunctions>
 #include<shadowsFragmentFunctions>

+ 4 - 0
src/Materials/babylon.material.ts

@@ -448,12 +448,16 @@
         public bindView(effect: Effect): void {
         public bindView(effect: Effect): void {
             if (this.getScene().getEngine().webGLVersion === 1) {
             if (this.getScene().getEngine().webGLVersion === 1) {
                 effect.setMatrix("view", this.getScene().getViewMatrix());
                 effect.setMatrix("view", this.getScene().getViewMatrix());
+            } else {
+                this.bindSceneUniformBuffer(effect, this.getScene().getSceneUniformBuffer());
             }
             }
         }
         }
 
 
         public bindViewProjection(effect: Effect): void {
         public bindViewProjection(effect: Effect): void {
             if (this.getScene().getEngine().webGLVersion === 1) {
             if (this.getScene().getEngine().webGLVersion === 1) {
                 effect.setMatrix("viewProjection", this.getScene().getTransformMatrix());
                 effect.setMatrix("viewProjection", this.getScene().getTransformMatrix());
+            } else {
+                this.bindSceneUniformBuffer(effect, this.getScene().getSceneUniformBuffer());
             }
             }
         }
         }
 
 

+ 4 - 1
src/Materials/babylon.materialHelper.ts

@@ -218,7 +218,10 @@
                     "lightMatrix" + lightIndex,
                     "lightMatrix" + lightIndex,
                     "shadowsInfo" + lightIndex
                     "shadowsInfo" + lightIndex
                 );
                 );
-                uniformBuffersList.push("Light" + lightIndex);
+
+                if (uniformBuffersList) {
+                    uniformBuffersList.push("Light" + lightIndex);
+                }
 
 
                 samplersList.push("shadowSampler" + lightIndex);
                 samplersList.push("shadowSampler" + lightIndex);
             }
             }

+ 1 - 9
src/Materials/babylon.standardMaterial.ts

@@ -726,14 +726,6 @@ module BABYLON {
                     maxSimultaneousLights: this._maxSimultaneousLights
                     maxSimultaneousLights: this._maxSimultaneousLights
                 });
                 });
 
 
-                var onCompiled = function(effect) {
-                    if (this.onCompiled) {
-                        this.onCompiled(effect);
-                    }
-
-                    this.bindSceneUniformBuffer(effect, scene.getSceneUniformBuffer());
-                }.bind(this);
-
                 subMesh.setEffect(scene.getEngine().createEffect(shaderName, <EffectCreationOptions>{
                 subMesh.setEffect(scene.getEngine().createEffect(shaderName, <EffectCreationOptions>{
                     attributes: attribs,
                     attributes: attribs,
                     uniformsNames: uniforms,
                     uniformsNames: uniforms,
@@ -741,7 +733,7 @@ module BABYLON {
                     samplers: samplers,
                     samplers: samplers,
                     defines: join,
                     defines: join,
                     fallbacks: fallbacks,
                     fallbacks: fallbacks,
-                    onCompiled: onCompiled,
+                    onCompiled: this.onCompiled,
                     onError: this.onError,
                     onError: this.onError,
                     indexParameters: { maxSimultaneousLights: this._maxSimultaneousLights, maxSimultaneousMorphTargets: defines.NUM_MORPH_INFLUENCERS }
                     indexParameters: { maxSimultaneousLights: this._maxSimultaneousLights, maxSimultaneousMorphTargets: defines.NUM_MORPH_INFLUENCERS }
                 }, engine), defines);
                 }, engine), defines);