depth-buffer

Logarithmic Depth Buffer OpenGL

荒凉一梦 提交于 2019-11-30 05:21:18
I've managed to implement a logarithmic depth buffer in OpenGL, mainly courtesy of articles from Outerra (You can read them here , here , and here ). However, I'm having some issues, and I'm not sure if these issues are inherent to using a logarithmic depth buffer or if there's some workaround I can't think of. Just to start off, this is how I calculate logarithmic depth within the vertex shader: gl_Position = MVP * vec4(inPosition, 1.0); gl_Position.z = log2(max(ZNEAR, 1.0 + gl_Position.w)) * FCOEF - 1.0; flogz = 1.0 + gl_Position.w; And this is how I fix depth values in the fragment shader:

Can't get depth testing to work in OpenGL

这一生的挚爱 提交于 2019-11-29 10:44:37
I use SFML to create the window. In this screenshot the cube should be behind the pyramid but it just doesn't work. Here is the minimal code I used: #include <OpenGL/gl.h> #include <OpenGL/glu.h> #include <SFML/Graphics.hpp> #include "ResourcePath.hpp" void resize(); void drawScene(); void initGL(); float rtri = 0; float rquad = 0; float z = -10.0f; int main (int argc, const char * argv[]) { // Create the main window sf::RenderWindow *window = new sf::RenderWindow(); window->Create( sf::VideoMode( 800, 600, 32 ), "Collision Detection", sf::Style::Close ); sf::Event event; bool run = true;

glReadPixels doesn't read depth buffer values on iOS

回眸只為那壹抹淺笑 提交于 2019-11-29 07:39:38
I can't seem to read the depth buffer values in OpenGL ES2 on iOS 4.3 afDepthPixels = (float*)malloc(sizeof(float) * iScreenWidth * iScreenHeight); glReadPixels(0, 0, iScreenWidth, iScreenHeight, GL_DEPTH_COMPONENT, GL_FLOAT, afDepthPixels); My depth buffer is currently bound in place and operational, however that function reads nothing but 0 values, and it seems to return almost immediately. If I give it a GL_RGBA, it will take quite a while, and will indeed return results. Is this functionality just not supported in ES2 on iOS? Thanks! As you guess, reading the depth buffer isn't supported

Logarithmic Depth Buffer OpenGL

这一生的挚爱 提交于 2019-11-29 03:37:11
问题 I've managed to implement a logarithmic depth buffer in OpenGL, mainly courtesy of articles from Outerra (You can read them here, here, and here). However, I'm having some issues, and I'm not sure if these issues are inherent to using a logarithmic depth buffer or if there's some workaround I can't think of. Just to start off, this is how I calculate logarithmic depth within the vertex shader: gl_Position = MVP * vec4(inPosition, 1.0); gl_Position.z = log2(max(ZNEAR, 1.0 + gl_Position.w)) *

Writing texture data onto depth buffer

筅森魡賤 提交于 2019-11-29 02:26:41
I'm trying to implement the technique described at : Compositing Images with Depth . The idea is to use an existing texture (loaded from an image) as a depth mask, to basically fake 3D. The problem I face is that glDrawPixels is not available in OpenglES. Is there a way to accomplish the same thing on the iPhone? The depth buffer is more obscured than you think in OpenGL ES; not only is glDrawPixels absent but gl_FragDepth has been removed from GLSL. So you can't write a custom fragment shader to spool values to the depth buffer as you might push colours. The most obvious solution is to pack

opengl z-sorting transparency

梦想与她 提交于 2019-11-28 13:05:36
im rendering png's on simple squares in opengl es 2.0, but when i try and draw something behind an square i have already drawn the transparent area in my top square are rendered the same color as the background. I am calling these at the start of every render call. glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glEnable(GL_DEPTH_TEST); glEnable (GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); Your title is essentially the answer to your question! Generally transparency is done by first rendering all opaque objects in the scene (letting the z-buffer figure out what's visible)

Can't get depth testing to work in OpenGL

假如想象 提交于 2019-11-28 03:57:18
问题 I use SFML to create the window. In this screenshot the cube should be behind the pyramid but it just doesn't work. Here is the minimal code I used: #include <OpenGL/gl.h> #include <OpenGL/glu.h> #include <SFML/Graphics.hpp> #include "ResourcePath.hpp" void resize(); void drawScene(); void initGL(); float rtri = 0; float rquad = 0; float z = -10.0f; int main (int argc, const char * argv[]) { // Create the main window sf::RenderWindow *window = new sf::RenderWindow(); window->Create( sf:

glReadPixels doesn't read depth buffer values on iOS

▼魔方 西西 提交于 2019-11-28 01:00:05
问题 I can't seem to read the depth buffer values in OpenGL ES2 on iOS 4.3 afDepthPixels = (float*)malloc(sizeof(float) * iScreenWidth * iScreenHeight); glReadPixels(0, 0, iScreenWidth, iScreenHeight, GL_DEPTH_COMPONENT, GL_FLOAT, afDepthPixels); My depth buffer is currently bound in place and operational, however that function reads nothing but 0 values, and it seems to return almost immediately. If I give it a GL_RGBA, it will take quite a while, and will indeed return results. Is this

opengl z-sorting transparency

为君一笑 提交于 2019-11-27 07:27:32
问题 im rendering png's on simple squares in opengl es 2.0, but when i try and draw something behind an square i have already drawn the transparent area in my top square are rendered the same color as the background. I am calling these at the start of every render call. glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glEnable(GL_DEPTH_TEST); glEnable (GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); 回答1: Your title is essentially the answer to your question! Generally transparency

OpenGL ES2 Alpha test problems

二次信任 提交于 2019-11-26 11:23:00
I am rendering in 3D multiple objects with textures that have alpha. All the textures load fine but when I try to render them in front of each other I get the following: Left is what I have. Right is what it should be. The grid is just to help visualize the perspective. The texture in front of the red circle texture is clipped. I searched around for an answer and it says for me to use: GLES20.glEnable( GLES20.GL_BLEND ); GLES20.glBlendFunc(GLES20.GL_SRC_ALPHA, GLES20.GL_ONE_MINUS_SRC_ALPHA ); But I am using it and it still isn't working. My setup in which I correctly placed in the