javascript - Unable to create a framebuffer with an RGBA32F texture - Stack Overflow
I'm unable to create a framebuffer from a texture with internal format RGBA32F.
The following code logs test.js:38 Framebuffer is incomplete. Status: 36054
in the console
function main() {
const canvas = document.getElementById('canvas');
const gl = canvas.getContext('webgl2'); // Use webgl2 for native RGBA32F support
if (!gl) {
console.error("WebGL 2.0 not supported.");
return;
}
const targetTextureWidth = 256;
const targetTextureHeight = 256;
const targetTexture = gl.createTexture();
gl.bindTexture(gl.TEXTURE_2D, targetTexture);
{
const level = 0;
const internalFormat = gl.RGBA32F;
const border = 0;
const format = gl.RGBA;
const type = gl.FLOAT;
const data = null;
gl.texImage2D(gl.TEXTURE_2D, level, internalFormat, targetTextureWidth, targetTextureHeight, border, format, type, data);
}
// Create and bind the framebuffer
const fb = gl.createFramebuffer();
gl.bindFramebuffer(gl.FRAMEBUFFER, fb);
// attach the texture as the first color attachment
const attachmentPoint = gl.COLOR_ATTACHMENT0;
const level = 0;
gl.framebufferTexture2D(gl.FRAMEBUFFER, attachmentPoint, gl.TEXTURE_2D, targetTexture, level);
// Check framebuffer status
const status = gl.checkFramebufferStatus(gl.FRAMEBUFFER);
if (status !== gl.FRAMEBUFFER_COMPLETE) {
console.error("Framebuffer is incomplete. Status: " + status);
return;
}
console.log("Framebuffer is complete!");
}
main();
If I use a different combination of internalFormat
, format
and type
from .0/#TEXTURE_TYPES_FORMATS_FROM_DOM_ELEMENTS_TABLE, which does not use 32 bit floats, the framebuffer will be completed.
I'm unable to create a framebuffer from a texture with internal format RGBA32F.
The following code logs test.js:38 Framebuffer is incomplete. Status: 36054
in the console
function main() {
const canvas = document.getElementById('canvas');
const gl = canvas.getContext('webgl2'); // Use webgl2 for native RGBA32F support
if (!gl) {
console.error("WebGL 2.0 not supported.");
return;
}
const targetTextureWidth = 256;
const targetTextureHeight = 256;
const targetTexture = gl.createTexture();
gl.bindTexture(gl.TEXTURE_2D, targetTexture);
{
const level = 0;
const internalFormat = gl.RGBA32F;
const border = 0;
const format = gl.RGBA;
const type = gl.FLOAT;
const data = null;
gl.texImage2D(gl.TEXTURE_2D, level, internalFormat, targetTextureWidth, targetTextureHeight, border, format, type, data);
}
// Create and bind the framebuffer
const fb = gl.createFramebuffer();
gl.bindFramebuffer(gl.FRAMEBUFFER, fb);
// attach the texture as the first color attachment
const attachmentPoint = gl.COLOR_ATTACHMENT0;
const level = 0;
gl.framebufferTexture2D(gl.FRAMEBUFFER, attachmentPoint, gl.TEXTURE_2D, targetTexture, level);
// Check framebuffer status
const status = gl.checkFramebufferStatus(gl.FRAMEBUFFER);
if (status !== gl.FRAMEBUFFER_COMPLETE) {
console.error("Framebuffer is incomplete. Status: " + status);
return;
}
console.log("Framebuffer is complete!");
}
main();
If I use a different combination of internalFormat
, format
and type
from https://registry.khronos.org/webgl/specs/latest/2.0/#TEXTURE_TYPES_FORMATS_FROM_DOM_ELEMENTS_TABLE, which does not use 32 bit floats, the framebuffer will be completed.
1 Answer
Reset to default 1gl.getExtension('EXT_color_buffer_float');
Allows framebuffer creation with textures that have 32 bit float internal types.
EXT_color_buffer_float
is not mentioned in the mdn web docs or the specification, despite 32 bit float types being listed in both.
- 向iPhone学习:谷歌计划改进Android后台管理机制
- 谷歌回应欧盟反垄断指控:安卓利于竞争和消费者
- 苹果兜售没用软件脸不红心不跳
- excel - When loading my userform i get Run-Time Error 381: Could not set the list property. Invalid property array index - Stack
- angularjs - Laravel Custom Auth in registering - Stack Overflow
- filename has 'netboxlabs-diode-netbox-plugin', but metadata has 'unknown' - Stack Overflow
- flutter - having issue about qr code scanner that can scan almost everything - Stack Overflow
- tracking - Add custom hand gestures in three.js - Stack Overflow
- python - Can't run pytest with a `FileNotFoundError: [Errno 2] No such file or directory: 'tmppip-build-env-3fag
- python - CERT_PATH points to the wrong directory even though I set it correctly in my Django project - Stack Overflow
- django - SimpleJWT: Re-apply Blacklist Token Migration: "Table 'token_blacklist_blacklistedtoken' doesn
- How to log information in Spring application when request is received and before response is returned - Stack Overflow
- In Visual Studio 2022, Can not export and import new Project Template - Stack Overflow
- javascript - Firebase Auth link - Problem with the Google login, no possibility to change to own project name - Stack Overflow
- sublimetext3 - Sublime Text 34: copypaste all text excluding comments - Stack Overflow
- r - Why does adding markers in a Shiny app work for one map but not the other? - Stack Overflow
- Need to find a way to change a library (SO file) without reinstalling an application in Android 13 on rooted device. Permission