Переглянути джерело

cleaned some normalMaterial code

Benjamin Guignabert 8 роки тому
батько
коміт
7f9852cc65
1 змінених файлів з 18 додано та 19 видалено
  1. 18 19
      materialsLibrary/src/normal/babylon.normalMaterial.ts

+ 18 - 19
materialsLibrary/src/normal/babylon.normalMaterial.ts

@@ -187,31 +187,30 @@ module BABYLON {
                 var shaderName = "normal";
                 var join = defines.toString();
 
+                var uniforms = ["world", "view", "viewProjection", "vEyePosition", "vLightsType", "vDiffuseColor",
+                    "vFogInfos", "vFogColor", "pointSize",
+                    "vDiffuseInfos", 
+                    "mBones",
+                    "vClipPlane", "diffuseMatrix",
+                    "depthValues"
+                ];
+                var samplers = ["diffuseSampler"];
                 var uniformBuffers = [];
-                for (var i = 0; i < 4; i++) {
-                    if (defines["LIGHT" + i]) {
-                        uniformBuffers.push("Light" + i);
-                    }
-                }
+
+                MaterialHelper.PrepareUniformsAndSamplersList(<EffectCreationOptions>{
+                    uniformsNames: uniforms, 
+                    uniformBuffersNames: uniformBuffers,
+                    samplers: samplers, 
+                    defines: defines, 
+                    maxSimultaneousLights: 4
+                });
 
                 subMesh.setEffect(scene.getEngine().createEffect(shaderName,
                     <EffectCreationOptions>{
                         attributes: attribs,
-                        uniformsNames: ["world", "view", "viewProjection", "vEyePosition", "vLightsType", "vDiffuseColor",
-                            "vLightData0", "vLightDiffuse0", "vLightDirection0", "vLightGround0", "lightMatrix0",
-                            "vLightData1", "vLightDiffuse1", "vLightDirection1", "vLightGround1", "lightMatrix1",
-                            "vLightData2", "vLightDiffuse2", "vLightDirection2", "vLightGround2", "lightMatrix2",
-                            "vLightData3", "vLightDiffuse3", "vLightDirection3", "vLightGround3", "lightMatrix3",
-                            "vFogInfos", "vFogColor", "pointSize",
-                            "vDiffuseInfos", 
-                            "mBones",
-                            "vClipPlane", "diffuseMatrix",
-                            "shadowsInfo0", "shadowsInfo1", "shadowsInfo2", "shadowsInfo3", "depthValues"
-                        ],
+                        uniformsNames: uniforms,
                         uniformBuffersNames: uniformBuffers,
-                        samplers: ["diffuseSampler",
-                            "shadowSampler0", "shadowSampler1", "shadowSampler2", "shadowSampler3"
-                        ],
+                        samplers: samplers,
                         defines: join,
                         fallbacks: fallbacks,
                         onCompiled: this.onCompiled,