From b58eb5b4b219c30b1c67e739f4d5728f6d3627d5 Mon Sep 17 00:00:00 2001 From: Ivan 'provod' Avdeev Date: Sat, 5 Jun 2021 13:06:03 -0700 Subject: [PATCH] rtx: slightly improve fake poc lighting --- ref_vk/TODO.md | 8 +++++--- ref_vk/shaders/rtx.comp | 8 +++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/ref_vk/TODO.md b/ref_vk/TODO.md index df7a2278..bd76f7b2 100644 --- a/ref_vk/TODO.md +++ b/ref_vk/TODO.md @@ -1,13 +1,14 @@ ## 2021-06-05, E103 - [x] rtx: dynamic surface lights / dynamic light clusters - [x] rtx: animated textures +- [x] rtx: attenuate surface lights by normal # Next -- [ ] rtx: attenuate surface lights by normal +- [ ] run under asan - [ ] rtx: better memory handling - [ ] robust tracking of memory hierarchies: global/static, map, frame - or just do a generic allocator with compaction? -- [ ] rtx: better light culling: normal, bsp visibility, light volumes and intensity, ... +- [ ] rtx: better light culling: normal, bsp visibility, light volumes and intensity, sort by intensity, etc - [ ] rtx: live rad file reloading (or other solution for tuning lights) - [ ] rtx: restore dynamic stuff like particles, beams, etc - [ ] rtx: emissive particles @@ -29,6 +30,8 @@ - [ ] studio models: fix lighting: should have white texture instead of lightmap OR we could write nearest surface lightmap coords to fake light # Planned +- [ ] rtx: too many emissive lights in c3a1b +- [ ] rtx: c3a1b: assert model->size >= build_size.accelerationStructureSize failed at vk_rtx.c:347 - [ ] studio models: pre-compute buffer sizes and allocate them at once - [ ] rtx: denoise - [ ] non local means ? @@ -70,7 +73,6 @@ # Someday - [ ] nvnsight into buffer memory and stuff -- [ ] run under asan - [ ] start building command buffers in beginframe - [ ] multiple frames in flight (#nd cmdbuf, ...) - [ ] cleanup unused stuff in vk_studio.c diff --git a/ref_vk/shaders/rtx.comp b/ref_vk/shaders/rtx.comp index 89068a91..aab7f36d 100644 --- a/ref_vk/shaders/rtx.comp +++ b/ref_vk/shaders/rtx.comp @@ -430,7 +430,7 @@ void main() { //C += kc * vec3(hash(float(kusok_index)), hash(float(kusok_index)+15.43), hash(float(kusok_index)+34.));//kusok.emissive.rgb; //C = vec3(1., 0., 1.); if (bounce == 0) - C += kc * emissive; + C += kc * emissive * baseColor; continue; } @@ -462,12 +462,14 @@ void main() { // const vec3 n3 = vertices[vi3].normal; vec3 light_dir = sample_pos - pos; - if (dot(light_dir, n1) >= 0.) { + float light_dot = -dot(light_dir, n1); + if (light_dot <= 0.) { //C = vec3(1., 0., 1.); continue; } const float light_dist = length(light_dir); + light_dot /= light_dist; light_dir /= light_dist; if (shadowed(pos, light_dir, light_dist - shadow_offset_fudge)) { //C = vec3(0., 1., 0.); @@ -476,7 +478,7 @@ void main() { // TODO const float brightness_fudge = 5.; - C += sampling_light_scale * brightness_fudge * kc * baseColor * emissive * dot(light_dir, normal) / (light_dist * light_dist); + C += light_dot * sampling_light_scale * brightness_fudge * kc * baseColor * emissive * dot(light_dir, normal) / (light_dist * light_dist); // Sample just one triangle break;