vk: rt: fixup bounce brightness

Shoulnd't have multiplied by diffuse BRDF result. It should be encoded
in diffuse-vs-specular split, and the cosine term is already taken care
of in sampling.
This commit is contained in:
Ivan Avdeev 2024-01-19 12:51:32 -05:00
parent d20bbe1761
commit 8359a04750
2 changed files with 12 additions and 9 deletions

View File

@ -1,12 +1,19 @@
## Next
- [ ] specular bounce
- [ ] specular-vs-diffuse choice based on metalness+frensel
- [ ] VNDF? sampling
- [ ] performance profiling and comparison
# Previously
## 2024-01-19 E366
- [x] investigate more shading nans
- found zero normals in studio models, see #731
- [x] guns and transparency → added legacy transparency overshoot threshold
- [x] cvar to force culling
- [ ] flashlight is too bright
- [ ] bounce diffuse is still way darker than before
- [x] flashlight is too bright
- [x] bounce diffuse is still way darker than before
→ it shouldn't have been multiplied by diffuse value
# Previously
## 2024-01-18 E365
- [-] flashlight far circular glitches
- This is due to f32 precision not being enough when working with small (light radius ~=1) and large (light

View File

@ -327,11 +327,6 @@ int brdfGetSample(vec2 rnd, MaterialProperties material, vec3 view, vec3 geometr
// TODO pick diffuse-vs-specular based on expected contribution
const int brdf_type = BRDF_TYPE_DIFFUSE;// (rand01() > .5) ? BRDF_TYPE_DIFFUSE : BRDF_TYPE_SPECULAR;
if (any(isnan(geometry_normal))) {
inout_throughput = 10.*vec3(1.,0.,1.);
return brdf_type;
}
#if defined(BRDF_COMPARE) && defined(TEST_LOCAL_FRAME)
if (g_mat_gltf2) {
#endif
@ -359,7 +354,8 @@ if (g_mat_gltf2) {
}
*/
inout_throughput *= (brdf_type == BRDF_TYPE_DIFFUSE) ? diffuse : specular;
const vec3 lambert_diffuse_term = vec3(1.f); // Cosine weight is already "encoded" in cosine hemisphere sampling.
inout_throughput *= (brdf_type == BRDF_TYPE_DIFFUSE) ? lambert_diffuse_term : specular;
const float throughput_threshold = 1e-3;
if (dot(inout_throughput, inout_throughput) < throughput_threshold)