8

While there is some interesting research into order-independent transparency rendering, it's extremely complex to implement. And even sorting individual leaves can still cause artifacts where one leaf overlaps itself. So your safest bet is probably Alpha Testing. This is where you specify a threshold opacity value; anything above that value is rendered 100% ...


6

so, to rework from comments: this is Z-fighting. The math is very well explained here: http://chaosinmotion.com/blog/?p=555, and the ways to solve it here: https://www.opengl.org/wiki/Depth_Buffer_Precision, but the gist is that Z-buffer is discrete, non-linear, and depends on the ratio of farplane/nearplane. discrete: the distance between near and far ...


6

It's important to note that glxinfo -v only reports the supported values for the default OpenGL framebuffer, the one that represents the visible screen itself. It's common for other configurations (ones not reported by glxinfo) to be supported in offscreen framebuffer objects (FBOs). As you've noticed, most video cards do not support a 32-bit depth buffer ...


5

The general rule of thumb when drawing alpha polys is: 1 - Draw all solid polys first. 2 - Sort back to front if you can. The main reason for this is to ensure that the final colour produced by the blending equation is consistent frame to frame. I often don't bother with this step unless it is something provided by the engine and I can justify the extra ...


5

In the Unity docs under shader references. Shadow mapping macros Declaring and sampling shadow maps can be very different depending on the platform, so Unity has several macros to help with that: UNITY_DECLARE_SHADOWMAP(tex) - declares a shadowmap texture variable with name “tex”. UNITY_SAMPLE_SHADOW(tex,uv) - samples shadowmap texture “tex” at given “uv”...


5

Indeed, the values stored in the z-buffer are not linear to the actual z coordinates of your objects, but to their reciprocal, in order to give more resolution to what's near the eye than to what's closer to the back plane. What you do is that you map your zNear to 0 and your zFar to 1. For zNear=1 and zFar=2, it should look like this The way to calculate ...


5

Solution I used good algorithm for depth linearization but I didn't convert depth to NDC first: const float near = 0.1; // projection matrix's near plane const float far = 90.0; // projection matrix's far plane float LinearizeDepth(float depth) { float z = depth * 2.0 - 1.0; // back to NDC return (2.0 * near * far) / (far + near - z * (far - near))...


5

"Z-buffers" and "raytracing" are not mutually exclusive. Z-buffers are frequently used to support triangle-based, back-projected rendering (though they are optional in actual usage), and they can also be used to support raytracing. Equating z-buffers to traditional GPU polygon-based, back-projected rendering, just because these are often found together, is ...


4

Basically if you number X and Y iso-coordinates their sum is the number of the diagonal, you sort tiles by diagonal, and then draw first tiles with lower Z. This is indipendent of screen coordinates. (of course assuming the camera is in the bottom left corner of the image)


4

Floating-point depth buffers would enhance range if they actually stored non-normalized depth values. You have a choice between 32-bit fixed-point or 32-bit floating-point depth, for all other bit-depths the depth buffer is always fixed-point. So compared to a 24-bit or 16-bit depth buffer, a floating-point depth buffer always has enhanced precision... but ...


4

The result sampled from gbuffer_texture[2] will be in the [0, 1] range, but in OpenGL, NDC space ranges from -1 to 1 along all three axes. (This is different from D3D, where the NDC space ranges from 0 to 1 along the z axis.) So, you need to multiply the depth result by 2 and subtract 1 to convert the range to [-1, 1], just as you're doing already for the ...


4

1: camera space, like Andon said. 2: the projection matrix contains those Fx,Fy values (f and f/aspect) at cells [0][0] and [1][1] see https://www.opengl.org/sdk/docs/man2/xhtml/gluPerspective.xml 2x/Vx-1.0 is to convert from screen pixel coordinates which are from (0, 0) to (WIDTH, HEIGHT) to 3D projected coordinates that are from -1 to 1. 3: the "real" ...


4

