Results 1 to 3 of 3

Thread: DEPTH BASED SHADOWS?

  1. #1
    Junior Member
    Join Date
    Jan 2010
    Posts
    1

    DEPTH BASED SHADOWS?

    From what I can tell, depth based shadows aren't supported yet (at least not on Firefox). Generating the texture for the FB throws an internal format error using gl.DEPTH_COMPONENT.

    Can anyone confirm? Can anyone provide information on downloading the webgl source for firefox? I've run in circles trying to make sense of mozilla's system.

    Thanks,

  2. #2
    Member Coolcat's Avatar
    Join Date
    Oct 2009
    Location
    NRW, Germany
    Posts
    75

    Re: DEPTH BASED SHADOWS?

    There was a bug with FBOs on Firefox in the past. This was fixed some time ago. You should update to the latest nightly.

    I was able to render successfully into the following FBO. However, I didn't try to read the depth-texture again, because I just needed the colorbuffer.
    Code :
    fbo = gl.createFramebuffer();
    depth = gl.createRenderbuffer();
    tex0 = gl.createTexture();
    gl.bindFramebuffer(gl.FRAMEBUFFER, fbo);
    gl.bindRenderbuffer(gl.RENDERBUFFER, depth);
    gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH_COMPONENT, size.x, size.y);
    gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.RENDERBUFFER, depth); 
    gl.bindTexture(gl.TEXTURE_2D, tex0);
    gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
    gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
    gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
    gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
    gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA,  size.x, size.y, 0, gl.RGBA, gl.UNSIGNED_BYTE, 
    		              WebGLUnsignedByteArray.create(size.x*size.y*4));
    gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, tex0, 0);
    check();
    gl.bindFramebuffer(gl.FRAMEBUFFER, null);

  3. #3

    Re: DEPTH BASED SHADOWS?

    I've had the same problem It doesn't seem to be working in any browser and at least in firefox it looks like there is no depth_component pixel format supported. I ended up converting the depth value to RGB values then converting it back the other side, costly but it works.

Similar Threads

  1. Lighting - Lioght Obstruction And Shadows
    By LordAshes in forum Developers Coding:Advanced
    Replies: 8
    Last Post: 03-08-2012, 06:16 AM
  2. Shadows in WebGL
    By jimmyt1988 in forum Developers Coding:Beginner
    Replies: 4
    Last Post: 03-06-2012, 07:07 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •