未验证 提交 2a8a3fae 编写于 作者: M Michael Herzog 提交者: GitHub

Merge pull request #15818 from Mugen87/dev27

Examples: Clean up
......@@ -49,7 +49,7 @@ THREE.AdaptiveToneMappingPass = function ( adaptive, resolution ) {
this.adaptLuminanceShader = {
defines: {
"MIP_LEVEL_1X1" : ( Math.log( this.resolution ) / Math.log( 2.0 ) ).toFixed( 1 )
"MIP_LEVEL_1X1": ( Math.log( this.resolution ) / Math.log( 2.0 ) ).toFixed( 1 )
},
uniforms: {
"lastLum": { value: null },
......@@ -63,8 +63,8 @@ THREE.AdaptiveToneMappingPass = function ( adaptive, resolution ) {
"void main() {",
"vUv = uv;",
"gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
" vUv = uv;",
" gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
"}"
].join( '\n' ),
......@@ -79,20 +79,20 @@ THREE.AdaptiveToneMappingPass = function ( adaptive, resolution ) {
"void main() {",
"vec4 lastLum = texture2D( lastLum, vUv, MIP_LEVEL_1X1 );",
"vec4 currentLum = texture2D( currentLum, vUv, MIP_LEVEL_1X1 );",
" vec4 lastLum = texture2D( lastLum, vUv, MIP_LEVEL_1X1 );",
" vec4 currentLum = texture2D( currentLum, vUv, MIP_LEVEL_1X1 );",
"float fLastLum = max( minLuminance, lastLum.r );",
"float fCurrentLum = max( minLuminance, currentLum.r );",
" float fLastLum = max( minLuminance, lastLum.r );",
" float fCurrentLum = max( minLuminance, currentLum.r );",
//The adaption seems to work better in extreme lighting differences
//if the input luminance is squared.
"fCurrentLum *= fCurrentLum;",
//The adaption seems to work better in extreme lighting differences
//if the input luminance is squared.
" fCurrentLum *= fCurrentLum;",
// Adapt the luminance using Pattanaik's technique
"float fAdaptedLum = fLastLum + (fCurrentLum - fLastLum) * (1.0 - exp(-delta * tau));",
// "fAdaptedLum = sqrt(fAdaptedLum);",
"gl_FragColor.r = fAdaptedLum;",
// Adapt the luminance using Pattanaik's technique
" float fAdaptedLum = fLastLum + (fCurrentLum - fLastLum) * (1.0 - exp(-delta * tau));",
// "fAdaptedLum = sqrt(fAdaptedLum);",
" gl_FragColor.r = fAdaptedLum;",
"}"
].join( '\n' )
};
......@@ -118,7 +118,7 @@ THREE.AdaptiveToneMappingPass = function ( adaptive, resolution ) {
} );
this.camera = new THREE.OrthographicCamera( - 1, 1, 1, - 1, 0, 1 );
this.scene = new THREE.Scene();
this.scene = new THREE.Scene();
this.quad = new THREE.Mesh( new THREE.PlaneBufferGeometry( 2, 2 ), null );
this.quad.frustumCulled = false; // Avoid getting clipped
......@@ -188,7 +188,7 @@ THREE.AdaptiveToneMappingPass.prototype = Object.assign( Object.create( THREE.Pa
},
reset: function( renderer ) {
reset: function ( renderer ) {
// render targets
if ( this.luminanceRT ) {
......@@ -240,7 +240,7 @@ THREE.AdaptiveToneMappingPass.prototype = Object.assign( Object.create( THREE.Pa
},
setAdaptive: function( adaptive ) {
setAdaptive: function ( adaptive ) {
if ( adaptive ) {
......@@ -259,7 +259,7 @@ THREE.AdaptiveToneMappingPass.prototype = Object.assign( Object.create( THREE.Pa
},
setAdaptionRate: function( rate ) {
setAdaptionRate: function ( rate ) {
if ( rate ) {
......@@ -269,7 +269,7 @@ THREE.AdaptiveToneMappingPass.prototype = Object.assign( Object.create( THREE.Pa
},
setMinLuminance: function( minLum ) {
setMinLuminance: function ( minLum ) {
if ( minLum ) {
......@@ -280,7 +280,7 @@ THREE.AdaptiveToneMappingPass.prototype = Object.assign( Object.create( THREE.Pa
},
setMaxLuminance: function( maxLum ) {
setMaxLuminance: function ( maxLum ) {
if ( maxLum ) {
......@@ -290,7 +290,7 @@ THREE.AdaptiveToneMappingPass.prototype = Object.assign( Object.create( THREE.Pa
},
setAverageLuminance: function( avgLum ) {
setAverageLuminance: function ( avgLum ) {
if ( avgLum ) {
......@@ -300,7 +300,7 @@ THREE.AdaptiveToneMappingPass.prototype = Object.assign( Object.create( THREE.Pa
},
setMiddleGrey: function( middleGrey ) {
setMiddleGrey: function ( middleGrey ) {
if ( middleGrey ) {
......@@ -310,7 +310,7 @@ THREE.AdaptiveToneMappingPass.prototype = Object.assign( Object.create( THREE.Pa
},
dispose: function() {
dispose: function () {
if ( this.luminanceRT ) {
......
......@@ -42,7 +42,7 @@ THREE.AfterimagePass = function ( damp ) {
this.sceneComp = new THREE.Scene();
this.scene = new THREE.Scene();
this.camera = new THREE.OrthographicCamera( -1, 1, 1, -1, 0, 1 );
this.camera = new THREE.OrthographicCamera( - 1, 1, 1, - 1, 0, 1 );
this.camera.position.z = 1;
var geometry = new THREE.PlaneBufferGeometry( 2, 2 );
......@@ -50,7 +50,7 @@ THREE.AfterimagePass = function ( damp ) {
this.quadComp = new THREE.Mesh( geometry, this.shaderMaterial );
this.sceneComp.add( this.quadComp );
var material = new THREE.MeshBasicMaterial( {
var material = new THREE.MeshBasicMaterial( {
map: this.textureComp.texture
} );
......
......@@ -56,7 +56,7 @@ THREE.BloomPass = function ( strength, kernelSize, sigma, resolution ) {
this.materialConvolution = new THREE.ShaderMaterial( {
uniforms: this.convolutionUniforms,
vertexShader: convolutionShader.vertexShader,
vertexShader: convolutionShader.vertexShader,
fragmentShader: convolutionShader.fragmentShader,
defines: {
"KERNEL_SIZE_FLOAT": kernelSize.toFixed( 1 ),
......@@ -68,7 +68,7 @@ THREE.BloomPass = function ( strength, kernelSize, sigma, resolution ) {
this.needsSwap = false;
this.camera = new THREE.OrthographicCamera( - 1, 1, 1, - 1, 0, 1 );
this.scene = new THREE.Scene();
this.scene = new THREE.Scene();
this.quad = new THREE.Mesh( new THREE.PlaneBufferGeometry( 2, 2 ), null );
this.quad.frustumCulled = false; // Avoid getting clipped
......
......@@ -67,7 +67,7 @@ THREE.BokehPass = function ( scene, camera, params ) {
this.needsSwap = false;
this.camera2 = new THREE.OrthographicCamera( - 1, 1, 1, - 1, 0, 1 );
this.scene2 = new THREE.Scene();
this.scene2 = new THREE.Scene();
this.quad2 = new THREE.Mesh( new THREE.PlaneBufferGeometry( 2, 2 ), null );
this.quad2.frustumCulled = false; // Avoid getting clipped
......
......@@ -26,7 +26,7 @@ THREE.DotScreenPass = function ( center, angle, scale ) {
} );
this.camera = new THREE.OrthographicCamera( - 1, 1, 1, - 1, 0, 1 );
this.scene = new THREE.Scene();
this.scene = new THREE.Scene();
this.quad = new THREE.Mesh( new THREE.PlaneBufferGeometry( 2, 2 ), null );
this.quad.frustumCulled = false; // Avoid getting clipped
......
......@@ -27,7 +27,7 @@ THREE.FilmPass = function ( noiseIntensity, scanlinesIntensity, scanlinesCount,
if ( scanlinesCount !== undefined ) this.uniforms.sCount.value = scanlinesCount;
this.camera = new THREE.OrthographicCamera( - 1, 1, 1, - 1, 0, 1 );
this.scene = new THREE.Scene();
this.scene = new THREE.Scene();
this.quad = new THREE.Mesh( new THREE.PlaneBufferGeometry( 2, 2 ), null );
this.quad.frustumCulled = false; // Avoid getting clipped
......
......@@ -24,7 +24,7 @@ THREE.GlitchPass = function ( dt_size ) {
} );
this.camera = new THREE.OrthographicCamera( - 1, 1, 1, - 1, 0, 1 );
this.scene = new THREE.Scene();
this.scene = new THREE.Scene();
this.quad = new THREE.Mesh( new THREE.PlaneBufferGeometry( 2, 2 ), null );
this.quad.frustumCulled = false; // Avoid getting clipped
......@@ -90,13 +90,13 @@ THREE.GlitchPass.prototype = Object.assign( Object.create( THREE.Pass.prototype
},
generateTrigger: function() {
generateTrigger: function () {
this.randX = THREE.Math.randInt( 120, 240 );
},
generateHeightmap: function( dt_size ) {
generateHeightmap: function ( dt_size ) {
var data_arr = new Float32Array( dt_size * dt_size * 3 );
var length = dt_size * dt_size;
......
......@@ -30,7 +30,7 @@ THREE.HalftonePass = function ( width, height, params ) {
if ( params.hasOwnProperty( key ) && this.uniforms.hasOwnProperty( key ) ) {
this.uniforms[key].value = params[key];
this.uniforms[ key ].value = params[ key ];
}
......@@ -42,9 +42,9 @@ THREE.HalftonePass = function ( width, height, params ) {
this.quad.frustumCulled = false;
this.scene.add( this.quad );
};
};
THREE.HalftonePass.prototype = Object.assign( Object.create( THREE.Pass.prototype ), {
THREE.HalftonePass.prototype = Object.assign( Object.create( THREE.Pass.prototype ), {
constructor: THREE.HalftonePass,
......
......@@ -73,7 +73,7 @@ THREE.MaskPass.prototype = Object.assign( Object.create( THREE.Pass.prototype ),
// only render where stencil is set to 1
state.buffers.stencil.setFunc( context.EQUAL, 1, 0xffffffff ); // draw if == 1
state.buffers.stencil.setFunc( context.EQUAL, 1, 0xffffffff ); // draw if == 1
state.buffers.stencil.setOp( context.KEEP, context.KEEP, context.KEEP );
}
......
......@@ -60,6 +60,7 @@ THREE.RenderPass.prototype = Object.assign( Object.create( THREE.Pass.prototype
this.scene.overrideMaterial = null;
renderer.autoClear = oldAutoClear;
}
} );
......@@ -319,7 +319,7 @@ THREE.SAOPass.prototype = Object.assign( Object.create( THREE.Pass.prototype ),
var originalClearAlpha = renderer.getClearAlpha();
var originalAutoClear = renderer.autoClear;
renderer.setRenderTarget( renderTarget);
renderer.setRenderTarget( renderTarget );
// setup pass state
renderer.autoClear = false;
......
......@@ -31,9 +31,11 @@ THREE.SMAAPass = function ( width, height ) {
var areaTextureImage = new Image();
areaTextureImage.src = this.getAreaTexture();
areaTextureImage.onload = function() {
areaTextureImage.onload = function () {
// assigning data to HTMLImageElement.src is asynchronous (see #15162)
scope.areaTexture.needsUpdate = true;
};
this.areaTexture = new THREE.Texture();
......
......@@ -100,7 +100,7 @@ THREE.SSAARenderPass.prototype = Object.assign( Object.create( THREE.Pass.protot
if ( this.camera.setViewOffset ) {
this.camera.setViewOffset( width, height,
jitterOffset[ 0 ] * 0.0625, jitterOffset[ 1 ] * 0.0625, // 0.0625 = 1 / 16
jitterOffset[ 0 ] * 0.0625, jitterOffset[ 1 ] * 0.0625, // 0.0625 = 1 / 16
width, height );
}
......
......@@ -42,7 +42,7 @@ THREE.ShaderPass.prototype = Object.assign( Object.create( THREE.Pass.prototype
constructor: THREE.ShaderPass,
render: function( renderer, writeBuffer, readBuffer, deltaTime, maskActive ) {
render: function ( renderer, writeBuffer, readBuffer, deltaTime, maskActive ) {
if ( this.uniforms[ this.textureID ] ) {
......
......@@ -88,7 +88,7 @@ THREE.TAARenderPass.prototype = Object.assign( Object.create( THREE.SSAARenderPa
if ( this.camera.setViewOffset ) {
this.camera.setViewOffset( readBuffer.width, readBuffer.height,
jitterOffset[ 0 ] * 0.0625, jitterOffset[ 1 ] * 0.0625, // 0.0625 = 1 / 16
jitterOffset[ 0 ] * 0.0625, jitterOffset[ 1 ] * 0.0625, // 0.0625 = 1 / 16
readBuffer.width, readBuffer.height );
}
......
......@@ -29,7 +29,7 @@ THREE.TexturePass = function ( map, opacity ) {
this.needsSwap = false;
this.camera = new THREE.OrthographicCamera( - 1, 1, 1, - 1, 0, 1 );
this.scene = new THREE.Scene();
this.scene = new THREE.Scene();
this.quad = new THREE.Mesh( new THREE.PlaneBufferGeometry( 2, 2 ), null );
this.quad.frustumCulled = false; // Avoid getting clipped
......
examples/textures/tri_pattern.jpg

19.8 KB | W: | H:

examples/textures/tri_pattern.jpg

64.4 KB | W: | H:

examples/textures/tri_pattern.jpg
examples/textures/tri_pattern.jpg
examples/textures/tri_pattern.jpg
examples/textures/tri_pattern.jpg
  • 2-up
  • Swipe
  • Onion skin
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册