|
@@ -2,6 +2,7 @@ module BABYLON {
|
|
|
/**
|
|
|
* Interface to follow in your material defines to integrate easily the
|
|
|
* Image proccessing functions.
|
|
|
+ * @ignore
|
|
|
*/
|
|
|
export interface IImageProcessingConfigurationDefines {
|
|
|
IMAGEPROCESSING: boolean;
|
|
@@ -17,6 +18,10 @@ module BABYLON {
|
|
|
SAMPLER3DGREENDEPTH: boolean;
|
|
|
SAMPLER3DBGRMAP: boolean;
|
|
|
IMAGEPROCESSINGPOSTPROCESS: boolean;
|
|
|
+ /**
|
|
|
+ * If the grain should be performed in the image processing shader.
|
|
|
+ */
|
|
|
+ GRAIN: boolean;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -216,6 +221,57 @@ module BABYLON {
|
|
|
public vignetteCameraFov = 0.5;
|
|
|
|
|
|
@serialize()
|
|
|
+ private _grainEnabled = false;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * If the grain effect should be enabled.
|
|
|
+ */
|
|
|
+ public get grainEnabled(): boolean {
|
|
|
+ return this._grainEnabled;
|
|
|
+ }
|
|
|
+ public set grainEnabled(value: boolean) {
|
|
|
+ if (this._grainEnabled === value) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ this._grainEnabled = value;
|
|
|
+ this._updateParameters();
|
|
|
+ }
|
|
|
+
|
|
|
+ @serialize()
|
|
|
+ private _grainIntensity = 30;
|
|
|
+ /**
|
|
|
+ * Amount of grain to be applied by the grain effect.
|
|
|
+ */
|
|
|
+ public get grainIntensity(): number {
|
|
|
+ return this._grainIntensity;
|
|
|
+ }
|
|
|
+ public set grainIntensity(value: number) {
|
|
|
+ if (this._grainIntensity === value) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ this._grainIntensity = value;
|
|
|
+ }
|
|
|
+
|
|
|
+ @serialize()
|
|
|
+ private _grainAnimated = false;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * If the grain effect should be animated.
|
|
|
+ */
|
|
|
+ public get grainAnimated(): boolean {
|
|
|
+ return this._grainAnimated;
|
|
|
+ }
|
|
|
+ public set grainAnimated(value: boolean) {
|
|
|
+ if (this._grainAnimated === value) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ this._grainAnimated = value;
|
|
|
+ this._updateParameters();
|
|
|
+ }
|
|
|
+
|
|
|
+ @serialize()
|
|
|
private _vignetteBlendMode = ImageProcessingConfiguration.VIGNETTEMODE_MULTIPLY;
|
|
|
/**
|
|
|
* Gets the vignette blend mode allowing different kind of effect.
|
|
@@ -335,6 +391,10 @@ module BABYLON {
|
|
|
if (defines.COLORCURVES) {
|
|
|
ColorCurves.PrepareUniforms(uniforms);
|
|
|
}
|
|
|
+ if (defines.GRAIN){
|
|
|
+ uniforms.push("grainVarianceAmount");
|
|
|
+ uniforms.push("grainAnimatedSeed");
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -382,7 +442,8 @@ module BABYLON {
|
|
|
defines.SAMPLER3DGREENDEPTH = this.colorGradingWithGreenDepth;
|
|
|
defines.SAMPLER3DBGRMAP = this.colorGradingBGR;
|
|
|
defines.IMAGEPROCESSINGPOSTPROCESS = this.applyByPostProcess;
|
|
|
- defines.IMAGEPROCESSING = defines.VIGNETTE || defines.TONEMAPPING || defines.CONTRAST || defines.EXPOSURE || defines.COLORCURVES || defines.COLORGRADING;
|
|
|
+ defines.GRAIN = this.grainEnabled;
|
|
|
+ defines.IMAGEPROCESSING = defines.VIGNETTE || defines.TONEMAPPING || defines.CONTRAST || defines.EXPOSURE || defines.COLORCURVES || defines.COLORGRADING || defines.GRAIN;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -440,6 +501,9 @@ module BABYLON {
|
|
|
this.colorGradingTexture.level // weight
|
|
|
);
|
|
|
}
|
|
|
+
|
|
|
+ effect.setFloat("grainVarianceAmount", this.grainIntensity);
|
|
|
+ effect.setFloat("grainAnimatedSeed", this.grainAnimated ? Math.random() + 1 : 1);
|
|
|
}
|
|
|
|
|
|
/**
|