Questions tagged [zbuffer]

is an array used to store the maximum Z coordinate of any feature plotted at a given (X, Y) location on the screen.

The Z-buffer is a memory buffer (array) used in a graphics accelerator to hold the maximum z-axis value of each (X, Y) location. This allows a pixel check so that if any pixel is "below" the z-buffer value for that location, it can be ignored. This is for "hidden surface removal."

114 questions
24
votes
7 answers

Three.js / WebGL - transparent planes hiding other planes behind them

When you have two planes in Three.js / WebGL and one or both of them are transparent, sometimes the plane behind will be hidden by the transparent plane above. Why is this?
MaiaVictor
  • 51,090
  • 44
  • 144
  • 286
10
votes
2 answers

Using OpenGL in Matlab to get depth buffer

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…
twerdster
  • 4,977
  • 3
  • 40
  • 70
10
votes
10 answers

How to work around a very large 2d array in C++

I need to create a 2D int array of size 800x800. But doing so creates a stack overflow (ha ha). I'm new to C++, so should I do something like a vector of vectors? And just encapsulate the 2d array into a class? Specifically, this array is my…
Bryan Denny
  • 27,363
  • 32
  • 109
  • 125
10
votes
3 answers

Reading .exr files in OpenCV

I have generated some depth maps using blender and have saved z-buffer values(32 bits) in OpenEXR format. Is there any way to access values from a .exr file (pixel by pixel depth info) using OpenCV 2.4.13 and python 2.7? There is no example anywhere…
gaya
  • 463
  • 2
  • 6
  • 22
8
votes
3 answers

Perspective correct texture mapping; z distance calculation might be wrong

I'm making a software rasterizer, and I've run into a bit of a snag: I can't seem to get perspective-correct texture mapping to work. My algorithm is to first sort the coordinates to plot by y. This returns a highest, lowest and center point. I then…
knight666
  • 1,599
  • 3
  • 22
  • 38
8
votes
1 answer

gl_FragCoord.x, y, z being 1 for all pixels and w being the depth

I'm using THREE.js with shader. I'm trying to get the zbuffer information. Vertex shader: // switch on high precision floats #ifdef GL_ES precision highp float; #endif void main() { gl_Position = projectionMatrix * modelViewMatrix *…
Ovilia
  • 7,066
  • 12
  • 47
  • 70
6
votes
2 answers

THREE.JS: Render large, distant objects at correct z-indicies and still zoom into small objects

I've got a scene where I'm drawing(to scale) the earth, moon, and some spacecraft. When the moon is occluded by the earth, instead of disappearing, it is still visible (through the earth). From my research I found that part of the problem is that…
Boogiechillin
  • 276
  • 3
  • 19
6
votes
1 answer

Get depth from camera for each pixel

I have a mesh model and, using VTK, have rendered a view of it from a given camera position (x,y,z). I can save this to an RGB image (640x480) but I also want to save a depth map where each pixel stores the value of the depth from the camera. I…
Aly
  • 15,865
  • 47
  • 119
  • 191
5
votes
1 answer

using renderOrder in three.js

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…
nebeleh
  • 83
  • 1
  • 8
5
votes
1 answer

Logarithmic depth buffer linearization

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…
user1075940
  • 1,086
  • 2
  • 22
  • 46
4
votes
2 answers

Zbuffer rules for gl_Position

Here are my settings for opengl, incase they matter: glViewport(0,0,w,h); //w=800, h=600 glShadeModel(GL_SMOOTH); glClearColor(0.0f, 0.0f, 0.0f,…
Kevin Kostlan
  • 3,311
  • 7
  • 29
  • 33
4
votes
1 answer

OpenGL optimizing skybox rendering

I'm learning how to draw skybox using cubemaps from the following resource. I've got to the part where he talks about how we can optimize the rendering of the skybox. I get that instead of rendering the skybox first, which will result in…
Jorayen
  • 1,737
  • 2
  • 21
  • 52
4
votes
2 answers

Get the z-Buffer in 16 bit resolution in 3ds max

I read out the z-Buffer from an image like the following: --get z buffer in HD resolution rbmpHD = render outputsize:[1920,1080] channels:#(#zdepth) vfb:off camera: z_cam z_dHD = getchannelasmask rbmp #zdepth outputfile:z_name…
Kev1n91
  • 3,553
  • 8
  • 46
  • 96
4
votes
1 answer

How to get Z values from Z Buffer

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
Sonoman
  • 3,379
  • 9
  • 45
  • 61
4
votes
1 answer

Drawing unobscured health bars in a Java 3D scene

So I'm working on a game in Java 3D and I'm implementing health bars that hover above units. I started by drawing a quad at a 3D point above the unit's location and applying a Billboard behavior to make it always face the camera. But the problem I'm…
mjomble
  • 521
  • 3
  • 9
  • 20
1
2 3 4 5 6 7 8