Skip to main content
← PSoXide SDK guides and examples · SDK f2fec1c301f1 · All Cargo features enabled; check feature gates before use.

LightRig

Struct LightRig 

Source
pub struct LightRig {
    pub lights: [Light; 3],
    pub ambient: (i32, i32, i32),
}
Expand description

A rig of up to 3 directional lights – the maximum the PSX GTE supports natively.

Fields§

§lights: [Light; 3]

Three light slots; unused slots should be Light::OFF.

§ambient: (i32, i32, i32)

Ambient term added before material multiply. Q3.12 per channel in an i32 (GTE’s BK register is 20-bit signed).

Implementations§

Source§

impl LightRig

Source

pub const OFF: Self

Empty rig: no lights, black ambient.

Source

pub const fn new(lights: [Light; 3], ambient: (i32, i32, i32)) -> Self

Build a rig from 3 lights + an ambient term.

Source

pub fn load(&self)

Pack this rig into the GTE’s control registers:

  • LLM ← rows are light directions
  • LCM ← columns are light RGB contributions
  • BK ← ambient

Call once per object (or once per frame if lights are in a universal frame). Any subsequent NCCS / NCS / NCDS reads these.

Source

pub fn for_object(&self, rotation: &Mat3I16) -> LightRig

Return a new rig with every light’s direction rotated into the frame in which rotation is the object’s local → world transform. I.e., if you pass the same Mat3I16 you pass to scene::load_rotation for RTPS, the returned rig is in object-local space – correct for feeding LLM when lighting mesh vertices that are themselves in local space.

Math: world_vert = R × local_vert, so local = R⁻¹ × world, and since R is a rotation, R⁻¹ = Rᵀ. We compute local_dir = Rᵀ × world_dir component-wise.

Source

pub fn rotated(&self, rotation: &Mat3I16) -> LightRig

Return a new rig with every light’s direction rotated by rotation (direct R × dir, not the transpose).

Used to animate world-space lights over time – e.g. an orbiting key light. Compose this BEFORE [for_object] so the per-object transpose applies on top of the animation.

Trait Implementations§

Source§

impl Clone for LightRig

Source§

fn clone(&self) -> LightRig

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for LightRig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Copy for LightRig

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.