threepipe
Version:
A modern 3D viewer framework built on top of three.js, written in TypeScript, designed to make creating high-quality, modular, and extensible 3D experiences on the web simple and enjoyable.
82 lines • 3.3 kB
JavaScript
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
import { uiFolderContainer, uiSlider, uiToggle } from 'uiconfig.js';
import { glsl, onChange, serialize } from 'ts-browser-helpers';
import { uniform } from '../../three';
import FilmicGrain from './shaders/FilmicGrainPlugin.glsl';
import { AScreenPassExtensionPlugin } from './AScreenPassExtensionPlugin';
/**
* Filmic Grain Plugin
* Adds an extension to {@link ScreenPass} material
* for applying filmic grain effect on the final buffer before rendering to screen.
* The intensity of the grain can be controlled with the `intensity` property
* and the `multiply` property can be used to multiply the grain effect on the image instead of adding.
*
* @category Plugins
*/
let FilmicGrainPlugin = class FilmicGrainPlugin extends AScreenPassExtensionPlugin {
/**
* @deprecated
*/
get grainIntensity() {
console.warn('FilmicGrainPlugin.grainIntensity is deprecated, use FilmicGrainPlugin.intensity instead');
return this.intensity;
}
/**
* @deprecated
*/
set grainIntensity(v) {
console.warn('FilmicGrainPlugin.grainIntensity is deprecated, use FilmicGrainPlugin.intensity instead');
this.intensity = v;
}
constructor(enabled = true) {
super();
this.extraUniforms = {
grainIntensity: { value: 1 },
grainMultiply: { value: false },
};
this.intensity = 10;
this.multiply = false;
/**
* The priority of the material extension when applied to the material in ScreenPass
* set to very low priority, so applied at the end
*/
this.priority = -50;
this.parsFragmentSnippet = () => {
if (this.isDisabled())
return '';
return glsl `
uniform float grainIntensity;
uniform bool grainMultiply;
${FilmicGrain}
`;
};
this._shaderPatch = 'diffuseColor = FilmicGrain(diffuseColor);';
this.enabled = enabled;
}
};
FilmicGrainPlugin.PluginType = 'FilmicGrain';
__decorate([
onChange(FilmicGrainPlugin.prototype.setDirty),
uiToggle('Enable'),
serialize()
], FilmicGrainPlugin.prototype, "enabled", void 0);
__decorate([
uiSlider('Intensity', [0., 20], 0.01),
uniform({ propKey: 'grainIntensity' }),
serialize('grainIntensity')
], FilmicGrainPlugin.prototype, "intensity", void 0);
__decorate([
uiToggle('Multiply'),
uniform({ propKey: 'grainMultiply' }),
serialize('grainMultiply')
], FilmicGrainPlugin.prototype, "multiply", void 0);
FilmicGrainPlugin = __decorate([
uiFolderContainer('FilmicGrain')
], FilmicGrainPlugin);
export { FilmicGrainPlugin };
//# sourceMappingURL=FilmicGrainPlugin.js.map