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

Add support for rendering to a mipLevel of RenderTarget on WebGL 2 #7052

Open
mvaligursky opened this issue Oct 21, 2024 · 1 comment
Open
Assignees
Labels
area: graphics Graphics related issue feature

Comments

@mvaligursky
Copy link
Contributor

see the API / WebGPU implementation here: #7051

it might need these to be utilized:

    gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_BASE_LEVEL, 0);
    gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAX_LEVEL, 2);
    gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAX_LOD, 2);

related issue: KhronosGroup/WebGL#3614

I tried to implement it but without success, the PIX capture shows that we render to level 1 as set up, but when sampling the texture to display it on the screen, only level 0 was somehow exposed. The above parameters didn't seem to make any difference.
Note: we create top level using texImage2D, and then create full chain using generateMipmap - it's possible we need to create the whole chain using texImage2D or texStorage2D.

@mvaligursky
Copy link
Contributor Author

Also note that the WebGPU implementation only handles rendering to Mipmap. The ultimate goal is to be able to write a custom mipmapper (specifically to generate mip versions of a depth texture). For this we need two parts:

  • rendering to a mipLevel
  • a way to sample from a single specified level (or a range). This is to avoid an issue of reading and writing uses the same texture warning - we need to exclude this on a per level.

For WebGPU, we need to create a custom view with some levels. For WebGL we need to use this texParameteri calls from the description.
Note that we could avoid writing a public API for this, as that could be tricky, and implement this under the hood only. WebgpuMipmapRenderer effectively does it already.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: graphics Graphics related issue feature
Projects
None yet
Development

No branches or pull requests

1 participant