add view(weapon) models

This commit is contained in:
Ivan Avdeev 2021-02-15 09:55:42 -08:00
parent 6fbd63bd1f
commit c53bfaf484
4 changed files with 30 additions and 4 deletions

View File

@ -1,9 +1,14 @@
## 2021-02-15
- [x] weapon models -- viewmodel
# Next
- [ ] studio models fixes
- [ ] sprites
- [ ] coalesce studio model draw calls
# Planned
- [ ] loading to the same map breaks geometry
- [ ] studio model lighting
- [ ] move all consts to vk_const
- [ ] sprites
- [ ] what is GL_Backend*/GL_RenderFrame ???
- [ ] beams
- [ ] particles
@ -17,6 +22,7 @@
- [ ] fog
- [ ] RTX
- [ ] studio models survive NewMap; need to compactify buffers after removing all brushes
- [ ] sometimes it gets very slow (1fps) when ran under lldb (only on stream?)
# Someday
- [ ] (helps with RTX?) unified rendering (brush/studio models/...), each model is instance, instance data is read from storage buffers, gives info about vertex format, texture bindings, etc; which are read from another set of storage buffers, ..
@ -26,6 +32,7 @@
- [ ] custom allocator for vulkan
- [ ] stats
- [ ] better 2d renderer: fill DRAWQUAD(texture, color, ...) command into storage buffer instead of 4 vertices
- [ ] auto-atlas lots of smol textures: most of model texture are tiny (64x64 or less), can we not rebind them all the time? alt: bindless texture array
## 2021-02-06
- [x] alpha test
@ -52,3 +59,4 @@
- [x] draw studio models somehow
- [x] studio models vk debug markers
- [x] studio models white texture as lightmap
- [x] studio models fixes

View File

@ -573,6 +573,15 @@ void VK_SceneRender( void )
prepareMatrix( &fixme_rvp, worldview, projection, mvp );
// Draw view model
{
uniform_data_t *ubo = VK_RenderGetUniformSlot(ubo_index);
Matrix4x4_ToArrayFloatGL( mvp, (float*)ubo->mvp );
Vector4Set(ubo->color, 1.f, 1.f, 1.f, 1.f);
R_RunViewmodelEvents();
R_DrawViewModel( ubo_index++ );
}
// Draw world brush
{
cl_entity_t *world = gEngine.GetEntityByIndex( 0 );

View File

@ -3271,7 +3271,7 @@ void R_GatherPlayerLight( void )
*/
}
void R_DrawViewModel( void )
void R_DrawViewModel( int ubo_index )
{
cl_entity_t *view = gEngine.GetViewModel();
@ -3298,10 +3298,11 @@ void R_DrawViewModel( void )
if( !RI.currententity->model )
return;
RI.currentmodel = RI.currententity->model;
/* FIXME VK
// adjust the depth range to prevent view model from poking into walls
pglDepthRange( gldepthmin, gldepthmin + 0.3f * ( gldepthmax - gldepthmin ));
RI.currentmodel = RI.currententity->model;
// backface culling for left-handed weapons
if( R_AllowFlipViewModel( RI.currententity ) || g_iBackFaceCull )
@ -3311,6 +3312,7 @@ void R_DrawViewModel( void )
}
*/
g_studio.vk_ubo_index = ubo_index;
switch( RI.currententity->model->type )
{
/* FIXME VK
@ -3324,6 +3326,10 @@ void R_DrawViewModel( void )
break;
}
g_studio.vk_ubo_index = -1;
RI.currententity = NULL;
RI.currentmodel = NULL;
/* FIXME VK
// restore depth range
pglDepthRange( gldepthmin, gldepthmax );

View File

@ -13,3 +13,6 @@ void Mod_LoadStudioModel( model_t *mod, const void *buffer, qboolean *loaded );
void Mod_StudioLoadTextures( model_t *mod, void *data );
void VK_StudioDrawModel( cl_entity_t *ent, int render_mode, int ubo_index );
void R_RunViewmodelEvents( void );
void R_DrawViewModel( int ubo_index );