Skip to content

Commit 81e85ce

Browse files
author
v1rtl
committedApr 30, 2023
fmt markdown and rearrange docs
1 parent bd7481d commit 81e85ce

File tree

9 files changed

+200
-603
lines changed

9 files changed

+200
-603
lines changed
 

‎CODE_OF_CONDUCT.md

+13-13
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,22 @@ appearance, race, religion, or sexual identity and orientation.
1414
Examples of behavior that contributes to creating a positive environment
1515
include:
1616

17-
* Using welcoming and inclusive language
18-
* Being respectful of differing viewpoints and experiences
19-
* Gracefully accepting constructive criticism
20-
* Focusing on what is best for the community
21-
* Showing empathy towards other community members
17+
- Using welcoming and inclusive language
18+
- Being respectful of differing viewpoints and experiences
19+
- Gracefully accepting constructive criticism
20+
- Focusing on what is best for the community
21+
- Showing empathy towards other community members
2222

2323
Examples of unacceptable behavior by participants include:
2424

25-
* The use of sexualized language or imagery and unwelcome sexual attention or
26-
advances
27-
* Trolling, insulting/derogatory comments, and personal or political attacks
28-
* Public or private harassment
29-
* Publishing others' private information, such as a physical or electronic
30-
address, without explicit permission
31-
* Other conduct which could reasonably be considered inappropriate in a
32-
professional setting
25+
- The use of sexualized language or imagery and unwelcome sexual attention or
26+
advances
27+
- Trolling, insulting/derogatory comments, and personal or political attacks
28+
- Public or private harassment
29+
- Publishing others' private information, such as a physical or electronic
30+
address, without explicit permission
31+
- Other conduct which could reasonably be considered inappropriate in a
32+
professional setting
3333

3434
## Our Responsibilities
3535

‎README.md

