zbuffer

OpenGL Z-Biasing (Polygon Offset) Limitations

落花浮王杯 提交于 2019-12-06 08:15:54
I have a two coplanar polygons. I tried doing. glEnable(GL_POLYGON_OFFSET_FILL); glPolygonOffset(0,1); and expected one to be distinctly "on top of" the other. This is the case until about 70-75 units away (with a near clipping plane of 1, and a far clipping plane of 10,000). Then a region of about 50 units where there is z-fighting, and then the alternate polygon seems to appear on top. Does the Polygon Offset get added before or after the normal z-calculations? If it was after, I would have thought it would have "just worked" at all distances. Am I using the wrong values? Am I

Logarithmic depth buffer linearization

本小妞迷上赌 提交于 2019-12-06 00:53:16
How to linearize logarithmic depth buffer? visualization of linear depth buffer in fragment shader float n = 1.0; // camera z near float f = 27000000.0; // camera z far float z = texture( DepthTex, TexCoord ).x; float d = (2.0 * n) / (f + n - z * (f - n)); FragColor=vec4(d,d,d,1); sphere vertex shader vec4 ClipCoords(vec3 position,mat4 matrix) { vec4 clip = matrix * vec4(position,1.0f); clip.z =((2.0f * log(1.0f * clip.z + 1.0f) / log(1.0f * 27000000.0f + 1.0f)) - 1.0f) * clip.w; return clip; } gl_Position = ClipCoords(position,matrix); The left part shows Logarithmic depth buffer

Why is openGL glDepthFunc() not working?

不羁的心 提交于 2019-12-05 19:05:41
im playing with openGL and im trying to get rid of blue marked triangles. I use for it this code: glEnable(GL_DEPTH_TEST); glDepthFunc(GL_LESS); glEnable(GL_CULL_FACE); And yes I use glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); in my main loop. I've read the problem can be projection matrix. I use these values: ProjectionMatrix = glm::perspective(45.5f, 4.0f / 3.0f, 0.1f, 100.0f); I was trying to change the near and far value but its still the same. I was also trying change parameter of glDepthFunc but it also didnt help me. So, any ideas?? Thanks a lot This is perfectly valid behavior

How to get Z values from Z Buffer

偶尔善良 提交于 2019-12-05 12:24:15
I'm having problems with drawing in OpenGL and I need to see exactly what values are being placed in the depth buffer. Can anyone tell me how to retrieve these values? Thanks Chris Use glReadPixels with format = GL_DEPTH_COMPONENT, for example: float depth; glReadPixels(0, 0, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &depth); Will get the depth of pixel (0, 0). 来源: https://stackoverflow.com/questions/4499999/how-to-get-z-values-from-z-buffer

using renderOrder in three.js

那年仲夏 提交于 2019-12-05 02:59:36
问题 I want to have two overlapping objects in a scene but I want to define which object should be drawn first. I have a sample of the code here: http://jsfiddle.net/sg02e5sm/1/ I'm using renderOrder = 1 for the second object to make it appear always on top of the first object (as long as they have the same Z value), but it's not working. 回答1: renderOrder does not make something appear "on top". It controls the order in which objects are rendered. If you want your 2nd plane to be "on top", you can

using renderOrder in three.js

醉酒当歌 提交于 2019-12-03 20:06:39
I want to have two overlapping objects in a scene but I want to define which object should be drawn first. I have a sample of the code here: http://jsfiddle.net/sg02e5sm/1/ I'm using renderOrder = 1 for the second object to make it appear always on top of the first object (as long as they have the same Z value), but it's not working. WestLangley renderOrder does not make something appear "on top". It controls the order in which objects are rendered. If you want your 2nd plane to be "on top", you can add mesh.material.depthTest = false; for the 2nd plane, for example. fiddle: http://jsfiddle

Ugly render on clouds

徘徊边缘 提交于 2019-12-01 10:40:18
I'm trying to implement the code from this tutorial , but in much greater proportions (radius = 100000 units). I don't know if the size matters but on my earth render the clouds have a strange render. As the tutorial does, I'm using two spheres and three textures (earth map, bump map, clouds). Here the result (that's worse if the clouds are closer): More the clouds are closer of the planet surface, more this glitch is visible. If the clouds are sufficiently far (but that's not realistic) the problem disappears completely. What can I do? Use logarithmic depth buffer instead of the linear one.

Ugly render on clouds

心不动则不痛 提交于 2019-12-01 09:08:31
问题 I'm trying to implement the code from this tutorial, but in much greater proportions (radius = 100000 units). I don't know if the size matters but on my earth render the clouds have a strange render. As the tutorial does, I'm using two spheres and three textures (earth map, bump map, clouds). Here the result (that's worse if the clouds are closer): More the clouds are closer of the planet surface, more this glitch is visible. If the clouds are sufficiently far (but that's not realistic) the

What are good reasons to enable 2D projection with cocos2d-iphone?

人盡茶涼 提交于 2019-12-01 06:12:33
In cocos2d-iphone the default projection type is "3D" projection. But you can also set the projection to "2D" like so: [[CCDirector sharedDirector] setProjection:CCDirectorProjection2D]; Behind the scenes the 3D projection uses perspective projection whereas 2D projection is the OpenGL orthographic projection. The technical details about these two projection modes can be reviewed here , that's not what I'm interested in. What are the benefits and drawbacks of 2D projection for cocos2d users? What are good reasons to switch to 2D projection? Personally I've used 2D projection to be able to use

Using OpenGL in Matlab to get depth buffer

这一生的挚爱 提交于 2019-11-27 19:11:31
Ive asked a similar question before and didnt manage to find a direct answer . Could someone provide sample code for extracting the depth buffer of the rendering of an object into a figure in Matlab? So lets say I load an obj file or even just a simple surf call, render it and now want to get to its depth buffer then what code will do that for me using both Matlab and OpenGL. I.e. how do I set this up and then access the actual data? I essentially want to be able to use Matlabs powerful plotting functions and then be able to access the underlying graphics context for getting the depth buffer