-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(post-processing): pixelation effect (#68)
* feat: added pixelation effect component * chore: added playground code for pixelation effect * docs: pixelation effect docs * chore: removed debug code
- Loading branch information
Showing
9 changed files
with
173 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<script lang="ts" setup> | ||
import { Color } from 'three' | ||
import { TresCanvas } from '@tresjs/core' | ||
import { OrbitControls } from '@tresjs/cientos' | ||
import { EffectComposer, Pixelation } from '@tresjs/post-processing' | ||
const boxWidth = 2 | ||
</script> | ||
|
||
<template> | ||
<TresCanvas | ||
clear-color="#121212" | ||
:alpha="false" | ||
:shadows="true" | ||
:disable-render="true" | ||
> | ||
<TresPerspectiveCamera | ||
:position="[3, 2, 4]" | ||
:look-at="[0, 0, 0]" | ||
/> | ||
<OrbitControls /> | ||
<TresMesh | ||
:position="[1, 0.5, 1]" | ||
> | ||
<TresBoxGeometry /> | ||
<TresMeshStandardMaterial | ||
color="hotpink" | ||
/> | ||
</TresMesh> | ||
<TresMesh | ||
:position="[-1.5, 0.75, 0]" | ||
> | ||
<TresConeGeometry :args="[1, 1.5, 4, 1, false, Math.PI * 0.25]" /> | ||
<TresMeshNormalMaterial /> | ||
<TresMeshStandardMaterial | ||
color="aqua" | ||
/> | ||
</TresMesh> | ||
|
||
<TresGridHelper /> | ||
<TresAmbientLight :intensity="0.9" /> | ||
<TresDirectionalLight | ||
:position="[-10, 5, 8]" | ||
:intensity="1" | ||
/> | ||
|
||
<Suspense> | ||
<EffectComposer> | ||
<Pixelation :granularity="8" /> | ||
</EffectComposer> | ||
</Suspense> | ||
</TresCanvas> | ||
</template> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Pixelation | ||
|
||
<DocsDemo> | ||
<PixelationDemo /> | ||
</DocsDemo> | ||
|
||
Pixelation is an effect that pixelates the scene. | ||
|
||
## Usage | ||
|
||
```vue | ||
<script setup lang="ts"> | ||
import { EffectComposer, Pixelation } from '@tresjs/post-processing' | ||
</script> | ||
<template> | ||
<EffectComposer> | ||
<Pixelation /> | ||
</EffectComposer> | ||
</template> | ||
``` | ||
|
||
## Props | ||
|
||
| Prop | Description | Default | | ||
| ----------- | ------------------------------ | ------- | | ||
| granularity | The granularity of the pixels. | 30 | | ||
|
||
## Further Reading | ||
see [postprocessing docs](https://pmndrs.github.io/postprocessing/public/docs/class/src/effects/PixelationEffect.js~PixelationEffect.html) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<script lang="ts" setup> | ||
import { computed } from 'vue' | ||
import { TresCanvas } from '@tresjs/core' | ||
import { OrbitControls } from '@tresjs/cientos' | ||
import { EffectComposer, Pixelation } from '@tresjs/post-processing' | ||
import { TresLeches, useControls } from '@tresjs/leches' | ||
import '@tresjs/leches/styles' | ||
useControls('fpsgraph') | ||
const { granularity } = useControls({ | ||
granularity: { | ||
value: 10, | ||
min: 1, | ||
max: 30, | ||
step: 1, | ||
}, | ||
}) | ||
</script> | ||
|
||
<template> | ||
<TresLeches /> | ||
<TresCanvas> | ||
<TresPerspectiveCamera | ||
:position="[5, 5, 5]" | ||
:look-at="[0, 0, 0]" | ||
/> | ||
<OrbitControls /> | ||
<TresMesh | ||
:position="[-3.5, 1, 0]" | ||
> | ||
<TresConeGeometry :args="[1.25, 2, 4, 1, false, Math.PI * 0.25]" /> | ||
<TresMeshNormalMaterial /> | ||
</TresMesh> | ||
|
||
<TresMesh :position="[0, 1, 0]"> | ||
<TresBoxGeometry :args="[2, 2, 2]" /> | ||
<TresMeshNormalMaterial /> | ||
</TresMesh> | ||
|
||
<TresMesh :position="[3.5, 1, 0]"> | ||
<TresSphereGeometry /> | ||
<TresMeshNormalMaterial /> | ||
</TresMesh> | ||
|
||
<TresGridHelper /> | ||
|
||
<EffectComposer> | ||
<Pixelation :granularity="granularity" /> | ||
</EffectComposer> | ||
</TresCanvas> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<script lang="ts" setup> | ||
import { PixelationEffect } from 'postprocessing' | ||
import { useEffect } from '../composables/effect' | ||
import { makePropWatchersUsingAllProps } from '../../util/prop' | ||
export interface PixelationProps { | ||
/** | ||
* The pixel granularity. | ||
*/ | ||
granularity?: number | ||
} | ||
const props = defineProps<PixelationProps>() | ||
const { pass, effect } = useEffect(() => new PixelationEffect(props.granularity)) | ||
defineExpose({ pass, effect }) // to allow users to modify pass and effect via template ref | ||
makePropWatchersUsingAllProps( | ||
props, | ||
effect, | ||
() => new PixelationEffect(), | ||
) | ||
</script> | ||
|
||
<template></template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,16 @@ | ||
import Bloom from './core/effects/Bloom.vue' | ||
import Glitch from './core/effects/Glitch.vue' | ||
import Outline from './core/effects/Outline.vue' | ||
import Pixelation from './core/effects/Pixelation.vue' | ||
import DepthOfField from './core/effects/DepthOfField.vue' | ||
|
||
import EffectComposer from './core/EffectComposer.vue' | ||
|
||
export { EffectComposer, Bloom, Outline, Glitch, DepthOfField } | ||
export { | ||
Bloom, | ||
Glitch, | ||
Outline, | ||
Pixelation, | ||
DepthOfField, | ||
EffectComposer, | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.