depth buffer

#1

hi,
im wondering what im doing wrong. so, i want to read the depth buffer information and get them out in a shader (texture). all what im doing is to create a depth buffer and punching this buffer into a texture. but i dont receive any informations in the shader. whats wrong?

thanks

greetz
dirk

here a snips from my rttMANAGER modul:


bufferINFO = [1,1];
initTF_buffer(0,1024,1024,bufferINFO);

var rttBUFFER = [];
var rttTEXTURE = [];
	
function initTF_buffer(id,resX,resY,bufferINFO) {
	//////////////////
	//bufferINFO = [0] -> buffers, [1] -> fboTYPES
	//////////////////
	rttBUFFER[id] = gl.createFramebuffer();
	gl.bindFramebuffer(gl.FRAMEBUFFER, rttBUFFER[id]);
	rttBUFFER[id].width = resX;
	rttBUFFER[id].height = resY;

	var rttBUFFER_depth = gl.createRenderbuffer();
	gl.bindRenderbuffer(gl.RENDERBUFFER, rttBUFFER_depth);
	gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH_COMPONENT16, rttBUFFER[id].width, rttBUFFER[id].height);
	
	gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.RENDERBUFFER, rttBUFFER_depth);
	
	var buffers = [
					rttBUFFER[id],
					rttBUFFER_depth
				  ];
	
	var fboTYPES = [
					gl.COLOR_ATTACHMENT0,
					gl.DEPTH_ATTACHMENT,
					gl.DEPTH_STENCIL_ATTACHMENT
				   ];
	
	createBUFFER_texture(id,buffers[bufferINFO[0]],fboTYPES[bufferINFO[1]],resX,resY);
	console.log(rttTEXTURE[id]);
}

function createBUFFER_texture(id,buffer,bufferTYPE,resX,resY){
	buffer.width = resX;
	buffer.height = resY;
	
	rttTEXTURE[id] = gl.createTexture();
	gl.bindTexture(gl.TEXTURE_2D, rttTEXTURE[id]);
	gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
	gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR_MIPMAP_NEAREST);
	gl.generateMipmap(gl.TEXTURE_2D);
	
	gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, buffer.width, buffer.height, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
	
	gl.framebufferTexture2D(gl.FRAMEBUFFER,bufferTYPE,gl.TEXTURE_2D, rttTEXTURE[id], 0);
	
	gl.bindTexture(gl.TEXTURE_2D, null);
	gl.copyTexSubImage2D(gl.TEXTURE_2D, 0, 0, 0, 0, 0, buffer.width, buffer.height);
	gl.bindRenderbuffer(gl.RENDERBUFFER, null);
	gl.bindFramebuffer(gl.FRAMEBUFFER, null);
}
#2

oops i forgot the maintain, im using a different way now. (like i used to before, just in the shaders)

#3

maybe you are interested into the developing process about LSD.

LSD is an hobby project of mine, which should make it possible for me to display 3D content in WEB. regular im digital artist, with an bit of dirve to hobby programming. of course there some webgl frame works and engines already around. but i thought me, hey i want to crack this nut by myself :smiley: and in the meantime, i got an quiet nice working framework together. of course there still lot of useless and none elegance solutions in. currently im planing a change, which should bring more elegance into.

i hope im getting the next stable release finished with the end of the next month.

developer and fun blog :wink:
http://ditus00.blogspot.co.at/

here you can see the engine in action:
http://www.aries-lenov.com/projekte/webgl/dev/experimental/LSD.php

stay tuned
greetz
dirk

#4

It’s usually easier to help if you can post a working sample in something like http://jsfiddle.net or http://codepen.io/

As for reading the depth buffer values one way is to use the WEBGL_depth_buffer extension. There’s a test for it here. It supported in Chrome. I’m not sure if Firefox has added support yet.
https://www.khronos.org/registry/webgl/ … xture.html

The test makes a depth textures, uses the depth texture as a depth buffer, then renders with the depth texture (using it as regular texture). And checks the values.

#5

Thanks greggman, mackeeper coupon code
green smoke coupons los angeles locksmith
I didn’t know you could test the depth bufffer, that would have come in handy on my last project but i’ve bookmarked it now incase i need it again :slight_smile:
toronto locksmith

Sarah