hello guys,
I’m trying to implement a cell shading style. to detect the silhouet, i need to first render the object’s normal as well as depth onto two texture maps and then use a second pass to check the discontinuity of the normal and depth on the image space.
i successfully binded a texture map to the color buffer. but i don’t know how to bind a texture map to the depth buffer with opengl es 2
the sample code for normal opengl i found is this one:
glTexImage2D (GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT24, SM_width,
SM_height, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_BYTE, NULL);
but according to the gles 2 manual , GL_DEPTH_COMPONENT is not supported by opengl es 2.
http://www.khronos.org/opengles/sdk/docs/man/
right now, my code looks like this:
glTexImage2D (GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, mWidth, mHeight, 0, GL_DEPTH_COMPONENT, GL_FLOAT, NULL);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, antiAliasingTexture, 0);
it will give me “not complete” error.
another question is, if binding to depth buffer is not supported by openg es 2, then i guess i will have to render everything to color buffer with a two passes.
but how should i specify the texture map format? GL_ILLUMINANCE? and how should i output to illuminance inside the shader program?
something like: gl_FragColor.a=illuminance?