{"size": 2752, "ext": "js", "max_stars_repo_path": "src/postEffect/bloom/PostEffect_Bloom.js", "max_stars_repo_name": "laobel/RedGPU", "max_stars_repo_stars_event_min_datetime": "2021-02-12T06:57:02.000Z", "max_stars_repo_stars_event_max_datetime": "2021-02-12T06:57:02.000Z", "max_issues_repo_path": "src/postEffect/bloom/PostEffect_Bloom.js", "max_issues_repo_name": "pawandayma/RedGPU", "max_issues_repo_issues_event_min_datetime": "2020-06-01T16:09:02.000Z", "max_issues_repo_issues_event_max_datetime": "2020-06-01T16:09:02.000Z", "max_forks_repo_path": "src/postEffect/bloom/PostEffect_Bloom.js", "max_forks_repo_name": "pawandayma/RedGPU", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 1, "max_issues_count": 1, "max_forks_count": null, "avg_line_length": 34.835443038, "max_line_length": 111, "alphanum_fraction": 0.7627180233}
/*
 *   RedGPU - MIT License
 *   Copyright (c) 2019 ~ By RedCamel( webseon@gmail.com )
 *   issue : https://github.com/redcamel/RedGPU/issues
 *   Last modification time of this file - 2020.1.2 21:31:8
 *
 */

"use strict";
import BaseMaterial from "../../base/BaseMaterial.js";
import BasePostEffect from "../../base/BasePostEffect.js";
import PostEffect_GaussianBlur from "../blur/PostEffect_GaussianBlur.js";
import PostEffect_Threshold from "../adjustments/PostEffect_Threshold.js";
import PostEffect_Bloom_blend from "./PostEffect_Bloom_blend.js";
import ShareGLSL from "../../base/ShareGLSL.js";

export default class PostEffect_Bloom extends BasePostEffect {

	static vertexShaderGLSL = `
		${ShareGLSL.GLSL_VERSION}
		void main() {}
	`;
	static fragmentShaderGLSL = `
		${ShareGLSL.GLSL_VERSION}
		void main() {}
	`;
	static PROGRAM_OPTION_LIST = {vertex: [], fragment: []};
	static uniformsBindGroupLayoutDescriptor_material = BasePostEffect.uniformsBindGroupLayoutDescriptor_material;
	static uniformBufferDescriptor_vertex = BaseMaterial.uniformBufferDescriptor_empty;
	static uniformBufferDescriptor_fragment = BaseMaterial.uniformBufferDescriptor_empty;
	#blurEffect;
	#blenderEffect;
	#thresholdEffect;
	#blur;
	#threshold;
	#exposure;
	#bloomStrength;
	get blur() {return this.#blur;}
	set blur(value) {
		this.#blur = value;
		this.#blurEffect.radius = value;
	}
	get threshold() {return this.#threshold;}
	set threshold(value) {
		this.#threshold = value;
		this.#thresholdEffect.threshold = value;
	}
	get exposure() {return this.#exposure;}
	set exposure(value) {
		this.#exposure = value;
		this.#blenderEffect.exposure = value;
	}
	get bloomStrength() {return this.#bloomStrength;}
	set bloomStrength(value) {
		this.#bloomStrength = value;
		this.#blenderEffect.bloomStrength = value;
	}
	constructor(redGPUContext) {
		super(redGPUContext);
		this.#thresholdEffect = new PostEffect_Threshold(redGPUContext);
		this.#blurEffect = new PostEffect_GaussianBlur(redGPUContext);
		this.#blenderEffect = new PostEffect_Bloom_blend(redGPUContext);
		this.blur = 20;
		this.threshold = 75;
		this.exposure = 1;
		this.bloomStrength = 1.2;
	}

	render(redGPUContext, redView, renderScene, sourceTextureView) {
		this.checkSize(redGPUContext, redView);
		this.#thresholdEffect.render(redGPUContext, redView, renderScene, sourceTextureView);
		this.#blurEffect.render(redGPUContext, redView, renderScene, this.#thresholdEffect.baseAttachmentView);
		this.#blenderEffect.blurTexture = this.#blurEffect.baseAttachmentView;
		this.#blenderEffect.render(redGPUContext, redView, renderScene, sourceTextureView);
		this.baseAttachment = this.#blenderEffect.baseAttachment;
		this.baseAttachmentView = this.#blenderEffect.baseAttachmentView;
	}
}
