|
@@ -242,93 +242,7 @@ module BABYLON {
|
|
|
|
|
|
return false;
|
|
|
}
|
|
|
-
|
|
|
- public static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: MaterialDefines): boolean {
|
|
|
- var lightIndex = 0;
|
|
|
- var needNormals = false;
|
|
|
- for (var index = 0; index < scene.lights.length; index++) {
|
|
|
- var light = scene.lights[index];
|
|
|
-
|
|
|
- if (!light.isEnabled()) {
|
|
|
- continue;
|
|
|
- }
|
|
|
-
|
|
|
- // Excluded check
|
|
|
- if (light._excludedMeshesIds.length > 0) {
|
|
|
- for (var excludedIndex = 0; excludedIndex < light._excludedMeshesIds.length; excludedIndex++) {
|
|
|
- var excludedMesh = scene.getMeshByID(light._excludedMeshesIds[excludedIndex]);
|
|
|
-
|
|
|
- if (excludedMesh) {
|
|
|
- light.excludedMeshes.push(excludedMesh);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- light._excludedMeshesIds = [];
|
|
|
- }
|
|
|
-
|
|
|
- // Included check
|
|
|
- if (light._includedOnlyMeshesIds.length > 0) {
|
|
|
- for (var includedOnlyIndex = 0; includedOnlyIndex < light._includedOnlyMeshesIds.length; includedOnlyIndex++) {
|
|
|
- var includedOnlyMesh = scene.getMeshByID(light._includedOnlyMeshesIds[includedOnlyIndex]);
|
|
|
-
|
|
|
- if (includedOnlyMesh) {
|
|
|
- light.includedOnlyMeshes.push(includedOnlyMesh);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- light._includedOnlyMeshesIds = [];
|
|
|
- }
|
|
|
-
|
|
|
- if (!light.canAffectMesh(mesh)) {
|
|
|
- continue;
|
|
|
- }
|
|
|
- needNormals = true;
|
|
|
- defines["LIGHT" + lightIndex] = true;
|
|
|
-
|
|
|
- var type;
|
|
|
- if (light instanceof SpotLight) {
|
|
|
- type = "SPOTLIGHT" + lightIndex;
|
|
|
- } else if (light instanceof HemisphericLight) {
|
|
|
- type = "HEMILIGHT" + lightIndex;
|
|
|
- } else if (light instanceof PointLight) {
|
|
|
- type = "POINTLIGHT" + lightIndex;
|
|
|
- } else {
|
|
|
- type = "DIRLIGHT" + lightIndex;
|
|
|
- }
|
|
|
-
|
|
|
- defines[type] = true;
|
|
|
-
|
|
|
- // Specular
|
|
|
- if (!light.specular.equalsFloats(0, 0, 0)) {
|
|
|
- defines["SPECULARTERM"] = true;
|
|
|
- }
|
|
|
-
|
|
|
- // Shadows
|
|
|
- if (scene.shadowsEnabled) {
|
|
|
- var shadowGenerator = light.getShadowGenerator();
|
|
|
- if (mesh && mesh.receiveShadows && shadowGenerator) {
|
|
|
- defines["SHADOW" + lightIndex] = true;
|
|
|
-
|
|
|
- defines["SHADOWS"] = true;
|
|
|
-
|
|
|
- if (shadowGenerator.useVarianceShadowMap || shadowGenerator.useBlurVarianceShadowMap) {
|
|
|
- defines["SHADOWVSM" + lightIndex] = true;
|
|
|
- }
|
|
|
-
|
|
|
- if (shadowGenerator.usePoissonSampling) {
|
|
|
- defines["SHADOWPCF" + lightIndex] = true;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- lightIndex++;
|
|
|
- if (lightIndex === maxSimultaneousLights)
|
|
|
- break;
|
|
|
- }
|
|
|
-
|
|
|
- return needNormals;
|
|
|
- }
|
|
|
-
|
|
|
+
|
|
|
private static _scaledAlbedo = new Color3();
|
|
|
private static _scaledReflectivity = new Color3();
|
|
|
private static _scaledEmissive = new Color3();
|
|
@@ -629,7 +543,7 @@ module BABYLON {
|
|
|
}
|
|
|
|
|
|
if (scene.lightsEnabled && !this.disableLighting) {
|
|
|
- needNormals = PBRMaterial.PrepareDefinesForLights(scene, mesh, this._defines) || needNormals;
|
|
|
+ needNormals = StandardMaterial.PrepareDefinesForLights(scene, mesh, this._defines) || needNormals;
|
|
|
}
|
|
|
|
|
|
if (StandardMaterial.FresnelEnabled) {
|