mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-04-05 17:01:11 +00:00
[scene] Add flags for finer rendering control
This takes care of rockets and lava balls casting shadows when they shouldn't (rockets more because the shadow doesn't look that nice, lava balls because they glow and thus shouldn't cast shadows). Same for flames, though the small torches lost their cool sconce shadows (need to split up the model into flame and sconce parts and mark each separately).
This commit is contained in:
parent
1cc65179b5
commit
6892dc1422
7 changed files with 21 additions and 6 deletions
|
@ -38,6 +38,11 @@
|
|||
#include "QF/Vulkan/qf_vid.h"
|
||||
#include "QF/Vulkan/command.h"
|
||||
|
||||
enum {
|
||||
alias_main,
|
||||
alias_shadow,
|
||||
};
|
||||
|
||||
typedef struct aliasvrt_s {
|
||||
float vertex[4];
|
||||
float normal[4];
|
||||
|
|
|
@ -75,9 +75,12 @@ typedef struct visibility_s {
|
|||
typedef struct renderer_s {
|
||||
struct model_s *model; // NULL = no model
|
||||
struct skin_s *skin;
|
||||
unsigned fullbright:1;
|
||||
unsigned noshadows:1;
|
||||
unsigned onlyshadows:1;
|
||||
unsigned depthhack:1;
|
||||
float colormod[4]; // color tint and alpha for model
|
||||
int skinnum; // for Alias models
|
||||
int fullbright;
|
||||
float min_light;
|
||||
int render_id;
|
||||
} renderer_t;
|
||||
|
|
|
@ -182,6 +182,7 @@ CL_ModelEffects (entity_t ent, int glow_color, double time)
|
|||
});
|
||||
Light_LinkLight (cl_world.scene->lights, light);
|
||||
clp_funcs->RocketTrail (*old_origin, ent_origin);
|
||||
renderer->noshadows = 1;
|
||||
} else if (model->flags & EF_GRENADE)
|
||||
clp_funcs->GrenadeTrail (*old_origin, ent_origin);
|
||||
else if (model->flags & EF_GIB)
|
||||
|
|
|
@ -121,6 +121,7 @@ CL_ParseStatic (qmsg_t *msg, int version)
|
|||
|
||||
// copy it to the current state
|
||||
renderer->model = cl_world.models.a[es.modelindex];
|
||||
renderer->noshadows = renderer->model->shadow_alpha < 0.5;
|
||||
animation->frame = es.frame;
|
||||
renderer->skinnum = es.skinnum;
|
||||
|
||||
|
|
|
@ -276,20 +276,22 @@ alias_draw (const exprval_t **params, exprval_t *result, exprctx_t *ectx)
|
|||
dfunc->vkCmdBindDescriptorSets (cmd, VK_PIPELINE_BIND_POINT_GRAPHICS,
|
||||
layout, 0, shadow ? 1 : 2, sets, 0, 0);
|
||||
|
||||
bool vmod = !stage && Entity_Valid (vr_data.view_model);
|
||||
|
||||
auto queue = r_ent_queue; //FIXME fetch from scene
|
||||
for (size_t i = 0; i < queue->ent_queues[mod_alias].size; i++) {
|
||||
entity_t ent = queue->ent_queues[mod_alias].a[i];
|
||||
auto renderer = alias_get_renderer (ent);
|
||||
if ((stage == alias_shadow && renderer->noshadows)
|
||||
|| (stage == alias_main && renderer->onlyshadows)) {
|
||||
continue;
|
||||
}
|
||||
// FIXME hack the depth range to prevent view model
|
||||
// from poking into walls
|
||||
if (vmod && ent.id == vr_data.view_model.id) {
|
||||
if (stage == alias_main && renderer->depthhack) {
|
||||
alias_depth_range (taskctx, 0.7, 1);
|
||||
}
|
||||
alias_draw_ent (taskctx, ent, pass, renderer);
|
||||
// unhack in case the view_model is not the last
|
||||
if (vmod && ent.id == vr_data.view_model.id) {
|
||||
if (stage == alias_main && renderer->depthhack) {
|
||||
alias_depth_range (taskctx, 0, 1);
|
||||
}
|
||||
}
|
||||
|
@ -302,7 +304,7 @@ static exprtype_t alias_stage_type = {
|
|||
.get_string = cexpr_enum_get_string,
|
||||
.data = &alias_stage_enum,
|
||||
};
|
||||
static int alias_stage_values[] = { 0, 1, };
|
||||
static int alias_stage_values[] = { alias_main, alias_shadow, };
|
||||
static exprsym_t alias_stage_symbols[] = {
|
||||
{"main", &alias_stage_type, alias_stage_values + 0},
|
||||
{"shadow", &alias_stage_type, alias_stage_values + 1},
|
||||
|
|
|
@ -150,6 +150,7 @@ set_entity_model (int ent_ind, int modelindex)
|
|||
} else {
|
||||
animation->syncbase = 0.0;
|
||||
}
|
||||
renderer->noshadows = renderer->model->shadow_alpha < 0.5;
|
||||
}
|
||||
// Changing the model can change the visibility of the entity and even
|
||||
// the model type
|
||||
|
|
|
@ -280,6 +280,8 @@ CL_ClearState (void)
|
|||
r_data->lightstyle = cl.lightstyle;
|
||||
|
||||
cl.viewstate.weapon_entity = Scene_CreateEntity (cl_world.scene);
|
||||
renderer_t *renderer = Ent_GetComponent (cl.viewstate.weapon_entity.id, scene_renderer, cl_world.scene->reg);
|
||||
renderer->depthhack = 1;
|
||||
CL_Init_Entity (cl.viewstate.weapon_entity);
|
||||
r_data->view_model = cl.viewstate.weapon_entity;
|
||||
|
||||
|
|
Loading…
Reference in a new issue