Single-channel float data texture with WebGL2 context
See original GitHub issueIs it possible to create float data textures with PIXI v5? If so, how would I have to configure the BaseTexture
?
I’ve tried the following but it doesn’t work:
const dataArray = new Float32Array([
1.0, 0.1, 0.1,
0.1, 0.75, 0.1,
0.1, 0.1, 0.5,
]);
const createDataTexture = (data, width, height) => {
const resource = new PIXI.resources.BufferResource(dataArray, { width, height });
return new PIXI.BaseTexture(resource, {
format: 0x822e, // gl.R32F
type: PIXI.FLOAT
})
}
const dataTexture = createDataTexture(dataArray, 3, 3);
E.g., in this demo nothing is rendered, i.e., I assume the texture didn’t get loaded: https://jsfiddle.net/flek/pct2qugr/136/
However, if I blow-up the data and create a 4-channel float texture it works:
const array = new Float32Array([
1.0, 0.1, 0.1, 1.0, 0.1, 0.1, 0.1, 1.0, 0.1, 0.1, 0.1, 1.0,
0.1, 0.1, 0.1, 1.0, 0.75, 0.1, 0.1, 1.0, 0.1, 0.1, 0.1, 1.0,
0.1, 0.1, 0.1, 1.0, 0.1, 0.1, 0.1, 1.0, 0.5, 0.1, 0.1, 1.0,
]);
const texture = PIXI.Texture.fromBuffer(array, 3, 3);
Notice how the first channel is identical.
Here’s the updated demo, which works as expected: https://jsfiddle.net/flek/pct2qugr/137/
pixi.js
version: 5.1.6- Browser & Version: Chrome 80
- OS & Version: macOS 10.14.6
- Running Example: _https://jsfiddle.net/flek/pct2qugr/126/_
Issue Analytics
- State:
- Created 4 years ago
- Comments:5
Top Results From Across the Web
Single-channel float data texture with WebGL2 context #6436
Is it possible to create float data textures with PIXI v5? If so, how would I have to configure the BaseTexture? I've tried...
Read more >Can I store signed 16bit value in single channel in webgl2?
1 Answer 1 ... @ffsa The sampler type must be isampler2D . See Sampler (GLSL). In this case texture(u_image, v_texCoord) returns a ivec4...
Read more >WebGL2 3D - Data Textures
Sized Format Base Format R bits G bits Color renderable Texture filterable
R8 RED 8 ○ ○
R8_SNORM RED s8 ○
RG8 RG 8 8 ○...
Read more >Emulating palette based graphics in WebGL
The palette texture is 256x1 RGBA pixels. Your image texture is any size you want but just a single channel ALPHA texture. You...
Read more >single channel float textures as render target - Google Groups
Hi,. I would like to use floating point textures for GPGPU (OES_float_extension). ... The best option for me is LUMINANCE (single channel texture,...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi all,
I’m very new at this but I’m trying to use this same strategy to render 16 bit unsigned integer data texture. However, it doesn’t look like Pixi supports the “usampler2d” uniform. Is there a way to support this uniform type so that I don’t need to convert to 32 bit float? If not, are there plans to add support?
Thanks a lot for the quick reply and detailed response!
I ended up extending
BufferResource
and adjusted theformat
andinternalFormat
inupload()
, which did the trick!This is what I ended up doing:
Here’s the updated demo: https://jsfiddle.net/flek/pct2qugr/175/
I wonder if you could expose
internalFormat
as that seems to be the only limitation ofBufferResource
.