+25-96
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,12 @@
44
[![Downloads](https://img.shields.io/npm/dt/@react-three/postprocessing.svg?style=flat&colorA=000000&colorB=000000)](https://www.npmjs.com/package/@react-three/postprocessing)
55
[![Discord Shield](https://img.shields.io/discord/740090768164651008?style=flat&colorA=000000&colorB=000000&label=discord&logo=discord&logoColor=ffffff)](https://discord.gg/ZZjjNvJ)
66

7-
`react-postprocessing` is a [postprocessing](https://github.com/pmndrs/postprocessing) wrapper for [@react-three/fiber](https://github.com/pmndrs/react-three-fiber). This is not (yet) meant for complex orchestration of effects, but can save you [hundreds of LOC](https://twitter.com/0xca0a/status/1289501594698960897) for a straight forward effects-chain.
7+
`react-postprocessing` is a
8+
[postprocessing](https://github.com/pmndrs/postprocessing) wrapper for
9+
[@react-three/fiber](https://github.com/pmndrs/react-three-fiber). This is not
10+
(yet) meant for complex orchestration of effects, but can save you
11+
[hundreds of LOC](https://twitter.com/0xca0a/status/1289501594698960897) for a
12+
straight forward effects-chain.
813

914
```bash
1015
npm install @react-three/postprocessing
@@ -20,25 +25,37 @@ npm install @react-three/postprocessing
2025

2126
#### Why postprocessing and not three/examples/jsm/postprocessing?
2227

23-
From [https://github.com/pmndrs/postprocessing](https://github.com/pmndrs/postprocessing#performance)
28+
From
29+
[https://github.com/pmndrs/postprocessing](https://github.com/pmndrs/postprocessing#performance)
2430

25-
> This library provides an EffectPass which automatically organizes and merges any given combination of effects. This minimizes the amount of render operations and makes it possible to combine many effects without the performance penalties of traditional pass chaining. Additionally, every effect can choose its own blend function.
31+
> This library provides an EffectPass which automatically organizes and merges
32+
> any given combination of effects. This minimizes the amount of render
33+
> operations and makes it possible to combine many effects without the
34+
> performance penalties of traditional pass chaining. Additionally, every effect
35+
> can choose its own blend function.
2636
>
27-
> All fullscreen render operations also use a single triangle that fills the screen. Compared to using a quad, this approach harmonizes with modern GPU rasterization patterns and eliminates unnecessary fragment calculations along the screen diagonal. This is especially beneficial for GPGPU passes and effects that use complex fragment shaders.
37+
> All fullscreen render operations also use a single triangle that fills the
38+
> screen. Compared to using a quad, this approach harmonizes with modern GPU
39+
> rasterization patterns and eliminates unnecessary fragment calculations along
40+
> the screen diagonal. This is especially beneficial for GPGPU passes and
41+
> effects that use complex fragment shaders.
2842
29-
Postprocessing also supports srgb-encoding out of the box, as well as WebGL2 MSAA (multi sample anti aliasing), which is react-postprocessing's default, you get high performance crisp results w/o jagged edges.
43+
Postprocessing also supports srgb-encoding out of the box, as well as WebGL2
44+
MSAA (multi sample anti aliasing), which is react-postprocessing's default, you
45+
get high performance crisp results w/o jagged edges.
3046

3147
#### What does it look like?
3248

33-
Here's an example combining a couple of effects ([live demo](https://codesandbox.io/s/react-postprocessing-dof-blob-pqrpl?)).
49+
Here's an example combining a couple of effects
50+
([live demo](https://codesandbox.io/s/react-postprocessing-dof-blob-pqrpl?)).
3451

3552
<a href="https://codesandbox.io/s/react-postprocessing-dof-blob-pqrpl?" target="_blank" rel="noopener">
3653
<img src="bubbles.jpg" alt="Bubbles Demo" />
3754
</a>
3855

3956
```jsx
4057
import React from 'react'
41-
import { EffectComposer, DepthOfField, Bloom, Noise, Vignette } from '@react-three/postprocessing'
58+
import { Bloom, DepthOfField, EffectComposer, Noise, Vignette } from '@react-three/postprocessing'
4259
import { Canvas } from '@react-three/fiber'
4360

4461
function App() {
@@ -58,93 +75,5 @@ function App() {
5875

5976
## Documentation
6077

61-
#### EffectComposer
62-
63-
The EffectComposer must wrap all your effects. It will manage them for you.
64-
65-
```jsx
66-
<EffectComposer
67-
enabled?: boolean
68-
children: JSX.Element | JSX.Element[]
69-
depthBuffer?: boolean
70-
disableNormalPass?: boolean
71-
stencilBuffer?: boolean
72-
autoClear?: boolean
73-
multisampling?: number
74-
frameBufferType?: TextureDataType
75-
/** For effects that support DepthDownsamplingPass */
76-
resolutionScale?: number
77-
renderPriority?: number
78-
camera?: THREE.Camera
79-
scene?: THREE.Scene
80-
>
81-
```
82-
83-
#### Selection/Select
84-
85-
Some effects, like Outline or SelectiveBloom can select specific objects. To manage this in a declarative scene with just references can be messy, especially when things have to be grouped. These two components take care of it:
86-
87-
```jsx
88-
<Selection
89-
children: JSX.Element | JSX.Element[]
90-
enabled?: boolean
91-
>
92-
93-
<Select
94-
children: JSX.Element | JSX.Element[]
95-
enabled?: boolean
96-
>
97-
```
98-
99-
You wrap everything into a selection, this one holds all the selections. Now you can individually select objects or groups. Effects that support selections (for instance `Outline`) will acknowledge it.
100-
101-
```jsx
102-
<Selection>
103-
<EffectComposer autoclear={false}>
104-
<Outline blur edgeStrength={100} />
105-
</EffectComposer>
106-
<Select enabled>
107-
<mesh />
108-
</Select>
109-
</Selection>
110-
```
111-
112-
Selection can be nested and group multiple object, higher up selection take precence over lower ones. The following for instance will select everything. Remove the outmost `enabled` and only the two mesh group is selected. You can flip the selections or bind them to interactions and state.
113-
114-
```jsx
115-
<Select enabled>
116-
<Select enabled>
117-
<mesh />
118-
<mesh />
119-
</Select>
120-
<Select>
121-
<mesh />
122-
</Select>
123-
</Select>
124-
```
125-
126-
#### Selective bloom
127-
128-
Bloom is selective by default, you control it not on the effect pass but on the materials by lifting their colors out of 0-1 range. a `luminanceThreshold` of 1 ensures that ootb nothing will glow, only the materials you pick. For this to work `toneMapped` has to be false on the materials, because it would otherwise clamp colors between 0 and 1 again.
129-
130-
```jsx
131-
<Bloom mipmapBlur luminanceThreshold={1} />
132-
133-
// ❌ will not glow, same as RGB [1,0,0]
134-
<meshStandardMaterial color="red"/>
135-
136-
// ✅ will glow, same as RGB [2,0,0]
137-
<meshStandardMaterial emissive="red" emissiveIntensity={2} toneMapped={false} />
138-
139-
// ❌ will not glow, same as RGB [1,0,0]
140-
<meshBasicMaterial color="red" />
141-
142-
// ❌ will not glow, same as RGB [1,0,0], tone-mapping will clamp colors between 0 and 1
143-
<meshBasicMaterial color={[2,0,0]} />
144-
145-
// ✅ will glow, same as RGB [2,0,0]
146-
<meshBasicMaterial color={[2,0,0]} toneMapped={false} />
147-
```
148-
149-
- [react-postprocessing exports](https://github.com/pmndrs/react-postprocessing/blob/master/api.md)
78+
- [react-postprocessing docs](https://docs.pmnd.rs/react-postprocessing)
15079
- [postprocessing docs](https://pmndrs.github.io/postprocessing/public/docs/)

‎api.md

-447
This file was deleted.

‎docs/effect-composer.mdx

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
title: EffectComposer
3+
nav: 0
4+
---
5+
6+
The `EffectComposer` must wrap all your effects. It will manage them for you.
7+
8+
```jsx
9+
<EffectComposer
10+
enabled?: boolean
11+
depthBuffer?: boolean
12+
disableNormalPass?: boolean
13+
stencilBuffer?: boolean
14+
autoClear?: boolean
15+
multisampling?: number
16+
frameBufferType?: TextureDataType
17+
/** For effects that support DepthDownsamplingPass */
18+
resolutionScale?: number
19+
renderPriority?: number
20+
camera?: THREE.Camera
21+
scene?: THREE.Scene
22+
>
23+
{/* your effects go here */}
24+
</EffectComposer>
25+
```

‎docs/effects/bloom.mdx

+32-5
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,47 @@ A bloom effect.
77

88
```jsx
99
import { Bloom } from '@react-three/postprocessing'
10-
import { BlurPass, Resizer, KernelSize } from 'postprocessing'
10+
import { BlurPass, Resizer, KernelSize, Resolution } from 'postprocessing'
1111

1212
return (
1313
<Bloom
1414
intensity={1.0} // The bloom intensity.
1515
blurPass={undefined} // A blur pass.
16-
width={Resizer.AUTO_SIZE} // render width
17-
height={Resizer.AUTO_SIZE} // render height
1816
kernelSize={KernelSize.LARGE} // blur kernel size
1917
luminanceThreshold={0.9} // luminance threshold. Raise this value to mask out darker elements in the scene.
2018
luminanceSmoothing={0.025} // smoothness of the luminance threshold. Range is [0, 1]
19+
mipmapBlur={false} // Enables or disables mipmap blur.
20+
resolutionX={Resolution.AUTO_SIZE} // The horizontal resolution.
21+
resolutionY={Resolution.AUTO_SIZE} // The vertical resolution.
2122
/>
2223
)
2324
```
2425

26+
Bloom is selective by default, you control it not on the effect pass but on the
27+
materials by lifting their colors out of 0-1 range. a `luminanceThreshold` of 1
28+
ensures that ootb nothing will glow, only the materials you pick. For this to
29+
work `toneMapped` has to be false on the materials, because it would otherwise
30+
clamp colors between 0 and 1 again.
31+
32+
```jsx
33+
<Bloom mipmapBlur luminanceThreshold={1} />
34+
35+
// ❌ will not glow, same as RGB [1,0,0]
36+
<meshStandardMaterial color="red"/>
37+
38+
// ✅ will glow, same as RGB [2,0,0]
39+
<meshStandardMaterial emissive="red" emissiveIntensity={2} toneMapped={false} />
40+
41+
// ❌ will not glow, same as RGB [1,0,0]
42+
<meshBasicMaterial color="red" />
43+
44+
// ❌ will not glow, same as RGB [1,0,0], tone-mapping will clamp colors between 0 and 1
45+
<meshBasicMaterial color={[2,0,0]} />
46+
47+
// ✅ will glow, same as RGB [2,0,0]
48+
<meshBasicMaterial color={[2,0,0]} toneMapped={false} />
49+
```
50+
2551
## Example
2652

2753
<Codesandbox id="r9ujf" />
@@ -34,7 +60,8 @@ return (
3460
| luminanceSmoothing | Number | 0.025 | Controls the smoothness of the luminance threshold. Range is [0, 1]. |
3561
| blendFunction | BlendFunction | BlendFunction.SCREEN | The blend function of this effect. |
3662
| intensity | Number | 1 | The intensity. |
37-
| width | Number | Resizer.AUTO_SIZE | The render width. |
38-
| height | Number | Resizer.AUTO_SIZE | The render height. |
63+
| resolutionX | Number | Resizer.AUTO_SIZE | The render width. |
64+
| resolutionY | Number | Resizer.AUTO_SIZE | The render height. |
3965
| kernelSize | Number | KernelSize.LARGE | The blur kernel size. |
4066
| blurPass | [BlurPass](https://vanruesc.github.io/postprocessing/public/docs/class/src/passes/BlurPass.js~BlurPass.html) | null | An efficient, incremental blur pass. |
67+
| mipMap | Boolean |

‎docs/effects/ssao.mdx

+7-26
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,7 @@ return (
6161
<td>depthAwareUpsampling</td>
6262
<td>Boolean</td>
6363
<td>true</td>
64-
<td>
65-
Enables or disables depth-aware upsampling. Has no effect if WebGL 2 is not supported.
66-
</td>
64+
<td>Enables or disables depth-aware upsampling. Has no effect if WebGL 2 is not supported.</td>
6765
</tr>
6866
<tr>
6967
<td>normalDepthBuffer</td>
@@ -86,45 +84,31 @@ return (
8684
<td>rings</td>
8785
<td>Number</td>
8886
<td>7</td>
89-
<td>
90-
The amount of spiral turns in the occlusion sampling pattern. Should be a prime number.
91-
</td>
87+
<td>The amount of spiral turns in the occlusion sampling pattern. Should be a prime number.</td>
9288
</tr>
9389
<tr>
9490
<td>distanceThreshold</td>
9591
<td>Number</td>
9692
<td>0.97</td>
97-
<td>
98-
A global distance threshold at which the occlusion effect starts to fade out. Range [0.0,
99-
1.0].
100-
</td>
93+
<td>A global distance threshold at which the occlusion effect starts to fade out. Range [0.0, 1.0].</td>
10194
</tr>
10295
<tr>
10396
<td>distanceFalloff</td>
10497
<td>Number</td>
10598
<td>0.03</td>
106-
<td>
107-
The distance falloff. Influences the smoothness of the overall occlusion cutoff. Range [0.0,
108-
1.0].
109-
</td>
99+
<td>The distance falloff. Influences the smoothness of the overall occlusion cutoff. Range [0.0, 1.0].</td>
110100
</tr>
111101
<tr>
112102
<td>rangeThreshold</td>
113103
<td>Number</td>
114104
<td>0.0005</td>
115-
<td>
116-
A local occlusion range threshold at which the occlusion starts to fade out. Range [0.0,
117-
1.0].
118-
</td>
105+
<td>A local occlusion range threshold at which the occlusion starts to fade out. Range [0.0, 1.0].</td>
119106
</tr>
120107
<tr>
121108
<td>rangeFalloff</td>
122109
<td>Number</td>
123110
<td>0.001</td>
124-
<td>
125-
The occlusion range falloff. Influences the smoothness of the proximity cutoff. Range [0.0,
126-
1.0].
127-
</td>
111+
<td>The occlusion range falloff. Influences the smoothness of the proximity cutoff. Range [0.0, 1.0].</td>
128112
</tr>
129113
<tr>
130114
<td>minRadiusScale</td>
@@ -142,10 +126,7 @@ return (
142126
<td>radius</td>
143127
<td>Number</td>
144128
<td>0.1825</td>
145-
<td>
146-
The occlusion sampling radius, expressed as a resolution independent scale. Range [1e-6,
147-
1.0].
148-
</td>
129+
<td>The occlusion sampling radius, expressed as a resolution independent scale. Range [1e-6, 1.0].</td>
149130
</tr>
150131
<tr>
151132
<td>intensity</td>

‎docs/introduction.mdx

+41-15
Original file line numberDiff line numberDiff line change
@@ -4,41 +4,62 @@ description: What is React Postprocessing and how you can use it
44
nav: 0
55
---
66

7-
`react-postprocessing` is a [postprocessing](https://github.com/vanruesc/postprocessing) wrapper for [@react-three/fiber](https://github.com/pmndrs/react-three-fiber). This is not (yet) meant for complex orchestration of effects, but can save you [hundreds of LOC](https://twitter.com/0xca0a/status/1289501594698960897) for a straight forward effects-chain.
7+
`react-postprocessing` is a
8+
[postprocessing](https://github.com/pmndrs/postprocessing) wrapper for
9+
[@react-three/fiber](https://github.com/pmndrs/react-three-fiber). This is not
10+
(yet) meant for complex orchestration of effects, but can save you
11+
[hundreds of LOC](https://twitter.com/0xca0a/status/1289501594698960897) for a
12+
straight forward effects-chain.
813

914
```bash
1015
npm install @react-three/postprocessing
1116
```
1217

13-
[![Bubbles](bubbles.jpg)](https://m94xb.csb.app)
14-
15-
[![Control](control.jpg)](https://5jgjz.csb.app)
16-
18+
<p align="center">
19+
<a href="https://pqrpl.csb.app" target="_blank">
20+
<img width="274" src="bubbles.jpg" alt="Bubbles" />
21+
</a>
22+
<a href="https://5jgjz.csb.app" target="_blank">
23+
<img width="274" src="control.jpg" alt="Take Control" />
24+
</a>
25+
</p>
1726
<p align="middle">
1827
<i>These demos are real, you can click them! They contain the full code, too. 📦</i>
1928
</p>
2029

21-
## Why postprocessing and not three/examples/jsm/postprocessing?
30+
#### Why postprocessing and not three/examples/jsm/postprocessing?
2231

23-
From [https://github.com/vanruesc/postprocessing](https://github.com/vanruesc/postprocessing#performance)
32+
From
33+
[https://github.com/pmndrs/postprocessing](https://github.com/pmndrs/postprocessing#performance)
2434

25-
> This library provides an EffectPass which automatically organizes and merges any given combination of effects. This minimizes the amount of render operations and makes it possible to combine many effects without the performance penalties of traditional pass chaining. Additionally, every effect can choose its own blend function.
35+
> This library provides an EffectPass which automatically organizes and merges
36+
> any given combination of effects. This minimizes the amount of render
37+
> operations and makes it possible to combine many effects without the
38+
> performance penalties of traditional pass chaining. Additionally, every effect
39+
> can choose its own blend function.
2640
>
27-
> All fullscreen render operations also use a single triangle that fills the screen. Compared to using a quad, this approach harmonizes with modern GPU rasterization patterns and eliminates unnecessary fragment calculations along the screen diagonal. This is especially beneficial for GPGPU passes and effects that use complex fragment shaders.
41+
> All fullscreen render operations also use a single triangle that fills the
42+
> screen. Compared to using a quad, this approach harmonizes with modern GPU
43+
> rasterization patterns and eliminates unnecessary fragment calculations along
44+
> the screen diagonal. This is especially beneficial for GPGPU passes and
45+
> effects that use complex fragment shaders.
2846
29-
Postprocessing also supports srgb-encoding out of the box, as well as WebGL2 MSAA (multi sample anti aliasing), which is react-postprocessing's default, you get high performance crisp results w/o jagged edges.
47+
Postprocessing also supports srgb-encoding out of the box, as well as WebGL2
48+
MSAA (multi sample anti aliasing), which is react-postprocessing's default, you
49+
get high performance crisp results w/o jagged edges.
3050

31-
## What does it look like?
51+
#### What does it look like?
3252

33-
Well, you can do pretty much anything, but here's an example combining a couple of effects ([live demo](https://codesandbox.io/s/vigorous-currying-3r6l2)).
53+
Here's an example combining a couple of effects
54+
([live demo](https://codesandbox.io/s/react-postprocessing-dof-blob-pqrpl?)).
3455

35-
<a href="https://codesandbox.io/s/vigorous-currying-3r6l2" target="_blank" rel="noopener">
36-
<img src="control.jpg" alt="Bubbles Demo" />
56+
<a href="https://codesandbox.io/s/react-postprocessing-dof-blob-pqrpl?" target="_blank" rel="noopener">
57+
<img src="bubbles.jpg" alt="Bubbles Demo" />
3758
</a>
3859

3960
```jsx
4061
import React from 'react'
41-
import { EffectComposer, DepthOfField, Bloom, Noise, Vignette } from '@react-three/postprocessing'
62+
import { Bloom, DepthOfField, EffectComposer, Noise, Vignette } from '@react-three/postprocessing'
4263
import { Canvas } from '@react-three/fiber'
4364

4465
function App() {
@@ -55,3 +76,8 @@ function App() {
5576
)
5677
}
5778
```
79+
80+
## Documentation
81+
82+
- [react-postprocessing docs](https://docs.pmnd.rs/react-postprocessing)
83+
- [postprocessing docs](https://pmndrs.github.io/postprocessing/public/docs/)

‎docs/selection.mdx

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
---
2+
title: Selection
3+
description: Selection/Select
4+
nav: 0
5+
---
6+
7+
Some effects, like Outline or SelectiveBloom can select specific objects. To
8+
manage this in a declarative scene with just references can be messy, especially
9+
when things have to be grouped. These two components take care of it:
10+
11+
```jsx
12+
<Selection
13+
children: JSX.Element | JSX.Element[]
14+
enabled?: boolean
15+
>
16+
17+
<Select
18+
children: JSX.Element | JSX.Element[]
19+
enabled?: boolean
20+
>
21+
```
22+
23+
You wrap everything into a selection, this one holds all the selections. Now you
24+
can individually select objects or groups. Effects that support selections (for
25+
instance `Outline`) will acknowledge it.
26+
27+
```jsx
28+
<Selection>
29+
<EffectComposer autoclear={false}>
30+
<Outline blur edgeStrength={100} />
31+
</EffectComposer>
32+
<Select enabled>
33+
<mesh />
34+
</Select>
35+
</Selection>
36+
```
37+
38+
Selection can be nested and group multiple object, higher up selection take
39+
precence over lower ones. The following for instance will select everything.
40+
Remove the outmost `enabled` and only the two mesh group is selected. You can
41+
flip the selections or bind them to interactions and state.
42+
43+
```jsx
44+
<Select enabled>
45+
<Select enabled>
46+
<mesh />
47+
<mesh />
48+
</Select>
49+
<Select>
50+
<mesh />
51+
</Select>
52+
</Select>
53+
```

‎src/effects/Bloom.tsx

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
import { BloomEffect, BlendFunction } from 'postprocessing'
2+
import type { BloomEffectOptions } from 'postprocessing'
23
import { wrapEffect } from '../util'
34

4-
export const Bloom = wrapEffect(BloomEffect, { blendFunction: BlendFunction.ADD })
5+
export const Bloom = wrapEffect<typeof BloomEffect, BloomEffectOptions>(BloomEffect, {
6+
blendFunction: BlendFunction.ADD,
7+
})

0 commit comments

Comments
 (0)
Please sign in to comment.