Trait Effect

Source
pub trait Effect {
    // Required methods
    fn fragment_shader_source(
        &self,
        lights: &[&dyn Light],
        color_texture: Option<ColorTexture<'_>>,
        depth_texture: Option<DepthTexture<'_>>,
    ) -> String;
    fn id(
        &self,
        color_texture: Option<ColorTexture<'_>>,
        depth_texture: Option<DepthTexture<'_>>,
    ) -> EffectMaterialId;
    fn use_uniforms(
        &self,
        program: &Program,
        viewer: &dyn Viewer,
        lights: &[&dyn Light],
        color_texture: Option<ColorTexture<'_>>,
        depth_texture: Option<DepthTexture<'_>>,
    );
    fn render_states(&self) -> RenderStates;
}
Expand description

Similar to Material, the difference is that an effect needs the rendered color texture and/or depth texture of the scene to be applied. Therefore an effect is always applied one at a time and after the scene has been rendered with the regular Material.

Required Methods§

Source

fn fragment_shader_source( &self, lights: &[&dyn Light], color_texture: Option<ColorTexture<'_>>, depth_texture: Option<DepthTexture<'_>>, ) -> String

Returns the fragment shader source for this effect.

Source

fn id( &self, color_texture: Option<ColorTexture<'_>>, depth_texture: Option<DepthTexture<'_>>, ) -> EffectMaterialId

Returns a unique ID for each variation of the shader source returned from Effect::fragment_shader_source.

Note: The first 16 bits are reserved to internally implemented effects, so if implementing the Effect trait outside of this crate, always return an id in the public use range as defined by EffectMaterialId.

Source

fn use_uniforms( &self, program: &Program, viewer: &dyn Viewer, lights: &[&dyn Light], color_texture: Option<ColorTexture<'_>>, depth_texture: Option<DepthTexture<'_>>, )

Sends the uniform data needed for this effect to the fragment shader.

Source

fn render_states(&self) -> RenderStates

Returns the render states needed to render with this effect.

Implementations on Foreign Types§

Source§

impl<T: Effect + ?Sized> Effect for &T

Source§

fn fragment_shader_source( &self, lights: &[&dyn Light], color_texture: Option<ColorTexture<'_>>, depth_texture: Option<DepthTexture<'_>>, ) -> String

Source§

fn id( &self, color_texture: Option<ColorTexture<'_>>, depth_texture: Option<DepthTexture<'_>>, ) -> EffectMaterialId

Source§

fn use_uniforms( &self, program: &Program, viewer: &dyn Viewer, lights: &[&dyn Light], color_texture: Option<ColorTexture<'_>>, depth_texture: Option<DepthTexture<'_>>, )

Source§

fn render_states(&self) -> RenderStates

Source§

impl<T: Effect + ?Sized> Effect for &mut T

Source§

fn fragment_shader_source( &self, lights: &[&dyn Light], color_texture: Option<ColorTexture<'_>>, depth_texture: Option<DepthTexture<'_>>, ) -> String

Source§

fn id( &self, color_texture: Option<ColorTexture<'_>>, depth_texture: Option<DepthTexture<'_>>, ) -> EffectMaterialId

Source§

fn use_uniforms( &self, program: &Program, viewer: &dyn Viewer, lights: &[&dyn Light], color_texture: Option<ColorTexture<'_>>, depth_texture: Option<DepthTexture<'_>>, )

Source§

fn render_states(&self) -> RenderStates

Source§

impl<T: Effect> Effect for Box<T>

Source§

fn fragment_shader_source( &self, lights: &[&dyn Light], color_texture: Option<ColorTexture<'_>>, depth_texture: Option<DepthTexture<'_>>, ) -> String

Source§

fn id( &self, color_texture: Option<ColorTexture<'_>>, depth_texture: Option<DepthTexture<'_>>, ) -> EffectMaterialId

Source§

fn use_uniforms( &self, program: &Program, viewer: &dyn Viewer, lights: &[&dyn Light], color_texture: Option<ColorTexture<'_>>, depth_texture: Option<DepthTexture<'_>>, )

Source§

fn render_states(&self) -> RenderStates

Source§

impl<T: Effect> Effect for Rc<T>

Source§

fn fragment_shader_source( &self, lights: &[&dyn Light], color_texture: Option<ColorTexture<'_>>, depth_texture: Option<DepthTexture<'_>>, ) -> String

Source§

fn id( &self, color_texture: Option<ColorTexture<'_>>, depth_texture: Option<DepthTexture<'_>>, ) -> EffectMaterialId

Source§

fn use_uniforms( &self, program: &Program, viewer: &dyn Viewer, lights: &[&dyn Light], color_texture: Option<ColorTexture<'_>>, depth_texture: Option<DepthTexture<'_>>, )

Source§

fn render_states(&self) -> RenderStates

Source§

impl<T: Effect> Effect for Arc<T>

Source§

fn fragment_shader_source( &self, lights: &[&dyn Light], color_texture: Option<ColorTexture<'_>>, depth_texture: Option<DepthTexture<'_>>, ) -> String

Source§

fn id( &self, color_texture: Option<ColorTexture<'_>>, depth_texture: Option<DepthTexture<'_>>, ) -> EffectMaterialId

Source§

fn use_uniforms( &self, program: &Program, viewer: &dyn Viewer, lights: &[&dyn Light], color_texture: Option<ColorTexture<'_>>, depth_texture: Option<DepthTexture<'_>>, )

Source§

fn render_states(&self) -> RenderStates

Source§

impl<T: Effect> Effect for RefCell<T>

Source§

fn fragment_shader_source( &self, lights: &[&dyn Light], color_texture: Option<ColorTexture<'_>>, depth_texture: Option<DepthTexture<'_>>, ) -> String

Source§

fn id( &self, color_texture: Option<ColorTexture<'_>>, depth_texture: Option<DepthTexture<'_>>, ) -> EffectMaterialId

Source§

fn use_uniforms( &self, program: &Program, viewer: &dyn Viewer, lights: &[&dyn Light], color_texture: Option<ColorTexture<'_>>, depth_texture: Option<DepthTexture<'_>>, )

Source§

fn render_states(&self) -> RenderStates

Source§

impl<T: Effect> Effect for RwLock<T>

Source§

fn fragment_shader_source( &self, lights: &[&dyn Light], color_texture: Option<ColorTexture<'_>>, depth_texture: Option<DepthTexture<'_>>, ) -> String

Source§

fn id( &self, color_texture: Option<ColorTexture<'_>>, depth_texture: Option<DepthTexture<'_>>, ) -> EffectMaterialId

Source§

fn use_uniforms( &self, program: &Program, viewer: &dyn Viewer, lights: &[&dyn Light], color_texture: Option<ColorTexture<'_>>, depth_texture: Option<DepthTexture<'_>>, )

Source§

fn render_states(&self) -> RenderStates

Implementors§