Changeset View
Changeset View
Standalone View
Standalone View
source/blender/draw/engines/eevee/eevee_lights.c
| Show First 20 Lines • Show All 591 Lines • ▼ Show 20 Lines | GPU_framebuffer_ensure_config(&sldata->shadow_cascade_store_fb, { | ||||
| GPU_ATTACHMENT_TEXTURE(sldata->shadow_cascade_pool) | GPU_ATTACHMENT_TEXTURE(sldata->shadow_cascade_pool) | ||||
| }); | }); | ||||
| /* Update Lights UBOs. */ | /* Update Lights UBOs. */ | ||||
| EEVEE_lights_update(sldata, vedata); | EEVEE_lights_update(sldata, vedata); | ||||
| } | } | ||||
| 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) { | ||||
brecht: I made this change compared to the original patch, initially I forgot to update the automatic… | |||||
| 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); | ||||
| 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) | ||||
| Show All 27 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 836 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.