2021-03-28 22:56:46 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "vk_const.h"
|
2022-07-30 21:38:34 +02:00
|
|
|
#include "vk_core.h"
|
2021-03-28 22:56:46 +02:00
|
|
|
|
|
|
|
#include "xash3d_types.h"
|
|
|
|
|
|
|
|
typedef struct {
|
2021-09-19 23:43:22 +02:00
|
|
|
uint8_t num_point_lights;
|
2022-01-15 08:48:57 +01:00
|
|
|
uint8_t num_polygons;
|
|
|
|
|
2021-09-19 23:43:22 +02:00
|
|
|
uint8_t point_lights[MAX_VISIBLE_POINT_LIGHTS];
|
2022-01-15 08:48:57 +01:00
|
|
|
uint8_t polygons[MAX_VISIBLE_SURFACE_LIGHTS];
|
2021-10-24 18:58:41 +02:00
|
|
|
|
|
|
|
struct {
|
|
|
|
uint8_t point_lights;
|
2022-01-15 08:48:57 +01:00
|
|
|
uint8_t polygons;
|
2021-10-24 18:58:41 +02:00
|
|
|
} num_static;
|
2021-06-05 21:48:16 +02:00
|
|
|
} vk_lights_cell_t;
|
2021-03-28 22:56:46 +02:00
|
|
|
|
|
|
|
typedef struct {
|
2022-01-16 06:34:43 +01:00
|
|
|
vec4_t plane;
|
2022-01-14 07:36:21 +01:00
|
|
|
vec3_t center;
|
2022-01-16 06:34:43 +01:00
|
|
|
float area;
|
|
|
|
|
|
|
|
vec3_t emissive;
|
2022-01-15 08:48:57 +01:00
|
|
|
|
|
|
|
struct {
|
2022-01-16 06:34:43 +01:00
|
|
|
int offset, count; // reference g_light.polygon_vertices
|
2022-01-15 08:48:57 +01:00
|
|
|
} vertices;
|
|
|
|
|
2022-01-14 07:36:21 +01:00
|
|
|
// uint32_t kusok_index;
|
|
|
|
} rt_light_polygon_t;
|
|
|
|
|
2021-10-16 23:33:02 +02:00
|
|
|
enum {
|
2021-10-20 20:29:48 +02:00
|
|
|
LightFlag_Environment = 0x1,
|
2021-10-16 23:33:02 +02:00
|
|
|
};
|
|
|
|
|
2021-09-19 23:43:22 +02:00
|
|
|
typedef struct {
|
2021-10-16 23:33:02 +02:00
|
|
|
vec3_t origin;
|
|
|
|
vec3_t color;
|
|
|
|
vec3_t dir;
|
|
|
|
float stopdot, stopdot2;
|
|
|
|
float radius;
|
|
|
|
int flags;
|
2021-10-26 18:56:16 +02:00
|
|
|
|
|
|
|
int lightstyle;
|
|
|
|
vec3_t base_color;
|
2021-09-19 23:43:22 +02:00
|
|
|
} vk_point_light_t;
|
|
|
|
|
2022-08-12 19:11:00 +02:00
|
|
|
// Used by infotool
|
2021-03-28 22:56:46 +02:00
|
|
|
typedef struct {
|
2021-04-12 20:07:41 +02:00
|
|
|
struct {
|
2021-06-05 21:48:16 +02:00
|
|
|
int grid_min_cell[3];
|
|
|
|
int grid_size[3];
|
|
|
|
int grid_cells;
|
|
|
|
} map;
|
2021-04-16 20:43:37 +02:00
|
|
|
|
2021-06-05 21:48:16 +02:00
|
|
|
vk_lights_cell_t cells[MAX_LIGHT_CLUSTERS];
|
|
|
|
} vk_lights_t;
|
2021-03-28 22:56:46 +02:00
|
|
|
|
2021-06-05 21:48:16 +02:00
|
|
|
extern vk_lights_t g_lights;
|
2021-03-28 22:56:46 +02:00
|
|
|
|
2022-07-30 21:38:34 +02:00
|
|
|
qboolean VK_LightsInit( void );
|
2021-03-28 22:56:46 +02:00
|
|
|
void VK_LightsShutdown( void );
|
2021-06-05 21:48:16 +02:00
|
|
|
|
2022-01-15 08:48:57 +01:00
|
|
|
struct model_s;
|
|
|
|
void RT_LightsNewMapBegin( const struct model_s *map );
|
|
|
|
void RT_LightsNewMapEnd( const struct model_s *map );
|
2021-06-05 21:48:16 +02:00
|
|
|
|
2022-07-30 20:37:06 +02:00
|
|
|
void RT_LightsFrameBegin( void );
|
|
|
|
void RT_LightsFrameEnd( void );
|
2022-01-14 07:36:21 +01:00
|
|
|
|
2022-08-07 18:45:54 +02:00
|
|
|
typedef struct {
|
|
|
|
VkBuffer buffer;
|
|
|
|
struct {
|
|
|
|
uint32_t offset, size;
|
|
|
|
} metadata, grid;
|
|
|
|
} vk_lights_bindings_t;
|
|
|
|
vk_lights_bindings_t VK_LightsUpload( VkCommandBuffer );
|
2022-07-30 21:38:34 +02:00
|
|
|
|
2022-07-30 20:37:06 +02:00
|
|
|
qboolean RT_GetEmissiveForTexture( vec3_t out, int texture_id );
|
2021-12-26 08:59:26 +01:00
|
|
|
|
2022-07-30 20:37:06 +02:00
|
|
|
int RT_LightCellIndex( const int light_cell[3] );
|
2021-12-30 04:27:46 +01:00
|
|
|
|
|
|
|
struct cl_entity_s;
|
2022-07-30 20:37:06 +02:00
|
|
|
void RT_LightAddFlashlight( const struct cl_entity_s *ent, qboolean local_player );
|
2022-01-15 08:48:57 +01:00
|
|
|
|
|
|
|
struct msurface_s;
|
2022-05-27 20:16:15 +02:00
|
|
|
typedef struct rt_light_add_polygon_s {
|
2022-01-15 08:48:57 +01:00
|
|
|
int num_vertices;
|
|
|
|
vec3_t vertices[7];
|
|
|
|
|
|
|
|
vec3_t emissive;
|
|
|
|
|
|
|
|
// Needed for BSP visibilty purposes
|
|
|
|
// TODO can we layer light code? like:
|
|
|
|
// - bsp/xash/rad/patch-specific stuff
|
|
|
|
// - mostly engine-agnostic light clusters
|
|
|
|
const struct msurface_s *surface;
|
2022-02-03 06:32:10 +01:00
|
|
|
|
|
|
|
qboolean dynamic;
|
|
|
|
const matrix3x4 *transform_row;
|
2022-01-15 08:48:57 +01:00
|
|
|
} rt_light_add_polygon_t;
|
|
|
|
int RT_LightAddPolygon(const rt_light_add_polygon_t *light);
|