Struct three_d::renderer::object::InstancedModel [−][src]
pub struct InstancedModel<M: ForwardMaterial> {
pub cull: Cull,
pub material: M,
// some fields omitted
}Expand description
Similar to Model, except it is possible to render many instances of the same model efficiently.
Fields
cull: Cullset in render states on material instead
material: MThe material applied to the instanced model
Implementations
Creates a new instanced 3D model with a triangle mesh as geometry and a default ColorMaterial. The transformations are applied to each model instance before they are rendered. The model is rendered in as many instances as there are transformation matrices.
pub fn new_with_material(
context: &Context,
transformations: &[Mat4],
cpu_mesh: &CPUMesh,
material: M
) -> ThreeDResult<Self>
Updates the transformations applied to each model instance before they are rendered. The model is rendered in as many instances as there are transformation matrices.
👎 Deprecated: Use ‘render_forward’ instead
Use ‘render_forward’ instead
Render the instanced model with a color per triangle vertex. The colors are defined when constructing the instanced model. Must be called in a render target render function, for example in the callback function of Screen::write. The transformation can be used to position, orientate and scale the instanced model.
Errors
Will return an error if the instanced model has no colors.
👎 Deprecated: Use ‘render_forward’ instead
Use ‘render_forward’ instead
Render the instanced model with the given color. The color is assumed to be in gamma color space (sRGBA). Must be called in a render target render function, for example in the callback function of Screen::write. The transformation can be used to position, orientate and scale the instanced model.
pub fn render_with_texture(
&self,
texture: &impl Texture,
camera: &Camera
) -> ThreeDResult<()>
👎 Deprecated: Use ‘render_forward’ instead
pub fn render_with_texture(
&self,
texture: &impl Texture,
camera: &Camera
) -> ThreeDResult<()>
Use ‘render_forward’ instead
Render the instanced model with the given texture which is assumed to be in sRGB color space with or without an alpha channel. Must be called in a render target render function, for example in the callback function of Screen::write. The transformation can be used to position, orientate and scale the instanced model.
Errors
Will return an error if the instanced model has no uv coordinates.
👎 Deprecated: Use ‘render_forward’ instead
Use ‘render_forward’ instead
Render the depth (scaled such that a value of 1 corresponds to max_depth) into the red channel of the current color render target which for example is used for picking. Must be called in a render target render function, for example in the callback function of Screen::write.
👎 Deprecated: Use ‘render_forward’ instead
Use ‘render_forward’ instead
Render only the depth into the current depth render target which is useful for shadow maps or depth pre-pass. Must be called in a render target render function, for example in the callback function of Screen::write.
Trait Implementations
Returns the AxisAlignedBoundingBox for this geometry. Read more
Returns the local to world transformation applied to this geometry. Read more
Set the local to world transformation applied to this geometry. Read more
Render the object. Must be called in a render target render function, for example in the callback function of Screen::write. You can use Lights::default() if you know the object does not require lights to be rendered. Read more
Returns whether or not this object should be considered transparent. Read more
fn render_forward(
&self,
material: &dyn ForwardMaterial,
camera: &Camera,
lights: &Lights
) -> ThreeDResult<()>
fn render_forward(
&self,
material: &dyn ForwardMaterial,
camera: &Camera,
lights: &Lights
) -> ThreeDResult<()>
Render the object with the given material. Must be called in a render target render function, for example in the callback function of Screen::write. You can use Lights::default() if you know the material does not require lights. Read more
fn render_deferred(
&self,
material: &dyn DeferredMaterial,
camera: &Camera,
viewport: Viewport
) -> ThreeDResult<()>
fn render_deferred(
&self,
material: &dyn DeferredMaterial,
camera: &Camera,
viewport: Viewport
) -> ThreeDResult<()>
Render the geometry and surface material parameters of the object. Should usually not be called directly but used in DeferredPipeline::geometry_pass. Read more
fn render_with_lighting(
&self,
camera: &Camera,
material: &PhysicalMaterial,
lighting_model: LightingModel,
ambient_light: Option<&AmbientLight>,
directional_lights: &[&DirectionalLight],
spot_lights: &[&SpotLight],
point_lights: &[&PointLight]
) -> ThreeDResult<()>
fn render_with_lighting(
&self,
camera: &Camera,
material: &PhysicalMaterial,
lighting_model: LightingModel,
ambient_light: Option<&AmbientLight>,
directional_lights: &[&DirectionalLight],
spot_lights: &[&SpotLight],
point_lights: &[&PointLight]
) -> ThreeDResult<()>
Use ‘render_forward’ instead
Render the object shaded with the given lights using physically based rendering (PBR). Must be called in a render target render function, for example in the callback function of Screen::write. Will render transparent if the material contain an albedo color with alpha value below 255 or if the albedo texture contain an alpha channel (ie. the format is Format::RGBA), you only need to render the model after all solid models. Read more
fn geometry_pass(
&self,
camera: &Camera,
viewport: Viewport,
material: &PhysicalMaterial
) -> ThreeDResult<()>
fn geometry_pass(
&self,
camera: &Camera,
viewport: Viewport,
material: &PhysicalMaterial
) -> ThreeDResult<()>
Use ‘render_deferred’ instead
Render the geometry and surface material parameters of the object. Should not be called directly but used in a deferred render pass. Read more
Auto Trait Implementations
impl<M> !RefUnwindSafe for InstancedModel<M>
impl<M> !Send for InstancedModel<M>
impl<M> !Sync for InstancedModel<M>
impl<M> Unpin for InstancedModel<M> where
M: Unpin,
impl<M> !UnwindSafe for InstancedModel<M>
Blanket Implementations
Mutably borrows from an owned value. Read more
Attaches the provided Subscriber to this type, returning a
WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a
WithDispatch wrapper. Read more