5

I want to render position or depth to a floating texture. I use

vsnTexture = new THREE.WebGLRenderTarget(window.innerWidth, window.innerHeight,
            { minFilter: THREE.NearestFilter, magFilter: THREE.NearestFilter, format: THREE.RGBAFormat ,type:THREE.FloatType }); 

as the render target.

Then, I tested

var gl = this.renderer.getContext();
    if( !gl.getExtension( "OES_texture_float" ) ){
        console.error( "No OES_texture_float support for float textures!" );
    } 

and found no error. Chrome supports OES_texture_float, and I step into THREE.js:

_gl.texImage2D( _gl.TEXTURE_2D, 0, glFormat, renderTarget.width, renderTarget.height, 0, glFormat, glType, null );
 //console.log(glType);

I found glType =5126(gl.FLOAT) ,when I set the WebGLRenderTarget:type:THREE.FloatType. This means I could use OES_texture_float. Do I have something wrong? Because whatever I set the type:THREE.FloatType or use the default ( THREE.UnsignedByteType), I both get the same render texture. Am I not using the OES_texture_float correctly?

yongnan
  • 405
  • 7
  • 20

1 Answers1

3

Yes, it does. This example shows how to use it:

http://threejs.org/examples/#webgl_gpgpu_birds

mrdoob
  • 19,334
  • 4
  • 63
  • 62
  • Thanks, @mrdoob I use the example from https://github.com/arose/arose.github.io/blob/master/demo/oit/examples/webgl_oit.html. I set the renderTarget gl.type. When debug into THREE.js, I add console.log(glType) in this.setRenderTarget function; I get result 5126, after setupFrameBuffer( renderTarget.__webglFramebuffer, renderTarget, _gl.TEXTURE_2D ); if(glType === 5126) if( _gl.checkFramebufferStatus(_gl.FRAMEBUFFER) != _gl.FRAMEBUFFER_COMPLETE) alert("You bronser doesn't support" + "FLOAT as the color attachment to an FBO"); And I get no alert, is that means I use the gl.Float collectly? – yongnan Jun 10 '14 at 15:15