Changeset View
Changeset View
Standalone View
Standalone View
source/blender/draw/engines/eevee/eevee_lights.c
| Show First 20 Lines • Show All 634 Lines • ▼ Show 20 Lines | |||||
| float light_attenuation_radius_get(Light *la, float light_threshold) | float light_attenuation_radius_get(Light *la, float light_threshold) | ||||
| { | { | ||||
| if (la->mode & LA_CUSTOM_ATTENUATION) { | if (la->mode & LA_CUSTOM_ATTENUATION) { | ||||
| return la->att_dist; | return la->att_dist; | ||||
| } | } | ||||
| /* Compute max light power. */ | /* Compute max light power. */ | ||||
| float power = max_fff(la->r, la->g, la->b); | float power = max_fff(la->r, la->g, la->b); | ||||
| power *= fabsf(la->energy); | power *= fabsf(la->energy); | ||||
brecht: I made this change compared to the original patch, initially I forgot to update the automatic… | |||||
| power *= max_ff(1.0f, la->spec_fac); | power *= max_ff(1.0f, la->spec_fac); | ||||
| /* Compute the distance (using the inverse square law) | /* Compute the distance (using the inverse square law) | ||||
| * at which the light power reaches the light_threshold. */ | * at which the light power reaches the light_threshold. */ | ||||
| float distance = sqrtf(max_ff(1e-16, power / max_ff(1e-16, light_threshold))); | float distance = sqrtf(max_ff(1e-16, power / max_ff(1e-16, light_threshold))); | ||||
| return distance; | return distance; | ||||
| } | } | ||||
| static void light_shape_parameters_set(EEVEE_Light *evli, const Light *la, float scale[3]) | static void light_shape_parameters_set(EEVEE_Light *evli, const Light *la, float scale[3]) | ||||
| Show All 21 Lines | |||||
| } | } | ||||
| static float light_shape_power_get(const Light *la, const EEVEE_Light *evli) | static float light_shape_power_get(const Light *la, const EEVEE_Light *evli) | ||||
| { | { | ||||
| float power; | float power; | ||||
| /* Make illumination power constant */ | /* Make illumination power constant */ | ||||
| if (la->type == LA_AREA) { | if (la->type == LA_AREA) { | ||||
| power = 1.0f / (evli->sizex * evli->sizey * 4.0f * M_PI) * /* 1/(w*h*Pi) */ | power = 1.0f / (evli->sizex * evli->sizey * 4.0f * M_PI) * /* 1/(w*h*Pi) */ | ||||
| 80.0f; /* XXX : Empirical, Fit cycles power */ | 0.8f; /* XXX : Empirical, Fit cycles power */ | ||||
| if (ELEM(la->area_shape, LA_AREA_DISK, LA_AREA_ELLIPSE)) { | if (ELEM(la->area_shape, LA_AREA_DISK, LA_AREA_ELLIPSE)) { | ||||
| /* Scale power to account for the lower area of the ellipse compared to the surrounding rectangle. */ | /* Scale power to account for the lower area of the ellipse compared to the surrounding rectangle. */ | ||||
| power *= 4.0f / M_PI; | power *= 4.0f / M_PI; | ||||
| } | } | ||||
| } | } | ||||
| else if (la->type == LA_SPOT || la->type == LA_LOCAL) { | else if (la->type == LA_SPOT || la->type == LA_LOCAL) { | ||||
| power = 1.0f / (4.0f * evli->radius * evli->radius * M_PI * M_PI) * /* 1/(4*r²*Pi²) */ | power = 1.0f / (4.0f * evli->radius * evli->radius * M_PI * M_PI); /* 1/(4*r²*Pi²) */ | ||||
| M_PI * M_PI * 10.0; /* XXX : Empirical, Fit cycles power */ | |||||
| /* for point lights (a.k.a radius == 0.0) */ | /* for point lights (a.k.a radius == 0.0) */ | ||||
| // power = M_PI * M_PI * 0.78; /* XXX : Empirical, Fit cycles power */ | // power = M_PI * M_PI * 0.78; /* XXX : Empirical, Fit cycles power */ | ||||
| } | } | ||||
| else { | else { | ||||
| power = 1.0f / (evli->radius * evli->radius * M_PI); /* 1/(r²*Pi) */ | power = 1.0f / (evli->radius * evli->radius * M_PI); /* 1/(r²*Pi) */ | ||||
| /* Make illumation power closer to cycles for bigger radii. Cycles uses a cos^3 term that we cannot reproduce | /* Make illumation power closer to cycles for bigger radii. Cycles uses a cos^3 term that we cannot reproduce | ||||
| * so we account for that by scaling the light power. This function is the result of a rough manual fitting. */ | * so we account for that by scaling the light power. This function is the result of a rough manual fitting. */ | ||||
| ▲ Show 20 Lines • Show All 871 Lines • Show Last 20 Lines | |||||
I made this change compared to the original patch, initially I forgot to update the automatic distance computation code which caused shadowing artifacts.
This does mean the results no longer match as well in the regression tests, since Eevee's automatic distance removes a fairly noticeable amount of light.