vk: rt: move empirical light scaling to native code
There are lots of empirical (and less-well undrestood things) scaling color values in native code, it makes sense to consolidate them in one place: - less weird math in shaders. shader should be as streamlined as possible - one big block of weird math is untangleable in the future when we get to work on light and clusters
This commit is contained in:
parent
f157762043
commit
2507a629cf
|
@ -2,12 +2,14 @@
|
|||
- [x] filter out invalid (r=0, etc) lights in native
|
||||
- [-] already do; it seems that clusters are not getting updates → see #730
|
||||
- [x] pass point lights r² directly?
|
||||
- [ ] move empirical scaling to native code
|
||||
- [x] move empirical scaling to native code
|
||||
- [ ] modify point light radius in entity patches
|
||||
- [ ] adjust brightness based on radius?
|
||||
- [ ] adjust brightness based on radius?
|
||||
- [ ] P NaNs
|
||||
- [ ] patchable sun angle
|
||||
- [ ] common intersection-local-normal-oriented basis
|
||||
- [ ] add direct_{diff,spec} to rendertests
|
||||
- [ ] and rerun tests for vulkan to get new gold images
|
||||
|
||||
# 2024-01-12 E362
|
||||
- [ ] point→spherical light sampling
|
||||
|
|
|
@ -207,20 +207,11 @@ void computeLighting(vec3 P, vec3 N, vec3 view_dir, MaterialProperties material,
|
|||
|
||||
#if LIGHT_POLYGON
|
||||
sampleEmissiveSurfaces(P, N, view_dir, material, cluster_index, diffuse, specular);
|
||||
// These constants are empirical. There's no known math reason behind them
|
||||
// TODO move to native code
|
||||
diffuse /= 25.0;
|
||||
specular /= 25.0;
|
||||
#endif
|
||||
|
||||
#if LIGHT_POINT
|
||||
vec3 ldiffuse = vec3(0.), lspecular = vec3(0.);
|
||||
computePointLights(P, N, cluster_index, view_dir, material, ldiffuse, lspecular);
|
||||
// These constants are empirical. There's no known math reason behind them
|
||||
// TODO move to native code
|
||||
ldiffuse /= 25.;
|
||||
lspecular /= 25.;
|
||||
|
||||
diffuse += ldiffuse;
|
||||
specular += lspecular;
|
||||
#endif
|
||||
|
|
|
@ -868,6 +868,9 @@ static qboolean addDlight( const dlight_t *dlight ) {
|
|||
|
||||
scaler = k_threshold / (max_comp * sphereSolidAngleFromDistDiv2Pi(k_light_radius, dlight->radius));
|
||||
|
||||
// These constants are empirical. There's no known math reason behind them
|
||||
scaler /= 25.;
|
||||
|
||||
VectorSet(
|
||||
color,
|
||||
dlight->color.r * scaler,
|
||||
|
@ -887,11 +890,13 @@ static void processStaticPointLights( void ) {
|
|||
for (int i = 0; i < g_map_entities.num_lights; ++i) {
|
||||
const vk_light_entity_t *le = g_map_entities.lights + i;
|
||||
const float default_radius = 2.f; // FIXME tune
|
||||
const float hack_attenuation = .1f; // FIXME tune
|
||||
const float hack_attenuation_spot = .1f; // FIXME tune
|
||||
const float radius = le->radius > 0.f ? le->radius : default_radius;
|
||||
int index;
|
||||
|
||||
// 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_spot = .1f / 25.f; // FIXME tune
|
||||
|
||||
int index;
|
||||
switch (le->type) {
|
||||
case LightTypePoint:
|
||||
index = addPointLight(le->origin, le->color, radius, le->style, hack_attenuation);
|
||||
|
@ -1089,7 +1094,12 @@ int RT_LightAddPolygon(const rt_light_add_polygon_t *addpoly) {
|
|||
poly->vertices.offset = g_lights_.num_polygon_vertices;
|
||||
poly->vertices.count = addpoly->num_vertices;
|
||||
|
||||
VectorCopy(addpoly->emissive, poly->emissive);
|
||||
{
|
||||
// These constants are empirical. There's no known math reason behind them
|
||||
const float hack_attenuation_poly = 1.f / 25.f;
|
||||
VectorScale(addpoly->emissive, hack_attenuation_poly, poly->emissive);
|
||||
}
|
||||
|
||||
VectorSet(poly->center, 0, 0, 0);
|
||||
VectorSet(normal, 0, 0, 0);
|
||||
|
||||
|
|
Loading…
Reference in New Issue