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<'_>>
    ) -> u16;
    fn fragment_attributes(&self) -> FragmentAttributes;
    fn use_uniforms(
        &self,
        program: &Program,
        camera: &Camera,
        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<'_>> ) -> u16

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 that is larger than or equal to 0b1u16 << 16.

source

fn fragment_attributes(&self) -> FragmentAttributes

Returns a FragmentAttributes struct that describes which fragment attributes, ie. the input from the vertex shader, are required for rendering with this effect.

source

fn use_uniforms( &self, program: &Program, camera: &Camera, 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<'_>> ) -> u16

source§

fn fragment_attributes(&self) -> FragmentAttributes

source§

fn use_uniforms( &self, program: &Program, camera: &Camera, 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<'_>> ) -> u16

source§

fn fragment_attributes(&self) -> FragmentAttributes

source§

fn use_uniforms( &self, program: &Program, camera: &Camera, 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<'_>> ) -> u16

source§

fn fragment_attributes(&self) -> FragmentAttributes

source§

fn use_uniforms( &self, program: &Program, camera: &Camera, 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<'_>> ) -> u16

source§

fn fragment_attributes(&self) -> FragmentAttributes

source§

fn use_uniforms( &self, program: &Program, camera: &Camera, 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<'_>> ) -> u16

source§

fn fragment_attributes(&self) -> FragmentAttributes

source§

fn use_uniforms( &self, program: &Program, camera: &Camera, 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<'_>> ) -> u16

source§

fn fragment_attributes(&self) -> FragmentAttributes

source§

fn use_uniforms( &self, program: &Program, camera: &Camera, 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<'_>> ) -> u16

source§

fn fragment_attributes(&self) -> FragmentAttributes

source§

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

source§

fn render_states(&self) -> RenderStates

Implementors§