Skip to content

Commit

Permalink
WebGLRenderer: Transmission code clean up.
Browse files Browse the repository at this point in the history
  • Loading branch information
mrdoob committed May 26, 2021
1 parent 738561b commit 00147d9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
6 changes: 4 additions & 2 deletions src/renderers/WebGLRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,6 @@ function WebGLRenderer( parameters ) {
// transmission

let _transmissionRenderTarget = null;
const _transmissionSamplerSize = new Vector2( 1024, 1024 ); // Should be configurable?

// camera matrices cache

Expand Down Expand Up @@ -1268,7 +1267,7 @@ function WebGLRenderer( parameters ) {

if ( _transmissionRenderTarget === null ) {

_transmissionRenderTarget = new WebGLRenderTarget( _transmissionSamplerSize.x, _transmissionSamplerSize.y, {
_transmissionRenderTarget = new WebGLRenderTarget( 1024, 1024, {
generateMipmaps: true,
minFilter: LinearMipmapLinearFilter,
magFilter: NearestFilter,
Expand All @@ -1281,8 +1280,11 @@ function WebGLRenderer( parameters ) {
const currentRenderTarget = _this.getRenderTarget();
_this.setRenderTarget( _transmissionRenderTarget );
_this.clear();

renderObjects( opaqueObjects, scene, camera );

textures.updateRenderTargetMipmap( _transmissionRenderTarget );

_this.setRenderTarget( currentRenderTarget );

renderObjects( transmissiveObjects, scene, camera );
Expand Down
16 changes: 12 additions & 4 deletions src/renderers/webgl/WebGLRenderLists.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,17 @@ function WebGLRenderList( properties ) {

const renderItem = getNextRenderItem( object, geometry, material, groupOrder, z, group );

if ( material.transmission !== undefined && material.transmission > 0.0 ) {
if ( material.transmission > 0.0 ) {

transmissive.push( renderItem );

} else if ( material.transparent === true ) {

transparent.push( renderItem );

} else {

( material.transparent === true ? transparent : opaque ).push( renderItem );
opaque.push( renderItem );

}

Expand All @@ -133,13 +137,17 @@ function WebGLRenderList( properties ) {

const renderItem = getNextRenderItem( object, geometry, material, groupOrder, z, group );

if ( material.transmission !== undefined && material.transmission > 0.0 ) {
if ( material.transmission > 0.0 ) {

transmissive.unshift( renderItem );

} else if ( material.transparent === true ) {

transparent.unshift( renderItem );

} else {

( material.transparent === true ? transparent : opaque ).unshift( renderItem );
opaque.unshift( renderItem );

}

Expand Down

0 comments on commit 00147d9

Please sign in to comment.