WebGL rendering for floating point texture

I am writing some WebGL code and need to render a floating point texture.
With extensions gl.getExtension('OES_texture_float');

and gl.getExtension('OES_texture_float_linear');

now I can create and paint this texture and use a line filter.
But that just doesn't seem to be correctly timed.

Basically the values ​​have to be added together, so I use

    gl.blendEquation(gl.FUNC_ADD);
    gl.blendFunc(gl.SRC_ALPHA, gl.ONE);
    gl.enable(gl.BLEND);
    gl.disable(gl.DEPTH_TEST);

      

when rendering a texture. Adding negative values ​​can also occur.

Now, after hours of browsing the internet, I came across this: WEBGL_color_buffer_float extension

So far I have used the command

    gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, rttFramebuffer.width, rttFramebuffer.height, 0, gl.RGBA, gl.FLOAT, null);

      

but i think i need to use RGBA32F

. Is this possible, and if so, how can I use the extension format?


SOLVED: As suggested, there were no errors in the format used. I assigned some wrong values ​​to the shader form and used a very unfavorable background color that results in incorrect rendering.

+3


source to share


1 answer


gl.getExtension('OES_texture_float_linear');

doesn't give you floating point textures. This gives you the ability to use LINEAR filtering for floating point textures. gl.getExtension('OES_texture_float');

gives you the ability to create floating point textures.

Regarding this

gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, rttFramebuffer.width, rttFramebuffer.height, 
              0, gl.RGBA, gl.FLOAT, null);

      



It is right. There is no RGBA32F in WebGL. That was donegl.RGBA, gl.FLOAT

Yes, it's silly. This oversight was fixed in OpenGL ES 3.0 and will be fixed in WebGL 2.0, but in the current WebGL, how do you create a floating point texture.

+8


source







All Articles