Skip to content

Conversation

@twastvedt
Copy link
Contributor

Description

The constructor appears to expect the depthTexture argument to be a boolean:

this.supportsDepthTextureExtension = ( depthTexture !== undefined ) ? depthTexture : false;

If true, a texture is created:

		if ( this.supportsDepthTextureExtension ) {

			const depthTexture = new DepthTexture();
			depthTexture.type = UnsignedShortType;

			this.beautyRenderTarget.depthTexture = depthTexture;
			this.beautyRenderTarget.depthBuffer = true;

		}

the const above means the created depthTexture is not available when it is subsequently used, resulting in a value of true for the tDepth uniform:

this.saoMaterial.uniforms[ 'tDepth' ].value = ( this.supportsDepthTextureExtension ) ? depthTexture : this.depthRenderTarget.texture;

I believe it was intended instead to overwrite the argument value with the new depth texture.

This contribution is funded by Proving Ground.

@Mugen87
Copy link
Collaborator

Mugen87 commented Sep 7, 2021

the const above means the created depthTexture is not available when it is subsequently used, resulting in a value of true for the tDepth uniform:

Good finding! Assigning a boolean to tDepth wouldn't be right indeed!

I think the code is still a bit hard to read. Simply because the type of depthTexture changes from boolean to a texture. I guess I would rename the ctor parameter to useDepthTexture and declare depthTexture right before this code block:

if ( this.supportsDepthTextureExtension ) {
depthTexture = new DepthTexture();
depthTexture.type = UnsignedShortType;
this.beautyRenderTarget.depthTexture = depthTexture;
this.beautyRenderTarget.depthBuffer = true;
}

What do you think?

@twastvedt
Copy link
Contributor Author

I think the code is still a bit hard to read. Simply because the type of depthTexture changes from boolean to a texture. I guess I would rename the ctor parameter to useDepthTexture and declare depthTexture right before this code block

Totally agree. I was trying not to make waves, but I'll happily clean that up a bit.

@mrdoob mrdoob added this to the r133 milestone Sep 7, 2021
@Mugen87 Mugen87 changed the title Fix depthTexture initialization SAOPass: Fix depthTexture initialization. Sep 8, 2021
@mrdoob mrdoob merged commit f27c0e8 into mrdoob:dev Sep 10, 2021
@mrdoob
Copy link
Owner

mrdoob commented Sep 10, 2021

Thanks!

@mrdoob
Copy link
Owner

mrdoob commented Sep 10, 2021

Some additional clean up: db72a7d

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants