|
@@ -1,9 +1,9 @@
|
|
/// <reference path="../../../dist/preview release/babylon.d.ts"/>
|
|
/// <reference path="../../../dist/preview release/babylon.d.ts"/>
|
|
|
|
|
|
-module BABYLON {
|
|
|
|
-
|
|
|
|
- // old version of standard material updated every 3 months
|
|
|
|
- export class StandardMaterialDefines_OldVer extends MaterialDefines implements IImageProcessingConfigurationDefines {
|
|
|
|
|
|
+module BABYLON {
|
|
|
|
+
|
|
|
|
+ // old version of standard material updated every 3 months
|
|
|
|
+ export class StandardMaterialDefines_OldVer extends MaterialDefines implements IImageProcessingConfigurationDefines {
|
|
public DIFFUSE = false;
|
|
public DIFFUSE = false;
|
|
public AMBIENT = false;
|
|
public AMBIENT = false;
|
|
public OPACITY = false;
|
|
public OPACITY = false;
|
|
@@ -85,11 +85,11 @@ module BABYLON {
|
|
|
|
|
|
public setReflectionMode(modeToEnable: string) {
|
|
public setReflectionMode(modeToEnable: string) {
|
|
var modes = [
|
|
var modes = [
|
|
- "REFLECTIONMAP_CUBIC", "REFLECTIONMAP_EXPLICIT", "REFLECTIONMAP_PLANAR",
|
|
|
|
- "REFLECTIONMAP_PROJECTION", "REFLECTIONMAP_PROJECTION", "REFLECTIONMAP_SKYBOX",
|
|
|
|
- "REFLECTIONMAP_SPHERICAL", "REFLECTIONMAP_EQUIRECTANGULAR", "REFLECTIONMAP_EQUIRECTANGULAR_FIXED",
|
|
|
|
- "REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED"
|
|
|
|
- ];
|
|
|
|
|
|
+ "REFLECTIONMAP_CUBIC", "REFLECTIONMAP_EXPLICIT", "REFLECTIONMAP_PLANAR",
|
|
|
|
+ "REFLECTIONMAP_PROJECTION", "REFLECTIONMAP_PROJECTION", "REFLECTIONMAP_SKYBOX",
|
|
|
|
+ "REFLECTIONMAP_SPHERICAL", "REFLECTIONMAP_EQUIRECTANGULAR", "REFLECTIONMAP_EQUIRECTANGULAR_FIXED",
|
|
|
|
+ "REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED"
|
|
|
|
+ ];
|
|
|
|
|
|
for (var mode of modes) {
|
|
for (var mode of modes) {
|
|
(<any>this)[mode] = (mode === modeToEnable);
|
|
(<any>this)[mode] = (mode === modeToEnable);
|
|
@@ -109,39 +109,39 @@ module BABYLON {
|
|
public ambientTexture: BaseTexture;
|
|
public ambientTexture: BaseTexture;
|
|
|
|
|
|
@serializeAsTexture("opacityTexture")
|
|
@serializeAsTexture("opacityTexture")
|
|
- private _opacityTexture: BaseTexture;
|
|
|
|
|
|
+ private _opacityTexture: BaseTexture;
|
|
@expandToProperty("_markAllSubMeshesAsTexturesDirty")
|
|
@expandToProperty("_markAllSubMeshesAsTexturesDirty")
|
|
- public opacityTexture: BaseTexture;
|
|
|
|
|
|
+ public opacityTexture: BaseTexture;
|
|
|
|
|
|
@serializeAsTexture("reflectionTexture")
|
|
@serializeAsTexture("reflectionTexture")
|
|
private _reflectionTexture: BaseTexture;
|
|
private _reflectionTexture: BaseTexture;
|
|
@expandToProperty("_markAllSubMeshesAsTexturesDirty")
|
|
@expandToProperty("_markAllSubMeshesAsTexturesDirty")
|
|
- public reflectionTexture: BaseTexture;
|
|
|
|
|
|
+ public reflectionTexture: BaseTexture;
|
|
|
|
|
|
@serializeAsTexture("emissiveTexture")
|
|
@serializeAsTexture("emissiveTexture")
|
|
private _emissiveTexture: BaseTexture;
|
|
private _emissiveTexture: BaseTexture;
|
|
@expandToProperty("_markAllSubMeshesAsTexturesDirty")
|
|
@expandToProperty("_markAllSubMeshesAsTexturesDirty")
|
|
- public emissiveTexture: BaseTexture;
|
|
|
|
|
|
+ public emissiveTexture: BaseTexture;
|
|
|
|
|
|
@serializeAsTexture("specularTexture")
|
|
@serializeAsTexture("specularTexture")
|
|
private _specularTexture: BaseTexture;
|
|
private _specularTexture: BaseTexture;
|
|
@expandToProperty("_markAllSubMeshesAsTexturesDirty")
|
|
@expandToProperty("_markAllSubMeshesAsTexturesDirty")
|
|
- public specularTexture: BaseTexture;
|
|
|
|
|
|
+ public specularTexture: BaseTexture;
|
|
|
|
|
|
@serializeAsTexture("bumpTexture")
|
|
@serializeAsTexture("bumpTexture")
|
|
private _bumpTexture: BaseTexture;
|
|
private _bumpTexture: BaseTexture;
|
|
@expandToProperty("_markAllSubMeshesAsTexturesDirty")
|
|
@expandToProperty("_markAllSubMeshesAsTexturesDirty")
|
|
- public bumpTexture: BaseTexture;
|
|
|
|
|
|
+ public bumpTexture: BaseTexture;
|
|
|
|
|
|
@serializeAsTexture("lightmapTexture")
|
|
@serializeAsTexture("lightmapTexture")
|
|
private _lightmapTexture: BaseTexture;
|
|
private _lightmapTexture: BaseTexture;
|
|
@expandToProperty("_markAllSubMeshesAsTexturesDirty")
|
|
@expandToProperty("_markAllSubMeshesAsTexturesDirty")
|
|
- public lightmapTexture: BaseTexture;
|
|
|
|
|
|
+ public lightmapTexture: BaseTexture;
|
|
|
|
|
|
@serializeAsTexture("refractionTexture")
|
|
@serializeAsTexture("refractionTexture")
|
|
private _refractionTexture: BaseTexture;
|
|
private _refractionTexture: BaseTexture;
|
|
@expandToProperty("_markAllSubMeshesAsTexturesDirty")
|
|
@expandToProperty("_markAllSubMeshesAsTexturesDirty")
|
|
- public refractionTexture: BaseTexture;
|
|
|
|
|
|
+ public refractionTexture: BaseTexture;
|
|
|
|
|
|
@serializeAsColor3("ambient")
|
|
@serializeAsColor3("ambient")
|
|
public ambientColor = new Color3(0, 0, 0);
|
|
public ambientColor = new Color3(0, 0, 0);
|
|
@@ -161,27 +161,27 @@ module BABYLON {
|
|
@serialize("useAlphaFromDiffuseTexture")
|
|
@serialize("useAlphaFromDiffuseTexture")
|
|
private _useAlphaFromDiffuseTexture = false;
|
|
private _useAlphaFromDiffuseTexture = false;
|
|
@expandToProperty("_markAllSubMeshesAsTexturesDirty")
|
|
@expandToProperty("_markAllSubMeshesAsTexturesDirty")
|
|
- public useAlphaFromDiffuseTexture: boolean;
|
|
|
|
|
|
+ public useAlphaFromDiffuseTexture: boolean;
|
|
|
|
|
|
@serialize("useEmissiveAsIllumination")
|
|
@serialize("useEmissiveAsIllumination")
|
|
private _useEmissiveAsIllumination = false;
|
|
private _useEmissiveAsIllumination = false;
|
|
@expandToProperty("_markAllSubMeshesAsTexturesDirty")
|
|
@expandToProperty("_markAllSubMeshesAsTexturesDirty")
|
|
- public useEmissiveAsIllumination: boolean;
|
|
|
|
-
|
|
|
|
|
|
+ public useEmissiveAsIllumination: boolean;
|
|
|
|
+
|
|
@serialize("linkEmissiveWithDiffuse")
|
|
@serialize("linkEmissiveWithDiffuse")
|
|
private _linkEmissiveWithDiffuse = false;
|
|
private _linkEmissiveWithDiffuse = false;
|
|
@expandToProperty("_markAllSubMeshesAsTexturesDirty")
|
|
@expandToProperty("_markAllSubMeshesAsTexturesDirty")
|
|
- public linkEmissiveWithDiffuse: boolean;
|
|
|
|
|
|
+ public linkEmissiveWithDiffuse: boolean;
|
|
|
|
|
|
@serialize("useSpecularOverAlpha")
|
|
@serialize("useSpecularOverAlpha")
|
|
private _useSpecularOverAlpha = false;
|
|
private _useSpecularOverAlpha = false;
|
|
@expandToProperty("_markAllSubMeshesAsTexturesDirty")
|
|
@expandToProperty("_markAllSubMeshesAsTexturesDirty")
|
|
- public useSpecularOverAlpha: boolean;
|
|
|
|
|
|
+ public useSpecularOverAlpha: boolean;
|
|
|
|
|
|
@serialize("useReflectionOverAlpha")
|
|
@serialize("useReflectionOverAlpha")
|
|
private _useReflectionOverAlpha = false;
|
|
private _useReflectionOverAlpha = false;
|
|
@expandToProperty("_markAllSubMeshesAsTexturesDirty")
|
|
@expandToProperty("_markAllSubMeshesAsTexturesDirty")
|
|
- public useReflectionOverAlpha: boolean;
|
|
|
|
|
|
+ public useReflectionOverAlpha: boolean;
|
|
|
|
|
|
@serialize("disableLighting")
|
|
@serialize("disableLighting")
|
|
private _disableLighting = false;
|
|
private _disableLighting = false;
|
|
@@ -191,12 +191,12 @@ module BABYLON {
|
|
@serialize("useParallax")
|
|
@serialize("useParallax")
|
|
private _useParallax = false;
|
|
private _useParallax = false;
|
|
@expandToProperty("_markAllSubMeshesAsTexturesDirty")
|
|
@expandToProperty("_markAllSubMeshesAsTexturesDirty")
|
|
- public useParallax: boolean;
|
|
|
|
|
|
+ public useParallax: boolean;
|
|
|
|
|
|
@serialize("useParallaxOcclusion")
|
|
@serialize("useParallaxOcclusion")
|
|
private _useParallaxOcclusion = false;
|
|
private _useParallaxOcclusion = false;
|
|
@expandToProperty("_markAllSubMeshesAsTexturesDirty")
|
|
@expandToProperty("_markAllSubMeshesAsTexturesDirty")
|
|
- public useParallaxOcclusion: boolean;
|
|
|
|
|
|
+ public useParallaxOcclusion: boolean;
|
|
|
|
|
|
@serialize()
|
|
@serialize()
|
|
public parallaxScaleBias = 0.05;
|
|
public parallaxScaleBias = 0.05;
|
|
@@ -204,7 +204,7 @@ module BABYLON {
|
|
@serialize("roughness")
|
|
@serialize("roughness")
|
|
private _roughness = 0;
|
|
private _roughness = 0;
|
|
@expandToProperty("_markAllSubMeshesAsTexturesDirty")
|
|
@expandToProperty("_markAllSubMeshesAsTexturesDirty")
|
|
- public roughness: number;
|
|
|
|
|
|
+ public roughness: number;
|
|
|
|
|
|
@serialize()
|
|
@serialize()
|
|
public indexOfRefraction = 0.98;
|
|
public indexOfRefraction = 0.98;
|
|
@@ -215,49 +215,49 @@ module BABYLON {
|
|
@serialize("useLightmapAsShadowmap")
|
|
@serialize("useLightmapAsShadowmap")
|
|
private _useLightmapAsShadowmap = false;
|
|
private _useLightmapAsShadowmap = false;
|
|
@expandToProperty("_markAllSubMeshesAsTexturesDirty")
|
|
@expandToProperty("_markAllSubMeshesAsTexturesDirty")
|
|
- public useLightmapAsShadowmap: boolean;
|
|
|
|
|
|
+ public useLightmapAsShadowmap: boolean;
|
|
|
|
|
|
// Fresnel
|
|
// Fresnel
|
|
@serializeAsFresnelParameters("diffuseFresnelParameters")
|
|
@serializeAsFresnelParameters("diffuseFresnelParameters")
|
|
private _diffuseFresnelParameters: FresnelParameters;
|
|
private _diffuseFresnelParameters: FresnelParameters;
|
|
@expandToProperty("_markAllSubMeshesAsFresnelDirty")
|
|
@expandToProperty("_markAllSubMeshesAsFresnelDirty")
|
|
- public diffuseFresnelParameters: FresnelParameters;
|
|
|
|
|
|
+ public diffuseFresnelParameters: FresnelParameters;
|
|
|
|
|
|
@serializeAsFresnelParameters("opacityFresnelParameters")
|
|
@serializeAsFresnelParameters("opacityFresnelParameters")
|
|
private _opacityFresnelParameters: FresnelParameters;
|
|
private _opacityFresnelParameters: FresnelParameters;
|
|
@expandToProperty("_markAllSubMeshesAsFresnelDirty")
|
|
@expandToProperty("_markAllSubMeshesAsFresnelDirty")
|
|
- public opacityFresnelParameters: FresnelParameters;
|
|
|
|
-
|
|
|
|
|
|
+ public opacityFresnelParameters: FresnelParameters;
|
|
|
|
+
|
|
|
|
|
|
@serializeAsFresnelParameters("reflectionFresnelParameters")
|
|
@serializeAsFresnelParameters("reflectionFresnelParameters")
|
|
private _reflectionFresnelParameters: FresnelParameters;
|
|
private _reflectionFresnelParameters: FresnelParameters;
|
|
@expandToProperty("_markAllSubMeshesAsFresnelDirty")
|
|
@expandToProperty("_markAllSubMeshesAsFresnelDirty")
|
|
- public reflectionFresnelParameters: FresnelParameters;
|
|
|
|
|
|
+ public reflectionFresnelParameters: FresnelParameters;
|
|
|
|
|
|
@serializeAsFresnelParameters("refractionFresnelParameters")
|
|
@serializeAsFresnelParameters("refractionFresnelParameters")
|
|
private _refractionFresnelParameters: FresnelParameters;
|
|
private _refractionFresnelParameters: FresnelParameters;
|
|
@expandToProperty("_markAllSubMeshesAsFresnelDirty")
|
|
@expandToProperty("_markAllSubMeshesAsFresnelDirty")
|
|
- public refractionFresnelParameters: FresnelParameters;
|
|
|
|
|
|
+ public refractionFresnelParameters: FresnelParameters;
|
|
|
|
|
|
@serializeAsFresnelParameters("emissiveFresnelParameters")
|
|
@serializeAsFresnelParameters("emissiveFresnelParameters")
|
|
private _emissiveFresnelParameters: FresnelParameters;
|
|
private _emissiveFresnelParameters: FresnelParameters;
|
|
@expandToProperty("_markAllSubMeshesAsFresnelDirty")
|
|
@expandToProperty("_markAllSubMeshesAsFresnelDirty")
|
|
- public emissiveFresnelParameters: FresnelParameters;
|
|
|
|
|
|
+ public emissiveFresnelParameters: FresnelParameters;
|
|
|
|
|
|
@serialize("useReflectionFresnelFromSpecular")
|
|
@serialize("useReflectionFresnelFromSpecular")
|
|
- private _useReflectionFresnelFromSpecular = false;
|
|
|
|
|
|
+ private _useReflectionFresnelFromSpecular = false;
|
|
@expandToProperty("_markAllSubMeshesAsFresnelDirty")
|
|
@expandToProperty("_markAllSubMeshesAsFresnelDirty")
|
|
- public useReflectionFresnelFromSpecular: boolean;
|
|
|
|
|
|
+ public useReflectionFresnelFromSpecular: boolean;
|
|
|
|
|
|
@serialize("useGlossinessFromSpecularMapAlpha")
|
|
@serialize("useGlossinessFromSpecularMapAlpha")
|
|
private _useGlossinessFromSpecularMapAlpha = false;
|
|
private _useGlossinessFromSpecularMapAlpha = false;
|
|
@expandToProperty("_markAllSubMeshesAsTexturesDirty")
|
|
@expandToProperty("_markAllSubMeshesAsTexturesDirty")
|
|
- public useGlossinessFromSpecularMapAlpha: boolean;
|
|
|
|
-
|
|
|
|
|
|
+ public useGlossinessFromSpecularMapAlpha: boolean;
|
|
|
|
+
|
|
@serialize("maxSimultaneousLights")
|
|
@serialize("maxSimultaneousLights")
|
|
private _maxSimultaneousLights = 4;
|
|
private _maxSimultaneousLights = 4;
|
|
@expandToProperty("_markAllSubMeshesAsLightsDirty")
|
|
@expandToProperty("_markAllSubMeshesAsLightsDirty")
|
|
- public maxSimultaneousLights: number;
|
|
|
|
|
|
+ public maxSimultaneousLights: number;
|
|
|
|
|
|
/**
|
|
/**
|
|
* If sets to true, x component of normal map value will invert (x = 1.0 - x).
|
|
* If sets to true, x component of normal map value will invert (x = 1.0 - x).
|
|
@@ -281,7 +281,7 @@ module BABYLON {
|
|
@serialize("twoSidedLighting")
|
|
@serialize("twoSidedLighting")
|
|
private _twoSidedLighting = false;
|
|
private _twoSidedLighting = false;
|
|
@expandToProperty("_markAllSubMeshesAsTexturesDirty")
|
|
@expandToProperty("_markAllSubMeshesAsTexturesDirty")
|
|
- public twoSidedLighting: boolean;
|
|
|
|
|
|
+ public twoSidedLighting: boolean;
|
|
|
|
|
|
/**
|
|
/**
|
|
* Default configuration related to image processing available in the standard Material.
|
|
* Default configuration related to image processing available in the standard Material.
|
|
@@ -395,7 +395,7 @@ module BABYLON {
|
|
public set cameraExposure(value: number) {
|
|
public set cameraExposure(value: number) {
|
|
this._imageProcessingConfiguration.exposure = value;
|
|
this._imageProcessingConfiguration.exposure = value;
|
|
};
|
|
};
|
|
-
|
|
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* Gets The camera contrast used on this material.
|
|
* Gets The camera contrast used on this material.
|
|
*/
|
|
*/
|
|
@@ -409,7 +409,7 @@ module BABYLON {
|
|
public set cameraContrast(value: number) {
|
|
public set cameraContrast(value: number) {
|
|
this._imageProcessingConfiguration.contrast = value;
|
|
this._imageProcessingConfiguration.contrast = value;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* Gets the Color Grading 2D Lookup Texture.
|
|
* Gets the Color Grading 2D Lookup Texture.
|
|
*/
|
|
*/
|
|
@@ -454,7 +454,7 @@ module BABYLON {
|
|
|
|
|
|
public getClassName(): string {
|
|
public getClassName(): string {
|
|
return "StandardMaterial_OldVer";
|
|
return "StandardMaterial_OldVer";
|
|
- }
|
|
|
|
|
|
+ }
|
|
|
|
|
|
@serialize()
|
|
@serialize()
|
|
public get useLogarithmicDepth(): boolean {
|
|
public get useLogarithmicDepth(): boolean {
|
|
@@ -486,7 +486,7 @@ module BABYLON {
|
|
/**
|
|
/**
|
|
* Child classes can use it to update shaders
|
|
* Child classes can use it to update shaders
|
|
*/
|
|
*/
|
|
- public isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean {
|
|
|
|
|
|
+ public isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean {
|
|
if (this.isFrozen) {
|
|
if (this.isFrozen) {
|
|
if (this._wasPreviouslyReady && subMesh.effect) {
|
|
if (this._wasPreviouslyReady && subMesh.effect) {
|
|
return true;
|
|
return true;
|
|
@@ -674,7 +674,7 @@ module BABYLON {
|
|
|
|
|
|
defines.EMISSIVEASILLUMINATION = this._useEmissiveAsIllumination;
|
|
defines.EMISSIVEASILLUMINATION = this._useEmissiveAsIllumination;
|
|
|
|
|
|
- defines.LINKEMISSIVEWITHDIFFUSE = this._linkEmissiveWithDiffuse;
|
|
|
|
|
|
+ defines.LINKEMISSIVEWITHDIFFUSE = this._linkEmissiveWithDiffuse;
|
|
|
|
|
|
defines.SPECULAROVERALPHA = this._useSpecularOverAlpha;
|
|
defines.SPECULAROVERALPHA = this._useSpecularOverAlpha;
|
|
}
|
|
}
|
|
@@ -702,9 +702,9 @@ module BABYLON {
|
|
|
|
|
|
defines.REFLECTIONFRESNELFROMSPECULAR = this._useReflectionFresnelFromSpecular;
|
|
defines.REFLECTIONFRESNELFROMSPECULAR = this._useReflectionFresnelFromSpecular;
|
|
|
|
|
|
- defines.REFRACTIONFRESNEL = (this._refractionFresnelParameters && this._refractionFresnelParameters.isEnabled) ;
|
|
|
|
|
|
+ defines.REFRACTIONFRESNEL = (this._refractionFresnelParameters && this._refractionFresnelParameters.isEnabled);
|
|
|
|
|
|
- defines.EMISSIVEFRESNEL = (this._emissiveFresnelParameters && this._emissiveFresnelParameters.isEnabled) ;
|
|
|
|
|
|
+ defines.EMISSIVEFRESNEL = (this._emissiveFresnelParameters && this._emissiveFresnelParameters.isEnabled);
|
|
|
|
|
|
defines._needNormals = true;
|
|
defines._needNormals = true;
|
|
defines.FRESNEL = true;
|
|
defines.FRESNEL = true;
|
|
@@ -814,9 +814,9 @@ module BABYLON {
|
|
MaterialHelper.PrepareAttributesForBones(attribs, mesh, defines, fallbacks);
|
|
MaterialHelper.PrepareAttributesForBones(attribs, mesh, defines, fallbacks);
|
|
MaterialHelper.PrepareAttributesForInstances(attribs, defines);
|
|
MaterialHelper.PrepareAttributesForInstances(attribs, defines);
|
|
MaterialHelper.PrepareAttributesForMorphTargets(attribs, mesh, defines);
|
|
MaterialHelper.PrepareAttributesForMorphTargets(attribs, mesh, defines);
|
|
-
|
|
|
|
|
|
+
|
|
var shaderName = "default";
|
|
var shaderName = "default";
|
|
-
|
|
|
|
|
|
+
|
|
var uniforms = ["world", "view", "viewProjection", "vEyePosition", "vLightsType", "vAmbientColor", "vDiffuseColor", "vSpecularColor", "vEmissiveColor",
|
|
var uniforms = ["world", "view", "viewProjection", "vEyePosition", "vLightsType", "vAmbientColor", "vDiffuseColor", "vSpecularColor", "vEmissiveColor",
|
|
"vFogInfos", "vFogColor", "pointSize",
|
|
"vFogInfos", "vFogColor", "pointSize",
|
|
"vDiffuseInfos", "vAmbientInfos", "vOpacityInfos", "vReflectionInfos", "vEmissiveInfos", "vSpecularInfos", "vBumpInfos", "vLightmapInfos", "vRefractionInfos",
|
|
"vDiffuseInfos", "vAmbientInfos", "vOpacityInfos", "vReflectionInfos", "vEmissiveInfos", "vSpecularInfos", "vBumpInfos", "vLightmapInfos", "vRefractionInfos",
|
|
@@ -834,10 +834,10 @@ module BABYLON {
|
|
ImageProcessingConfiguration.PrepareSamplers(samplers, defines);
|
|
ImageProcessingConfiguration.PrepareSamplers(samplers, defines);
|
|
|
|
|
|
MaterialHelper.PrepareUniformsAndSamplersList(<EffectCreationOptions>{
|
|
MaterialHelper.PrepareUniformsAndSamplersList(<EffectCreationOptions>{
|
|
- uniformsNames: uniforms,
|
|
|
|
|
|
+ uniformsNames: uniforms,
|
|
uniformBuffersNames: uniformBuffers,
|
|
uniformBuffersNames: uniformBuffers,
|
|
- samplers: samplers,
|
|
|
|
- defines: defines,
|
|
|
|
|
|
+ samplers: samplers,
|
|
|
|
+ defines: defines,
|
|
maxSimultaneousLights: this._maxSimultaneousLights
|
|
maxSimultaneousLights: this._maxSimultaneousLights
|
|
});
|
|
});
|
|
|
|
|
|
@@ -857,7 +857,7 @@ module BABYLON {
|
|
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);
|
|
-
|
|
|
|
|
|
+
|
|
this.buildUniformLayout();
|
|
this.buildUniformLayout();
|
|
}
|
|
}
|
|
|
|
|
|
@@ -946,7 +946,7 @@ module BABYLON {
|
|
MaterialHelper.BindBonesParameters(mesh, effect);
|
|
MaterialHelper.BindBonesParameters(mesh, effect);
|
|
if (this._mustRebind(scene, effect, mesh.visibility)) {
|
|
if (this._mustRebind(scene, effect, mesh.visibility)) {
|
|
this._uniformBuffer.bindToEffect(effect, "Material");
|
|
this._uniformBuffer.bindToEffect(effect, "Material");
|
|
-
|
|
|
|
|
|
+
|
|
this.bindViewProjection(effect);
|
|
this.bindViewProjection(effect);
|
|
if (!this._uniformBuffer.useUbo || !this.isFrozen || !this._uniformBuffer.isSync) {
|
|
if (!this._uniformBuffer.useUbo || !this.isFrozen || !this._uniformBuffer.isSync) {
|
|
|
|
|
|
@@ -1035,7 +1035,7 @@ module BABYLON {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
this._uniformBuffer.updateFloat4("vRefractionInfos", this._refractionTexture.level, this.indexOfRefraction, depth, this.invertRefractionY ? -1 : 1);
|
|
this._uniformBuffer.updateFloat4("vRefractionInfos", this._refractionTexture.level, this.indexOfRefraction, depth, this.invertRefractionY ? -1 : 1);
|
|
- }
|
|
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
// Point size
|
|
// Point size
|
|
@@ -1051,7 +1051,7 @@ module BABYLON {
|
|
// Diffuse
|
|
// Diffuse
|
|
this._uniformBuffer.updateColor4("vDiffuseColor", this.diffuseColor, this.alpha * mesh.visibility);
|
|
this._uniformBuffer.updateColor4("vDiffuseColor", this.diffuseColor, this.alpha * mesh.visibility);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
// Textures
|
|
// Textures
|
|
if (scene.texturesEnabled) {
|
|
if (scene.texturesEnabled) {
|
|
if (this._diffuseTexture && StandardMaterial_OldVer.DiffuseTextureEnabled) {
|
|
if (this._diffuseTexture && StandardMaterial_OldVer.DiffuseTextureEnabled) {
|
|
@@ -1120,7 +1120,7 @@ module BABYLON {
|
|
if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== Scene.FOGMODE_NONE || this._reflectionTexture || this._refractionTexture) {
|
|
if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== Scene.FOGMODE_NONE || this._reflectionTexture || this._refractionTexture) {
|
|
this.bindView(effect);
|
|
this.bindView(effect);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
// Fog
|
|
// Fog
|
|
MaterialHelper.BindFogParameters(scene, mesh, effect);
|
|
MaterialHelper.BindFogParameters(scene, mesh, effect);
|
|
|
|
|
|
@@ -1340,8 +1340,8 @@ module BABYLON {
|
|
|
|
|
|
StandardMaterial_OldVer._ReflectionTextureEnabled = value;
|
|
StandardMaterial_OldVer._ReflectionTextureEnabled = value;
|
|
Engine.MarkAllMaterialsAsDirty(Material.TextureDirtyFlag);
|
|
Engine.MarkAllMaterialsAsDirty(Material.TextureDirtyFlag);
|
|
- }
|
|
|
|
-
|
|
|
|
|
|
+ }
|
|
|
|
+
|
|
static _EmissiveTextureEnabled = true;
|
|
static _EmissiveTextureEnabled = true;
|
|
public static get EmissiveTextureEnabled(): boolean {
|
|
public static get EmissiveTextureEnabled(): boolean {
|
|
return StandardMaterial_OldVer._EmissiveTextureEnabled;
|
|
return StandardMaterial_OldVer._EmissiveTextureEnabled;
|
|
@@ -1353,7 +1353,7 @@ module BABYLON {
|
|
|
|
|
|
StandardMaterial_OldVer._EmissiveTextureEnabled = value;
|
|
StandardMaterial_OldVer._EmissiveTextureEnabled = value;
|
|
Engine.MarkAllMaterialsAsDirty(Material.TextureDirtyFlag);
|
|
Engine.MarkAllMaterialsAsDirty(Material.TextureDirtyFlag);
|
|
- }
|
|
|
|
|
|
+ }
|
|
|
|
|
|
static _SpecularTextureEnabled = true;
|
|
static _SpecularTextureEnabled = true;
|
|
public static get SpecularTextureEnabled(): boolean {
|
|
public static get SpecularTextureEnabled(): boolean {
|
|
@@ -1366,7 +1366,7 @@ module BABYLON {
|
|
|
|
|
|
StandardMaterial_OldVer._SpecularTextureEnabled = value;
|
|
StandardMaterial_OldVer._SpecularTextureEnabled = value;
|
|
Engine.MarkAllMaterialsAsDirty(Material.TextureDirtyFlag);
|
|
Engine.MarkAllMaterialsAsDirty(Material.TextureDirtyFlag);
|
|
- }
|
|
|
|
|
|
+ }
|
|
|
|
|
|
static _BumpTextureEnabled = true;
|
|
static _BumpTextureEnabled = true;
|
|
public static get BumpTextureEnabled(): boolean {
|
|
public static get BumpTextureEnabled(): boolean {
|
|
@@ -1379,7 +1379,7 @@ module BABYLON {
|
|
|
|
|
|
StandardMaterial_OldVer._BumpTextureEnabled = value;
|
|
StandardMaterial_OldVer._BumpTextureEnabled = value;
|
|
Engine.MarkAllMaterialsAsDirty(Material.TextureDirtyFlag);
|
|
Engine.MarkAllMaterialsAsDirty(Material.TextureDirtyFlag);
|
|
- }
|
|
|
|
|
|
+ }
|
|
|
|
|
|
static _LightmapTextureEnabled = true;
|
|
static _LightmapTextureEnabled = true;
|
|
public static get LightmapTextureEnabled(): boolean {
|
|
public static get LightmapTextureEnabled(): boolean {
|
|
@@ -1392,9 +1392,9 @@ module BABYLON {
|
|
|
|
|
|
StandardMaterial_OldVer._LightmapTextureEnabled = value;
|
|
StandardMaterial_OldVer._LightmapTextureEnabled = value;
|
|
Engine.MarkAllMaterialsAsDirty(Material.TextureDirtyFlag);
|
|
Engine.MarkAllMaterialsAsDirty(Material.TextureDirtyFlag);
|
|
- }
|
|
|
|
|
|
+ }
|
|
|
|
|
|
- static _RefractionTextureEnabled = true;
|
|
|
|
|
|
+ static _RefractionTextureEnabled = true;
|
|
public static get RefractionTextureEnabled(): boolean {
|
|
public static get RefractionTextureEnabled(): boolean {
|
|
return StandardMaterial_OldVer._RefractionTextureEnabled;
|
|
return StandardMaterial_OldVer._RefractionTextureEnabled;
|
|
}
|
|
}
|
|
@@ -1405,7 +1405,7 @@ module BABYLON {
|
|
|
|
|
|
StandardMaterial_OldVer._RefractionTextureEnabled = value;
|
|
StandardMaterial_OldVer._RefractionTextureEnabled = value;
|
|
Engine.MarkAllMaterialsAsDirty(Material.TextureDirtyFlag);
|
|
Engine.MarkAllMaterialsAsDirty(Material.TextureDirtyFlag);
|
|
- }
|
|
|
|
|
|
+ }
|
|
|
|
|
|
static _ColorGradingTextureEnabled = true;
|
|
static _ColorGradingTextureEnabled = true;
|
|
public static get ColorGradingTextureEnabled(): boolean {
|
|
public static get ColorGradingTextureEnabled(): boolean {
|
|
@@ -1418,7 +1418,7 @@ module BABYLON {
|
|
|
|
|
|
StandardMaterial_OldVer._ColorGradingTextureEnabled = value;
|
|
StandardMaterial_OldVer._ColorGradingTextureEnabled = value;
|
|
Engine.MarkAllMaterialsAsDirty(Material.TextureDirtyFlag);
|
|
Engine.MarkAllMaterialsAsDirty(Material.TextureDirtyFlag);
|
|
- }
|
|
|
|
|
|
+ }
|
|
|
|
|
|
static _FresnelEnabled = true;
|
|
static _FresnelEnabled = true;
|
|
public static get FresnelEnabled(): boolean {
|
|
public static get FresnelEnabled(): boolean {
|
|
@@ -1431,54 +1431,54 @@ module BABYLON {
|
|
|
|
|
|
StandardMaterial_OldVer._FresnelEnabled = value;
|
|
StandardMaterial_OldVer._FresnelEnabled = value;
|
|
Engine.MarkAllMaterialsAsDirty(Material.FresnelDirtyFlag);
|
|
Engine.MarkAllMaterialsAsDirty(Material.FresnelDirtyFlag);
|
|
- }
|
|
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
- export class CustomShaderStructure {
|
|
|
|
-
|
|
|
|
- public FragmentStore : string;
|
|
|
|
- public VertexStore : string;
|
|
|
|
|
|
|
|
- constructor(){
|
|
|
|
|
|
+ export class CustomShaderStructure {
|
|
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ public FragmentStore: string;
|
|
|
|
+ public VertexStore: string;
|
|
|
|
|
|
- export class ShaderSpecialParts{
|
|
|
|
-
|
|
|
|
- constructor(){}
|
|
|
|
|
|
+ constructor() {
|
|
|
|
|
|
- public Fragment_Begin:string;
|
|
|
|
- public Fragment_Definitions:string;
|
|
|
|
- public Fragment_MainBegin: string;
|
|
|
|
-
|
|
|
|
- // diffuseColor
|
|
|
|
- public Fragment_Custom_Diffuse: string;
|
|
|
|
-
|
|
|
|
- // alpha
|
|
|
|
- public Fragment_Custom_Alpha : string;
|
|
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
- public Fragment_Before_FragColor: string;
|
|
|
|
|
|
+ export class ShaderSpecialParts {
|
|
|
|
|
|
- public Vertex_Begin:string;
|
|
|
|
- public Vertex_Definitions:string;
|
|
|
|
- public Vertex_MainBegin: string;
|
|
|
|
-
|
|
|
|
- // positionUpdated
|
|
|
|
- public Vertex_Before_PositionUpdated:string;
|
|
|
|
|
|
+ constructor() { }
|
|
|
|
|
|
- // normalUpdated
|
|
|
|
- public Vertex_Before_NormalUpdated : string;
|
|
|
|
- }
|
|
|
|
|
|
+ public Fragment_Begin: string;
|
|
|
|
+ public Fragment_Definitions: string;
|
|
|
|
+ public Fragment_MainBegin: string;
|
|
|
|
|
|
- export class ShaderForVer3_0 extends CustomShaderStructure {
|
|
|
|
|
|
+ // diffuseColor
|
|
|
|
+ public Fragment_Custom_Diffuse: string;
|
|
|
|
|
|
- constructor() {
|
|
|
|
|
|
+ // alpha
|
|
|
|
+ public Fragment_Custom_Alpha: string;
|
|
|
|
+
|
|
|
|
+ public Fragment_Before_FragColor: string;
|
|
|
|
+
|
|
|
|
+ public Vertex_Begin: string;
|
|
|
|
+ public Vertex_Definitions: string;
|
|
|
|
+ public Vertex_MainBegin: string;
|
|
|
|
+
|
|
|
|
+ // positionUpdated
|
|
|
|
+ public Vertex_Before_PositionUpdated: string;
|
|
|
|
+
|
|
|
|
+ // normalUpdated
|
|
|
|
+ public Vertex_Before_NormalUpdated: string;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ export class ShaderForVer3_0 extends CustomShaderStructure {
|
|
|
|
+
|
|
|
|
+ constructor() {
|
|
super();
|
|
super();
|
|
-
|
|
|
|
|
|
+
|
|
this.VertexStore = "";
|
|
this.VertexStore = "";
|
|
-
|
|
|
|
|
|
+
|
|
this.FragmentStore = "#include<__decl__defaultFragment>\n\
|
|
this.FragmentStore = "#include<__decl__defaultFragment>\n\
|
|
#[Fragment_Begin]\n\
|
|
#[Fragment_Begin]\n\
|
|
#extension GL_OES_standard_derivatives : enable\n\
|
|
#extension GL_OES_standard_derivatives : enable\n\
|
|
@@ -1780,7 +1780,7 @@ gl_FragColor=color;\n\
|
|
}";
|
|
}";
|
|
|
|
|
|
|
|
|
|
-this.VertexStore = "#include<__decl__defaultVertex>\n\
|
|
|
|
|
|
+ this.VertexStore = "#include<__decl__defaultVertex>\n\
|
|
\n\
|
|
\n\
|
|
#[Vertex_Begin]\n\
|
|
#[Vertex_Begin]\n\
|
|
\n\
|
|
\n\
|
|
@@ -1974,188 +1974,185 @@ vColor=color;\n\
|
|
}";
|
|
}";
|
|
|
|
|
|
|
|
|
|
- }
|
|
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
-
|
|
|
|
- export class StandardShaderVersions{
|
|
|
|
|
|
+ export class StandardShaderVersions {
|
|
|
|
|
|
public static Ver3_0 = "3.0.0";
|
|
public static Ver3_0 = "3.0.0";
|
|
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- export class CustomMaterial extends StandardMaterial_OldVer {
|
|
|
|
- public static ShaderIndexer = 1;
|
|
|
|
- public CustomParts : ShaderSpecialParts;
|
|
|
|
- public ShaderVersion : CustomShaderStructure ;
|
|
|
|
- _isCreatedShader : boolean;
|
|
|
|
- _createdShaderName : string;
|
|
|
|
- _customUniform : string[];
|
|
|
|
- _newUniforms : string[];
|
|
|
|
- _newUniformInstances : any[];
|
|
|
|
- _newSamplerInstances : Texture[];
|
|
|
|
-
|
|
|
|
- public AttachAfterBind(mesh:Mesh,effect:Effect){
|
|
|
|
- for(var el in this._newUniformInstances){
|
|
|
|
- var ea = el.toString().split('-');
|
|
|
|
- if(ea[0] == 'vec2') effect.setVector2(ea[1],this._newUniformInstances[el]);
|
|
|
|
- else if(ea[0] == 'vec3') effect.setVector3(ea[1],this._newUniformInstances[el]);
|
|
|
|
- else if(ea[0] == 'vec4') effect.setVector4(ea[1],this._newUniformInstances[el]);
|
|
|
|
- else if(ea[0] == 'mat4') effect.setMatrix(ea[1],this._newUniformInstances[el]);
|
|
|
|
- else if(ea[0] == 'float') effect.setFloat(ea[1],this._newUniformInstances[el]);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- for(var el in this._newSamplerInstances){
|
|
|
|
- var ea = el.toString().split('-');
|
|
|
|
- if(ea[0] == 'sampler2D' && this._newSamplerInstances[el].isReady && this._newSamplerInstances[el].isReady())
|
|
|
|
- effect.setTexture(ea[1],this._newSamplerInstances[el]);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public ReviewUniform(name:string, arr : string[] ) : string[]{
|
|
|
|
- if(name == "uniform")
|
|
|
|
- {
|
|
|
|
- for(var ind in this._newUniforms)
|
|
|
|
- if(this._customUniform[ind].indexOf('sampler')== -1)
|
|
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ export class CustomMaterial extends StandardMaterial_OldVer {
|
|
|
|
+ public static ShaderIndexer = 1;
|
|
|
|
+ public CustomParts: ShaderSpecialParts;
|
|
|
|
+ public ShaderVersion: CustomShaderStructure;
|
|
|
|
+ _isCreatedShader: boolean;
|
|
|
|
+ _createdShaderName: string;
|
|
|
|
+ _customUniform: string[];
|
|
|
|
+ _newUniforms: string[];
|
|
|
|
+ _newUniformInstances: any[];
|
|
|
|
+ _newSamplerInstances: Texture[];
|
|
|
|
+
|
|
|
|
+ public AttachAfterBind(mesh: Mesh, effect: Effect) {
|
|
|
|
+ for (var el in this._newUniformInstances) {
|
|
|
|
+ var ea = el.toString().split('-');
|
|
|
|
+ if (ea[0] == 'vec2') effect.setVector2(ea[1], this._newUniformInstances[el]);
|
|
|
|
+ else if (ea[0] == 'vec3') effect.setVector3(ea[1], this._newUniformInstances[el]);
|
|
|
|
+ else if (ea[0] == 'vec4') effect.setVector4(ea[1], this._newUniformInstances[el]);
|
|
|
|
+ else if (ea[0] == 'mat4') effect.setMatrix(ea[1], this._newUniformInstances[el]);
|
|
|
|
+ else if (ea[0] == 'float') effect.setFloat(ea[1], this._newUniformInstances[el]);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ for (var el in this._newSamplerInstances) {
|
|
|
|
+ var ea = el.toString().split('-');
|
|
|
|
+ if (ea[0] == 'sampler2D' && this._newSamplerInstances[el].isReady && this._newSamplerInstances[el].isReady())
|
|
|
|
+ effect.setTexture(ea[1], this._newSamplerInstances[el]);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public ReviewUniform(name: string, arr: string[]): string[] {
|
|
|
|
+ if (name == "uniform") {
|
|
|
|
+ for (var ind in this._newUniforms)
|
|
|
|
+ if (this._customUniform[ind].indexOf('sampler') == -1)
|
|
arr.push(this._newUniforms[ind]);
|
|
arr.push(this._newUniforms[ind]);
|
|
- }
|
|
|
|
|
|
+ }
|
|
|
|
|
|
- if(name == "sampler")
|
|
|
|
- {
|
|
|
|
- for(var ind in this._newUniforms)
|
|
|
|
- if(this._customUniform[ind].indexOf('sampler')!= -1)
|
|
|
|
|
|
+ if (name == "sampler") {
|
|
|
|
+ for (var ind in this._newUniforms)
|
|
|
|
+ if (this._customUniform[ind].indexOf('sampler') != -1)
|
|
arr.push(this._newUniforms[ind]);
|
|
arr.push(this._newUniforms[ind]);
|
|
- }
|
|
|
|
-
|
|
|
|
- return arr;
|
|
|
|
- }
|
|
|
|
- public Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines_OldVer) : string {
|
|
|
|
-
|
|
|
|
- if(this._isCreatedShader) return this._createdShaderName;
|
|
|
|
- this._isCreatedShader = false;
|
|
|
|
-
|
|
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return arr;
|
|
|
|
+ }
|
|
|
|
+ public Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines_OldVer): string {
|
|
|
|
+
|
|
|
|
+ if (this._isCreatedShader) return this._createdShaderName;
|
|
|
|
+ this._isCreatedShader = false;
|
|
|
|
+
|
|
CustomMaterial.ShaderIndexer++;
|
|
CustomMaterial.ShaderIndexer++;
|
|
var name: string = "custom_" + CustomMaterial.ShaderIndexer;
|
|
var name: string = "custom_" + CustomMaterial.ShaderIndexer;
|
|
|
|
|
|
- this.ReviewUniform("uniform",uniforms);
|
|
|
|
- this.ReviewUniform("sampler",samplers);
|
|
|
|
-
|
|
|
|
|
|
+ this.ReviewUniform("uniform", uniforms);
|
|
|
|
+ this.ReviewUniform("sampler", samplers);
|
|
|
|
|
|
- var fn_afterBind = this._afterBind;
|
|
|
|
- this._afterBind = (m,e) => {
|
|
|
|
|
|
+
|
|
|
|
+ var fn_afterBind = this._afterBind.bind(this);
|
|
|
|
+ this._afterBind = (m, e) => {
|
|
if (!e) {
|
|
if (!e) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
this.AttachAfterBind(m, e);
|
|
this.AttachAfterBind(m, e);
|
|
- try{fn_afterBind(m,e);}catch(e){};
|
|
|
|
- } ;
|
|
|
|
-
|
|
|
|
- BABYLON.Effect.ShadersStore[name+"VertexShader"] = this.ShaderVersion.VertexStore
|
|
|
|
- .replace('#[Vertex_Begin]',(this.CustomParts.Vertex_Begin ? this.CustomParts.Vertex_Begin : ""))
|
|
|
|
- .replace('#[Vertex_Definitions]',(this._customUniform? this._customUniform.join("\n"):"")+ (this.CustomParts.Vertex_Definitions ? this.CustomParts.Vertex_Definitions : ""))
|
|
|
|
- .replace('#[Vertex_MainBegin]',(this.CustomParts.Vertex_MainBegin ? this.CustomParts.Vertex_MainBegin : ""))
|
|
|
|
- .replace('#[Vertex_Before_PositionUpdated]',(this.CustomParts.Vertex_Before_PositionUpdated ? this.CustomParts.Vertex_Before_PositionUpdated : ""))
|
|
|
|
- .replace('#[Vertex_Before_NormalUpdated]',(this.CustomParts.Vertex_Before_NormalUpdated ? this.CustomParts.Vertex_Before_NormalUpdated : "")) ;
|
|
|
|
-
|
|
|
|
- BABYLON.Effect.ShadersStore[name+"PixelShader"] = this.ShaderVersion.FragmentStore
|
|
|
|
- .replace('#[Fragment_Begin]',(this.CustomParts.Fragment_Begin ? this.CustomParts.Fragment_Begin : ""))
|
|
|
|
- .replace('#[Fragment_MainBegin]',(this.CustomParts.Fragment_MainBegin ? this.CustomParts.Fragment_MainBegin : ""))
|
|
|
|
- .replace('#[Fragment_Definitions]',(this._customUniform? this._customUniform.join("\n"):"")+(this.CustomParts.Fragment_Definitions ? this.CustomParts.Fragment_Definitions : ""))
|
|
|
|
- .replace('#[Fragment_Custom_Diffuse]',(this.CustomParts.Fragment_Custom_Diffuse ? this.CustomParts.Fragment_Custom_Diffuse : ""))
|
|
|
|
- .replace('#[Fragment_Custom_Alpha]',(this.CustomParts.Fragment_Custom_Alpha ? this.CustomParts.Fragment_Custom_Alpha : ""))
|
|
|
|
- .replace('#[Fragment_Before_FragColor]',(this.CustomParts.Fragment_Before_FragColor ? this.CustomParts.Fragment_Before_FragColor : "")) ;
|
|
|
|
-
|
|
|
|
- this._isCreatedShader = true;
|
|
|
|
- this._createdShaderName = name;
|
|
|
|
-
|
|
|
|
- return name ;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- public SelectVersion(ver:string){
|
|
|
|
- switch(ver){
|
|
|
|
- case "3.0.0" : this.ShaderVersion = new ShaderForVer3_0();break;
|
|
|
|
|
|
+ try { fn_afterBind(m, e); } catch (e) { };
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ BABYLON.Effect.ShadersStore[name + "VertexShader"] = this.ShaderVersion.VertexStore
|
|
|
|
+ .replace('#[Vertex_Begin]', (this.CustomParts.Vertex_Begin ? this.CustomParts.Vertex_Begin : ""))
|
|
|
|
+ .replace('#[Vertex_Definitions]', (this._customUniform ? this._customUniform.join("\n") : "") + (this.CustomParts.Vertex_Definitions ? this.CustomParts.Vertex_Definitions : ""))
|
|
|
|
+ .replace('#[Vertex_MainBegin]', (this.CustomParts.Vertex_MainBegin ? this.CustomParts.Vertex_MainBegin : ""))
|
|
|
|
+ .replace('#[Vertex_Before_PositionUpdated]', (this.CustomParts.Vertex_Before_PositionUpdated ? this.CustomParts.Vertex_Before_PositionUpdated : ""))
|
|
|
|
+ .replace('#[Vertex_Before_NormalUpdated]', (this.CustomParts.Vertex_Before_NormalUpdated ? this.CustomParts.Vertex_Before_NormalUpdated : ""));
|
|
|
|
+
|
|
|
|
+ BABYLON.Effect.ShadersStore[name + "PixelShader"] = this.ShaderVersion.FragmentStore
|
|
|
|
+ .replace('#[Fragment_Begin]', (this.CustomParts.Fragment_Begin ? this.CustomParts.Fragment_Begin : ""))
|
|
|
|
+ .replace('#[Fragment_MainBegin]', (this.CustomParts.Fragment_MainBegin ? this.CustomParts.Fragment_MainBegin : ""))
|
|
|
|
+ .replace('#[Fragment_Definitions]', (this._customUniform ? this._customUniform.join("\n") : "") + (this.CustomParts.Fragment_Definitions ? this.CustomParts.Fragment_Definitions : ""))
|
|
|
|
+ .replace('#[Fragment_Custom_Diffuse]', (this.CustomParts.Fragment_Custom_Diffuse ? this.CustomParts.Fragment_Custom_Diffuse : ""))
|
|
|
|
+ .replace('#[Fragment_Custom_Alpha]', (this.CustomParts.Fragment_Custom_Alpha ? this.CustomParts.Fragment_Custom_Alpha : ""))
|
|
|
|
+ .replace('#[Fragment_Before_FragColor]', (this.CustomParts.Fragment_Before_FragColor ? this.CustomParts.Fragment_Before_FragColor : ""));
|
|
|
|
+
|
|
|
|
+ this._isCreatedShader = true;
|
|
|
|
+ this._createdShaderName = name;
|
|
|
|
+
|
|
|
|
+ return name;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ public SelectVersion(ver: string) {
|
|
|
|
+ switch (ver) {
|
|
|
|
+ case "3.0.0": this.ShaderVersion = new ShaderForVer3_0(); break;
|
|
}
|
|
}
|
|
- }
|
|
|
|
-
|
|
|
|
- constructor(name:string,scene:Scene ){
|
|
|
|
- super(name,scene);
|
|
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ constructor(name: string, scene: Scene) {
|
|
|
|
+ super(name, scene);
|
|
this.CustomParts = new ShaderSpecialParts();
|
|
this.CustomParts = new ShaderSpecialParts();
|
|
- this.customShaderNameResolve = this.Builder;
|
|
|
|
- this.SelectVersion("3.0.0");
|
|
|
|
- }
|
|
|
|
- public AddUniform(name:string,kind:string,param:any):CustomMaterial{
|
|
|
|
- if(!this._customUniform)
|
|
|
|
- {
|
|
|
|
- this._customUniform = new Array();
|
|
|
|
- this._newUniforms = new Array();
|
|
|
|
- this._newSamplerInstances = new Array();
|
|
|
|
- this._newUniformInstances = new Array();
|
|
|
|
- }
|
|
|
|
- if(param){
|
|
|
|
- if(kind.indexOf("sampler") == -1) {
|
|
|
|
- (<any>this._newUniformInstances)[kind+"-"+name] = param;
|
|
|
|
- }
|
|
|
|
- else{
|
|
|
|
- (<any>this._newUniformInstances)[kind+"-"+name] = param;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- this._customUniform.push("uniform "+kind+" "+name+";");
|
|
|
|
|
|
+ this.customShaderNameResolve = this.Builder;
|
|
|
|
+ this.SelectVersion("3.0.0");
|
|
|
|
+ }
|
|
|
|
+ public AddUniform(name: string, kind: string, param: any): CustomMaterial {
|
|
|
|
+ if (!this._customUniform) {
|
|
|
|
+ this._customUniform = new Array();
|
|
|
|
+ this._newUniforms = new Array();
|
|
|
|
+ this._newSamplerInstances = new Array();
|
|
|
|
+ this._newUniformInstances = new Array();
|
|
|
|
+ }
|
|
|
|
+ if (param) {
|
|
|
|
+ if (kind.indexOf("sampler") == -1) {
|
|
|
|
+ (<any>this._newUniformInstances)[kind + "-" + name] = param;
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ (<any>this._newUniformInstances)[kind + "-" + name] = param;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ this._customUniform.push("uniform " + kind + " " + name + ";");
|
|
this._newUniforms.push(name);
|
|
this._newUniforms.push(name);
|
|
-
|
|
|
|
|
|
+
|
|
return this;
|
|
return this;
|
|
- }
|
|
|
|
- public Fragment_Begin(shaderPart:string):CustomMaterial{
|
|
|
|
|
|
+ }
|
|
|
|
+ public Fragment_Begin(shaderPart: string): CustomMaterial {
|
|
this.CustomParts.Fragment_Begin = shaderPart;
|
|
this.CustomParts.Fragment_Begin = shaderPart;
|
|
return this;
|
|
return this;
|
|
- }
|
|
|
|
|
|
+ }
|
|
|
|
|
|
- public Fragment_Definitions(shaderPart:string):CustomMaterial{
|
|
|
|
|
|
+ public Fragment_Definitions(shaderPart: string): CustomMaterial {
|
|
this.CustomParts.Fragment_Definitions = shaderPart;
|
|
this.CustomParts.Fragment_Definitions = shaderPart;
|
|
return this;
|
|
return this;
|
|
- }
|
|
|
|
|
|
+ }
|
|
|
|
|
|
- public Fragment_MainBegin(shaderPart:string):CustomMaterial{
|
|
|
|
|
|
+ public Fragment_MainBegin(shaderPart: string): CustomMaterial {
|
|
this.CustomParts.Fragment_MainBegin = shaderPart;
|
|
this.CustomParts.Fragment_MainBegin = shaderPart;
|
|
return this;
|
|
return this;
|
|
- }
|
|
|
|
- public Fragment_Custom_Diffuse(shaderPart:string):CustomMaterial{
|
|
|
|
- this.CustomParts.Fragment_Custom_Diffuse = shaderPart.replace("result","diffuseColor");
|
|
|
|
|
|
+ }
|
|
|
|
+ public Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial {
|
|
|
|
+ this.CustomParts.Fragment_Custom_Diffuse = shaderPart.replace("result", "diffuseColor");
|
|
return this;
|
|
return this;
|
|
- }
|
|
|
|
- public Fragment_Custom_Alpha(shaderPart:string):CustomMaterial{
|
|
|
|
- this.CustomParts.Fragment_Custom_Alpha = shaderPart.replace("result","alpha");
|
|
|
|
|
|
+ }
|
|
|
|
+ public Fragment_Custom_Alpha(shaderPart: string): CustomMaterial {
|
|
|
|
+ this.CustomParts.Fragment_Custom_Alpha = shaderPart.replace("result", "alpha");
|
|
return this;
|
|
return this;
|
|
- }
|
|
|
|
- public Fragment_Before_FragColor(shaderPart:string):CustomMaterial{
|
|
|
|
- this.CustomParts.Fragment_Before_FragColor = shaderPart.replace("result","color");
|
|
|
|
|
|
+ }
|
|
|
|
+ public Fragment_Before_FragColor(shaderPart: string): CustomMaterial {
|
|
|
|
+ this.CustomParts.Fragment_Before_FragColor = shaderPart.replace("result", "color");
|
|
return this;
|
|
return this;
|
|
- }
|
|
|
|
- public Vertex_Begin(shaderPart:string):CustomMaterial{
|
|
|
|
|
|
+ }
|
|
|
|
+ public Vertex_Begin(shaderPart: string): CustomMaterial {
|
|
this.CustomParts.Vertex_Begin = shaderPart;
|
|
this.CustomParts.Vertex_Begin = shaderPart;
|
|
return this;
|
|
return this;
|
|
- }
|
|
|
|
- public Vertex_Definitions(shaderPart:string):CustomMaterial{
|
|
|
|
|
|
+ }
|
|
|
|
+ public Vertex_Definitions(shaderPart: string): CustomMaterial {
|
|
this.CustomParts.Vertex_Definitions = shaderPart;
|
|
this.CustomParts.Vertex_Definitions = shaderPart;
|
|
return this;
|
|
return this;
|
|
- }
|
|
|
|
- public Vertex_MainBegin(shaderPart:string):CustomMaterial{
|
|
|
|
|
|
+ }
|
|
|
|
+ public Vertex_MainBegin(shaderPart: string): CustomMaterial {
|
|
this.CustomParts.Vertex_MainBegin = shaderPart;
|
|
this.CustomParts.Vertex_MainBegin = shaderPart;
|
|
return this;
|
|
return this;
|
|
- }
|
|
|
|
- public Vertex_Before_PositionUpdated(shaderPart:string):CustomMaterial{
|
|
|
|
- this.CustomParts.Vertex_Before_PositionUpdated = shaderPart.replace("result","positionUpdated");
|
|
|
|
|
|
+ }
|
|
|
|
+ public Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial {
|
|
|
|
+ this.CustomParts.Vertex_Before_PositionUpdated = shaderPart.replace("result", "positionUpdated");
|
|
return this;
|
|
return this;
|
|
- }
|
|
|
|
-
|
|
|
|
- public Vertex_Before_NormalUpdated(shaderPart:string):CustomMaterial{
|
|
|
|
- this.CustomParts.Vertex_Before_NormalUpdated = shaderPart.replace("result","normalUpdated");
|
|
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial {
|
|
|
|
+ this.CustomParts.Vertex_Before_NormalUpdated = shaderPart.replace("result", "normalUpdated");
|
|
return this;
|
|
return this;
|
|
- }
|
|
|
|
-
|
|
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|