提交 f91185a3 编写于 作者: M Mr.doob 提交者: GitHub

Merge pull request #10230 from NickGerleman/dev

Rename ManualMSAARenderPass to SSAARenderPass
......@@ -204,8 +204,8 @@ var files = {
"webgl_postprocessing_glitch",
"webgl_postprocessing_godrays",
"webgl_postprocessing_masking",
"webgl_postprocessing_msaa",
"webgl_postprocessing_msaa_unbiased",
"webgl_postprocessing_ssaa",
"webgl_postprocessing_ssaa_unbiased",
"webgl_postprocessing_nodes",
"webgl_postprocessing_outline",
"webgl_postprocessing_procedural",
......
/**
*
* Manual Multi-Sample Anti-Aliasing Render Pass
* Supersample Anti-Aliasing Render Pass
*
* @author bhouston / http://clara.io/
*
* This manual approach to MSAA re-renders the scene ones for each sample with camera jitter and accumulates the results.
* This manual approach to SSAA re-renders the scene ones for each sample with camera jitter and accumulates the results.
*
* References: https://en.wikipedia.org/wiki/Multisample_anti-aliasing
* References: https://en.wikipedia.org/wiki/Supersampling
*
*/
THREE.ManualMSAARenderPass = function ( scene, camera, clearColor, clearAlpha ) {
THREE.SSAARenderPass = function ( scene, camera, clearColor, clearAlpha ) {
THREE.Pass.call( this );
......@@ -24,7 +24,7 @@ THREE.ManualMSAARenderPass = function ( scene, camera, clearColor, clearAlpha )
this.clearColor = ( clearColor !== undefined ) ? clearColor : 0x000000;
this.clearAlpha = ( clearAlpha !== undefined ) ? clearAlpha : 0;
if ( THREE.CopyShader === undefined ) console.error( "THREE.ManualMSAARenderPass relies on THREE.CopyShader" );
if ( THREE.CopyShader === undefined ) console.error( "THREE.SSAARenderPass relies on THREE.CopyShader" );
var copyShader = THREE.CopyShader;
this.copyUniforms = Object.assign( {}, copyShader.uniforms );
......@@ -47,9 +47,9 @@ THREE.ManualMSAARenderPass = function ( scene, camera, clearColor, clearAlpha )
};
THREE.ManualMSAARenderPass.prototype = Object.assign( Object.create( THREE.Pass.prototype ), {
THREE.SSAARenderPass.prototype = Object.assign( Object.create( THREE.Pass.prototype ), {
constructor: THREE.ManualMSAARenderPass,
constructor: THREE.SSAARenderPass,
dispose: function() {
......@@ -77,7 +77,7 @@ THREE.ManualMSAARenderPass.prototype = Object.assign( Object.create( THREE.Pass.
}
var jitterOffsets = THREE.ManualMSAARenderPass.JitterVectors[ Math.max( 0, Math.min( this.sampleLevel, 5 ) ) ];
var jitterOffsets = THREE.SSAARenderPass.JitterVectors[ Math.max( 0, Math.min( this.sampleLevel, 5 ) ) ];
var autoClear = renderer.autoClear;
renderer.autoClear = false;
......@@ -135,7 +135,7 @@ THREE.ManualMSAARenderPass.prototype = Object.assign( Object.create( THREE.Pass.
// before being used, thus these integers need to be scaled by 1/16.
//
// Sample patterns reference: https://msdn.microsoft.com/en-us/library/windows/desktop/ff476218%28v=vs.85%29.aspx?f=255&MSPPError=-2147217396
THREE.ManualMSAARenderPass.JitterVectors = [
THREE.SSAARenderPass.JitterVectors = [
[
[ 0, 0 ]
],
......
......@@ -14,21 +14,21 @@
THREE.TAARenderPass = function ( scene, camera, params ) {
if ( THREE.ManualMSAARenderPass === undefined ) {
if ( THREE.SSAARenderPass === undefined ) {
console.error( "THREE.TAARenderPass relies on THREE.ManualMSAARenderPass" );
console.error( "THREE.TAARenderPass relies on THREE.ManualSSAARenderPass" );
}
THREE.ManualMSAARenderPass.call( this, scene, camera, params );
THREE.SSAARenderPass.call( this, scene, camera, params );
this.sampleLevel = 0;
this.accumulate = false;
};
THREE.TAARenderPass.JitterVectors = THREE.ManualMSAARenderPass.JitterVectors;
THREE.TAARenderPass.JitterVectors = THREE.SSAARenderPass.JitterVectors;
THREE.TAARenderPass.prototype = Object.assign( Object.create( THREE.ManualMSAARenderPass.prototype ), {
THREE.TAARenderPass.prototype = Object.assign( Object.create( THREE.SSAARenderPass.prototype ), {
constructor: THREE.TAARenderPass,
......@@ -36,7 +36,7 @@ THREE.TAARenderPass.prototype = Object.assign( Object.create( THREE.ManualMSAARe
if( ! this.accumulate ) {
THREE.ManualMSAARenderPass.prototype.render.call( this, renderer, writeBuffer, readBuffer, delta );
THREE.SSAARenderPass.prototype.render.call( this, renderer, writeBuffer, readBuffer, delta );
this.accumulateIndex = -1;
return;
......@@ -59,7 +59,7 @@ THREE.TAARenderPass.prototype = Object.assign( Object.create( THREE.ManualMSAARe
if( this.accumulate && this.accumulateIndex === -1 ) {
THREE.ManualMSAARenderPass.prototype.render.call( this, renderer, this.holdRenderTarget, readBuffer, delta );
THREE.SSAARenderPass.prototype.render.call( this, renderer, this.holdRenderTarget, readBuffer, delta );
this.accumulateIndex = 0;
......
<!DOCTYPE html>
<html lang="en">
<head>
<title>three.js webgl - postprocessing manual msaa</title>
<title>three.js webgl - postprocessing ssaa</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
<style>
......@@ -30,9 +30,9 @@
</head>
<body>
<div id="info">
<a href="http://threejs.org" target="_blank">three.js</a> - Manual Multi-Sample Anti-Aliasing (MSAA) pass by <a href="https://clara.io" target="_blank">Ben Houston</a><br/><br/>
This manual approach to MSAA re-renders the scene ones for each sample with camera jitter and accumulates the results.<br/><br/>
Texture interpolation, mipmapping and anistropic sampling is disabled to emphasize<br/> the effect MSAA levels have one the resulting render quality.
<a href="http://threejs.org" target="_blank">three.js</a> - Manual Supersampling Anti-Aliasing (SSAA) pass by <a href="https://clara.io" target="_blank">Ben Houston</a><br/><br/>
This manual approach to SSAA re-renders the scene once for each sample with camera jitter and accumulates the results.<br/><br/>
Texture interpolation, mipmapping and anistropic sampling is disabled to emphasize<br/> the effect SSAA levels have one the resulting render quality.
</div>
<div id="container"></div>
......@@ -44,7 +44,7 @@
<script src="js/shaders/CopyShader.js"></script>
<script src="js/postprocessing/EffectComposer.js"></script>
<script src="js/postprocessing/ManualMSAARenderPass.js"></script>
<script src="js/postprocessing/SSAARenderPass.js"></script>
<script src="js/postprocessing/RenderPass.js"></script>
<script src="js/postprocessing/MaskPass.js"></script>
<script src="js/postprocessing/ShaderPass.js"></script>
......@@ -52,7 +52,7 @@
<script>
var camera, scene, renderer, composer, copyPass, msaaRenderPass;
var camera, scene, renderer, composer, copyPass, ssaaRenderPass;
var gui, stats, texture;
var param = {
......@@ -95,8 +95,6 @@
stats = new Stats();
container.appendChild( stats.dom );
//
camera = new THREE.PerspectiveCamera( 70, window.innerWidth / window.innerHeight, 1, 1000 );
camera.position.z = 300;
......@@ -125,12 +123,12 @@
composer = new THREE.EffectComposer( renderer );
msaaRenderPass = new THREE.ManualMSAARenderPass( scene, camera );
msaaRenderPass.unbiased = false;
composer.addPass( msaaRenderPass );
ssaaRenderPass = new THREE.SSAARenderPass( scene, camera );
ssaaRenderPass.unbiased = false;
composer.addPass( ssaaRenderPass );
copyPass = new THREE.ShaderPass( THREE.CopyShader );
copyPass.renderToScreen = true;
copyPass.renderToScreen = true;
composer.addPass( copyPass );
window.addEventListener( 'resize', onWindowResize, false );
......@@ -169,7 +167,7 @@
}
msaaRenderPass.sampleLevel = param.sampleLevel;
ssaaRenderPass.sampleLevel = param.sampleLevel;
composer.render();
stats.end();
......
<!DOCTYPE html>
<html lang="en">
<head>
<title>three.js webgl - postprocessing manual msaa</title>
<title>three.js webgl - postprocessing manual ssaa</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
<style>
......@@ -30,8 +30,8 @@
</head>
<body>
<div id="info">
<a href="http://threejs.org" target="_blank">three.js</a> - Unbiased Manual Multi-Sample Anti-Aliasing (MSAA) pass by <a href="https://clara.io" target="_blank">Ben Houston</a><br/><br/>
This example shows how to unbias the rounding errors accumulated using high number of MSAA samples on a 8-bit per channel buffer.<br/><br/>
<a href="http://threejs.org" target="_blank">three.js</a> - Unbiased Manual Supersamling Anti-Aliasing (SSAA) pass by <a href="https://clara.io" target="_blank">Ben Houston</a><br/><br/>
This example shows how to unbias the rounding errors accumulated using high number of SSAA samples on a 8-bit per channel buffer.<br/><br/>
Turn off the "unbiased" feature to see the banding that results from accumulated rounding errors.
</div>
......@@ -44,7 +44,7 @@
<script src="js/shaders/CopyShader.js"></script>
<script src="js/postprocessing/EffectComposer.js"></script>
<script src="js/postprocessing/ManualMSAARenderPass.js"></script>
<script src="js/postprocessing/SSAARenderPass.js"></script>
<script src="js/postprocessing/RenderPass.js"></script>
<script src="js/postprocessing/MaskPass.js"></script>
<script src="js/postprocessing/ShaderPass.js"></script>
......@@ -53,8 +53,8 @@
<script>
var scene, renderer, composer, copyPass;
var cameraP, msaaRenderPassP;
var cameraO, msaaRenderPassO;
var cameraP, ssaaRenderPassP;
var cameraO, ssaaRenderPassO;
var gui, stats, texture;
var params = {
......@@ -115,8 +115,6 @@
stats = new Stats();
container.appendChild( stats.dom );
//
cameraP = new THREE.PerspectiveCamera( 65, aspect, 3, 10 );
cameraP.position.z = 7;
......@@ -178,14 +176,14 @@
// postprocessing
composer = new THREE.EffectComposer( renderer );
msaaRenderPassP = new THREE.ManualMSAARenderPass( scene, cameraP );
composer.addPass( msaaRenderPassP );
msaaRenderPassO = new THREE.ManualMSAARenderPass( scene, cameraO );
composer.addPass( msaaRenderPassO );
ssaaRenderPassP = new THREE.SSAARenderPass( scene, cameraP );
composer.addPass( ssaaRenderPassP );
ssaaRenderPassO = new THREE.SSAARenderPass( scene, cameraO );
composer.addPass( ssaaRenderPassO );
copyPass = new THREE.ShaderPass( THREE.CopyShader );
copyPass.renderToScreen = true;
composer.addPass( copyPass );
window.addEventListener( 'resize', onWindowResize, false );
}
......@@ -231,7 +229,7 @@
}
}
var newColor = msaaRenderPassP.clearColor;
var newColor = ssaaRenderPassP.clearColor;
switch( params.clearColor ) {
case 'blue': newColor = 0x0000ff; break;
case 'red': newColor = 0xff0000; break;
......@@ -239,16 +237,16 @@
case 'white': newColor = 0xffffff; break;
case 'black': newColor = 0x000000; break;
}
msaaRenderPassP.clearColor = msaaRenderPassO.clearColor = newColor;
msaaRenderPassP.clearAlpha = msaaRenderPassO.clearAlpha = params.clearAlpha;
ssaaRenderPassP.clearColor = ssaaRenderPassO.clearColor = newColor;
ssaaRenderPassP.clearAlpha = ssaaRenderPassO.clearAlpha = params.clearAlpha;
msaaRenderPassP.sampleLevel = msaaRenderPassO.sampleLevel = params.sampleLevel;
msaaRenderPassP.unbiased = msaaRenderPassO.unbiased = params.unbiased;
ssaaRenderPassP.sampleLevel = ssaaRenderPassO.sampleLevel = params.sampleLevel;
ssaaRenderPassP.unbiased = ssaaRenderPassO.unbiased = params.unbiased;
msaaRenderPassP.enabled = ( params.camera === 'perspective' );
msaaRenderPassO.enabled = ( params.camera === 'orthographic' );
ssaaRenderPassP.enabled = ( params.camera === 'perspective' );
ssaaRenderPassO.enabled = ( params.camera === 'orthographic' );
msaaRenderPassP.renderToScreen = msaaRenderPassO.renderToScreen = params.renderToScreen;
ssaaRenderPassP.renderToScreen = ssaaRenderPassO.renderToScreen = params.renderToScreen;
copyPass.enabled = !params.renderToScreen;
composer.render();
......
<!DOCTYPE html>
<html lang="en">
<head>
<title>three.js webgl - postprocessing manual msaa</title>
<title>three.js webgl - postprocessing manual taa and ssaa</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
<style>
......@@ -33,7 +33,7 @@
<a href="http://threejs.org" target="_blank">three.js</a> - Temporal Anti-Aliasing (TAA) pass by <a href="https://clara.io" target="_blank">Ben Houston</a><br/><br/>
When there is no motion in the scene, the TAA render pass accumulates jittered camera samples<br/>
across frames to create a high quality anti-aliased result.<br/><br/>
Texture interpolation, mipmapping and anistropic sampling is disabled to emphasize<br/> the effect MSAA levels have one the resulting render quality.
Texture interpolation, mipmapping and anistropic sampling is disabled to emphasize<br/> the effect SSAA levels have one the resulting render quality.
</div>
<div id="container"></div>
......@@ -45,7 +45,7 @@
<script src="js/shaders/CopyShader.js"></script>
<script src="js/postprocessing/EffectComposer.js"></script>
<script src="js/postprocessing/ManualMSAARenderPass.js"></script>
<script src="js/postprocessing/SSAARenderPass.js"></script>
<script src="js/postprocessing/TAARenderPass.js"></script>
<script src="js/postprocessing/RenderPass.js"></script>
<script src="js/postprocessing/MaskPass.js"></script>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册