vk: rt: added minimal distance for legacy soft blending

Only engage soft particles/blending after a certain distance. Makes
certain see-beams-through-weapons visual glitches disappear.

Engages soft particles with a smoothstep so the don't immediately pop up
after a certain distance, rather appear gradually.
This commit is contained in:
Ivan Avdeev 2024-01-19 11:58:33 -05:00
parent 6ee8af040e
commit e12b2c47b4
2 changed files with 11 additions and 3 deletions

View File

@ -1,7 +1,7 @@
## 2024-01-19 E366
- [x] investigate more shading nans
- found zero normals in studio models, see #731
- [ ] guns and transparency
- [x] guns and transparency → added legacy transparency overshoot threshold
- [ ] flashlight is too bright
- [ ] bounce diffuse is still way darker than before

View File

@ -7,7 +7,7 @@
// Done in sRGB-γ space for legacy-look reasons.
// Returns vec4(emissive_srgb.rgb, revealage)
vec4 traceLegacyBlending(vec3 pos, vec3 dir, float L) {
const float glow_soft_overshoot = 16.;
const float kGlowSoftOvershoot = 16.;
vec3 emissive = vec3(0.);
// TODO probably a better way would be to sort only MIX entries.
@ -29,13 +29,21 @@ vec4 traceLegacyBlending(vec3 pos, vec3 dir, float L) {
//| gl_RayFlagsSkipClosestHitShaderEXT
| gl_RayFlagsNoOpaqueEXT // force all to be non-opaque
;
rayQueryInitializeEXT(rq, tlas, flags, GEOMETRY_BIT_BLEND, pos, 0., dir, L + glow_soft_overshoot);
rayQueryInitializeEXT(rq, tlas, flags, GEOMETRY_BIT_BLEND, pos, 0., dir, L + kGlowSoftOvershoot);
while (rayQueryProceedEXT(rq)) {
const MiniGeometry geom = readCandidateMiniGeometry(rq);
const int model_index = rayQueryGetIntersectionInstanceIdEXT(rq, false);
const ModelHeader model = getModelHeader(model_index);
const Kusok kusok = getKusok(geom.kusok_index);
const float hit_t = rayQueryGetIntersectionTEXT(rq, false);
// Engage soft particles/blending gradually after a certain distance.
// Makes see-beams-through-weapons visual glitch mostly disappear.
// Engage-vs-Full difference to make soft particles appear gradually, and not pop immediately.
const float kOvershootEngageDist = 20.;
const float kOvershootFullDist = 40.;
const float glow_soft_overshoot = kGlowSoftOvershoot * smoothstep(kOvershootEngageDist, kOvershootFullDist, hit_t);
const float overshoot = hit_t - L;
// Use soft alpha depth effect globally, not only for glow