Yes, your Z value, distToCamera, will be correct at each triangle's vertices, but won't be anywhere else (except between vertices of matching Z-value), because of linear interpolation. Edit: In current GLSL, the default interpolation is "in perspective", where gl_Position/gl_FragCoord is taken into account for interpolating. This can be overridden (you won'...


4

Your depth buffer does not contain "entities". It contains the stuff you rendered. So if you read the depth buffer, you will read the depth for the closest stuff you rendered. So either you make a special depth-only rendering pass that does not contain "entities", or you're going to have to do something else to convert from the user's selected location to a ...


4

A common mistake is to zero out MinDepth and MaxDepth of the D3D11_VIEWPORT, effectively clamping all depth to the near plane. The default depth states are test enabled, write enabled, compare less. See the list at MSDN. In Direct3D 11, normalized device coordinates in clip space after W division run from [-1.0, +1.0] on the X and Y axes, and (0.0, 1.0] on ...


4

You should perform the depth test in the fragment shader "manually". OpenGL doesn't support multiple depth tests, and that its just what you need to render the second nearest pixels, because: You need the second front pixels (GL_LESS over the actual depth buffer) You need the second front pixels (GL_GREATER over the depth buffer of the first framebuffer). ...


4

One solution is to use DLL injection. This technique facilitates attaching and executing a payload (your code) within the address space of another process (the game or graphics driver) by way of a dynamic link library (DLL). Once the injected, your payload code would: intercept instructions of interest process them as needed (log them for later, perform ...


3

A smart bubble/insertion sort is faster than quick sort when the array is already mostly sorted (reused on the next frame). To speed up the copy of data rather than copying entire vertex values use an index buffer to sort the vertices. When you remove quads you can quickly degenerate them (set all vertices to the same value) instead of removing them and ...


3

XNA has a depth option when drawing with a SpriteBatch. This is the command I use for drawing: Batch.Draw(sprite.Sheet.Texture, sprite.Position, sprite.Sheet.GetSourceRect(sprite.SpriteX, sprite.SpriteY), sprite.Color, sprite.Rotation, sprite.Origin, sprite.Scale, SpriteEffects.None, sprite.Depth); My sprite is a class which contains a couple of ...


3

The problem with the models overlapping after ToggleFullscreen() is that the Depth Stencil View also needs to be recreated when the back buffer is resized. I made these modifications to ToggleFullscreen(): ... D3D11_TEXTURE2D_DESC depthBufferDesc; D3D11_DEPTH_STENCIL_VIEW_DESC depthStencilViewDesc; depthStencilView->Release(); depthStencilBuffer->...


3

Of course it is possible, if people can write a depth buffer you can too, but it will be hideously slow. Reading from and updating SDL2 textures is very slow because it's all via software, i.e. not hardware accelerated. Proper depth buffers operate at the rasterisation step and are accelerated via your massively parallel graphics hardware. Since SDL2 doesn'...


3

The depth is stored from 0 to 1 (0 - closest, 1 - farthest) by default. Addition to that, depth in perspective projection is not linear, it looked something like this: So it makes sense to me if it fades to white faster. Unless, you normalize it (see János Turánszki's answer).


3

After much trial and error and Google-fu, I've come across a texture blend shader that gave a similar effect to what you wanted. After a bit of tinkering I've achieved a satisfactory result. What this shader does, is that it blends the mesh right below itself and it'd normally add some sort of transparency effect to the material. I've modified the values ...


3

You will need to implement multiple alternative solutions depending on the GPU. Not only are there many choices (GL_DEPTH_COMPONENT16, GL_DEPTH_COMPONENT24, GL_DEPTH_COMPONENT32, GL_DEPTH_COMPONENT32F, and GL_DEPTH24_STENCIL8, GL_UNSIGNED_INT_24_8_OES) every GPU has different levels of support and fallbacks must be implemented. It is possible the GPU does ...


3

What is the Depth Buffer? The depth buffer stores how far away from the "camera" is what you have rendered. This allows the graphic system (the GPU does this in modern hardware) to check if what you are drawing is in front or behind, for every pixel, and based on that decide if it is drawn (and update the depth buffer) or not. We call that, the ...


2

The hardware slope-scaled depth bias should work fine with deferred shading. It only affects the depth values written into the shadow map, so you generate the same shadow map regardless of whether you're using forward or deferred shading. Is it possible you're not reconstructing position from (camera) depth correctly when you do your lighting passes? That ...


2

The most robust way to do this is probably to split your geometry into two separate draw calls, one with depth testing and one without. That said, if you want to do it in one batch... 1) If the depth override is set on a per-vertex level, you can do something like this in your vertex shader: output.position = mul(worldViewProjectionMatrix, vertex.position)...


2

First, from the picture it seems that in fact your light is not a "directional" light but a spotlight because you are using perspective projection, not an orthographic one (If not, then it is just the picture :) ). It is just a little thing, it should work more-or less the same. The important thing is, you don't render the positions from the light's point ...


2

There are two main ways to do this. First way is to do exactly what you're trying to avoid doing, and use a render target. This is the way used by the Shadow Mapping sample for D3D9 in the old DirectX SDK, although it needn't be 32-bit (D3DFMT_R16F may well be sufficient). As a possible optimization you could use a NULL depth/stencil target, enable ...


Only top voted, non community-wiki answers of a minimum length are eligible