EEVEE DoF: Fix runtime error: division by zero when blades was 0
Even though the fragment shader was already discarding all members of dof_bokeh_sides when blades was zero, the C code was still trying to use this for a few divisions leading to runtime asserts. Those are harmless yet can lead some to waste time while pursuiting other bugs (namely a near freeze when blades aspect ratio is too low).
This commit is contained in:
parent
4d8ed937f2
commit
bdbe484428
Notes:
blender-bot
2023-02-14 04:12:30 +01:00
Referenced by issue #60148, 2.8 crashes when changing aperture ratio to 0
|
@ -178,9 +178,9 @@ int EEVEE_depth_of_field_init(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_Data *v
|
|||
|
||||
/* Precompute values to save instructions in fragment shader. */
|
||||
effects->dof_bokeh_sides[0] = blades;
|
||||
effects->dof_bokeh_sides[1] = 2.0f * M_PI / blades;
|
||||
effects->dof_bokeh_sides[1] = blades > 0.0f ? 2.0f * M_PI / blades : 0.0f;
|
||||
effects->dof_bokeh_sides[2] = blades / (2.0f * M_PI);
|
||||
effects->dof_bokeh_sides[3] = cosf(M_PI / blades);
|
||||
effects->dof_bokeh_sides[3] = blades > 0.0f ? cosf(M_PI / blades) : 0.0f;
|
||||
|
||||
return EFFECT_DOF | EFFECT_POST_BUFFER;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue