WIP Make shadows visible for Storm delegate #80

Closed
Vasyl Pidhirskyi wants to merge 16 commits from Vasyl-Pidhirskyi/blender_bn:BLEN-469 into hydra-render

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
2 changed files with 11 additions and 6 deletions
Showing only changes of commit e61f89ba11 - Show all commits

View File

@ -95,8 +95,15 @@ void LightData::init()
prim_type_ = prim_type(light);
write_shadow_params();
write_transform();
}
void LightData::write_shadow_params()
{
Vasyl-Pidhirskyi marked this conversation as resolved Outdated

move this outside if

move this outside `if`
/* Shadow section, only Sunlight is supported.
Vasyl-Pidhirskyi marked this conversation as resolved Outdated

rename shadow_params

rename `shadow_params`
we verified if any of light's shadow is turned on, if yes shadow task will be added*/
Light *light = (Light *)((Object *)id)->data;
bool use_shadow = (light->mode & LA_SHADOW) && light->type == LA_SUN;
scene_delegate_->shading_settings.use_storm_shadows |= use_shadow;
if (use_shadow) {
@ -112,7 +119,7 @@ void LightData::init()
the approximate value is calculated using sun_angle property
180 degrees is window size 1000 by 1000 */
shadow_matrix->SetWindow(static_cast<int>(light->sun_angle * 0.5f / M_PI * 1000),
static_cast<int>(light->sun_angle * 0.5f / M_PI * 1000));
static_cast<int>(light->sun_angle * 0.5f / M_PI * 1000));
shadow_matrix->CalculateMatrix();
shadow_params.enabled = use_shadow;
shadow_params.resolution = scene_delegate_->scene->eevee.shadow_cascade_size;
@ -124,8 +131,6 @@ void LightData::init()
data_[pxr::HdLightTokens->shadowCollection] = pxr::HdRprimCollection(
pxr::HdTokens->geometry, pxr::HdReprSelector(pxr::HdReprTokens->refined));
}
write_transform();
}
void LightData::insert()
@ -145,9 +150,7 @@ void LightData::update()
Object *object = (Object *)id;
Light *light = (Light *)object->data;
pxr::HdDirtyBits bits = pxr::HdLight::Clean;
if (id->recalc & ID_RECALC_GEOMETRY || light->id.recalc & ID_RECALC_GEOMETRY ||
scene_delegate_->shading_settings.use_storm_shadows)
{
if (id->recalc & ID_RECALC_GEOMETRY || light->id.recalc & ID_RECALC_GEOMETRY) {
if (prim_type(light) != prim_type_) {
remove();
init();
@ -158,6 +161,7 @@ void LightData::update()
bits = pxr::HdLight::AllDirty;
}
else if (id->recalc & ID_RECALC_TRANSFORM) {
write_shadow_params();
write_transform();
bits = pxr::HdLight::DirtyTransform;
}

View File

@ -30,6 +30,7 @@ class LightData : public ObjectData {
void remove() override;
void update() override;
void write_shadow_params();
pxr::VtValue get_data(pxr::TfToken const &key) const override;
protected: