UNPKG

@polygonjs/polygonjs

Version:

node-based WebGL 3D engine https://polygonjs.com

58 lines (57 loc) 1.83 kB
"use strict"; import { TypedPostNode, PostParamOptions } from "./_Base"; import { BlendFunction, BrightnessContrastEffect, EffectPass } from "postprocessing"; import { NodeParamsConfig, ParamConfig } from "../utils/params/ParamsConfig"; import { BLEND_FUNCTION_MENU_OPTIONS } from "../../../core/post/BlendFunction"; class BrightnessContrastPostParamsConfig extends NodeParamsConfig { constructor() { super(...arguments); /** @param brightness */ this.brightness = ParamConfig.FLOAT(0, { range: [-1, 1], rangeLocked: [false, false], ...PostParamOptions }); /** @param contrast */ this.contrast = ParamConfig.FLOAT(0, { range: [-1, 1], rangeLocked: [false, false], ...PostParamOptions }); /** @param effect opacity */ this.opacity = ParamConfig.FLOAT(1, { range: [0, 1], rangeLocked: [true, false], ...PostParamOptions }); /** @param render mode */ this.blendFunction = ParamConfig.INTEGER(BlendFunction.NORMAL, { ...PostParamOptions, ...BLEND_FUNCTION_MENU_OPTIONS }); } } const ParamsConfig = new BrightnessContrastPostParamsConfig(); export class BrightnessContrastPostNode extends TypedPostNode { constructor() { super(...arguments); this.paramsConfig = ParamsConfig; } static type() { return "brightnessContrast"; } createPass(context) { const effect = new BrightnessContrastEffect(); const camera = context.camera; const pass = new EffectPass(camera, effect); this.updatePass(pass); return pass; } updatePass(pass) { const effect = pass.effects[0]; effect.brightness = this.pv.brightness; effect.contrast = this.pv.contrast; effect.blendMode.opacity.value = this.pv.opacity; effect.blendMode.blendFunction = this.pv.blendFunction; } }