Merge pull request #715 from w23/stream-E350

Stuff done during stream E350

- [x] Restore skybox reflection
- [x] Improve skybox log messages
This commit is contained in:
Ivan Avdeev 2023-12-20 06:41:12 -08:00 committed by GitHub
commit c3d4d0fbe9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 76 additions and 53 deletions

View File

@ -1,8 +1,45 @@
Longer-term agenda for current season:
- [ ] Better PBR math, e.g.:
- [ ] Black metals: https://github.com/w23/xash3d-fwgs/issues/666
- [ ] Fresnel issues (esp. with skybox)
- [ ] Just make sure that all the BRDF math is correct
- [ ] Transparency/translucency:
- [ ] Proper material mode for translucency, with reflections, refraction (index), fresnel, etc.
- [ ] Figure out why additive transparency differs visibly from raster
- [ ] Extract and specialize effects, e.g.
- [ ] Rays -> volumetrics
- [ ] Glow -> bloom
- [ ] Smoke -> volumetrics
- [ ] Sprites/portals -> emissive volumetrics
- [ ] Holo models -> emissive additive
- [ ] Some additive -> translucent
- [ ] what else
- [ ] Render-graph-ish approach to resources.
- [ ] Performance tools -- needed for perf and lighting work below:
- [ ] Needs: render-graph-ish things for fast iterations when exporting custom situational metrics for the shader.
- [ ] Purpose: shader profiling. Measure impact of changes. Regressions.
- [ ] WIP shader clocks: https://github.com/w23/xash3d-fwgs/pull/692
- [ ] WIP perf query: https://github.com/w23/xash3d-fwgs/pull/500
- [ ] Lighting
- [ ] Point spheres sampling
- [ ] Increase limits
- [ ] s/poly/triangle/ -- simpler sampling, universal
- [ ] Better and dynamically sized clusters
- [ ] Cache rays -- do not cast shadow rays for everything, do a separate ray-only pass for visibility caching
- [ ] Bounces
- [ ] Moar bounces
- [ ] MIS
- [ ] Cache directions for strong indirect light
# 2023-12-19 E350
- [x] fixup skybox reflections
- [x] improve logs "vk/tex: Loaded skybox pbr/env/%.*s"
- [x] add skybox test
# 2023-12-18 E349
- [x] KTX2 cubemaps
- [ ] improve logs "vk/tex: Loaded skybox pbr/env/%.*s"
- [ ] variable cubemap exposure
- [ ] add skybox test
- [x] variable cubemap exposure (in .mat file)
# 2023-12-15 E348
- [x] fix ktx2 sides corruption
@ -38,32 +75,6 @@
- [x] Discuss shader profiling
- [-] Discuss Env-based verbose log control
Longer-term agenda for current season:
- [ ] Tools:
- [ ] Shader profiling. Measure impact of changes. Regressions.
- [ ] Better PBR math, e.g.:
- [ ] Transparency:
- [ ] Figure out why additive transparency differs visibly from raster
- [ ] Extract and specialize effects, e.g.
- [ ] Rays -> volumetrics
- [ ] Glow -> bloom
- [ ] Smoke -> volumetrics
- [ ] Sprites/portals -> emissive volumetrics
- [ ] Holo models -> emissive additive
- [ ] Some additive -> translucent
- [ ] what else
- [ ] Proper material mode for translucency, with reflections, refraction (index), fresnel, etc.
- [ ] Lighting
- [ ] Point spheres sampling
- [ ] Increase limits
- [ ] s/poly/triangle/ -- simpler sampling, universal
- [ ] Better and dynamically sized clusters
- [ ] Cache rays -- do not cast shadow rays for everything, do a separate ray-only pass for visibility caching
- [ ] Bounces
- [ ] Moar bounces
- [ ] MIS
- [ ] Cache directions for strong indirect light
# 2023-12-04 E341
- [-] investigate envlight missing #680
- couldn't reproduce more than once

View File

@ -767,17 +767,21 @@ cleanup:
Mem_Free(data);
}
static qboolean skyboxLoad(const_string_view_t base, const char *prefix) {
static qboolean skyboxLoadF(const char *fmt, ...) {
qboolean success = false;
char loadname[MAX_STRING];
Q_snprintf( loadname, sizeof( loadname ), prefix, base.len, base.s );
char buffer[MAX_STRING];
rgbdata_t *pic = gEngine.FS_LoadImage( loadname, NULL, 0 );
va_list argptr;
va_start( argptr, fmt );
Q_vsnprintf( buffer, sizeof buffer, fmt, argptr );
va_end( argptr );
rgbdata_t *pic = gEngine.FS_LoadImage( buffer, NULL, 0 );
if (!pic)
return false;
if (!(pic->flags & IMAGE_CUBEMAP)) {
ERR("%s: '%s' is invalid: skybox is expected to be a cubemap ", __FUNCTION__, loadname);
ERR("%s: '%s' is invalid: skybox is expected to be a cubemap ", __FUNCTION__, buffer);
goto cleanup;
}
@ -791,18 +795,18 @@ static qboolean skyboxLoad(const_string_view_t base, const char *prefix) {
{
const qboolean is_placeholder = false;
success = R_VkTexturesSkyboxUpload( prefix, pic, kColorspaceGamma, is_placeholder );
success = R_VkTexturesSkyboxUpload( buffer, pic, kColorspaceGamma, is_placeholder );
}
if (success)
skyboxParseInfo(loadname);
skyboxParseInfo(buffer);
cleanup:
if (pic)
gEngine.FS_FreeImage(pic);
if (success)
DEBUG( "Loaded skybox %s", prefix );
DEBUG( "Loaded skybox %s", buffer );
return success;
}
@ -841,11 +845,11 @@ static qboolean skyboxTryLoad( const char *skyboxname, qboolean force_reload ) {
return true;
// Try loading newer "PBR" upscaled skybox first
if (skyboxLoad(basename, "pbr/env/%.*s"))
if (skyboxLoadF("pbr/env/%.*s", basename.len, basename.s))
goto success;
// Try loading original game skybox
if (skyboxLoad(basename, "gfx/env/%.*s"))
if (skyboxLoadF("gfx/env/%.*s", basename.len, basename.s))
goto success;
skyboxUnload();

View File

@ -158,17 +158,16 @@ void computeBounce(ivec2 pix, vec3 direction, out vec3 diffuse, out vec3 specula
payload.base_color_a = vec4(0.);
payload.emissive = vec4(0.);
payload.material_rmxx = vec4(0.);
const vec3 pos = pos_t.xyz + geometry_normal * ray_normal_fudge;
if (!getHit(pos, bounce_direction, payload))
return;
// 4. Sample light sources
{
vec3 ldiffuse = vec3(0.);
vec3 lspecular = vec3(0.);
vec3 lighting = vec3(0.);
const vec3 pos = pos_t.xyz + geometry_normal * ray_normal_fudge;
if (getHit(pos, bounce_direction, payload)) {
// 4. Sample light sources
const vec3 hit_pos = payload.hit_t.xyz;
const vec3 hit_shading_normal = normalDecode(payload.normals_gs.zw);
vec3 ldiffuse = vec3(0.);
vec3 lspecular = vec3(0.);
MaterialProperties hit_material;
hit_material.baseColor = vec3(1.);
hit_material.emissive = vec3(0.f);
@ -181,13 +180,16 @@ void computeBounce(ivec2 pix, vec3 direction, out vec3 diffuse, out vec3 specula
vec3 emissive = vec3(0.);
traceSimpleBlending(pos, bounce_direction, payload.hit_t.w, emissive, background);
const vec3 final_color = emissive + background;
if (brdf_type == DIFFUSE_TYPE)
diffuse += final_color;
else
specular += final_color + payload.emissive.rgb;
lighting = emissive + background;
} else {
lighting = texture(skybox, bounce_direction).rgb * ubo.ubo.skybox_exposure;
//payload.emissive.rgb = texture(skybox, bounce_direction).rgb * ubo.ubo.skybox_exposure;
}
if (brdf_type == DIFFUSE_TYPE)
diffuse += lighting;
else
specular += lighting + payload.emissive.rgb;
}

View File

@ -304,6 +304,7 @@ static void performTracing( vk_combuf_t *combuf, const perform_tracing_args_t* a
ASSERT(res->source_index_plus_1 <= COUNTOF(g_rtx.res));
rt_resource_t *const src = g_rtx.res + res->source_index_plus_1 - 1;
ASSERT(res != src);
// Swap resources
const vk_resource_t tmp_res = res->resource;
@ -319,6 +320,7 @@ static void performTracing( vk_combuf_t *combuf, const perform_tracing_args_t* a
// If there was no initial state, prepare it. (this should happen only for the first frame)
if (g_rtx.discontinuity || res->resource.write.pipelines == 0) {
// TODO is there a better way? Can image be cleared w/o explicit clear op?
DEBUG("discontinuity: %s", res->name);
R_VkImageClear( cmdbuf, res->image.image );
res->resource.write.pipelines = VK_PIPELINE_STAGE_TRANSFER_BIT;
res->resource.write.image_layout = VK_IMAGE_LAYOUT_GENERAL;
@ -326,6 +328,10 @@ static void performTracing( vk_combuf_t *combuf, const perform_tracing_args_t* a
}
}
if (g_rtx.discontinuity)
DEBUG("discontinuity => false");
g_rtx.discontinuity = false;
// Clear intra-frame resources
for (int i = ExternalResource_COUNT; i < MAX_RESOURCES; ++i) {
rt_resource_t* const res = g_rtx.res + i;
@ -688,7 +694,6 @@ void VK_RayFrameEnd(const vk_ray_frame_render_args_t* args)
tail:
APROF_SCOPE_END(ray_frame_end);
g_rtx.discontinuity = false;
}
static void reloadPipeline( void ) {
@ -780,5 +785,6 @@ void VK_RayShutdown( void ) {
}
void RT_FrameDiscontinuity( void ) {
DEBUG("%s", __FUNCTION__);
g_rtx.discontinuity = true;
}