diff --git a/ref/vk/shaders/ray_interop.h b/ref/vk/shaders/ray_interop.h index cda6263845..c6ad0bb516 100644 --- a/ref/vk/shaders/ray_interop.h +++ b/ref/vk/shaders/ray_interop.h @@ -89,6 +89,7 @@ struct Kusok { float normal_scale; uint flags; + // TODO per-model mat4 prev_transform; }; diff --git a/ref/vk/vk_brush.c b/ref/vk/vk_brush.c index 082a667f33..b320c90215 100644 --- a/ref/vk/vk_brush.c +++ b/ref/vk/vk_brush.c @@ -238,7 +238,7 @@ static void EmitWaterPolys( const cl_entity_t *ent, const msurface_t *warp, qboo const vk_render_geometry_t geometry = { .texture = warp->texinfo->texture->gl_texturenum, // FIXME assert >= 0 .material = kXVkMaterialWater, - .surf = warp, + .surf_deprecate = warp, .max_vertex = num_vertices, .vertex_offset = buffer.vertices.unit_offset, @@ -407,7 +407,7 @@ void VK_BrushModelDraw( const cl_entity_t *ent, int render_mode, float blend, co for (int i = 0; i < bmodel->render_model.num_geometries; ++i) { vk_render_geometry_t *geom = bmodel->render_model.geometries + i; - const int surface_index = geom->surf - mod->surfaces; + const int surface_index = geom->surf_deprecate - mod->surfaces; const xvk_patch_surface_t *const patch_surface = R_VkPatchGetSurface(surface_index); if (render_mode == kRenderTransColor) { @@ -419,7 +419,7 @@ void VK_BrushModelDraw( const cl_entity_t *ent, int render_mode, float blend, co } else { // Optionally patch by texture_s pointer and run animations const struct texture_s *texture_override = patch_surface ? patch_surface->tex : NULL; - const texture_t *t = R_TextureAnimation(ent, geom->surf, texture_override); + const texture_t *t = R_TextureAnimation(ent, geom->surf_deprecate, texture_override); if (t->gl_texturenum >= 0) geom->texture = t->gl_texturenum; } @@ -561,7 +561,7 @@ static qboolean loadBrushSurfaces( model_sizes_t sizes, const model_t *mod ) { VectorClear(model_geometry->emissive); - model_geometry->surf = surf; + model_geometry->surf_deprecate = surf; model_geometry->texture = tex_id; model_geometry->vertex_offset = buffer.vertices.unit_offset; diff --git a/ref/vk/vk_render.h b/ref/vk/vk_render.h index 8bd1f2be96..b61e32b003 100644 --- a/ref/vk/vk_render.h +++ b/ref/vk/vk_render.h @@ -27,33 +27,56 @@ void VK_RenderStateSetMatrixModel(const matrix4x4 model); // FIXME these should be bits, not enums typedef enum { kXVkMaterialRegular = 0, + + // Set for dynamic water surface in vk_brush.c. Used to + // TYno NOT USED, REMOVE NOW. + // Remove: No prerequisites. Water material should be decided based on texture, not whether it's being drawn as dynamic water surface. kXVkMaterialWater, + + // Set for SURF_DRAWSKY surfaces in vk_brush.c. + // Used: for setting KUSOK_MATERIAL_FLAG_SKYBOX for skybox texture sampling and environment shadows. + // Remove: pass it as a special texture/material index (e.g. -2). kXVkMaterialSky, + + // Set by beams and sprites. + // Used: as a negative flag for setting model color from emissive color. A bit tricky, don't really follow. + // Remove: ??? kXVkMaterialEmissive, + + // Set by sprites. + // Used: glow means no depth test. Allows for slight ray overshoot (KUSOK_MATERIAL_FLAG_FIXME_GLOW). Desired effect: literally glow. + // Remove: should be able to extract this info from kRenderType kXVkMaterialEmissiveGlow, + + // Set for brush surfaces with dynamic UVs. + // Used: currently unused, conveyors are drawn incorrectly. + // Remove: it's more efficient to solve this via explicit list of dynamic-uv geometries. kXVkMaterialConveyor, + + // Set for chrome studio submodels. + // Used: ray tracing sets gray roughness texture to get smooth surface look. + // Remove: Have an explicit material for chrome surfaces. kXVkMaterialChrome, } XVkMaterialType; typedef struct vk_render_geometry_s { int index_offset, vertex_offset; - // Animated textures will be dynamic and change between frames - int texture; - - // If this geometry is special, it will have a material type override - XVkMaterialType material; - uint32_t element_count; // Maximum index of vertex used for this geometry; needed for ray tracing BLAS building uint32_t max_vertex; // Non-null only for brush models - // Used for: - // - updating animated textures for brush models - // - updating dynamic lights (TODO: can decouple from surface/brush models by providing texture_id and aabb directly here) - const struct msurface_s *surf; + // Used for updating animated textures for brush models + // Remove: have an explicit list of surfaces with animated textures + const struct msurface_s *surf_deprecate; + + // Animated textures will be dynamic and change between frames + int texture; + + // If this geometry is special, it will have a material type override + XVkMaterialType material; // for kXVkMaterialEmissive{,Glow} and others vec3_t emissive; @@ -61,12 +84,45 @@ typedef struct vk_render_geometry_s { typedef enum { kVkRenderTypeSolid, // no blending, depth RW + + // Mix alpha blending with depth test and write + // Set by: + // - brush: kRenderTransColor + // - studio: kRenderTransColor, kRenderTransTexture, kRenderTransAlpha, kRenderGlow + // - sprite: kRenderTransColor, kRenderTransTexture + // - triapi: kRenderTransColor, kRenderTransTexture kVkRenderType_A_1mA_RW, // blend: src*a + dst*(1-a), depth: RW + + // Mix alpha blending with depth test only + // Set by: + // - brush: kRenderTransTexture, kRenderGlow + // - sprite: kRenderTransAlpha + // - triapi: kRenderTransAlpha kVkRenderType_A_1mA_R, // blend: src*a + dst*(1-a), depth test + + // Additive alpha blending, no depth + // Set by: + // - sprite: kRenderGlow kVkRenderType_A_1, // blend: src*a + dst, no depth test or write + + // Additive alpha blending with depth test + // Set by: + // - brush: kRenderTransAdd + // - beams: all modes except kRenderNormal and beams going through triapi + // - sprite: kRenderTransAdd + // - triapi: kRenderTransAdd, kRenderGlow kVkRenderType_A_1_R, // blend: src*a + dst, depth test + + // No blend, alpha test, depth test and write + // Set by: + // - brush: kRenderTransAlpha kVkRenderType_AT, // no blend, depth RW, alpha test + + // Additive no alpha blend, depth test only + // Set by: + // - studio: kRenderTransAdd kVkRenderType_1_1_R, // blend: src + dst, depth test + kVkRenderType_COUNT } vk_render_type_e; diff --git a/ref/vk/vk_triapi.c b/ref/vk/vk_triapi.c index 152ffbc241..2b95239e97 100644 --- a/ref/vk/vk_triapi.c +++ b/ref/vk/vk_triapi.c @@ -42,13 +42,21 @@ int TriSpriteTexture( model_t *pSpriteModel, int frame ) void TriRenderMode( int render_mode ) { switch( render_mode ) { - case kRenderTransAlpha: g_triapi.render_type = kVkRenderType_A_1mA_R; break; + case kRenderTransAlpha: + g_triapi.render_type = kVkRenderType_A_1mA_R; + break; case kRenderTransColor: - case kRenderTransTexture: g_triapi.render_type = kVkRenderType_A_1mA_RW; break; + case kRenderTransTexture: + g_triapi.render_type = kVkRenderType_A_1mA_RW; + break; case kRenderGlow: - case kRenderTransAdd: g_triapi.render_type = kVkRenderType_A_1_R; break; + case kRenderTransAdd: + g_triapi.render_type = kVkRenderType_A_1_R; + break; case kRenderNormal: - default: g_triapi.render_type = kVkRenderTypeSolid; break; + default: + g_triapi.render_type = kVkRenderTypeSolid; + break; } }