[vulkan] Tweak the lighting to look a bit better

Reduced the gamma correction a bit and increased the intensity of
dynamic lights. Not sure the latter is correct, but it looks much
better.
This commit is contained in:
Bill Currie 2021-03-20 19:15:06 +09:00
parent cadea27577
commit 0a79348ce9
3 changed files with 12 additions and 10 deletions

View file

@ -15,6 +15,6 @@ main (void)
o = subpassLoad (opaque).rgb;
t = subpassLoad (translucent);
c = mix (o, t.rgb, t.a);
c = pow (c, vec3(0.67));//FIXME make gamma correction configurable
c = pow (c, vec3(0.83));//FIXME make gamma correction configurable
frag_color = vec4 (c, 1);
}

View file

@ -33,8 +33,8 @@ calc_light (LightData light, vec3 position, vec3 normal)
float r = light.radius;
float intensity = light.intensity * step (d, r);
intensity *= step (spotdot, light.cone) * clamp (lightdot, 0, 1);
return light.color * intensity * (r - d) / 255.0;
intensity *= smoothstep (spotdot, 1 - (1 - spotdot) * 0.995, light.cone) * clamp (lightdot, 0, 1);
return light.color * intensity * (r - d);
}
void
@ -51,5 +51,5 @@ main (void)
light += calc_light (lights[i], p, n);
}
}
frag_color = vec4 (c * light, 1);
frag_color = vec4 (c * light / 255.0, 1);
}

View file

@ -131,7 +131,7 @@ update_lights (vulkan_ctx_t *ctx)
VectorCopy (lights[i]->color, light_data->lights[i].color);
VectorCopy (lights[i]->origin, light_data->lights[i].position);
light_data->lights[i].radius = lights[i]->radius;
light_data->lights[i].intensity = 1;
light_data->lights[i].intensity = 16;
VectorZero (light_data->lights[i].direction);
light_data->lights[i].cone = 1;
}
@ -370,19 +370,23 @@ parse_light (qfv_light_t *light, const plitem_t *entity,
{
const char *str;
Sys_Printf ("{\n");
/*Sys_Printf ("{\n");
for (int i = PL_D_NumKeys (entity); i-- > 0; ) {
const char *field = PL_KeyAtIndex (entity, i);
const char *value = PL_String (PL_ObjectForKey (entity, field));
Sys_Printf ("\t%s = %s\n", field, value);
}
Sys_Printf ("}\n");
Sys_Printf ("}\n");*/
light->cone = 1;
light->intensity = 1;
light->radius = 300;
VectorSet (1, 1, 1, light->color);
if ((str = PL_String (PL_ObjectForKey (entity, "origin")))) {
sscanf (str, "%f %f %f", VectorExpandAddr (light->position));
}
light->cone = 1;
if ((str = PL_String (PL_ObjectForKey (entity, "target")))) {
vec3_t position = {};
plitem_t *target = PL_ObjectForKey (targets, str);
@ -401,13 +405,11 @@ parse_light (qfv_light_t *light, const plitem_t *entity,
light->cone = -cos (angle * M_PI / 360); // half angle
}
light->intensity = 1;
if ((str = PL_String (PL_ObjectForKey (entity, "light_lev")))
|| (str = PL_String (PL_ObjectForKey (entity, "_light")))) {
light->radius = atof (str);
}
VectorSet (1, 1, 1, light->color);
if ((str = PL_String (PL_ObjectForKey (entity, "color")))
|| (str = PL_String (PL_ObjectForKey (entity, "_color")))) {
sscanf (str, "%f %f %f", VectorExpandAddr (light->color));