vk: wkrutily lampotschkee
fixed missing emissive values for brush models
This commit is contained in:
parent
ea1a98716d
commit
3e14591082
|
@ -1090,6 +1090,7 @@ void R_VkBrushModelCollectEmissiveSurfaces( const struct model_s *mod, qboolean
|
|||
vec3_t emissive;
|
||||
} emissive_surface_t;
|
||||
emissive_surface_t emissive_surfaces[MAX_SURFACE_LIGHTS];
|
||||
int geom_indices[MAX_SURFACE_LIGHTS];
|
||||
int emissive_surfaces_count = 0;
|
||||
|
||||
// Load list of all emissive surfaces
|
||||
|
@ -1172,9 +1173,17 @@ void R_VkBrushModelCollectEmissiveSurfaces( const struct model_s *mod, qboolean
|
|||
}
|
||||
|
||||
// Assign the emissive value to the right geometry
|
||||
VectorCopy(polylight.emissive, bmodel->render_model.geometries[bmodel->surface_to_geometry_index[s->model_surface_index]].emissive);
|
||||
const int geom_index = bmodel->surface_to_geometry_index[s->model_surface_index];
|
||||
geom_indices[i] = geom_index;
|
||||
VectorCopy(polylight.emissive, bmodel->render_model.geometries[geom_index].emissive);
|
||||
}
|
||||
|
||||
if (emissive_surfaces_count > 0)
|
||||
if (emissive_surfaces_count > 0) {
|
||||
// Update emissive values in kusochki. This is required because initial VK_BrushModelLoad happens before we've read
|
||||
// RAD data in vk_light.c, so the emissive values are empty. This is the place and time where we actually get to
|
||||
// know them, so let's fixup things.
|
||||
// TODO minor optimization: sort geom_indices to have a better chance for them to be sequential
|
||||
R_RenderModelUpdateMaterials(&bmodel->render_model, geom_indices, emissive_surfaces_count);
|
||||
INFO("Loaded %d polylights for %s model %s", emissive_surfaces_count, is_static ? "static" : "movable", mod->name);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -104,9 +104,6 @@ void RT_KusochkiFree(const rt_kusochki_t*);
|
|||
struct vk_render_geometry_s;
|
||||
qboolean RT_KusochkiUpload(uint32_t kusochki_offset, const struct vk_render_geometry_s *geoms, int geoms_count, int override_texture_id, const vec4_t *override_color);
|
||||
|
||||
// Update animated materials
|
||||
void RT_KusochkiUploadSubset(rt_kusochki_t *kusochki, const struct vk_render_geometry_s *geoms, const int *geoms_indices, int geoms_indices_count);
|
||||
|
||||
qboolean RT_DynamicModelInit(void);
|
||||
void RT_DynamicModelShutdown(void);
|
||||
|
||||
|
|
|
@ -177,6 +177,7 @@ void RT_KusochkiFree(const rt_kusochki_t *kusochki) {
|
|||
PRINT_NOT_IMPLEMENTED();
|
||||
}
|
||||
|
||||
// TODO this function can't really fail. It'd mean that staging is completely broken.
|
||||
qboolean RT_KusochkiUpload(uint32_t kusochki_offset, const struct vk_render_geometry_s *geoms, int geoms_count, int override_texture_id, const vec4_t *override_colors) {
|
||||
const vk_staging_buffer_args_t staging_args = {
|
||||
.buffer = g_ray_model_state.kusochki_buffer.buffer,
|
||||
|
@ -253,11 +254,41 @@ void RT_ModelDestroy(struct rt_model_s* model) {
|
|||
}
|
||||
|
||||
qboolean RT_ModelUpdate(struct rt_model_s *model, const struct vk_render_geometry_s *geometries, int geometries_count) {
|
||||
// TODO some updates, which change geometry location, textures, etc, might need kusochki update too
|
||||
// TODO mark it with a flag or something
|
||||
return RT_BlasBuild(model->blas, geometries, geometries_count);
|
||||
}
|
||||
|
||||
qboolean RT_ModelUpdateMaterials(struct rt_model_s *model, const struct vk_render_geometry_s *geometries, int geometries_count, const int *geom_indices, int geom_indices_count) {
|
||||
if (!geom_indices_count)
|
||||
return true;
|
||||
|
||||
int begin = 0;
|
||||
for (int i = 1; i < geom_indices_count; ++i) {
|
||||
const int geom_index = geom_indices[i];
|
||||
ASSERT(geom_index >= 0);
|
||||
ASSERT(geom_index < geometries_count);
|
||||
|
||||
if (geom_indices[i - 1] + 1 != geom_index) {
|
||||
const int offset = geom_indices[begin];
|
||||
const int count = i - begin;
|
||||
ASSERT(offset + count <= geometries_count);
|
||||
if (!RT_KusochkiUpload(model->kusochki.offset + offset, geometries + offset, count, -1, NULL))
|
||||
return false;
|
||||
|
||||
begin = i;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
const int offset = geom_indices[begin];
|
||||
const int count = geom_indices_count - begin;
|
||||
ASSERT(offset + count <= geometries_count);
|
||||
if (!RT_KusochkiUpload(model->kusochki.offset + offset, geometries + offset, count, -1, NULL))
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
rt_draw_instance_t *getDrawInstance(void) {
|
||||
if (g_ray_model_state.frame.instances_count >= ARRAYSIZE(g_ray_model_state.frame.instances)) {
|
||||
gEngine.Con_Printf(S_ERROR "Too many RT draw instances, max = %d\n", (int)(ARRAYSIZE(g_ray_model_state.frame.instances)));
|
||||
|
@ -411,6 +442,5 @@ void RT_FrameAddOnce( rt_frame_add_once_t args ) {
|
|||
Vector4Copy(*args.color, dyn->colors[dyn->geometries_count]);
|
||||
dyn->geometries[dyn->geometries_count++] = args.geometries[i];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -679,6 +679,13 @@ qboolean R_RenderModelUpdate( const vk_render_model_t *model ) {
|
|||
return RT_ModelUpdate(model->rt_model, model->geometries, model->num_geometries);
|
||||
}
|
||||
|
||||
qboolean R_RenderModelUpdateMaterials( const vk_render_model_t *model, const int *geom_indices, int geom_indices_count) {
|
||||
if (!model->rt_model)
|
||||
return true;
|
||||
|
||||
return RT_ModelUpdateMaterials(model->rt_model, model->geometries, model->num_geometries, geom_indices, geom_indices_count);
|
||||
}
|
||||
|
||||
static void uboComputeAndSetMVPFromModel( const matrix4x4 model ) {
|
||||
matrix4x4 mvp;
|
||||
Matrix4x4_Concat(mvp, g_render_state.projection_view, model);
|
||||
|
|
|
@ -136,6 +136,7 @@ qboolean R_RenderModelCreate( vk_render_model_t *model, vk_render_model_init_t a
|
|||
void R_RenderModelDestroy( vk_render_model_t* model );
|
||||
|
||||
qboolean R_RenderModelUpdate( const vk_render_model_t *model );
|
||||
qboolean R_RenderModelUpdateMaterials( const vk_render_model_t *model, const int *geom_indices, int geom_indices_count);
|
||||
|
||||
typedef struct {
|
||||
vk_render_type_e render_type;
|
||||
|
|
|
@ -52,6 +52,8 @@ void RT_ModelDestroy(struct rt_model_s *model);
|
|||
|
||||
qboolean RT_ModelUpdate(struct rt_model_s *model, const struct vk_render_geometry_s *geometries, int geometries_count);
|
||||
|
||||
qboolean RT_ModelUpdateMaterials(struct rt_model_s *model, const struct vk_render_geometry_s *geometries, int geometries_count, const int *geom_indices, int geom_indices_count);
|
||||
|
||||
typedef struct {
|
||||
int render_type; // TODO material_mode
|
||||
const matrix3x4 *transform, *prev_transform;
|
||||
|
|
Loading…
Reference in New Issue