Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitba92ef5

Browse files
committed
Create LuminanceHighPassMaterial
1 parentcfd7f6d commitba92ef5

File tree

5 files changed

+91
-7
lines changed

5 files changed

+91
-7
lines changed

‎src/effects/BloomEffect.ts‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import{Uniform}from"three";
22
import{LuminancePass}from"../passes/LuminancePass.js";
33
import{MipmapBlurPass,MipmapBlurPassOptions}from"../passes/MipmapBlurPass.js";
4-
import{LuminanceMaterial}from"../materials/LuminanceMaterial.js";
4+
import{LuminanceHighPassMaterial}from"../materials/LuminanceHighPassMaterial.js";
55
import{AddBlendFunction}from"./blending/blend-functions/AddBlendFunction.js";
66
import{Effect}from"./Effect.js";
77

@@ -92,7 +92,6 @@ export class BloomEffect extends Effect implements BloomEffectOptions {
9292
constluminanceMaterial=this.luminanceMaterial;
9393
luminanceMaterial.threshold=luminanceThreshold;
9494
luminanceMaterial.smoothing=luminanceSmoothing;
95-
luminanceMaterial.colorOutput=true;
9695

9796
constmipmapBlurPass=newMipmapBlurPass({ levels, radius, fullResolutionUpsampling, clampToBorder});
9897
this.mipmapBlurPass=mipmapBlurPass;
@@ -110,7 +109,7 @@ export class BloomEffect extends Effect implements BloomEffectOptions {
110109
* The luminance high-pass material.
111110
*/
112111

113-
getluminanceMaterial():LuminanceMaterial{
112+
getluminanceMaterial():LuminanceHighPassMaterial{
114113

115114
returnthis.luminancePass.fullscreenMaterial;
116115

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
import{Uniform}from"three";
2+
import{FullscreenMaterial}from"./FullscreenMaterial.js";
3+
4+
importfragmentShaderfrom"./shaders/luminance-high-pass.frag";
5+
importvertexShaderfrom"./shaders/common.vert";
6+
7+
/**
8+
* A luminance high-pass shader material.
9+
*
10+
*@see https://www.poynton.com/notes/colour_and_gamma/ColorFAQ.html#RTFToC9
11+
*@see https://hsto.org/getpro/habr/post_images/2ab/69d/084/2ab69d084f9a597e032624bcd74d57a7.png
12+
*@category Materials
13+
*/
14+
15+
exportclassLuminanceHighPassMaterialextendsFullscreenMaterial{
16+
17+
/**
18+
* Constructs a new luminance high-pass material.
19+
*/
20+
21+
constructor(){
22+
23+
super({
24+
name:"LuminanceHighPassMaterial",
25+
fragmentShader,
26+
vertexShader,
27+
uniforms:{
28+
threshold:newUniform(0.0),
29+
smoothing:newUniform(0.0)
30+
}
31+
});
32+
33+
}
34+
35+
/**
36+
* The luminance threshold.
37+
*/
38+
39+
getthreshold():number{
40+
41+
returnthis.uniforms.threshold.valueasnumber;
42+
43+
}
44+
45+
setthreshold(value:number){
46+
47+
this.uniforms.threshold.value=value;
48+
49+
}
50+
51+
/**
52+
* The luminance smoothing.
53+
*/
54+
55+
getsmoothing():number{
56+
57+
returnthis.uniforms.smoothing.valueasnumber;
58+
59+
}
60+
61+
setsmoothing(value:number){
62+
63+
this.uniforms.smoothing.value=value;
64+
65+
}
66+
67+
}

‎src/materials/index.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export * from "./EffectMaterial.js";
1212
export*from"./FullscreenMaterial.js";
1313
export*from"./GaussianBlurMaterial.js";
1414
export*from"./KawaseBlurMaterial.js";
15-
export*from"./LuminanceMaterial.js";
15+
export*from"./LuminanceHighPassMaterial.js";
1616
export*from"./MaskMaterial.js";
1717
export*from"./SkyBoxMaterial.js";
1818
export*from"./SMAAEdgeDetectionMaterial.js";
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#include<common>
2+
#include<pp_default_output_pars_fragment>
3+
#include<pp_input_buffer_pars_fragment>
4+
5+
uniformfloat threshold;
6+
uniformfloat smoothing;
7+
8+
invec2 vUv;
9+
10+
void main() {
11+
12+
vec4 texel= texture(inputBuffer, vUv);
13+
float l= luminance(texel.rgb);
14+
float mask=smoothstep(threshold, threshold+ smoothing, l);
15+
16+
out_Color= texel* mask;
17+
18+
}

‎src/passes/LuminancePass.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import{WebGLRenderTarget}from"three";
22
import{TextureResource}from"../core/io/TextureResource.js";
33
import{Pass}from"../core/Pass.js";
4-
import{LuminanceMaterial}from"../materials/LuminanceMaterial.js";
4+
import{LuminanceHighPassMaterial}from"../materials/LuminanceHighPassMaterial.js";
55

66
/**
77
* A luminance pass.
88
*
99
*@category Passes
1010
*/
1111

12-
exportclassLuminancePassextendsPass<LuminanceMaterial>{
12+
exportclassLuminancePassextendsPass<LuminanceHighPassMaterial>{
1313

1414
/**
1515
* Identifies the luminance output buffer.
@@ -26,7 +26,7 @@ export class LuminancePass extends Pass<LuminanceMaterial> {
2626
super("LuminancePass");
2727

2828
this.output.setBuffer(LuminancePass.BUFFER_LUMINANCE,this.createFramebuffer());
29-
this.fullscreenMaterial=newLuminanceMaterial();
29+
this.fullscreenMaterial=newLuminanceHighPassMaterial();
3030

3131
}
3232

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp