xash3d-fwgs/ref_vk/vk_light.h

106 lines
2.0 KiB
C
Raw Normal View History

2021-03-28 22:56:46 +02:00
#pragma once
#include "vk_const.h"
#include "vk_core.h"
2021-03-28 22:56:46 +02:00
#include "xash3d_types.h"
typedef struct {
uint8_t num_point_lights;
uint8_t num_polygons;
uint8_t point_lights[MAX_VISIBLE_POINT_LIGHTS];
uint8_t polygons[MAX_VISIBLE_SURFACE_LIGHTS];
struct {
uint8_t point_lights;
uint8_t polygons;
} num_static;
} vk_lights_cell_t;
2021-03-28 22:56:46 +02:00
typedef struct {
vec4_t plane;
vec3_t center;
float area;
vec3_t emissive;
struct {
int offset, count; // reference g_light.polygon_vertices
} vertices;
// uint32_t kusok_index;
} rt_light_polygon_t;
enum {
LightFlag_Environment = 0x1,
};
typedef struct {
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;
} 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 {
struct {
int grid_min_cell[3];
int grid_size[3];
int grid_cells;
} map;
2021-04-16 20:43:37 +02:00
vk_lights_cell_t cells[MAX_LIGHT_CLUSTERS];
} vk_lights_t;
2021-03-28 22:56:46 +02:00
extern vk_lights_t g_lights;
2021-03-28 22:56:46 +02:00
qboolean VK_LightsInit( void );
2021-03-28 22:56:46 +02:00
void VK_LightsShutdown( void );
struct model_s;
void RT_LightsNewMapBegin( const struct model_s *map );
void RT_LightsNewMapEnd( const struct model_s *map );
2022-07-30 20:37:06 +02:00
void RT_LightsFrameBegin( void );
void RT_LightsFrameEnd( void );
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 20:37:06 +02:00
qboolean RT_GetEmissiveForTexture( vec3_t out, int texture_id );
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 );
struct msurface_s;
typedef struct rt_light_add_polygon_s {
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;
} rt_light_add_polygon_t;
int RT_LightAddPolygon(const rt_light_add_polygon_t *light);