OpenUT99-Plus
Unreal Engine 1, rebuilt from scratch
Loading...
Searching...
No Matches
lighting.h
Go to the documentation of this file.
1// Static lighting from BSP lightmaps: luxel positions, shadow bits, light colours, atlas packing.
2// Spec: docs/formats/level.md (lightmaps); the colour model is engine behaviour, unverified against the original.
3#pragma once
4#include <cstdint>
5#include <vector>
6
7#include "level.h"
8
9namespace ut {
10
11// World position of luxel (i, j): texture coordinates (pan.x + i * uscale, pan.y + j * vscale) on the surface plane.
12Vec3 luxel_position(const Model& m, const Surf& s, const LightMap& lm, int i, int j);
13int lightmap_lights(const Model& m, const LightMap& lm); // lights listed for the lightmap (up to the 0 entry)
14// Whether light number `light` of the lightmap reaches luxel (i, j): one bit per luxel, rows padded to bytes, LSB first.
15bool shadow_bit(const Model& m, const LightMap& lm, int light, int i, int j);
16// UE1 light colour: hue 0..255, saturation 255 = white, brightness 0..255 → RGB 0..1.
17Vec3 light_colour(int hue, int saturation, int brightness);
18// Light falloff at distance d for LightRadius r (world radius 25 * (r + 1); shortcut: curve and scale unverified).
19float light_falloff(float d, int radius);
20
21// Shelf packer for lightmaps into one texture of fixed width.
22class Atlas {
23public:
24 explicit Atlas(int width) : width_(width) {}
25 bool place(int w, int h, int* x, int* y); // false if wider than the atlas
26 int width() const { return width_; }
27 int height() const { return shelf_y_ + shelf_h_; }
28
29private:
30 int width_, shelf_x_ = 0, shelf_y_ = 0, shelf_h_ = 0;
31};
32
33} // namespace ut
bool place(int w, int h, int *x, int *y)
Definition lighting.cpp:54
int width() const
Definition lighting.h:26
Atlas(int width)
Definition lighting.h:24
int height() const
Definition lighting.h:27
Definition collision.cpp:7
float light_falloff(float d, int radius)
Definition lighting.cpp:49
Vec3 light_colour(int hue, int saturation, int brightness)
Definition lighting.cpp:35
bool shadow_bit(const Model &m, const LightMap &lm, int light, int i, int j)
Definition lighting.cpp:29
int lightmap_lights(const Model &m, const LightMap &lm)
Definition lighting.cpp:22
Vec3 luxel_position(const Model &m, const Surf &s, const LightMap &lm, int i, int j)
Definition lighting.cpp:11
Definition level.h:30
Definition level.h:38
Definition level.h:20
Definition upkg.h:66