Skip to content

Weird sunlight cornercase #486

@dsvensson

Description

@dsvensson

Say that someone for no reason at all creates an entity with classname light and _sun 1, delay 5, and _deviance 5 for example, which makes no sense as formula has no impact on sunlight, then the sun will be much more dim than its value dictates due to:

A sun is divided by sun samples and jittered here:

/* set photons */
light /= sun_num_samples;
for (i = 0; i < sun_num_samples; i++) {
qvec3f direction;

Thus not jittered here:

static void JitterEntity(const light_t &entity)
{
// don't jitter suns
if (entity.sun.value()) {
return;
}

And then divided again here, this time by _samples, as it had delay set to something other than 0:

/* For most formulas, we need to divide the light value by the number of
samples (jittering) to keep the brightness approximately the same. */
if (entity->getFormula() == LF_INVERSE || entity->getFormula() == LF_INVERSE2 ||
entity->getFormula() == LF_INFINITE || (entity->getFormula() == LF_LOCALMIN && cfg.addminlight.value()) ||
entity->getFormula() == LF_INVERSE2A) {
entity->light.set_value(entity->light.value() / entity->samples.value(), settings::source::MAP);
}

Unless I'm mistaken that CheckEntityFields condition ought to have a && !entity->sun.value(), and perhaps not a bad idea to emit a warning if a _sun 1 entity has delay set?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions