-
-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Post-Process example #5648
Open
enzofrancescaHM
wants to merge
37
commits into
aframevr:master
Choose a base branch
from
enzofrancescaHM:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+190
−0
Open
Post-Process example #5648
Changes from 34 commits
Commits
Show all changes
37 commits
Select commit
Hold shift + click to select a range
9094de9
Create base html file for post-processing bloom example
enzofrancescaHM 19f78b4
Create bloom.js for post-process bloom example
enzofrancescaHM 868863a
Update index.html changing path
enzofrancescaHM 22ad7d0
Update index.html to use importmap
enzofrancescaHM fbd5cef
Update bloom.js to use importmap
enzofrancescaHM d6b9d96
Update examples/post-process/index.html
enzofrancescaHM d86dd9f
Update examples/post-process/bloom.js
enzofrancescaHM 2b409aa
Update bloom.js to discard useless wait
enzofrancescaHM 5617d2f
Update index.html to set bloom directly on a-scene tag
enzofrancescaHM 485fe53
Update index.html to fix typo and fix importmap paths
enzofrancescaHM f12edb5
Update bloom.js to fix various issues and to optimize code
enzofrancescaHM b8fc265
Rename examples/post-process/bloom.js to examples/showcase/post-proce…
enzofrancescaHM 2c30d30
Rename examples/post-process/index.html to examples/showcase/post-pro…
enzofrancescaHM d1f9285
Update index.html to get rid of useless tags
enzofrancescaHM 003bb43
Update bloom.js to use right value of delta
enzofrancescaHM c72fb8c
Update bloom.js to reflect better formatting of schema
enzofrancescaHM 97c97f7
Update index.html to get rid of semicolon and trailing comma
enzofrancescaHM fbf8c44
Update bloom.js to implement multisampling
enzofrancescaHM 53afd13
Update bloom.js to resize EffectComposer
enzofrancescaHM 97d4fed
Update bloom.js with correct parameter in setSize
enzofrancescaHM 3ecf142
Update index.html to get right position and raise red cube emissive
enzofrancescaHM b08a29d
Update bloom.js to fix distorsions in VR Mode
enzofrancescaHM cdc609c
Update bloom.js to add OutputPass, improving quality
enzofrancescaHM 70ca6bd
Update bloom.js, removed useless parameter in OutputPass
enzofrancescaHM 3c422ac
Update index.html, added toneMapping tag
enzofrancescaHM 3276558
Update bloom.js, FullScreenQuad global patch
enzofrancescaHM 4c2cb7c
Update index.html to list post-processing example
enzofrancescaHM 0a342d0
Update bloom.js to get rid of reduntant parts already implemented in …
enzofrancescaHM eae775a
Update examples/showcase/post-processing/bloom.js
enzofrancescaHM 379acfe
Update examples/showcase/post-processing/bloom.js
enzofrancescaHM 4e4041f
Update examples/showcase/post-processing/bloom.js
enzofrancescaHM b954921
Updated bloom.js after lint:fix passed
ec757df
Final demo scene with toon car
3c73498
Refactor names
448ea27
Update index.html
enzofrancescaHM cce2821
change description
4570f97
Merge branch 'master' of https://github.com/enzofrancescaHM/aframe_po…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Binary file not shown.
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,97 @@ | ||
/* global THREE */ | ||
/** | ||
* Unreal Bloom Effect | ||
* Implementation for A-Frame | ||
* Code modified from Akbartus's post-processing A-Frame integration | ||
* https://github.com/akbartus/A-Frame-Component-Postprocessing | ||
*/ | ||
|
||
import AFRAME from 'aframe'; | ||
import { EffectComposer } from 'three/addons/postprocessing/EffectComposer.js'; | ||
import { RenderPass } from 'three/addons/postprocessing/RenderPass.js'; | ||
import { UnrealBloomPass } from 'three/addons/postprocessing/UnrealBloomPass.js'; | ||
import { OutputPass } from 'three/addons/postprocessing/OutputPass.js'; | ||
|
||
AFRAME.registerComponent('bloom', { | ||
schema: { | ||
threshold: { type: 'number', default: 1 }, | ||
strength: { type: 'number', default: 0.5 }, | ||
radius: { type: 'number', default: 1 } | ||
}, | ||
events: { | ||
rendererresize: function () { | ||
this.renderer.getSize(this.size); | ||
this.composer.setSize(this.size.width, this.size.height); | ||
} | ||
}, | ||
init: function () { | ||
this.size = new THREE.Vector2(); | ||
this.scene = this.el.object3D; | ||
this.renderer = this.el.renderer; | ||
this.camera = this.el.camera; | ||
this.bind(); | ||
}, | ||
update: function () { | ||
if (this.composer) { | ||
this.composer.dispose(); | ||
} | ||
// create composer with multisampling to avoid aliasing | ||
const resolution = this.renderer.getDrawingBufferSize(new THREE.Vector2()); | ||
const renderTarget = new THREE.WebGLRenderTarget( | ||
resolution.width, | ||
resolution.height, | ||
{ type: THREE.HalfFloatType, samples: 8 } | ||
); | ||
|
||
this.composer = new EffectComposer(this.renderer, renderTarget); | ||
|
||
// create render pass | ||
const renderScene = new RenderPass(this.scene, this.camera); | ||
this.composer.addPass(renderScene); | ||
|
||
// create bloom pass | ||
const strength = this.data.strength; | ||
const radius = this.data.radius; | ||
const threshold = this.data.threshold; | ||
if (this.bloomPass) { | ||
this.bloomPass.dispose(); | ||
} | ||
this.bloomPass = new UnrealBloomPass( | ||
resolution, | ||
strength, | ||
radius, | ||
threshold | ||
); | ||
this.composer.addPass(this.bloomPass); | ||
|
||
// create output pass | ||
if (this.outputPass) { | ||
this.outputPass.dispose(); | ||
} | ||
this.outputPass = new OutputPass(); | ||
this.composer.addPass(this.outputPass); | ||
}, | ||
|
||
bind: function () { | ||
this.originalRender = this.el.renderer.render; | ||
const self = this; | ||
let isInsideComposerRender = false; | ||
|
||
this.el.renderer.render = function () { | ||
if (isInsideComposerRender) { | ||
self.originalRender.apply(this, arguments); | ||
} else { | ||
isInsideComposerRender = true; | ||
self.composer.render(self.el.sceneEl.delta / 1000); | ||
isInsideComposerRender = false; | ||
} | ||
}; | ||
}, | ||
|
||
remove: function () { | ||
this.el.renderer.render = this.originalRender; | ||
this.bloomPass.dispose(); | ||
this.outputPass.dispose(); | ||
this.composer.dispose(); | ||
} | ||
}); |
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,69 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
enzofrancescaHM marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
<head> | ||
|
||
<meta charset="utf-8" /> | ||
<title>Post Processing Bloom Effect</title> | ||
<meta name="description" content="Post Processing Bloom Effect • A-Frame" /> | ||
|
||
<style src="./style.css"></style> | ||
|
||
<script type="importmap"> | ||
{ | ||
"imports": { | ||
"aframe": "../../dist/aframe-master.module.min.js", | ||
"three": "../../../super-three-package/build/three.module.js", | ||
"three/addons/": "../../../super-three-package/examples/jsm/" | ||
} | ||
} | ||
</script> | ||
<script type="module" src="./bloom.js"></script> | ||
|
||
</head> | ||
|
||
<body> | ||
|
||
<div id="infopanel"> | ||
<a href="https://aframe.io/" target="_blank" rel="noopener" style="color:#00ceff;pointer-events: auto;">A-Frame</a> | ||
PostProcessing - Bloom<br /> | ||
Model: <a href="https://skfb.ly/owUr9" target="_blank" rel="noopener">Low-poly cartoon style car 03</a> by | ||
<a href="https://sketchfab.com/arturs.vitas" target="_blank" rel="noopener">artus.vitas</a>, CC Attribution. | ||
</div> | ||
|
||
<a-scene bloom="threshold: 1.0; strength: 0.3; radius: 1;" background="color: #000000" | ||
renderer="toneMapping: ACESFilmic;"> | ||
|
||
<a-assets> | ||
<!-- model by arturs.vitas https://skfb.ly/owUr9 --> | ||
<a-asset-item id="testbed" src="../../assets/models/fancy-car.glb"></a-asset-item> | ||
</a-assets> | ||
|
||
<a-entity id="rig" position="0 0 2"> | ||
<a-entity id="camera" position="0 1.6 0" camera look-controls wasd-controls></a-entity> | ||
</a-entity> | ||
|
||
<a-entity id="base" geometry="primitive: cylinder; height: 0.1; radius: 1.93" position="0 0 -2" | ||
material="color: #201d1d" shadow | ||
animation="property: rotation; to: 0 360 0 ; loop: true; dur: 15000; easing: linear;"> | ||
|
||
<a-entity id="tooncar" gltf-model="#testbed" position="0 0.050 0" scale="2 2 2" shadow> | ||
</a-entity> | ||
|
||
<a-entity id="neon01" | ||
geometry="primitive: torus; radius: 1.92; radiusTubular: 0.02; segmentsRadial: 50; segmentsTubular: 40" | ||
material="color: #d100e0; emissive: #b300a4; emissiveIntensity: 9.34" rotation="90 0 0"> | ||
</a-entity> | ||
|
||
</a-entity> | ||
|
||
<a-entity id="ambient" light="type: ambient; intensity: 0.48; color: #ffffff"> | ||
</a-entity> | ||
|
||
<a-entity id="point01" light="color: #7cd2fe; intensity: 5; type: point;" position="0 3.51 -1"> | ||
</a-entity> | ||
|
||
</a-scene> | ||
</body> | ||
|
||
</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,23 @@ | ||
#infopanel { | ||
font-family: Monospace; | ||
font-size: 13px; | ||
line-height: 24px; | ||
color:#ffffff; | ||
position: absolute; | ||
top: 0px; | ||
width: 100%; | ||
padding: 10px; | ||
box-sizing: border-box; | ||
text-align: center; | ||
pointer-events: none; | ||
-moz-user-select: none; | ||
-webkit-user-select: none; | ||
-ms-user-select: none; | ||
user-select: none; | ||
z-index: 1; | ||
} | ||
|
||
#infopanel a { | ||
color:#00ceff; | ||
pointer-events: auto; | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to add
(bloom effect)
for simplicity