ohzi-core 12.2.1 → 12.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/index.mjs +1 -1
- package/build/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/materials/AddMaterial.js +2 -2
- package/src/materials/GaussianBlurMaterial.js +9 -1
- package/src/materials/LuminosityHighPassMaterial.js +8 -1
- package/src/materials/UnrealBloomComposeMaterial.js +3 -2
- package/src/render_mode/UnrealBloomRender.js +47 -38
- package/src/render_utilities/Blitter.js +3 -3
- package/src/render_utilities/GaussianBlurrer.js +33 -14
- package/src/shaders/add/add.frag +21 -2
- package/src/shaders/gaussian_blur/gaussian_blur.frag +23 -4
- package/src/shaders/gaussian_blur/unreal_bloom_compose.frag +17 -5
- package/src/shaders/luminosity_high_pass/luminosity_high_pass.frag +16 -1
- package/build/index.module.js +0 -2
- package/build/index.module.js.map +0 -1
package/package.json
CHANGED
|
@@ -4,10 +4,10 @@ import frag from '../shaders/add/add.frag';
|
|
|
4
4
|
|
|
5
5
|
class AddMaterial extends BlitMaterial
|
|
6
6
|
{
|
|
7
|
-
constructor(
|
|
7
|
+
constructor(use_half_float = false)
|
|
8
8
|
{
|
|
9
9
|
super(frag);
|
|
10
|
-
|
|
10
|
+
this.defines.USE_LINEAR_COLOR_SPACE = use_half_float;
|
|
11
11
|
this.uniforms._SecondTex = { value: undefined };
|
|
12
12
|
}
|
|
13
13
|
|
|
@@ -6,7 +6,7 @@ import { Vector2 } from 'three';
|
|
|
6
6
|
|
|
7
7
|
class GaussianBlurMaterial extends BlitMaterial
|
|
8
8
|
{
|
|
9
|
-
constructor(kernel_radius)
|
|
9
|
+
constructor(kernel_radius, use_half_float)
|
|
10
10
|
{
|
|
11
11
|
super(frag, undefined, {
|
|
12
12
|
KERNEL_RADIUS: kernel_radius,
|
|
@@ -15,6 +15,9 @@ class GaussianBlurMaterial extends BlitMaterial
|
|
|
15
15
|
|
|
16
16
|
this.uniforms.texSize = { value: new Vector2(0.5, 0.5) };
|
|
17
17
|
this.uniforms.direction = { value: new Vector2(0.5, 0.5) };
|
|
18
|
+
this.uniforms.radius = { value: 1 };
|
|
19
|
+
|
|
20
|
+
this.defines.USE_LINEAR_COLOR_SPACE = true;
|
|
18
21
|
}
|
|
19
22
|
|
|
20
23
|
set_size(w, h)
|
|
@@ -27,6 +30,11 @@ class GaussianBlurMaterial extends BlitMaterial
|
|
|
27
30
|
{
|
|
28
31
|
this.uniforms.direction.value.set(x, y);
|
|
29
32
|
}
|
|
33
|
+
|
|
34
|
+
set_radius(value = 1)
|
|
35
|
+
{
|
|
36
|
+
this.uniforms.radius.value = value;
|
|
37
|
+
}
|
|
30
38
|
}
|
|
31
39
|
|
|
32
40
|
export { GaussianBlurMaterial };
|
|
@@ -5,7 +5,7 @@ import frag from '../shaders/luminosity_high_pass/luminosity_high_pass.frag';
|
|
|
5
5
|
import { Color } from 'three';
|
|
6
6
|
class LuminosityHighPassMaterial extends BlitMaterial
|
|
7
7
|
{
|
|
8
|
-
constructor(
|
|
8
|
+
constructor(use_half_float)
|
|
9
9
|
{
|
|
10
10
|
super(frag);
|
|
11
11
|
|
|
@@ -13,6 +13,13 @@ class LuminosityHighPassMaterial extends BlitMaterial
|
|
|
13
13
|
this.uniforms.smoothWidth = { value: 0.01 };
|
|
14
14
|
this.uniforms.defaultColor = { value: new Color('#000000') };
|
|
15
15
|
this.uniforms.defaultOpacity = { value: 0.0 };
|
|
16
|
+
|
|
17
|
+
this.defines.USE_LINEAR_COLOR_SPACE = true;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
set_threshold(value_01)
|
|
21
|
+
{
|
|
22
|
+
this.uniforms.luminosityThreshold.value = value_01;
|
|
16
23
|
}
|
|
17
24
|
}
|
|
18
25
|
|
|
@@ -5,7 +5,7 @@ import frag from '../shaders/gaussian_blur/unreal_bloom_compose.frag';
|
|
|
5
5
|
import { Color } from 'three';
|
|
6
6
|
class UnrealBloomComposeMaterial extends BlitMaterial
|
|
7
7
|
{
|
|
8
|
-
constructor(nMips)
|
|
8
|
+
constructor(nMips, use_linear_color_space = false)
|
|
9
9
|
{
|
|
10
10
|
super(frag, undefined, {
|
|
11
11
|
NUM_MIPS: nMips
|
|
@@ -22,8 +22,9 @@ class UnrealBloomComposeMaterial extends BlitMaterial
|
|
|
22
22
|
|
|
23
23
|
this.uniforms.bloomStrength = { value: 1.0 };
|
|
24
24
|
this.uniforms.bloomFactors = { value: [1.0, 0.8, 0.6, 0.4, 0.2] };
|
|
25
|
-
this.uniforms.bloomRadius = { value:
|
|
25
|
+
this.uniforms.bloomRadius = { value: 1.0 };
|
|
26
26
|
|
|
27
|
+
this.defines.USE_LINEAR_COLOR_SPACE = use_linear_color_space;
|
|
27
28
|
const bloomTintColors = [
|
|
28
29
|
new Color('#FFFFFF'),
|
|
29
30
|
new Color('#FFFFFF'),
|
|
@@ -3,7 +3,7 @@ import { BaseRender } from '../render_mode/BaseRender';
|
|
|
3
3
|
import { UnrealBloomComposeMaterial } from '../materials/UnrealBloomComposeMaterial';
|
|
4
4
|
import { AddMaterial } from '../materials/AddMaterial';
|
|
5
5
|
|
|
6
|
-
import { WebGLRenderTarget } from 'three';
|
|
6
|
+
import { HalfFloatType, LinearSRGBColorSpace, NearestFilter, RGBAFormat, UnsignedByteType, WebGLRenderTarget } from 'three';
|
|
7
7
|
|
|
8
8
|
import { GaussianBlurrer } from '../render_utilities/GaussianBlurrer';
|
|
9
9
|
import { Graphics } from '../Graphics';
|
|
@@ -12,40 +12,61 @@ import { SceneManager } from '../SceneManager';
|
|
|
12
12
|
|
|
13
13
|
class UnrealBloomRender extends BaseRender
|
|
14
14
|
{
|
|
15
|
-
constructor()
|
|
15
|
+
constructor(use_antialiasing, use_half_float, use_hight_luminosity_pass)
|
|
16
16
|
{
|
|
17
17
|
super();
|
|
18
18
|
|
|
19
|
-
this.
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
19
|
+
this.add_mat = new AddMaterial(use_half_float);
|
|
20
|
+
|
|
21
|
+
const rt_settings = {
|
|
22
|
+
samples: use_antialiasing ? 8 : 1,
|
|
23
|
+
type: use_half_float ? HalfFloatType : UnsignedByteType,
|
|
24
|
+
format: RGBAFormat,
|
|
25
|
+
colorSpace: LinearSRGBColorSpace,
|
|
26
|
+
minFilter: NearestFilter,
|
|
27
|
+
magFilter: NearestFilter
|
|
28
|
+
};
|
|
29
|
+
this.main_RT = new WebGLRenderTarget(1, 1, rt_settings);
|
|
30
|
+
this.main_RT.texture.colorSpace = LinearSRGBColorSpace;
|
|
31
|
+
this.main_RT.texture.minFilter = NearestFilter;
|
|
32
|
+
this.main_RT.texture.magFilter = NearestFilter;
|
|
33
|
+
|
|
34
|
+
this.bloom_compose_mat = new UnrealBloomComposeMaterial(5, use_half_float);
|
|
35
|
+
this.blurrer = new GaussianBlurrer(use_half_float);
|
|
36
|
+
this.use_hight_luminosity_pass = use_hight_luminosity_pass;
|
|
37
|
+
this.luminosity_threshold = 0.5;
|
|
26
38
|
}
|
|
27
39
|
|
|
28
40
|
on_enter()
|
|
29
41
|
{
|
|
30
|
-
this.blurrer = new GaussianBlurrer();
|
|
31
|
-
this.main_RT = new WebGLRenderTarget(OScreen.width, OScreen.height);
|
|
32
|
-
this.blur_RT = new WebGLRenderTarget(OScreen.width, OScreen.height);
|
|
33
|
-
|
|
34
|
-
this.bloom_compose_mat = new UnrealBloomComposeMaterial(5);
|
|
35
|
-
this.blurrer = new GaussianBlurrer(5);
|
|
36
|
-
|
|
37
42
|
this.bloom_compose_mat.set_RT_0(this.blurrer.renderTargetsVertical[0].texture);
|
|
38
43
|
this.bloom_compose_mat.set_RT_1(this.blurrer.renderTargetsVertical[1].texture);
|
|
39
44
|
this.bloom_compose_mat.set_RT_2(this.blurrer.renderTargetsVertical[2].texture);
|
|
40
45
|
this.bloom_compose_mat.set_RT_3(this.blurrer.renderTargetsVertical[3].texture);
|
|
41
46
|
this.bloom_compose_mat.set_RT_4(this.blurrer.renderTargetsVertical[4].texture);
|
|
42
47
|
|
|
43
|
-
this.bloom_compose_mat.set_bloom_strength(1);
|
|
44
|
-
this.bloom_compose_mat.set_bloom_radius(1);
|
|
45
|
-
|
|
46
48
|
this.add_mat.set_add_texture(this.blurrer.renderTargetsHorizontal[0].texture);
|
|
47
49
|
}
|
|
48
50
|
|
|
51
|
+
render()
|
|
52
|
+
{
|
|
53
|
+
this.__check_RT_size();
|
|
54
|
+
|
|
55
|
+
Graphics.clear(this.main_RT, CameraManager.current, true, false);
|
|
56
|
+
Graphics.render(SceneManager.current, CameraManager.current, this.main_RT);
|
|
57
|
+
|
|
58
|
+
// // // BLUR
|
|
59
|
+
this.blurrer.blur(this.main_RT, this.use_hight_luminosity_pass);
|
|
60
|
+
|
|
61
|
+
// // Blur compose
|
|
62
|
+
Graphics.material_pass(this.bloom_compose_mat, this.blurrer.renderTargetsHorizontal[0]);
|
|
63
|
+
|
|
64
|
+
// // Additive blend
|
|
65
|
+
// Graphics.clear(undefined, CameraManager.current, true, false);
|
|
66
|
+
// Graphics.render(SceneManager.current, CameraManager.current);
|
|
67
|
+
Graphics.blit(this.main_RT, undefined, this.add_mat);
|
|
68
|
+
}
|
|
69
|
+
|
|
49
70
|
set_bloom_strength(val)
|
|
50
71
|
{
|
|
51
72
|
this.bloom_compose_mat.set_bloom_strength(val);
|
|
@@ -53,7 +74,13 @@ class UnrealBloomRender extends BaseRender
|
|
|
53
74
|
|
|
54
75
|
set_bloom_radius(val)
|
|
55
76
|
{
|
|
56
|
-
this.bloom_compose_mat.set_bloom_radius(val);
|
|
77
|
+
// this.bloom_compose_mat.set_bloom_radius(val);
|
|
78
|
+
this.blurrer.set_radius(val);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
set_luminosity_threshold(value)
|
|
82
|
+
{
|
|
83
|
+
this.blurrer.set_luminosity_threshold(value);
|
|
57
84
|
}
|
|
58
85
|
|
|
59
86
|
set_tint_color_0(col_string)
|
|
@@ -81,29 +108,11 @@ class UnrealBloomRender extends BaseRender
|
|
|
81
108
|
this.bloom_compose_mat.set_tint_color_4(col_string);
|
|
82
109
|
}
|
|
83
110
|
|
|
84
|
-
render()
|
|
85
|
-
{
|
|
86
|
-
this.__check_RT_size();
|
|
87
|
-
|
|
88
|
-
Graphics.clear(this.main_RT, CameraManager.current, true, false);
|
|
89
|
-
Graphics.render(SceneManager.current, CameraManager.current, this.main_RT);
|
|
90
|
-
|
|
91
|
-
// // BLUR
|
|
92
|
-
this.blurrer.blur(this.main_RT, true);
|
|
93
|
-
|
|
94
|
-
// Blur compose
|
|
95
|
-
Graphics.material_pass(this.bloom_compose_mat, this.blurrer.renderTargetsHorizontal[0]);
|
|
96
|
-
|
|
97
|
-
// Additive blend
|
|
98
|
-
Graphics.blit(this.main_RT, undefined, this.add_mat);
|
|
99
|
-
}
|
|
100
|
-
|
|
101
111
|
__check_RT_size()
|
|
102
112
|
{
|
|
103
113
|
if (this.main_RT.width !== OScreen.width || this.main_RT.height !== OScreen.height)
|
|
104
114
|
{
|
|
105
115
|
this.main_RT.setSize(OScreen.width, OScreen.height);
|
|
106
|
-
this.blur_RT.setSize(OScreen.width, OScreen.height);
|
|
107
116
|
}
|
|
108
117
|
}
|
|
109
118
|
}
|
|
@@ -85,13 +85,13 @@ class Blitter
|
|
|
85
85
|
this._blit_quad.material.dispose();
|
|
86
86
|
}
|
|
87
87
|
|
|
88
|
-
__render(
|
|
88
|
+
__render(dst_RT)
|
|
89
89
|
{
|
|
90
|
-
RT =
|
|
90
|
+
const RT = dst_RT === undefined ? null : dst_RT;
|
|
91
91
|
|
|
92
92
|
const current_rt = this.renderer.getRenderTarget();
|
|
93
93
|
|
|
94
|
-
this.renderer.setRenderTarget(RT
|
|
94
|
+
this.renderer.setRenderTarget(RT);
|
|
95
95
|
this.renderer.render(this._blit_scene, this._blit_camera);
|
|
96
96
|
|
|
97
97
|
this.renderer.setRenderTarget(current_rt);
|
|
@@ -2,11 +2,11 @@ import { GaussianBlurMaterial } from '../materials/GaussianBlurMaterial';
|
|
|
2
2
|
import { LuminosityHighPassMaterial } from '../materials/LuminosityHighPassMaterial';
|
|
3
3
|
import { Graphics } from '../Graphics';
|
|
4
4
|
|
|
5
|
-
import { WebGLRenderTarget, LinearFilter, RGBAFormat } from 'three';
|
|
5
|
+
import { WebGLRenderTarget, LinearFilter, RGBAFormat, HalfFloatType, UnsignedByteType, SRGBColorSpace, LinearSRGBColorSpace } from 'three';
|
|
6
6
|
|
|
7
7
|
class GaussianBlurrer
|
|
8
8
|
{
|
|
9
|
-
constructor(
|
|
9
|
+
constructor(use_half_float = false)
|
|
10
10
|
{
|
|
11
11
|
this.current_width = 1;
|
|
12
12
|
this.current_height = 1;
|
|
@@ -14,10 +14,16 @@ class GaussianBlurrer
|
|
|
14
14
|
this.separableBlurMaterials = [];
|
|
15
15
|
this.renderTargetsHorizontal = [];
|
|
16
16
|
this.renderTargetsVertical = [];
|
|
17
|
-
|
|
18
|
-
this.nMips =
|
|
17
|
+
this.use_half_float = use_half_float;
|
|
18
|
+
this.nMips = 5;
|
|
19
19
|
this.kernelSizeArray = [3, 5, 7, 9, 11];
|
|
20
|
-
this.rt_pars = {
|
|
20
|
+
this.rt_pars = {
|
|
21
|
+
minFilter: LinearFilter,
|
|
22
|
+
magFilter: LinearFilter,
|
|
23
|
+
format: RGBAFormat,
|
|
24
|
+
type: use_half_float ? HalfFloatType : UnsignedByteType,
|
|
25
|
+
colorSpace: use_half_float ? LinearSRGBColorSpace : SRGBColorSpace
|
|
26
|
+
};
|
|
21
27
|
|
|
22
28
|
this.renderTargetBright = new WebGLRenderTarget(1, 1, this.rt_pars);
|
|
23
29
|
this.renderTargetBright.texture.generateMipmaps = false;
|
|
@@ -25,24 +31,21 @@ class GaussianBlurrer
|
|
|
25
31
|
this.init_materials();
|
|
26
32
|
this.init_RT();
|
|
27
33
|
|
|
28
|
-
this.luminosity_high_pass_mat = new LuminosityHighPassMaterial();
|
|
34
|
+
this.luminosity_high_pass_mat = new LuminosityHighPassMaterial(use_half_float);
|
|
29
35
|
}
|
|
30
36
|
|
|
31
37
|
blur(RT, use_luminosity_high_pass)
|
|
32
38
|
{
|
|
33
39
|
this.resize_RT(RT.width, RT.height);
|
|
34
40
|
|
|
41
|
+
let inputRenderTarget = RT;
|
|
42
|
+
|
|
35
43
|
if (use_luminosity_high_pass)
|
|
36
44
|
{
|
|
37
45
|
Graphics.blit(RT, this.renderTargetBright, this.luminosity_high_pass_mat);
|
|
38
|
-
|
|
39
|
-
else
|
|
40
|
-
{
|
|
41
|
-
Graphics.blit(RT, this.renderTargetBright);
|
|
46
|
+
inputRenderTarget = this.renderTargetBright;
|
|
42
47
|
}
|
|
43
48
|
|
|
44
|
-
let inputRenderTarget = this.renderTargetBright;
|
|
45
|
-
|
|
46
49
|
for (let i = 0; i < this.nMips; i++)
|
|
47
50
|
{
|
|
48
51
|
const mat = this.separableBlurMaterials[i];
|
|
@@ -81,6 +84,9 @@ class GaussianBlurrer
|
|
|
81
84
|
hor.texture.generateMipmaps = false;
|
|
82
85
|
ver.texture.generateMipmaps = false;
|
|
83
86
|
|
|
87
|
+
hor.texture.colorSpace = this.rt_pars.colorSpace;
|
|
88
|
+
ver.texture.colorSpace = this.rt_pars.colorSpace;
|
|
89
|
+
|
|
84
90
|
this.renderTargetsHorizontal.push(hor);
|
|
85
91
|
this.renderTargetsVertical.push(ver);
|
|
86
92
|
}
|
|
@@ -112,16 +118,29 @@ class GaussianBlurrer
|
|
|
112
118
|
}
|
|
113
119
|
}
|
|
114
120
|
|
|
115
|
-
init_materials(
|
|
121
|
+
init_materials()
|
|
116
122
|
{
|
|
117
123
|
this.dispose_materials();
|
|
118
124
|
|
|
119
125
|
for (let i = 0; i < this.nMips; i++)
|
|
120
126
|
{
|
|
121
|
-
this.separableBlurMaterials.push(new GaussianBlurMaterial(this.kernelSizeArray[i]));
|
|
127
|
+
this.separableBlurMaterials.push(new GaussianBlurMaterial(this.kernelSizeArray[i], this.use_half_float));
|
|
122
128
|
}
|
|
123
129
|
}
|
|
124
130
|
|
|
131
|
+
set_radius(value)
|
|
132
|
+
{
|
|
133
|
+
for (let i = 0; i < this.separableBlurMaterials.length; i++)
|
|
134
|
+
{
|
|
135
|
+
this.separableBlurMaterials[i].set_radius(value);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
set_luminosity_threshold(value)
|
|
140
|
+
{
|
|
141
|
+
this.luminosity_high_pass_mat.set_threshold(value);
|
|
142
|
+
}
|
|
143
|
+
|
|
125
144
|
dispose_materials()
|
|
126
145
|
{
|
|
127
146
|
for (let i = 0; i < this.separableBlurMaterials.length; i++)
|
package/src/shaders/add/add.frag
CHANGED
|
@@ -2,8 +2,27 @@ uniform sampler2D _MainTex;
|
|
|
2
2
|
uniform sampler2D _SecondTex;
|
|
3
3
|
|
|
4
4
|
varying vec2 vUv;
|
|
5
|
+
|
|
6
|
+
vec4 sampleTex(sampler2D tex, vec2 uv)
|
|
7
|
+
{
|
|
8
|
+
vec4 col = texture2D( tex, uv);
|
|
9
|
+
|
|
10
|
+
#ifndef USE_LINEAR_COLOR_SPACE
|
|
11
|
+
col.rgb = pow(col.rgb, vec3(2.2));
|
|
12
|
+
#endif
|
|
13
|
+
|
|
14
|
+
return col;
|
|
15
|
+
}
|
|
5
16
|
void main()
|
|
6
17
|
{
|
|
7
|
-
|
|
8
|
-
|
|
18
|
+
vec4 col0 = sampleTex(_MainTex, vUv);
|
|
19
|
+
vec4 col1 = sampleTex(_SecondTex, vUv);
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
gl_FragColor = col0+col1;
|
|
23
|
+
// gl_FragColor = texture2D(_SecondTex, vUv);
|
|
24
|
+
gl_FragColor.rgb = pow(gl_FragColor.rgb, vec3(0.4545));
|
|
25
|
+
|
|
26
|
+
// gl_FragColor = texture2D(_MainTex, vUv)+texture2D(_SecondTex, vUv);
|
|
27
|
+
|
|
9
28
|
}
|
|
@@ -3,23 +3,42 @@ varying vec2 vUv;
|
|
|
3
3
|
uniform sampler2D _MainTex;
|
|
4
4
|
uniform vec2 texSize;
|
|
5
5
|
uniform vec2 direction;
|
|
6
|
+
uniform float radius;
|
|
6
7
|
|
|
7
8
|
float gaussianPdf(in float x, in float sigma) {
|
|
8
9
|
return 0.39894 * exp( -0.5 * x * x/( sigma * sigma))/sigma;
|
|
9
10
|
}
|
|
11
|
+
|
|
12
|
+
vec4 sampleTex(sampler2D tex, vec2 uv)
|
|
13
|
+
{
|
|
14
|
+
vec4 col = texture2D( tex, uv);
|
|
15
|
+
|
|
16
|
+
#ifndef USE_LINEAR_COLOR_SPACE
|
|
17
|
+
col.rgb = pow(col.rgb, vec3(2.2));
|
|
18
|
+
#endif
|
|
19
|
+
|
|
20
|
+
return col;
|
|
21
|
+
}
|
|
22
|
+
|
|
10
23
|
void main() {
|
|
11
24
|
vec2 invSize = 1.0 / texSize;
|
|
12
25
|
float fSigma = float(SIGMA);
|
|
13
26
|
float weightSum = gaussianPdf(0.0, fSigma);
|
|
14
|
-
vec4 diffuseSum =
|
|
27
|
+
vec4 diffuseSum = sampleTex( _MainTex, vUv) * weightSum;
|
|
15
28
|
for( int i = 1; i < KERNEL_RADIUS; i ++ ) {
|
|
16
29
|
float x = float(i);
|
|
17
30
|
float w = gaussianPdf(x, fSigma);
|
|
18
|
-
vec2 uvOffset = direction * invSize * x;
|
|
19
|
-
vec4 sample1 =
|
|
20
|
-
vec4 sample2 =
|
|
31
|
+
vec2 uvOffset = direction * invSize * x * radius;
|
|
32
|
+
vec4 sample1 = sampleTex( _MainTex, vUv + uvOffset);
|
|
33
|
+
vec4 sample2 = sampleTex( _MainTex, vUv - uvOffset);
|
|
21
34
|
diffuseSum += (sample1 + sample2) * w;
|
|
22
35
|
weightSum += 2.0 * w;
|
|
23
36
|
}
|
|
24
37
|
gl_FragColor = vec4(diffuseSum/weightSum);
|
|
38
|
+
|
|
39
|
+
#ifndef USE_LINEAR_COLOR_SPACE
|
|
40
|
+
gl_FragColor.rgb = pow(gl_FragColor.rgb, vec3(0.4545));
|
|
41
|
+
#endif
|
|
42
|
+
// #include <colorspace_fragment>
|
|
43
|
+
|
|
25
44
|
}
|
|
@@ -15,10 +15,22 @@ float lerpBloomFactor(const in float factor) {
|
|
|
15
15
|
return mix(factor, mirrorFactor, bloomRadius);
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
+
vec4 sampleTex(sampler2D tex, vec2 uv)
|
|
19
|
+
{
|
|
20
|
+
vec4 col = texture2D( tex, uv);
|
|
21
|
+
#ifndef USE_LINEAR_COLOR_SPACE
|
|
22
|
+
col.rgb = pow(col.rgb, vec3(2.2));
|
|
23
|
+
#endif
|
|
24
|
+
return col;
|
|
25
|
+
}
|
|
18
26
|
void main() {
|
|
19
|
-
gl_FragColor = bloomStrength * ( lerpBloomFactor(bloomFactors[0]) * vec4(bloomTintColors[0], 1.0) *
|
|
20
|
-
lerpBloomFactor(bloomFactors[1]) * vec4(bloomTintColors[1], 1.0) *
|
|
21
|
-
lerpBloomFactor(bloomFactors[2]) * vec4(bloomTintColors[2], 1.0) *
|
|
22
|
-
lerpBloomFactor(bloomFactors[3]) * vec4(bloomTintColors[3], 1.0) *
|
|
23
|
-
lerpBloomFactor(bloomFactors[4]) * vec4(bloomTintColors[4], 1.0) *
|
|
27
|
+
gl_FragColor = bloomStrength * ( lerpBloomFactor(bloomFactors[0]) * vec4(bloomTintColors[0], 1.0) * sampleTex(blurTexture1, vUv) +
|
|
28
|
+
lerpBloomFactor(bloomFactors[1]) * vec4(bloomTintColors[1], 1.0) * sampleTex(blurTexture2, vUv) +
|
|
29
|
+
lerpBloomFactor(bloomFactors[2]) * vec4(bloomTintColors[2], 1.0) * sampleTex(blurTexture3, vUv) +
|
|
30
|
+
lerpBloomFactor(bloomFactors[3]) * vec4(bloomTintColors[3], 1.0) * sampleTex(blurTexture4, vUv) +
|
|
31
|
+
lerpBloomFactor(bloomFactors[4]) * vec4(bloomTintColors[4], 1.0) * sampleTex(blurTexture5, vUv) );
|
|
32
|
+
|
|
33
|
+
#ifndef USE_LINEAR_COLOR_SPACE
|
|
34
|
+
gl_FragColor.rgb = pow(gl_FragColor.rgb, vec3(0.4545));
|
|
35
|
+
#endif
|
|
24
36
|
}
|
|
@@ -6,9 +6,17 @@ uniform float smoothWidth;
|
|
|
6
6
|
|
|
7
7
|
varying vec2 vUv;
|
|
8
8
|
|
|
9
|
+
vec4 sampleTex(sampler2D tex, vec2 uv)
|
|
10
|
+
{
|
|
11
|
+
vec4 col = texture2D( tex, uv);
|
|
12
|
+
#ifndef USE_LINEAR_COLOR_SPACE
|
|
13
|
+
col.rgb = pow(col.rgb, vec3(2.2));
|
|
14
|
+
#endif
|
|
15
|
+
return col;
|
|
16
|
+
}
|
|
9
17
|
void main() {
|
|
10
18
|
|
|
11
|
-
vec4 texel =
|
|
19
|
+
vec4 texel = sampleTex( _MainTex, vUv );
|
|
12
20
|
|
|
13
21
|
vec3 luma = vec3( 0.299, 0.587, 0.114 );
|
|
14
22
|
|
|
@@ -19,5 +27,12 @@ void main() {
|
|
|
19
27
|
float alpha = smoothstep( luminosityThreshold, luminosityThreshold + smoothWidth, v );
|
|
20
28
|
|
|
21
29
|
gl_FragColor = mix( outputColor, texel, alpha );
|
|
30
|
+
|
|
31
|
+
// #include <colorspace_fragment>
|
|
32
|
+
|
|
33
|
+
#ifndef USE_LINEAR_COLOR_SPACE
|
|
34
|
+
gl_FragColor.rgb = pow(gl_FragColor.rgb, vec3(0.4545));
|
|
35
|
+
#endif
|
|
36
|
+
|
|
22
37
|
|
|
23
38
|
}
|