[2.3] Quad Pass Depth

Problems building or running the engine, queries about how to use features etc.
Post Reply
psysu
Halfling
Posts: 72
Joined: Tue Jun 01, 2021 7:47 am
x 6

[2.3] Quad Pass Depth

Post by psysu »

Hi, I'm wondering whether the quad mesh's depth during quad pass can be controlled.

I would appreciate it if someone could explain how the quad geometry is constructed during quad pass.

Thanks

User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5298
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1279
Contact:

Re: [2.3] Quad Pass Depth

Post by dark_sylinc »

Do you mean per pixel or per vertex?

I would appreciate it if someone could explain how the quad geometry is constructed during quad pass.

PassQuad uses v1::Rectangle, which means the vertices are populated in Rectangle2D::_restoreManualHardwareResources here.

The depth is hardcoded to z = -1 which, when multiplied against an identity projection matrix in the vertex shader (see Samples/Media/2.0/scripts/materials/Common/GLSL/Quad_vs.glsl and HLSL/Metal equivalents), the Z value becomes either 0 (D3D11/Vulkan/Metal), -1 (OpenGL) or 1 (D3D11/Vulkan/Metal when reverse Z is enabled, aka the default).

Whether a quad or a triangle is used depends on the use_quad compositor option (see Manual)

psysu
Halfling
Posts: 72
Joined: Tue Jun 01, 2021 7:47 am
x 6

Re: [2.3] Quad Pass Depth

Post by psysu »

Code: Select all

Do you mean per pixel or per vertex?

Per Pixel. i have to do this on shader i assume.

Thanks for explaining how the quad geometry is constructed.

User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5298
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1279
Contact:

Re: [2.3] Quad Pass Depth

Post by dark_sylinc »

I forgot to reply per pixel.

See Samples/Media/2.0/scripts/materials/Common/GLSL/DepthDownscaleMax_ps.glsl which outputs to gl_FragDepth (and its HLSL/Metal equivalents).

Please note that outputting to gl_FragDepth will disable various GPU HW optimizations for anything that is rendered afterwards (Hi Z, Early Z, depth compression, etc). See Depth In Depth. It's an old article, but most of what it says still holds for desktop GPUs.

Post Reply