Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebGLRenderer: Improve RGBA_INTEGER support. #28829

Closed
tomhsiao1260 opened this issue Jul 7, 2024 · 5 comments · Fixed by #29392
Closed

WebGLRenderer: Improve RGBA_INTEGER support. #28829

tomhsiao1260 opened this issue Jul 7, 2024 · 5 comments · Fixed by #29392
Milestone

Comments

@tomhsiao1260
Copy link
Contributor

tomhsiao1260 commented Jul 7, 2024

Description

I face the same issue that @gkjohnson mentioned 3 years ago. Seems the error comes from three.js doesn't support clearing or rendering to integer render targets (as Garrett Johnson said). Any update for this issue?
https://arc.net/l/quote/gnimfrqg

Reproduction steps

Please check the fiddle, you can compare the different between RGBAFormat and RGBAIntegerFormat in console panel.

Code

See fiddle for complete example.

const data = new Uint8Array(2 * 3 * 4)
const texture = new THREE.DataTexture(data, 2, 3)
// texture.format = THREE.RGBAFormat // this work
texture.format = THREE.RGBAIntegerFormat // this not work
texture.type = THREE.UnsignedByteType
texture.minFilter = THREE.NearestFilter
texture.magFilter = THREE.NearestFilter
texture.needsUpdate = true

const renderTarget = new THREE.WebGLRenderTarget(2, 3)
renderTarget.texture = texture
renderer.setRenderTarget(renderTarget)

Live example

https://jsfiddle.net/yaohsiao/np97zdve/21/

Screenshots

image

Version

r166

Device

Desktop

Browser

Chrome

OS

MacOS

@Mugen87
Copy link
Collaborator

Mugen87 commented Jul 7, 2024

Related #22351 and #26249.

@Mugen87
Copy link
Collaborator

Mugen87 commented Jul 7, 2024

There are a couple of issue in your code. Here is a fixed version: https://jsfiddle.net/5hyf3jzo/1/

  • You have to define the internal format of the texture, in your case: texture.internalFormat = 'RGBA8UI'.
  • Your fragment shader has to render the correct data type. In your case it is uvec4.

Next time, please ask for help at the forum first.

@gkjohnson
Copy link
Collaborator

It's possible that glInternalFormat could be a bit smarter here. It looks like integer types are handled more gracefully for Red and RG formats but not for RGBA.

@Mugen87 Mugen87 added this to the r167 milestone Jul 7, 2024
@Mugen87
Copy link
Collaborator

Mugen87 commented Jul 7, 2024

That sounds like a good addition. Would you make a PR with your suggestion?

@gkjohnson
Copy link
Collaborator

gkjohnson commented Jul 8, 2024

That sounds like a good addition. Would you make a PR with your suggestion?

Perhaps at some point but I don't think I can commit time to implementing and testing it right now. It may be worth keeping the issue open to keep track of it for the moment.

@Mugen87 Mugen87 reopened this Jul 8, 2024
@Mugen87 Mugen87 changed the title WebGLRenderTarget not work for IntegerFormat WebGLRenderer: Improve RGBA_INTEGER support. Jul 8, 2024
@Mugen87 Mugen87 removed this from the r167 milestone Jul 8, 2024
@Mugen87 Mugen87 added this to the r169 milestone Sep 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants