Realistic rendering plugins for three.js.
Create high-quality 3D experiences on the web quickly and easily. now free
Let's create a model viewer with webgi plugins. You can see the preview on the right side. Drop any 3d model file on the canvas to load it in the viewer.
The following code creates a threepipe viewer for a canvas in the HTML.
WebGi Plugins are added to the viewer to enhance the rendering quality and features.
Scroll down to see the plugins in action
npm install threepipe @threepipe/webgi-plugins
<script type="importmap">
{
"imports": {
"threepipe": "https://unpkg.com/threepipe@latest/dist/index.mjs",
"@threepipe/webgi-plugins": "https://unpkg.com/@threepipe/webgi-plugins@latest/dist/index.mjs"
}
}
</script>
<div id="webgi-canvas-container" style="width: 1024px; height: 1024px;">
<canvas id="webgi-canvas" style="width: 100%; height: 100%;"></canvas>
</div>
import {ThreeViewer, timeout, LoadingScreenPlugin, GBufferPlugin, BaseGroundPlugin, SSAAPlugin, PickingPlugin, SSAOPlugin} from 'threepipe';
import {BloomPlugin, SSReflectionPlugin, TemporalAAPlugin, DepthOfFieldPlugin} from '@threepipe/webgi-plugins';
async function init() {
const viewer = new ThreeViewer({
canvas: document.getElementById('webgi-canvas'),
plugins: [
LoadingScreenPlugin,
GBufferPlugin,
BaseGroundPlugin,
BloomPlugin,
SSAAPlugin,
SSAOPlugin,
SSReflectionPlugin,
TemporalAAPlugin,
DepthOfFieldPlugin,
],
});
await viewer.setEnvironmentMap('https://threejs.org/examples/textures/equirectangular/venice_sunset_1k.hdr');
await viewer.load('https://threejs.org/examples/models/gltf/DamagedHelmet/glTF/DamagedHelmet.gltf', {
autoCenter: true,
autoScale: true,
});
}
init()
Now let's check out all the plugins in action and how they look the look and feel of the rendering.
The basic rendering of the model without any plugins.
Let's enable the SSAA plugin to get some anti-aliasing when the camera stops
The plugin can be configured to improve the anti-aliasing at the cost of performance.
import {SSAAPlugin} from "threepipe"
// ...
const ssaa = viewer.getPlugin(SSAAPlugin)
ssaa.enabled = true
ssaa.rendersPerFrame = 2
ssaa.jitterRenderCamera = true
We added SSAA plugin to get some anti-aliasing when the camera stops. Temporal AA Plugin adds temporal anti-aliasing when the camera is moving.
The plugin can be configured with feedBack
to control the rate of blurring.
import {TemporalAAPlugin} from "@threepipe/webgi-plugins"
// ...
const taa = viewer.getPlugin(TemporalAAPlugin)
taa.enabled = true
taa.feedBack.set(0.88, 0.97)
SSAO Plugin from threepipe add a light ambient occlusion effect to the scene.
The plugin can be configured with many properties like radius, intensity, bias, etc.
import {SSAOPlugin} from "threepipe"
// ...
const ssao = viewer.getPlugin(SSAOPlugin)
ssao.enabled = true
ssao.intensity = 0.5
ssao.bias = 0.001
ssao.falloff = 1.25
ssao.numSamples = 8
SSReflection Plugin adds screen space reflections to the scene.
The plugin can be configured with many properties like radius, intensity, bias, etc.
import {SSReflectionPlugin} from "@threepipe/webgi-plugins"
// ...
const ssrefl = viewer.getPlugin(SSReflectionPlugin)
ssrefl.enabled = true
ssrefl.intensity = 1
ssrefl.objectRadius = 0.001
ssrefl.tolerance = 0.8
Bloom Plugin adds object independent screen space HDR bloom to the scene.
The plugin can be configured with many properties like bloomIterations, intensity, threshold, etc.
import {BloomPlugin} from "@threepipe/webgi-plugins"
// ...
const bloom = viewer.getPlugin(BloomPlugin)
bloom.enabled = true
bloom.intensity = 0.4
bloom.threshold = 2
bloom.bloomIterations = 4
Depth of Field Plugin adds a depth of field effect to the scene.
import {DepthOfFieldPlugin} from "@threepipe/webgi-plugins"
// ...
const dof = viewer.getPlugin(DepthOfFieldPlugin)
dof.enabled = true
dof.enableEdit = true