|
@@ -101,7 +101,7 @@
|
|
|
}
|
|
|
|
|
|
|
|
|
- if (!this.emitter || !this._updateEffect.isReady() || !this._renderEffect.isReady() || !this.particleTexture || !this.particleTexture.isReady()) {
|
|
|
+ if (!this.emitter || !this._updateEffect.isReady() || !this._imageProcessingConfiguration.isReady() || !this._renderEffect.isReady() || !this.particleTexture || !this.particleTexture.isReady()) {
|
|
|
return false;
|
|
|
}
|
|
|
|
|
@@ -393,7 +393,48 @@
|
|
|
(<any>this._limitVelocityGradientsTexture) = null;
|
|
|
|
|
|
return this;
|
|
|
- }
|
|
|
+ }
|
|
|
+
|
|
|
+ private _imageProcessingConfigurationDefines = new ImageProcessingConfigurationDefines();
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Default configuration related to image processing available in the standard Material.
|
|
|
+ */
|
|
|
+ protected _imageProcessingConfiguration: ImageProcessingConfiguration;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Gets the image processing configuration used either in this material.
|
|
|
+ */
|
|
|
+ public get imageProcessingConfiguration(): ImageProcessingConfiguration {
|
|
|
+ return this._imageProcessingConfiguration;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Sets the Default image processing configuration used either in the this material.
|
|
|
+ *
|
|
|
+ * If sets to null, the scene one is in use.
|
|
|
+ */
|
|
|
+ public set imageProcessingConfiguration(value: ImageProcessingConfiguration) {
|
|
|
+ this._attachImageProcessingConfiguration(value);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Attaches a new image processing configuration to the Standard Material.
|
|
|
+ * @param configuration
|
|
|
+ */
|
|
|
+ protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void {
|
|
|
+ if (configuration === this._imageProcessingConfiguration) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ // Pick the scene configuration if needed.
|
|
|
+ if (!configuration) {
|
|
|
+ this._imageProcessingConfiguration = this._scene.imageProcessingConfiguration;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ this._imageProcessingConfiguration = configuration;
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* Instantiates a GPU particle system.
|
|
@@ -409,6 +450,9 @@
|
|
|
}>, scene: Scene, isAnimationSheetEnabled: boolean = false) {
|
|
|
super(name);
|
|
|
this._scene = scene || Engine.LastCreatedScene;
|
|
|
+ // Setup the default processing configuration to the scene.
|
|
|
+ this._attachImageProcessingConfiguration(null);
|
|
|
+
|
|
|
this._engine = this._scene.getEngine();
|
|
|
|
|
|
if (!options.randomTextureSize) {
|
|
@@ -755,14 +799,27 @@
|
|
|
defines += "\n#define ANIMATESHEET";
|
|
|
}
|
|
|
|
|
|
+ if (this._imageProcessingConfiguration) {
|
|
|
+ this._imageProcessingConfiguration.prepareDefines(this._imageProcessingConfigurationDefines);
|
|
|
+ defines += "\n" + this._imageProcessingConfigurationDefines.toString();
|
|
|
+ }
|
|
|
+
|
|
|
if (this._renderEffect && this._renderEffect.defines === defines) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
+ var uniforms = ["view", "projection", "colorDead", "invView", "vClipPlane", "sheetInfos", "translationPivot", "eyePosition"];
|
|
|
+ var samplers = ["textureSampler", "colorGradientSampler"];
|
|
|
+
|
|
|
+ if (ImageProcessingConfiguration) {
|
|
|
+ ImageProcessingConfiguration.PrepareUniforms(uniforms, this._imageProcessingConfigurationDefines);
|
|
|
+ ImageProcessingConfiguration.PrepareSamplers(samplers, this._imageProcessingConfigurationDefines);
|
|
|
+ }
|
|
|
+
|
|
|
this._renderEffect = new Effect("gpuRenderParticles",
|
|
|
["position", "age", "life", "size", "color", "offset", "uv", "initialDirection", "angle", "cellIndex"],
|
|
|
- ["view", "projection", "colorDead", "invView", "vClipPlane", "sheetInfos", "translationPivot", "eyePosition"],
|
|
|
- ["textureSampler", "colorGradientSampler"], this._scene.getEngine(), defines);
|
|
|
+ uniforms,
|
|
|
+ samplers, this._scene.getEngine(), defines);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -986,7 +1043,12 @@
|
|
|
invView.invert();
|
|
|
this._renderEffect.setMatrix("invView", invView);
|
|
|
this._renderEffect.setFloat4("vClipPlane", clipPlane.normal.x, clipPlane.normal.y, clipPlane.normal.z, clipPlane.d);
|
|
|
- }
|
|
|
+ }
|
|
|
+
|
|
|
+ // image processing
|
|
|
+ if (this._imageProcessingConfiguration && !this._imageProcessingConfiguration.applyByPostProcess) {
|
|
|
+ this._imageProcessingConfiguration.bind(this._renderEffect);
|
|
|
+ }
|
|
|
|
|
|
// Draw order
|
|
|
switch(this.blendMode)
|