physis/layer/
light.rs

1// SPDX-FileCopyrightText: 2025 Joshua Goins <josh@redstrate.com>
2// SPDX-License-Identifier: GPL-3.0-or-later
3
4use binrw::{binread, binrw};
5
6use super::{ColorHDRI, read_bool_from};
7
8#[binrw]
9#[brw(repr = i32)]
10#[derive(Debug, PartialEq)]
11pub enum LightType {
12    None = 0x0,
13    Directional = 0x1,
14    Point = 0x2,
15    Spot = 0x3,
16    Plane = 0x4,
17    Line = 0x5,
18    Specular = 0x6,
19}
20
21#[binrw]
22#[brw(repr = i32)]
23#[derive(Debug, PartialEq)]
24pub enum PointLightType {
25    Sphere = 0x0,
26    Hemisphere = 0x1,
27}
28
29#[binread]
30#[derive(Debug)]
31#[br(little)]
32pub struct LightInstanceObject {
33    pub light_type: LightType,
34    pub attenuation: f32,
35    pub range_rate: f32,
36    pub point_light_type: PointLightType,
37    pub attenuation_cone_coefficient: f32,
38    pub cone_degree: f32,
39    pub texture_path_offset: u32,
40    pub diffuse_color_hdri: ColorHDRI,
41    #[br(map = read_bool_from::<u8>)]
42    pub follows_directional_light: bool,
43    padding1: u8,
44    padding2: u16,
45    #[br(map = read_bool_from::<u8>)]
46    pub specular_enabled: bool,
47    #[br(map = read_bool_from::<u8>)]
48    pub bg_shadow_enabled: bool,
49    #[br(map = read_bool_from::<u8>)]
50    pub character_shadow_enabled: bool,
51    padding3: u8,
52    pub shadow_clip_range: f32,
53    pub plane_light_rotation_x: f32,
54    pub plane_light_rotation_y: f32,
55    pub merge_group_id: u16,
56    padding4: u8,
57}