vk: rt: fixup environment attenuation
Now environment emissive strength also depends on cos_theta (derived from sun solid angle).
This commit is contained in:
parent
e7ff1f3d3a
commit
7ef9bb87a9
|
@ -1,19 +1,19 @@
|
||||||
# 2024-01-16 E364
|
# 2024-01-16 E364
|
||||||
- [x] P NaNs
|
- [x] P NaNs
|
||||||
- [x] need to remove degenerate triangles
|
- [x] need to remove degenerate triangles
|
||||||
- [ ] add direct_{diff,spec} to rendertests
|
- [x] light_environment is too dark
|
||||||
- [ ] and rerun tests for vulkan to get new gold images
|
- [ ] add direct_{diff,spec} to rendertests → only can do for this handmade-brdfs branch
|
||||||
- [ ] light_environment is too dark
|
- [ ] :x: and rerun tests for vulkan to get new gold images → imuposshiburu, see above
|
||||||
- [ ] patchable sun angle
|
- [ ] patchable sun angle
|
||||||
|
|
||||||
# 2024-01-15 E363
|
# 2024-01-15 E363
|
||||||
- [x] filter out invalid (r=0, etc) lights in native
|
- [x] filter out invalid (r=0, etc) lights in native
|
||||||
- [-] already do; it seems that clusters are not getting updates → see #730
|
- [-] :o: already do; it seems that clusters are not getting updates → see #730
|
||||||
- [x] pass point lights r² directly?
|
- [x] pass point lights r² directly?
|
||||||
- [x] move empirical scaling to native code
|
- [x] move empirical scaling to native code
|
||||||
- [x] modify point light radius in entity patches → already done
|
- [x] modify point light radius in entity patches → already done
|
||||||
- [x] adjust brightness based on radius? → already done
|
- [x] adjust brightness based on radius? → already done
|
||||||
- [ ] ~~common intersection-local-normal-oriented basis~~ → point light construct light-oriented frames, not reusable
|
- [ ] :x: ~~common intersection-local-normal-oriented basis~~ → point light construct light-oriented frames, not reusable
|
||||||
|
|
||||||
# 2024-01-12 E362
|
# 2024-01-12 E362
|
||||||
- [ ] point→spherical light sampling
|
- [ ] point→spherical light sampling
|
||||||
|
@ -27,7 +27,7 @@
|
||||||
- [ ] need proper sampling asap, as different instabilities approaches are visually different, and it's impossible to reason which one is preferable
|
- [ ] need proper sampling asap, as different instabilities approaches are visually different, and it's impossible to reason which one is preferable
|
||||||
- [x] add material debug display mode
|
- [x] add material debug display mode
|
||||||
- [ ] vulkan validation layers crashes on too many `debugPrintfEXT` messages
|
- [ ] vulkan validation layers crashes on too many `debugPrintfEXT` messages
|
||||||
- [ ] diffuse is stil way darker than before
|
- [ ] diffuse is still way darker than before
|
||||||
|
|
||||||
# 2024-01-09 E360
|
# 2024-01-09 E360
|
||||||
- [x] validate all intermediate and final outputs against invalid values, complain into log
|
- [x] validate all intermediate and final outputs against invalid values, complain into log
|
||||||
|
|
|
@ -43,13 +43,10 @@ void computePointLights(vec3 P, vec3 N, uint cluster_index, vec3 view_dir, Mater
|
||||||
vec3 light_dir;
|
vec3 light_dir;
|
||||||
vec3 color = lights.m.point_lights[i].color_stopdot.rgb;
|
vec3 color = lights.m.point_lights[i].color_stopdot.rgb;
|
||||||
float light_dist = 0.;
|
float light_dist = 0.;
|
||||||
|
float one_over_pdf = 1.;
|
||||||
if (is_environment) {
|
if (is_environment) {
|
||||||
// Environment/directional light
|
// Environment/directional light
|
||||||
// FIXME extract, it is very different from other point/sphere/spotlights
|
// FIXME extract, it is rather different from other point/sphere/spotlights
|
||||||
|
|
||||||
// Empirical? TODO WHY?
|
|
||||||
// TODO move to native code
|
|
||||||
color *= 2.;
|
|
||||||
|
|
||||||
// TODO parametrize externally, via entity patches, etc
|
// TODO parametrize externally, via entity patches, etc
|
||||||
const float sun_solid_angle = 6.794e-5; // Wikipedia
|
const float sun_solid_angle = 6.794e-5; // Wikipedia
|
||||||
|
@ -62,7 +59,9 @@ void computePointLights(vec3 P, vec3 N, uint cluster_index, vec3 view_dir, Mater
|
||||||
const float light_dot = dot(light_dir, N);
|
const float light_dot = dot(light_dir, N);
|
||||||
if (light_dot < 1e-5)
|
if (light_dot < 1e-5)
|
||||||
continue;
|
continue;
|
||||||
} else {
|
|
||||||
|
one_over_pdf = 2. * kPi * max(0., 1. - cos_theta_max);
|
||||||
|
} /* is_environment */ else {
|
||||||
// Spherical lights
|
// Spherical lights
|
||||||
const vec3 light_pos = lights.m.point_lights[i].origin_r2.xyz;
|
const vec3 light_pos = lights.m.point_lights[i].origin_r2.xyz;
|
||||||
const float light_r2 = lights.m.point_lights[i].origin_r2.w;
|
const float light_r2 = lights.m.point_lights[i].origin_r2.w;
|
||||||
|
@ -154,17 +153,17 @@ void computePointLights(vec3 P, vec3 N, uint cluster_index, vec3 view_dir, Mater
|
||||||
// d2=4489108.500000 r2=1.000000 dist=2118.751465 spot_attenuation=0.092902 INVALID pdf=-316492608.000000
|
// d2=4489108.500000 r2=1.000000 dist=2118.751465 spot_attenuation=0.092902 INVALID pdf=-316492608.000000
|
||||||
// Therefore, need to clamp denom with max
|
// Therefore, need to clamp denom with max
|
||||||
// TODO need better sampling right nao
|
// TODO need better sampling right nao
|
||||||
const float one_over_pdf = 2. * kPi * max(0., 1. - cos_theta_max) * spot_attenuation;
|
one_over_pdf = 2. * kPi * max(0., 1. - cos_theta_max) * spot_attenuation;
|
||||||
#ifdef DEBUG_VALIDATE_EXTRA
|
#ifdef DEBUG_VALIDATE_EXTRA
|
||||||
if (IS_INVALID(one_over_pdf) || one_over_pdf < 0.) {
|
if (IS_INVALID(one_over_pdf) || one_over_pdf < 0.) {
|
||||||
debugPrintfEXT("light.glsl:%d light_dist2=%f light_r2=%f light_dist=%f spot_attenuation=%f INVALID one_over_pdf=%f",
|
debugPrintfEXT("light.glsl:%d light_dist2=%f light_r2=%f light_dist=%f spot_attenuation=%f INVALID one_over_pdf=%f",
|
||||||
__LINE__, light_dist2, light_r2, light_dist, spot_attenuation, one_over_pdf);
|
__LINE__, light_dist2, light_r2, light_dist, spot_attenuation, one_over_pdf);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
color *= one_over_pdf;
|
|
||||||
} // Sphere/spot lights
|
} // Sphere/spot lights
|
||||||
|
|
||||||
|
color *= one_over_pdf;
|
||||||
|
|
||||||
vec3 ldiffuse, lspecular;
|
vec3 ldiffuse, lspecular;
|
||||||
evalSplitBRDF(N, light_dir, view_dir, material, ldiffuse, lspecular);
|
evalSplitBRDF(N, light_dir, view_dir, material, ldiffuse, lspecular);
|
||||||
ldiffuse *= color;
|
ldiffuse *= color;
|
||||||
|
|
|
@ -893,8 +893,9 @@ static void processStaticPointLights( void ) {
|
||||||
const float radius = le->radius > 0.f ? le->radius : default_radius;
|
const float radius = le->radius > 0.f ? le->radius : default_radius;
|
||||||
|
|
||||||
// These constants are empirical. There's no known math reason behind them
|
// These constants are empirical. There's no known math reason behind them
|
||||||
const float hack_attenuation = .1f / 25.f; // FIXME tune
|
const float hack_attenuation = (le->type == LightTypeEnvironment)
|
||||||
const float hack_attenuation_spot = .1f / 25.f; // FIXME tune
|
? 700.f // FIXME why?
|
||||||
|
: .1f / 25.f; // FIXME why?
|
||||||
|
|
||||||
int index;
|
int index;
|
||||||
switch (le->type) {
|
switch (le->type) {
|
||||||
|
@ -902,9 +903,9 @@ static void processStaticPointLights( void ) {
|
||||||
index = addPointLight(le->origin, le->color, radius, le->style, hack_attenuation);
|
index = addPointLight(le->origin, le->color, radius, le->style, hack_attenuation);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LightTypeSpot:
|
|
||||||
case LightTypeEnvironment:
|
case LightTypeEnvironment:
|
||||||
index = addSpotLight(le, radius, le->style, hack_attenuation_spot, i == g_map_entities.single_environment_index);
|
case LightTypeSpot:
|
||||||
|
index = addSpotLight(le, radius, le->style, hack_attenuation, i == g_map_entities.single_environment_index);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
Loading…
Reference in New Issue