softbox 4.16.1 → 4.18.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/README.md +7 -6
- package/dist/{BrightnessContrastShader-BN6FBcLV.cjs → BrightnessContrastShader-C1jbh-NA.cjs} +2 -2
- package/dist/BrightnessContrastShader-CoM5EjqG.js +13 -0
- package/dist/ContactShadowBaker-MzqtJ-0h.js +2052 -0
- package/dist/ContactShadowBaker-lWQW97Cr.cjs +2 -0
- package/dist/CopyShader-C2Oc7n1P.js +12 -0
- package/dist/{CopyShader-DPSZNOxL.cjs → CopyShader-CM1OGKAp.cjs} +2 -2
- package/dist/EffectComposer-CMs4vldH.js +88 -0
- package/dist/EffectComposer-CdAQB6p0.cjs +1 -0
- package/dist/HueSaturationShader-BeHSjNY8.js +13 -0
- package/dist/{HueSaturationShader-BEp7jjxf.cjs → HueSaturationShader-bN5IWhh8.cjs} +2 -2
- package/dist/OutputPass-DicIJHut.cjs +72 -0
- package/dist/OutputPass-oQu4Xmeb.js +29 -0
- package/dist/Pass-CSHIrJrV.js +51 -0
- package/dist/Pass-D0vYi-gB.cjs +1 -0
- package/dist/RenderPass-DS8SYAhJ.js +16 -0
- package/dist/RenderPass-DlRq51Kq.cjs +1 -0
- package/dist/ShaderPass-DghZ7TAj.cjs +1 -0
- package/dist/ShaderPass-h4P0lBmc.js +22 -0
- package/dist/{ThreePathTracingService-VOgJGtMH.cjs → ThreePathTracingService-B1WEEKgQ.cjs} +96 -96
- package/dist/ThreePathTracingService-qV8I_V9u.js +2546 -0
- package/dist/UnrealBloomPass-BTHiW_Y8.js +123 -0
- package/dist/UnrealBloomPass-CQHHa-s_.cjs +115 -0
- package/dist/VignetteShader-CPF_iEkO.js +13 -0
- package/dist/{VignetteShader-Drpo9YxI.cjs → VignetteShader-CQmGrpns.cjs} +2 -2
- package/dist/index.d.cts +7 -0
- package/dist/index.d.ts +7 -0
- package/dist/simple-viewer.cjs +23 -1
- package/dist/simple-viewer.es.js +8473 -11
- package/package.json +26 -18
- package/dist/BrightnessContrastShader-B9tNAd_c.js +0 -49
- package/dist/CopyShader-DVL8Bcar.js +0 -41
- package/dist/EffectComposer-BdHnHszK.js +0 -188
- package/dist/EffectComposer-D2IQ0sek.cjs +0 -1
- package/dist/HueSaturationShader-B6tnz2ga.js +0 -60
- package/dist/OutputPass-Dy4KNHYF.cjs +0 -72
- package/dist/OutputPass-Tt8WbC_B.js +0 -125
- package/dist/Pass-C1mreNp8.cjs +0 -1
- package/dist/Pass-DOcH4lwV.js +0 -88
- package/dist/RenderPass-B57TYmjs.js +0 -37
- package/dist/RenderPass-BVzyKWsC.cjs +0 -1
- package/dist/ShaderPass-BQRqK8zp.cjs +0 -1
- package/dist/ShaderPass-C2HX8lsT.js +0 -45
- package/dist/ThreePathTracingService-CK3zD4Qj.js +0 -6383
- package/dist/UnrealBloomPass-Kx7djcld.cjs +0 -115
- package/dist/UnrealBloomPass-rjyQu37v.js +0 -281
- package/dist/VignetteShader-BG_QwoTp.js +0 -45
- package/dist/index-BWjJNKzq.js +0 -13030
- package/dist/index-BqbKpEQh.cjs +0 -29
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { t as e } from "./CopyShader-C2Oc7n1P.js";
|
|
2
|
+
import { n as t, t as n } from "./Pass-CSHIrJrV.js";
|
|
3
|
+
import { AdditiveBlending as r, Color as i, HalfFloatType as a, MeshBasicMaterial as o, ShaderMaterial as s, UniformsUtils as c, Vector2 as l, Vector3 as u, WebGLRenderTarget as d } from "three";
|
|
4
|
+
//#region node_modules/three/examples/jsm/shaders/LuminosityHighPassShader.js
|
|
5
|
+
var f = {
|
|
6
|
+
name: "LuminosityHighPassShader",
|
|
7
|
+
uniforms: {
|
|
8
|
+
tDiffuse: { value: null },
|
|
9
|
+
luminosityThreshold: { value: 1 },
|
|
10
|
+
smoothWidth: { value: 1 },
|
|
11
|
+
defaultColor: { value: new i(0) },
|
|
12
|
+
defaultOpacity: { value: 0 }
|
|
13
|
+
},
|
|
14
|
+
vertexShader: "\n\n varying vec2 vUv;\n\n void main() {\n\n vUv = uv;\n\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n }",
|
|
15
|
+
fragmentShader: "\n\n uniform sampler2D tDiffuse;\n uniform vec3 defaultColor;\n uniform float defaultOpacity;\n uniform float luminosityThreshold;\n uniform float smoothWidth;\n\n varying vec2 vUv;\n\n void main() {\n\n vec4 texel = texture2D( tDiffuse, vUv );\n\n float v = luminance( texel.xyz );\n\n vec4 outputColor = vec4( defaultColor.rgb, defaultOpacity );\n\n float alpha = smoothstep( luminosityThreshold, luminosityThreshold + smoothWidth, v );\n\n gl_FragColor = mix( outputColor, texel, alpha );\n\n }"
|
|
16
|
+
}, p = class p extends t {
|
|
17
|
+
constructor(t, p = 1, m, h) {
|
|
18
|
+
super(), this.strength = p, this.radius = m, this.threshold = h, this.resolution = t === void 0 ? new l(256, 256) : new l(t.x, t.y), this.clearColor = new i(0, 0, 0), this.needsSwap = !1, this.renderTargetsHorizontal = [], this.renderTargetsVertical = [], this.nMips = 5;
|
|
19
|
+
let g = Math.round(this.resolution.x / 2), _ = Math.round(this.resolution.y / 2);
|
|
20
|
+
this.renderTargetBright = new d(g, _, { type: a }), this.renderTargetBright.texture.name = "UnrealBloomPass.bright", this.renderTargetBright.texture.generateMipmaps = !1;
|
|
21
|
+
for (let e = 0; e < this.nMips; e++) {
|
|
22
|
+
let t = new d(g, _, { type: a });
|
|
23
|
+
t.texture.name = "UnrealBloomPass.h" + e, t.texture.generateMipmaps = !1, this.renderTargetsHorizontal.push(t);
|
|
24
|
+
let n = new d(g, _, { type: a });
|
|
25
|
+
n.texture.name = "UnrealBloomPass.v" + e, n.texture.generateMipmaps = !1, this.renderTargetsVertical.push(n), g = Math.round(g / 2), _ = Math.round(_ / 2);
|
|
26
|
+
}
|
|
27
|
+
let v = f;
|
|
28
|
+
this.highPassUniforms = c.clone(v.uniforms), this.highPassUniforms.luminosityThreshold.value = h, this.highPassUniforms.smoothWidth.value = .01, this.materialHighPassFilter = new s({
|
|
29
|
+
uniforms: this.highPassUniforms,
|
|
30
|
+
vertexShader: v.vertexShader,
|
|
31
|
+
fragmentShader: v.fragmentShader
|
|
32
|
+
}), this.separableBlurMaterials = [];
|
|
33
|
+
let y = [
|
|
34
|
+
6,
|
|
35
|
+
10,
|
|
36
|
+
14,
|
|
37
|
+
18,
|
|
38
|
+
22
|
|
39
|
+
];
|
|
40
|
+
g = Math.round(this.resolution.x / 2), _ = Math.round(this.resolution.y / 2);
|
|
41
|
+
for (let e = 0; e < this.nMips; e++) this.separableBlurMaterials.push(this._getSeparableBlurMaterial(y[e])), this.separableBlurMaterials[e].uniforms.invSize.value = new l(1 / g, 1 / _), g = Math.round(g / 2), _ = Math.round(_ / 2);
|
|
42
|
+
this.compositeMaterial = this._getCompositeMaterial(this.nMips), this.compositeMaterial.uniforms.blurTexture1.value = this.renderTargetsVertical[0].texture, this.compositeMaterial.uniforms.blurTexture2.value = this.renderTargetsVertical[1].texture, this.compositeMaterial.uniforms.blurTexture3.value = this.renderTargetsVertical[2].texture, this.compositeMaterial.uniforms.blurTexture4.value = this.renderTargetsVertical[3].texture, this.compositeMaterial.uniforms.blurTexture5.value = this.renderTargetsVertical[4].texture, this.compositeMaterial.uniforms.bloomStrength.value = p, this.compositeMaterial.uniforms.bloomRadius.value = .1;
|
|
43
|
+
let b = [
|
|
44
|
+
1,
|
|
45
|
+
.8,
|
|
46
|
+
.6,
|
|
47
|
+
.4,
|
|
48
|
+
.2
|
|
49
|
+
];
|
|
50
|
+
this.compositeMaterial.uniforms.bloomFactors.value = b, this.bloomTintColors = [
|
|
51
|
+
new u(1, 1, 1),
|
|
52
|
+
new u(1, 1, 1),
|
|
53
|
+
new u(1, 1, 1),
|
|
54
|
+
new u(1, 1, 1),
|
|
55
|
+
new u(1, 1, 1)
|
|
56
|
+
], this.compositeMaterial.uniforms.bloomTintColors.value = this.bloomTintColors, this.copyUniforms = c.clone(e.uniforms), this.blendMaterial = new s({
|
|
57
|
+
uniforms: this.copyUniforms,
|
|
58
|
+
vertexShader: e.vertexShader,
|
|
59
|
+
fragmentShader: e.fragmentShader,
|
|
60
|
+
premultipliedAlpha: !0,
|
|
61
|
+
blending: r,
|
|
62
|
+
depthTest: !1,
|
|
63
|
+
depthWrite: !1,
|
|
64
|
+
transparent: !0
|
|
65
|
+
}), this._oldClearColor = new i(), this._oldClearAlpha = 1, this._basic = new o(), this._fsQuad = new n(null);
|
|
66
|
+
}
|
|
67
|
+
dispose() {
|
|
68
|
+
for (let e = 0; e < this.renderTargetsHorizontal.length; e++) this.renderTargetsHorizontal[e].dispose();
|
|
69
|
+
for (let e = 0; e < this.renderTargetsVertical.length; e++) this.renderTargetsVertical[e].dispose();
|
|
70
|
+
this.renderTargetBright.dispose();
|
|
71
|
+
for (let e = 0; e < this.separableBlurMaterials.length; e++) this.separableBlurMaterials[e].dispose();
|
|
72
|
+
this.compositeMaterial.dispose(), this.blendMaterial.dispose(), this._basic.dispose(), this._fsQuad.dispose();
|
|
73
|
+
}
|
|
74
|
+
setSize(e, t) {
|
|
75
|
+
let n = Math.round(e / 2), r = Math.round(t / 2);
|
|
76
|
+
this.renderTargetBright.setSize(n, r);
|
|
77
|
+
for (let e = 0; e < this.nMips; e++) this.renderTargetsHorizontal[e].setSize(n, r), this.renderTargetsVertical[e].setSize(n, r), this.separableBlurMaterials[e].uniforms.invSize.value = new l(1 / n, 1 / r), n = Math.round(n / 2), r = Math.round(r / 2);
|
|
78
|
+
}
|
|
79
|
+
render(e, t, n, r, i) {
|
|
80
|
+
e.getClearColor(this._oldClearColor), this._oldClearAlpha = e.getClearAlpha();
|
|
81
|
+
let a = e.autoClear;
|
|
82
|
+
e.autoClear = !1, e.setClearColor(this.clearColor, 0), i && e.state.buffers.stencil.setTest(!1), this.renderToScreen && (this._fsQuad.material = this._basic, this._basic.map = n.texture, e.setRenderTarget(null), e.clear(), this._fsQuad.render(e)), this.highPassUniforms.tDiffuse.value = n.texture, this.highPassUniforms.luminosityThreshold.value = this.threshold, this._fsQuad.material = this.materialHighPassFilter, e.setRenderTarget(this.renderTargetBright), e.clear(), this._fsQuad.render(e);
|
|
83
|
+
let o = this.renderTargetBright;
|
|
84
|
+
for (let t = 0; t < this.nMips; t++) this._fsQuad.material = this.separableBlurMaterials[t], this.separableBlurMaterials[t].uniforms.colorTexture.value = o.texture, this.separableBlurMaterials[t].uniforms.direction.value = p.BlurDirectionX, e.setRenderTarget(this.renderTargetsHorizontal[t]), e.clear(), this._fsQuad.render(e), this.separableBlurMaterials[t].uniforms.colorTexture.value = this.renderTargetsHorizontal[t].texture, this.separableBlurMaterials[t].uniforms.direction.value = p.BlurDirectionY, e.setRenderTarget(this.renderTargetsVertical[t]), e.clear(), this._fsQuad.render(e), o = this.renderTargetsVertical[t];
|
|
85
|
+
this._fsQuad.material = this.compositeMaterial, this.compositeMaterial.uniforms.bloomStrength.value = this.strength, this.compositeMaterial.uniforms.bloomRadius.value = this.radius, this.compositeMaterial.uniforms.bloomTintColors.value = this.bloomTintColors, e.setRenderTarget(this.renderTargetsHorizontal[0]), e.clear(), this._fsQuad.render(e), this._fsQuad.material = this.blendMaterial, this.copyUniforms.tDiffuse.value = this.renderTargetsHorizontal[0].texture, i && e.state.buffers.stencil.setTest(!0), this.renderToScreen ? (e.setRenderTarget(null), this._fsQuad.render(e)) : (e.setRenderTarget(n), this._fsQuad.render(e)), e.setClearColor(this._oldClearColor, this._oldClearAlpha), e.autoClear = a;
|
|
86
|
+
}
|
|
87
|
+
_getSeparableBlurMaterial(e) {
|
|
88
|
+
let t = [], n = e / 3;
|
|
89
|
+
for (let r = 0; r < e; r++) t.push(.39894 * Math.exp(-.5 * r * r / (n * n)) / n);
|
|
90
|
+
return new s({
|
|
91
|
+
defines: { KERNEL_RADIUS: e },
|
|
92
|
+
uniforms: {
|
|
93
|
+
colorTexture: { value: null },
|
|
94
|
+
invSize: { value: new l(.5, .5) },
|
|
95
|
+
direction: { value: new l(.5, .5) },
|
|
96
|
+
gaussianCoefficients: { value: t }
|
|
97
|
+
},
|
|
98
|
+
vertexShader: "\n\n varying vec2 vUv;\n\n void main() {\n\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n }",
|
|
99
|
+
fragmentShader: "\n\n #include <common>\n\n varying vec2 vUv;\n\n uniform sampler2D colorTexture;\n uniform vec2 invSize;\n uniform vec2 direction;\n uniform float gaussianCoefficients[KERNEL_RADIUS];\n\n void main() {\n\n float weightSum = gaussianCoefficients[0];\n vec3 diffuseSum = texture2D( colorTexture, vUv ).rgb * weightSum;\n\n for ( int i = 1; i < KERNEL_RADIUS; i ++ ) {\n\n float x = float( i );\n float w = gaussianCoefficients[i];\n vec2 uvOffset = direction * invSize * x;\n vec3 sample1 = texture2D( colorTexture, vUv + uvOffset ).rgb;\n vec3 sample2 = texture2D( colorTexture, vUv - uvOffset ).rgb;\n diffuseSum += ( sample1 + sample2 ) * w;\n\n }\n\n gl_FragColor = vec4( diffuseSum, 1.0 );\n\n }"
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
_getCompositeMaterial(e) {
|
|
103
|
+
return new s({
|
|
104
|
+
defines: { NUM_MIPS: e },
|
|
105
|
+
uniforms: {
|
|
106
|
+
blurTexture1: { value: null },
|
|
107
|
+
blurTexture2: { value: null },
|
|
108
|
+
blurTexture3: { value: null },
|
|
109
|
+
blurTexture4: { value: null },
|
|
110
|
+
blurTexture5: { value: null },
|
|
111
|
+
bloomStrength: { value: 1 },
|
|
112
|
+
bloomFactors: { value: null },
|
|
113
|
+
bloomTintColors: { value: null },
|
|
114
|
+
bloomRadius: { value: 0 }
|
|
115
|
+
},
|
|
116
|
+
vertexShader: "\n\n varying vec2 vUv;\n\n void main() {\n\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n }",
|
|
117
|
+
fragmentShader: "\n\n varying vec2 vUv;\n\n uniform sampler2D blurTexture1;\n uniform sampler2D blurTexture2;\n uniform sampler2D blurTexture3;\n uniform sampler2D blurTexture4;\n uniform sampler2D blurTexture5;\n uniform float bloomStrength;\n uniform float bloomRadius;\n uniform float bloomFactors[NUM_MIPS];\n uniform vec3 bloomTintColors[NUM_MIPS];\n\n float lerpBloomFactor( const in float factor ) {\n\n float mirrorFactor = 1.2 - factor;\n return mix( factor, mirrorFactor, bloomRadius );\n\n }\n\n void main() {\n\n // 3.0 for backwards compatibility with previous alpha-based intensity\n vec3 bloom = 3.0 * bloomStrength * (\n lerpBloomFactor( bloomFactors[ 0 ] ) * bloomTintColors[ 0 ] * texture2D( blurTexture1, vUv ).rgb +\n lerpBloomFactor( bloomFactors[ 1 ] ) * bloomTintColors[ 1 ] * texture2D( blurTexture2, vUv ).rgb +\n lerpBloomFactor( bloomFactors[ 2 ] ) * bloomTintColors[ 2 ] * texture2D( blurTexture3, vUv ).rgb +\n lerpBloomFactor( bloomFactors[ 3 ] ) * bloomTintColors[ 3 ] * texture2D( blurTexture4, vUv ).rgb +\n lerpBloomFactor( bloomFactors[ 4 ] ) * bloomTintColors[ 4 ] * texture2D( blurTexture5, vUv ).rgb\n );\n\n float bloomAlpha = max( bloom.r, max( bloom.g, bloom.b ) );\n gl_FragColor = vec4( bloom, bloomAlpha );\n\n }"
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
p.BlurDirectionX = new l(1, 0), p.BlurDirectionY = new l(0, 1);
|
|
122
|
+
//#endregion
|
|
123
|
+
export { p as UnrealBloomPass };
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
const e=require("./CopyShader-CM1OGKAp.cjs"),t=require("./Pass-D0vYi-gB.cjs");let n=require("three");var r={name:`LuminosityHighPassShader`,uniforms:{tDiffuse:{value:null},luminosityThreshold:{value:1},smoothWidth:{value:1},defaultColor:{value:new n.Color(0)},defaultOpacity:{value:0}},vertexShader:`
|
|
2
|
+
|
|
3
|
+
varying vec2 vUv;
|
|
4
|
+
|
|
5
|
+
void main() {
|
|
6
|
+
|
|
7
|
+
vUv = uv;
|
|
8
|
+
|
|
9
|
+
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
|
10
|
+
|
|
11
|
+
}`,fragmentShader:`
|
|
12
|
+
|
|
13
|
+
uniform sampler2D tDiffuse;
|
|
14
|
+
uniform vec3 defaultColor;
|
|
15
|
+
uniform float defaultOpacity;
|
|
16
|
+
uniform float luminosityThreshold;
|
|
17
|
+
uniform float smoothWidth;
|
|
18
|
+
|
|
19
|
+
varying vec2 vUv;
|
|
20
|
+
|
|
21
|
+
void main() {
|
|
22
|
+
|
|
23
|
+
vec4 texel = texture2D( tDiffuse, vUv );
|
|
24
|
+
|
|
25
|
+
float v = luminance( texel.xyz );
|
|
26
|
+
|
|
27
|
+
vec4 outputColor = vec4( defaultColor.rgb, defaultOpacity );
|
|
28
|
+
|
|
29
|
+
float alpha = smoothstep( luminosityThreshold, luminosityThreshold + smoothWidth, v );
|
|
30
|
+
|
|
31
|
+
gl_FragColor = mix( outputColor, texel, alpha );
|
|
32
|
+
|
|
33
|
+
}`},i=class i extends t.n{constructor(i,a=1,o,s){super(),this.strength=a,this.radius=o,this.threshold=s,this.resolution=i===void 0?new n.Vector2(256,256):new n.Vector2(i.x,i.y),this.clearColor=new n.Color(0,0,0),this.needsSwap=!1,this.renderTargetsHorizontal=[],this.renderTargetsVertical=[],this.nMips=5;let c=Math.round(this.resolution.x/2),l=Math.round(this.resolution.y/2);this.renderTargetBright=new n.WebGLRenderTarget(c,l,{type:n.HalfFloatType}),this.renderTargetBright.texture.name=`UnrealBloomPass.bright`,this.renderTargetBright.texture.generateMipmaps=!1;for(let e=0;e<this.nMips;e++){let t=new n.WebGLRenderTarget(c,l,{type:n.HalfFloatType});t.texture.name=`UnrealBloomPass.h`+e,t.texture.generateMipmaps=!1,this.renderTargetsHorizontal.push(t);let r=new n.WebGLRenderTarget(c,l,{type:n.HalfFloatType});r.texture.name=`UnrealBloomPass.v`+e,r.texture.generateMipmaps=!1,this.renderTargetsVertical.push(r),c=Math.round(c/2),l=Math.round(l/2)}let u=r;this.highPassUniforms=n.UniformsUtils.clone(u.uniforms),this.highPassUniforms.luminosityThreshold.value=s,this.highPassUniforms.smoothWidth.value=.01,this.materialHighPassFilter=new n.ShaderMaterial({uniforms:this.highPassUniforms,vertexShader:u.vertexShader,fragmentShader:u.fragmentShader}),this.separableBlurMaterials=[];let d=[6,10,14,18,22];c=Math.round(this.resolution.x/2),l=Math.round(this.resolution.y/2);for(let e=0;e<this.nMips;e++)this.separableBlurMaterials.push(this._getSeparableBlurMaterial(d[e])),this.separableBlurMaterials[e].uniforms.invSize.value=new n.Vector2(1/c,1/l),c=Math.round(c/2),l=Math.round(l/2);this.compositeMaterial=this._getCompositeMaterial(this.nMips),this.compositeMaterial.uniforms.blurTexture1.value=this.renderTargetsVertical[0].texture,this.compositeMaterial.uniforms.blurTexture2.value=this.renderTargetsVertical[1].texture,this.compositeMaterial.uniforms.blurTexture3.value=this.renderTargetsVertical[2].texture,this.compositeMaterial.uniforms.blurTexture4.value=this.renderTargetsVertical[3].texture,this.compositeMaterial.uniforms.blurTexture5.value=this.renderTargetsVertical[4].texture,this.compositeMaterial.uniforms.bloomStrength.value=a,this.compositeMaterial.uniforms.bloomRadius.value=.1;let f=[1,.8,.6,.4,.2];this.compositeMaterial.uniforms.bloomFactors.value=f,this.bloomTintColors=[new n.Vector3(1,1,1),new n.Vector3(1,1,1),new n.Vector3(1,1,1),new n.Vector3(1,1,1),new n.Vector3(1,1,1)],this.compositeMaterial.uniforms.bloomTintColors.value=this.bloomTintColors,this.copyUniforms=n.UniformsUtils.clone(e.t.uniforms),this.blendMaterial=new n.ShaderMaterial({uniforms:this.copyUniforms,vertexShader:e.t.vertexShader,fragmentShader:e.t.fragmentShader,premultipliedAlpha:!0,blending:n.AdditiveBlending,depthTest:!1,depthWrite:!1,transparent:!0}),this._oldClearColor=new n.Color,this._oldClearAlpha=1,this._basic=new n.MeshBasicMaterial,this._fsQuad=new t.t(null)}dispose(){for(let e=0;e<this.renderTargetsHorizontal.length;e++)this.renderTargetsHorizontal[e].dispose();for(let e=0;e<this.renderTargetsVertical.length;e++)this.renderTargetsVertical[e].dispose();this.renderTargetBright.dispose();for(let e=0;e<this.separableBlurMaterials.length;e++)this.separableBlurMaterials[e].dispose();this.compositeMaterial.dispose(),this.blendMaterial.dispose(),this._basic.dispose(),this._fsQuad.dispose()}setSize(e,t){let r=Math.round(e/2),i=Math.round(t/2);this.renderTargetBright.setSize(r,i);for(let e=0;e<this.nMips;e++)this.renderTargetsHorizontal[e].setSize(r,i),this.renderTargetsVertical[e].setSize(r,i),this.separableBlurMaterials[e].uniforms.invSize.value=new n.Vector2(1/r,1/i),r=Math.round(r/2),i=Math.round(i/2)}render(e,t,n,r,a){e.getClearColor(this._oldClearColor),this._oldClearAlpha=e.getClearAlpha();let o=e.autoClear;e.autoClear=!1,e.setClearColor(this.clearColor,0),a&&e.state.buffers.stencil.setTest(!1),this.renderToScreen&&(this._fsQuad.material=this._basic,this._basic.map=n.texture,e.setRenderTarget(null),e.clear(),this._fsQuad.render(e)),this.highPassUniforms.tDiffuse.value=n.texture,this.highPassUniforms.luminosityThreshold.value=this.threshold,this._fsQuad.material=this.materialHighPassFilter,e.setRenderTarget(this.renderTargetBright),e.clear(),this._fsQuad.render(e);let s=this.renderTargetBright;for(let t=0;t<this.nMips;t++)this._fsQuad.material=this.separableBlurMaterials[t],this.separableBlurMaterials[t].uniforms.colorTexture.value=s.texture,this.separableBlurMaterials[t].uniforms.direction.value=i.BlurDirectionX,e.setRenderTarget(this.renderTargetsHorizontal[t]),e.clear(),this._fsQuad.render(e),this.separableBlurMaterials[t].uniforms.colorTexture.value=this.renderTargetsHorizontal[t].texture,this.separableBlurMaterials[t].uniforms.direction.value=i.BlurDirectionY,e.setRenderTarget(this.renderTargetsVertical[t]),e.clear(),this._fsQuad.render(e),s=this.renderTargetsVertical[t];this._fsQuad.material=this.compositeMaterial,this.compositeMaterial.uniforms.bloomStrength.value=this.strength,this.compositeMaterial.uniforms.bloomRadius.value=this.radius,this.compositeMaterial.uniforms.bloomTintColors.value=this.bloomTintColors,e.setRenderTarget(this.renderTargetsHorizontal[0]),e.clear(),this._fsQuad.render(e),this._fsQuad.material=this.blendMaterial,this.copyUniforms.tDiffuse.value=this.renderTargetsHorizontal[0].texture,a&&e.state.buffers.stencil.setTest(!0),this.renderToScreen?(e.setRenderTarget(null),this._fsQuad.render(e)):(e.setRenderTarget(n),this._fsQuad.render(e)),e.setClearColor(this._oldClearColor,this._oldClearAlpha),e.autoClear=o}_getSeparableBlurMaterial(e){let t=[],r=e/3;for(let n=0;n<e;n++)t.push(.39894*Math.exp(-.5*n*n/(r*r))/r);return new n.ShaderMaterial({defines:{KERNEL_RADIUS:e},uniforms:{colorTexture:{value:null},invSize:{value:new n.Vector2(.5,.5)},direction:{value:new n.Vector2(.5,.5)},gaussianCoefficients:{value:t}},vertexShader:`
|
|
34
|
+
|
|
35
|
+
varying vec2 vUv;
|
|
36
|
+
|
|
37
|
+
void main() {
|
|
38
|
+
|
|
39
|
+
vUv = uv;
|
|
40
|
+
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
|
41
|
+
|
|
42
|
+
}`,fragmentShader:`
|
|
43
|
+
|
|
44
|
+
#include <common>
|
|
45
|
+
|
|
46
|
+
varying vec2 vUv;
|
|
47
|
+
|
|
48
|
+
uniform sampler2D colorTexture;
|
|
49
|
+
uniform vec2 invSize;
|
|
50
|
+
uniform vec2 direction;
|
|
51
|
+
uniform float gaussianCoefficients[KERNEL_RADIUS];
|
|
52
|
+
|
|
53
|
+
void main() {
|
|
54
|
+
|
|
55
|
+
float weightSum = gaussianCoefficients[0];
|
|
56
|
+
vec3 diffuseSum = texture2D( colorTexture, vUv ).rgb * weightSum;
|
|
57
|
+
|
|
58
|
+
for ( int i = 1; i < KERNEL_RADIUS; i ++ ) {
|
|
59
|
+
|
|
60
|
+
float x = float( i );
|
|
61
|
+
float w = gaussianCoefficients[i];
|
|
62
|
+
vec2 uvOffset = direction * invSize * x;
|
|
63
|
+
vec3 sample1 = texture2D( colorTexture, vUv + uvOffset ).rgb;
|
|
64
|
+
vec3 sample2 = texture2D( colorTexture, vUv - uvOffset ).rgb;
|
|
65
|
+
diffuseSum += ( sample1 + sample2 ) * w;
|
|
66
|
+
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
gl_FragColor = vec4( diffuseSum, 1.0 );
|
|
70
|
+
|
|
71
|
+
}`})}_getCompositeMaterial(e){return new n.ShaderMaterial({defines:{NUM_MIPS:e},uniforms:{blurTexture1:{value:null},blurTexture2:{value:null},blurTexture3:{value:null},blurTexture4:{value:null},blurTexture5:{value:null},bloomStrength:{value:1},bloomFactors:{value:null},bloomTintColors:{value:null},bloomRadius:{value:0}},vertexShader:`
|
|
72
|
+
|
|
73
|
+
varying vec2 vUv;
|
|
74
|
+
|
|
75
|
+
void main() {
|
|
76
|
+
|
|
77
|
+
vUv = uv;
|
|
78
|
+
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
|
79
|
+
|
|
80
|
+
}`,fragmentShader:`
|
|
81
|
+
|
|
82
|
+
varying vec2 vUv;
|
|
83
|
+
|
|
84
|
+
uniform sampler2D blurTexture1;
|
|
85
|
+
uniform sampler2D blurTexture2;
|
|
86
|
+
uniform sampler2D blurTexture3;
|
|
87
|
+
uniform sampler2D blurTexture4;
|
|
88
|
+
uniform sampler2D blurTexture5;
|
|
89
|
+
uniform float bloomStrength;
|
|
90
|
+
uniform float bloomRadius;
|
|
91
|
+
uniform float bloomFactors[NUM_MIPS];
|
|
92
|
+
uniform vec3 bloomTintColors[NUM_MIPS];
|
|
93
|
+
|
|
94
|
+
float lerpBloomFactor( const in float factor ) {
|
|
95
|
+
|
|
96
|
+
float mirrorFactor = 1.2 - factor;
|
|
97
|
+
return mix( factor, mirrorFactor, bloomRadius );
|
|
98
|
+
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
void main() {
|
|
102
|
+
|
|
103
|
+
// 3.0 for backwards compatibility with previous alpha-based intensity
|
|
104
|
+
vec3 bloom = 3.0 * bloomStrength * (
|
|
105
|
+
lerpBloomFactor( bloomFactors[ 0 ] ) * bloomTintColors[ 0 ] * texture2D( blurTexture1, vUv ).rgb +
|
|
106
|
+
lerpBloomFactor( bloomFactors[ 1 ] ) * bloomTintColors[ 1 ] * texture2D( blurTexture2, vUv ).rgb +
|
|
107
|
+
lerpBloomFactor( bloomFactors[ 2 ] ) * bloomTintColors[ 2 ] * texture2D( blurTexture3, vUv ).rgb +
|
|
108
|
+
lerpBloomFactor( bloomFactors[ 3 ] ) * bloomTintColors[ 3 ] * texture2D( blurTexture4, vUv ).rgb +
|
|
109
|
+
lerpBloomFactor( bloomFactors[ 4 ] ) * bloomTintColors[ 4 ] * texture2D( blurTexture5, vUv ).rgb
|
|
110
|
+
);
|
|
111
|
+
|
|
112
|
+
float bloomAlpha = max( bloom.r, max( bloom.g, bloom.b ) );
|
|
113
|
+
gl_FragColor = vec4( bloom, bloomAlpha );
|
|
114
|
+
|
|
115
|
+
}`})}};i.BlurDirectionX=new n.Vector2(1,0),i.BlurDirectionY=new n.Vector2(0,1),exports.UnrealBloomPass=i;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
//#region node_modules/three/examples/jsm/shaders/VignetteShader.js
|
|
2
|
+
var e = {
|
|
3
|
+
name: "VignetteShader",
|
|
4
|
+
uniforms: {
|
|
5
|
+
tDiffuse: { value: null },
|
|
6
|
+
offset: { value: 1 },
|
|
7
|
+
darkness: { value: 1 }
|
|
8
|
+
},
|
|
9
|
+
vertexShader: "\n\n varying vec2 vUv;\n\n void main() {\n\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n }",
|
|
10
|
+
fragmentShader: "\n\n uniform float offset;\n uniform float darkness;\n\n uniform sampler2D tDiffuse;\n\n varying vec2 vUv;\n\n void main() {\n\n // Eskil's vignette\n\n vec4 texel = texture2D( tDiffuse, vUv );\n vec2 uv = ( vUv - vec2( 0.5 ) ) * vec2( offset );\n gl_FragColor = vec4( mix( texel.rgb, vec3( 1.0 - darkness ), dot( uv, uv ) ), texel.a );\n\n }"
|
|
11
|
+
};
|
|
12
|
+
//#endregion
|
|
13
|
+
export { e as VignetteShader };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
var e={name:`VignetteShader`,uniforms:{tDiffuse:{value:null},offset:{value:1},darkness:{value:1}},vertexShader:`
|
|
2
2
|
|
|
3
3
|
varying vec2 vUv;
|
|
4
4
|
|
|
@@ -24,4 +24,4 @@
|
|
|
24
24
|
vec2 uv = ( vUv - vec2( 0.5 ) ) * vec2( offset );
|
|
25
25
|
gl_FragColor = vec4( mix( texel.rgb, vec3( 1.0 - darkness ), dot( uv, uv ) ), texel.a );
|
|
26
26
|
|
|
27
|
-
}`};exports.VignetteShader=e;
|
|
27
|
+
}`};exports.VignetteShader=e;
|
package/dist/index.d.cts
CHANGED
|
@@ -171,6 +171,13 @@ export declare interface DirectionalLightOptions {
|
|
|
171
171
|
};
|
|
172
172
|
/** Depth offset against shadow acne (self-shadowing stripes). */
|
|
173
173
|
bias?: number;
|
|
174
|
+
/**
|
|
175
|
+
* WORLD-SPACE offset along the receiver's normal against shadow acne.
|
|
176
|
+
* Unlike `bias` (normalized depth, whose world effect scales with the
|
|
177
|
+
* fitted camera range), this is absolute — the scale-correct escape hatch
|
|
178
|
+
* if acne ever shows on a model's own surfaces.
|
|
179
|
+
*/
|
|
180
|
+
normalBias?: number;
|
|
174
181
|
/** Shadow edge blur in shadow-map texels. */
|
|
175
182
|
radius?: number;
|
|
176
183
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -171,6 +171,13 @@ export declare interface DirectionalLightOptions {
|
|
|
171
171
|
};
|
|
172
172
|
/** Depth offset against shadow acne (self-shadowing stripes). */
|
|
173
173
|
bias?: number;
|
|
174
|
+
/**
|
|
175
|
+
* WORLD-SPACE offset along the receiver's normal against shadow acne.
|
|
176
|
+
* Unlike `bias` (normalized depth, whose world effect scales with the
|
|
177
|
+
* fitted camera range), this is absolute — the scale-correct escape hatch
|
|
178
|
+
* if acne ever shows on a model's own surfaces.
|
|
179
|
+
*/
|
|
180
|
+
normalBias?: number;
|
|
174
181
|
/** Shadow edge blur in shadow-map texels. */
|
|
175
182
|
radius?: number;
|
|
176
183
|
};
|