Struct three_d::core::render_target::ColorTarget
source · pub struct ColorTarget<'a> { /* private fields */ }
Expand description
Adds additional functionality to clear, read from and write to a texture.
Use the as_color_target
function directly on the texture structs (for example Texture2D) to construct a color target.
Combine this together with a DepthTarget with RenderTarget::new to be able to write to both a depth and color target at the same time.
A color target purely adds functionality, so it can be created each time it is needed, the actual data is saved in the texture.
Note: DepthTest is disabled if not also writing to a DepthTarget.
Implementations§
source§impl<'a> ColorTarget<'a>
impl<'a> ColorTarget<'a>
sourcepub fn clear(&self, clear_state: ClearState) -> &Self
pub fn clear(&self, clear_state: ClearState) -> &Self
Clears the color of this color target as defined by the given clear state.
sourcepub fn clear_partially(
&self,
scissor_box: ScissorBox,
clear_state: ClearState
) -> &Self
pub fn clear_partially( &self, scissor_box: ScissorBox, clear_state: ClearState ) -> &Self
Clears the color of the part of this color target that is inside the given scissor box.
sourcepub fn write<E: Error>(
&self,
render: impl FnOnce() -> Result<(), E>
) -> Result<&Self, E>
pub fn write<E: Error>( &self, render: impl FnOnce() -> Result<(), E> ) -> Result<&Self, E>
Writes whatever rendered in the render
closure into this color target.
sourcepub fn write_partially<E: Error>(
&self,
scissor_box: ScissorBox,
render: impl FnOnce() -> Result<(), E>
) -> Result<&Self, E>
pub fn write_partially<E: Error>( &self, scissor_box: ScissorBox, render: impl FnOnce() -> Result<(), E> ) -> Result<&Self, E>
Writes whatever rendered in the render
closure into the part of this color target defined by the scissor box.
sourcepub fn read<T: TextureDataType>(&self) -> Vec<T>
pub fn read<T: TextureDataType>(&self) -> Vec<T>
Returns the colors of the pixels in this color target.
The number of channels per pixel and the data format for each channel returned from this function is specified by the generic parameter T
.
Note:
The base type of the generic parameter T
must match the base type of the color target, for example if the color targets base type is u8
, the base type of T
must also be u8
.
Web:
The generic parameter T
is limited to:
- Unsigned byte RGBA (Specify
T
as eitherVec4<u8>
or[u8; 4]
) which works with any color target usingu8
as its base type. - 32-bit float RGBA (Specify
T
as eitherVec4<f32>
or[f32; 4]
) which works with any color target usingf16
orf32
as its base type.
sourcepub fn read_partially<T: TextureDataType>(
&self,
scissor_box: ScissorBox
) -> Vec<T>
pub fn read_partially<T: TextureDataType>( &self, scissor_box: ScissorBox ) -> Vec<T>
Returns the colors of the pixels in this color target inside the given scissor box.
The number of channels per pixel and the data format for each channel returned from this function is specified by the generic parameter T
.
Note:
The base type of the generic parameter T
must match the base type of the color target, for example if the color targets base type is u8
, the base type of T
must also be u8
.
Web:
The generic parameter T
is limited to:
- Unsigned byte RGBA (Specify
T
as eitherVec4<u8>
or[u8; 4]
) which works with any color target usingu8
as its base type. - 32-bit float RGBA (Specify
T
as eitherVec4<f32>
or[f32; 4]
) which works with any color target usingf16
orf32
as its base type.
source§impl<'a> ColorTarget<'a>
impl<'a> ColorTarget<'a>
sourcepub fn scissor_box(&self) -> ScissorBox
pub fn scissor_box(&self) -> ScissorBox
Returns the scissor box that encloses the entire target.
source§impl<'a> ColorTarget<'a>
impl<'a> ColorTarget<'a>
sourcepub fn render(
&self,
camera: &Camera,
objects: impl IntoIterator<Item = impl Object>,
lights: &[&dyn Light]
) -> &Self
pub fn render( &self, camera: &Camera, objects: impl IntoIterator<Item = impl Object>, lights: &[&dyn Light] ) -> &Self
Render the objects using the given camera and lights into this render target.
Use an empty array for the lights
argument, if the objects does not require lights to be rendered.
Also, objects outside the camera frustum are not rendered and the objects are rendered in the order given by cmp_render_order.
sourcepub fn render_partially(
&self,
scissor_box: ScissorBox,
camera: &Camera,
objects: impl IntoIterator<Item = impl Object>,
lights: &[&dyn Light]
) -> &Self
pub fn render_partially( &self, scissor_box: ScissorBox, camera: &Camera, objects: impl IntoIterator<Item = impl Object>, lights: &[&dyn Light] ) -> &Self
Render the objects using the given camera and lights into the part of this render target defined by the scissor box.
Use an empty array for the lights
argument, if the objects does not require lights to be rendered.
Also, objects outside the camera frustum are not rendered and the objects are rendered in the order given by cmp_render_order.
sourcepub fn render_with_material(
&self,
material: &dyn Material,
camera: &Camera,
geometries: impl IntoIterator<Item = impl Geometry>,
lights: &[&dyn Light]
) -> &Self
pub fn render_with_material( &self, material: &dyn Material, camera: &Camera, geometries: impl IntoIterator<Item = impl Geometry>, lights: &[&dyn Light] ) -> &Self
Render the geometries with the given Material using the given camera and lights into this render target.
Use an empty array for the lights
argument, if the material does not require lights to be rendered.
sourcepub fn render_partially_with_material(
&self,
scissor_box: ScissorBox,
material: &dyn Material,
camera: &Camera,
geometries: impl IntoIterator<Item = impl Geometry>,
lights: &[&dyn Light]
) -> &Self
pub fn render_partially_with_material( &self, scissor_box: ScissorBox, material: &dyn Material, camera: &Camera, geometries: impl IntoIterator<Item = impl Geometry>, lights: &[&dyn Light] ) -> &Self
Render the geometries with the given Material using the given camera and lights into the part of this render target defined by the scissor box.
Use an empty array for the lights
argument, if the material does not require lights to be rendered.
sourcepub fn render_with_effect(
&self,
effect: &dyn Effect,
camera: &Camera,
geometries: impl IntoIterator<Item = impl Geometry>,
lights: &[&dyn Light],
color_texture: Option<ColorTexture<'_>>,
depth_texture: Option<DepthTexture<'_>>
) -> &Self
pub fn render_with_effect( &self, effect: &dyn Effect, camera: &Camera, geometries: impl IntoIterator<Item = impl Geometry>, lights: &[&dyn Light], color_texture: Option<ColorTexture<'_>>, depth_texture: Option<DepthTexture<'_>> ) -> &Self
Render the geometries with the given Effect using the given camera and lights into this render target.
Use an empty array for the lights
argument, if the effect does not require lights to be rendered.
sourcepub fn render_partially_with_effect(
&self,
scissor_box: ScissorBox,
effect: &dyn Effect,
camera: &Camera,
geometries: impl IntoIterator<Item = impl Geometry>,
lights: &[&dyn Light],
color_texture: Option<ColorTexture<'_>>,
depth_texture: Option<DepthTexture<'_>>
) -> &Self
pub fn render_partially_with_effect( &self, scissor_box: ScissorBox, effect: &dyn Effect, camera: &Camera, geometries: impl IntoIterator<Item = impl Geometry>, lights: &[&dyn Light], color_texture: Option<ColorTexture<'_>>, depth_texture: Option<DepthTexture<'_>> ) -> &Self
Render the geometries with the given Effect using the given camera and lights into the part of this render target defined by the scissor box.
Use an empty array for the lights
argument, if the effect does not require lights to be rendered.
sourcepub fn apply_screen_material(
&self,
material: &dyn Material,
camera: &Camera,
lights: &[&dyn Light]
) -> &Self
pub fn apply_screen_material( &self, material: &dyn Material, camera: &Camera, lights: &[&dyn Light] ) -> &Self
Apply the given Material to this render target.
Use an empty array for the lights
argument, if the material does not require lights to be rendered.
sourcepub fn apply_screen_material_partially(
&self,
scissor_box: ScissorBox,
material: &dyn Material,
camera: &Camera,
lights: &[&dyn Light]
) -> &Self
pub fn apply_screen_material_partially( &self, scissor_box: ScissorBox, material: &dyn Material, camera: &Camera, lights: &[&dyn Light] ) -> &Self
Apply the given Material to the part of this render target defined by the scissor box.
Use an empty array for the lights
argument, if the material does not require lights to be rendered.
sourcepub fn apply_screen_effect(
&self,
effect: &dyn Effect,
camera: &Camera,
lights: &[&dyn Light],
color_texture: Option<ColorTexture<'_>>,
depth_texture: Option<DepthTexture<'_>>
) -> &Self
pub fn apply_screen_effect( &self, effect: &dyn Effect, camera: &Camera, lights: &[&dyn Light], color_texture: Option<ColorTexture<'_>>, depth_texture: Option<DepthTexture<'_>> ) -> &Self
Apply the given Effect to this render target.
Use an empty array for the lights
argument, if the effect does not require lights to be rendered.
sourcepub fn apply_screen_effect_partially(
&self,
scissor_box: ScissorBox,
effect: &dyn Effect,
camera: &Camera,
lights: &[&dyn Light],
color_texture: Option<ColorTexture<'_>>,
depth_texture: Option<DepthTexture<'_>>
) -> &Self
pub fn apply_screen_effect_partially( &self, scissor_box: ScissorBox, effect: &dyn Effect, camera: &Camera, lights: &[&dyn Light], color_texture: Option<ColorTexture<'_>>, depth_texture: Option<DepthTexture<'_>> ) -> &Self
Apply the given Effect to the part of this render target defined by the scissor box.
Use an empty array for the lights
argument, if the effect does not require lights to be rendered.
Trait Implementations§
source§impl<'a> Clone for ColorTarget<'a>
impl<'a> Clone for ColorTarget<'a>
source§fn clone(&self) -> ColorTarget<'a>
fn clone(&self) -> ColorTarget<'a>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more