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§
Sourcetype ViewLightProbeInfo: Send + Sync + Default
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.
Sourcetype QueryData: ReadOnlyQueryData
type QueryData: ReadOnlyQueryData
Any additional query data needed to determine the
RenderLightProbeFlags for this light probe.
Required Methods§
Sourcefn id(&self, image_assets: &RenderAssets<GpuImage>) -> Option<Self::AssetId>
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.
Sourcefn intensity(&self) -> f32
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.
Sourcefn flags(
&self,
query_components: &<Self::QueryData as QueryData>::Item<'_, '_>,
) -> RenderLightProbeFlags
fn flags( &self, query_components: &<Self::QueryData as QueryData>::Item<'_, '_>, ) -> RenderLightProbeFlags
Returns the appropriate value of RenderLightProbeFlags for this
component.
Sourcefn create_render_view_light_probes(
view_component: Option<&Self>,
image_assets: &RenderAssets<GpuImage>,
) -> RenderViewLightProbes<Self>
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§
Sourcefn get_world_from_light_matrix(
&self,
original_world_from_light: &Affine3A,
) -> Affine3A
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.
Sourcefn parallax_correction_bounds(
&self,
_query_components: &<Self::QueryData as QueryData>::Item<'_, '_>,
) -> Vec3
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".