[−][src]Struct web_glitz::pipeline::graphics::DepthTest
Provides instructions on how depth testing should be performed.
In order to do a depth test, the [RenderTarget] that is being rendered to must include a depth
buffer. A depth buffer stores a depth value between 0.0
(close) and 1.0
(far) for each
fragment. Initially the depth value for each fragment is set to 1.0
. When rendering to a
[RenderTarget] with no depth buffer attached, the depth test behaves as though depth testing is
disabled.
The depth test is performed for each fragment. The fragment's depth output will be mapped onto the range defined by [depth_range]:
- Values smaller than the lower bound will be mapped to
0.0
. - Values greater than the upper bound will be mapped to
1.0
. - Values contained on the range will be mapped to the range
0.0..1.0
.
The lower bound of the [depth_range] must not be smaller than 0.0
, the upper bound of the
[depth_range] must not be greater than 1.0
, and the lower bound must be strictly smaller than
the upper bound.
The resulting depth value may then be compared to the depth buffer's current depth value for this fragment using the test. The test can be one of the following functions:
- TestFunction::Equal: the test passes if the fragment's depth value is equal to the depth buffer's current depth value for this fragment.
- TestFunction::NotEqual: the test passes if the fragment's depth value is not equal to the depth buffer's current depth value for this fragment.
- TestFunction::Less: the test passes if the fragment's depth value is smaller than the depth buffer's current depth value for this fragment.
- TestFunction::Greater: the test passes if the fragment's depth value is greater than the depth buffer's current depth value for this fragment.
- TestFunction::LessOrEqual: the test passes if the fragment's depth value is smaller than or equal to the depth buffer's current depth value for this fragment.
- TestFunction::GreaterOrEqual: the test passes if the fragment's depth value is greater than or equal to the depth buffer's current depth value for this fragment.
- TestFunction::NeverPass: the test never passes, regardless of how the fragment's depth value compares to the depth buffer's current depth value for this fragment.
- TestFunction::AlwaysPass: the test always passes, regardless of how the fragment's depth value compares to depth buffer's current depth value for this fragment.
If the test fails, the fragment will be discarded: none of the [RenderTarget]'s output buffers
will be updated. If the test passes and write is true
, then the depth buffer's depth value
for this fragment will be replaced with the new depth value; if write is false
, then the
depth buffer will not be updated. If the test passes, the fragment will not be discarded by the
depth test, but note that other stages of the pipeline (such as front/back-face culling, stencil
testing, the fragment shader) may still discard the fragment.
An instance of for the default depth test options may be obtained via Default:
use web_glitz::pipeline::graphics::{DepthTest, TestFunction, DepthRange}; assert_eq!(DepthTest::default(), DepthTest { test: TestFunction::Less, write: true, depth_range: DepthRange::default(), polygon_offset: None });
Fields
test: TestFunction
The TestFunction used to decide if the DepthTest passes or fails.
Defaults to TestFunction::Less.
write: bool
Whether or not the depth buffer will be updated when the depth test passes.
When set to false
, the depth buffer will not be updated when the depth test passes.
Defaults to true
.
depth_range: DepthRange
Defines how a fragment's depth output will be mapped onto the range 0.0..1.0
from the near
plane at 0.0
to the far plane at 1.0
.
See DepthRange for details.
polygon_offset: Option<PolygonOffset>
Defines an optional polygon-offset to be applied to depth fragments optioned from polygonal primitives (triangles).
See PolygonOffset for details.
Defaults to None
, in which case no polygon offset will be applied.
Trait Implementations
impl Clone for DepthTest
[src]
impl Debug for DepthTest
[src]
impl Default for DepthTest
[src]
impl PartialEq<DepthTest> for DepthTest
[src]
impl StructuralPartialEq for DepthTest
[src]
Auto Trait Implementations
impl RefUnwindSafe for DepthTest
impl Send for DepthTest
impl Sync for DepthTest
impl Unpin for DepthTest
impl UnwindSafe for DepthTest
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<D, T> IntoBuffer<T> for D where
D: Borrow<T> + 'static,
T: Copy + 'static,
[src]
D: Borrow<T> + 'static,
T: Copy + 'static,
pub fn into_buffer<Rc>(Self, &Rc, BufferId, UsageHint) -> Buffer<T> where
Rc: RenderingContext + Clone + 'static,
[src]
Rc: RenderingContext + Clone + 'static,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,