Skip to main content

LightProbeComponent

Trait LightProbeComponent 

Source
pub trait LightProbeComponent:
    Send
    + Sync
    + Component
    + Sized {
    type AssetId: Send + Sync + Clone + Eq + Hash;
    type ViewLightProbeInfo: Send + Sync + Default;
    type QueryData: ReadOnlyQueryData;

    // Required methods
    fn id(&self, image_assets: &RenderAssets<GpuImage>) -> Option<Self::AssetId>;
    fn intensity(&self) -> f32;
    fn flags(
        &self,
        query_components: &<Self::QueryData as QueryData>::Item<'_, '_>,
    ) -> RenderLightProbeFlags;
    fn create_render_view_light_probes(
        view_component: Option<&Self>,
        image_assets: &RenderAssets<GpuImage>,
    ) -> RenderViewLightProbes<Self>;

    // Provided methods
    fn get_world_from_light_matrix(
        &self,
        original_world_from_light: &Affine3A,
    ) -> Affine3A { ... }
    fn parallax_correction_bounds(
        &self,
        _query_components: &<Self::QueryData as QueryData>::Item<'_, '_>,
    ) -> Vec3 { ... }
}
Expand description

A trait implemented by all components that represent light probes.

Currently, the two light probe types are EnvironmentMapLight and IrradianceVolume, for reflection probes and irradiance volumes respectively.

Most light probe systems are written to be generic over the type of light probe. This allows much of the code to be shared and enables easy addition of more light probe types (e.g. real-time reflection planes) in the future.

Required Associated Types§

Source

type AssetId: Send + Sync + Clone + Eq + Hash

Holds AssetIds of the texture or textures that this light probe references.

This can just be AssetId if the light probe only references one texture. If it references multiple textures, it will be a structure containing those asset IDs.

Source

type ViewLightProbeInfo: Send + Sync + Default

If the light probe can be attached to the view itself (as opposed to a cuboid region within the scene), this contains the information that will be passed to the GPU in order to render it. Otherwise, this will be ().

Currently, only reflection probes (i.e. EnvironmentMapLight) can be attached directly to views.

Source

type QueryData: ReadOnlyQueryData

Any additional query data needed to determine the RenderLightProbeFlags for this light probe.

Required Methods§

Source

fn id(&self, image_assets: &RenderAssets<GpuImage>) -> Option<Self::AssetId>

Returns the asset ID or asset IDs of the texture or textures referenced by this light probe.

Source

fn intensity(&self) -> f32

Returns the intensity of this light probe.

This is a scaling factor that will be multiplied by the value or values sampled from the texture.

Source

fn flags( &self, query_components: &<Self::QueryData as QueryData>::Item<'_, '_>, ) -> RenderLightProbeFlags

Returns the appropriate value of RenderLightProbeFlags for this component.

Source

fn create_render_view_light_probes( view_component: Option<&Self>, image_assets: &RenderAssets<GpuImage>, ) -> RenderViewLightProbes<Self>

Creates an instance of RenderViewLightProbes containing all the information needed to render this light probe.

This is called for every light probe in view every frame.

Provided Methods§

Source

fn get_world_from_light_matrix( &self, original_world_from_light: &Affine3A, ) -> Affine3A

Given the matrix value of the GlobalTransform of the light probe, returns the matrix that transforms world positions into light probe space.

The default implementation simply returns the matrix unchanged, but some light probes may want to perform other transforms.

Source

fn parallax_correction_bounds( &self, _query_components: &<Self::QueryData as QueryData>::Item<'_, '_>, ) -> Vec3

Returns the appropriate parallax correction bounds, as half extents in light probe space, for this component.

See the comments in bevy_light::ParallaxCorrection::Custom for more details.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl LightProbeComponent for EnvironmentMapLight

Source§

type AssetId = EnvironmentMapIds

Source§

type ViewLightProbeInfo = EnvironmentMapViewLightProbeInfo

Source§

type QueryData = Option<&'static ParallaxCorrection>

Source§

fn id(&self, image_assets: &RenderAssets<GpuImage>) -> Option<Self::AssetId>

Source§

fn intensity(&self) -> f32

Source§

fn flags( &self, maybe_parallax_correction: &<Self::QueryData as QueryData>::Item<'_, '_>, ) -> RenderLightProbeFlags

Source§

fn create_render_view_light_probes( view_component: Option<&EnvironmentMapLight>, image_assets: &RenderAssets<GpuImage>, ) -> RenderViewLightProbes<Self>

Source§

fn get_world_from_light_matrix(&self, original_transform: &Affine3A) -> Affine3A

Source§

fn parallax_correction_bounds( &self, maybe_parallax_correction: &<Self::QueryData as QueryData>::Item<'_, '_>, ) -> Vec3

Source§

impl LightProbeComponent for IrradianceVolume

Implementors§