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.
Showing only changes of commit 479b8be3ef - Show all commits

View File

@ -101,26 +101,26 @@ void LightData::init()
scene_delegate_->shading_settings.use_storm_shadows |= use_shadow; scene_delegate_->shading_settings.use_storm_shadows |= use_shadow;
if (use_shadow) { if (use_shadow) {
data_[pxr::HdLightTokens->hasShadow] = use_shadow; data_[pxr::HdLightTokens->hasShadow] = use_shadow;
pxr::HdxShadowParams shadowParams_ = pxr::HdxShadowParams(); pxr::HdxShadowParams shadow_params = pxr::HdxShadowParams();
/* ShadowMatrix class is used to calculates shadow matrix from light frustum.*/ /* ShadowMatrix class is used to calculates shadow matrix from light frustum.*/
ShadowMatrix *shadowMatrix = new ShadowMatrix(); ShadowMatrix *shadow_matrix = new ShadowMatrix();
shadowMatrix->SetNearFar(0.1, light->cascade_max_dist); shadow_matrix->SetNearFar(0.1, light->cascade_max_dist);
shadowMatrix->SetTransform(gf_matrix_from_transform(((Object *)id)->object_to_world)); shadow_matrix->SetTransform(gf_matrix_from_transform(((Object *)id)->object_to_world));
/* SetWindow sets size of projected shadow texture texture in /* SetWindow sets size of projected shadow texture texture in
the approximate value is calculated using sun_angle property the approximate value is calculated using sun_angle property
180 degrees is window size 1000 by 1000 */ 180 degrees is window size 1000 by 1000 */
shadowMatrix->SetWindow(static_cast<int>(light->sun_angle * 0.5f / M_PI * 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));
shadowMatrix->CalculateMatrix(); shadow_matrix->CalculateMatrix();
shadowParams_.enabled = use_shadow; shadow_params.enabled = use_shadow;
shadowParams_.resolution = scene_delegate_->scene->eevee.shadow_cascade_size; shadow_params.resolution = scene_delegate_->scene->eevee.shadow_cascade_size;
shadowParams_.shadowMatrix = pxr::HdxShadowMatrixComputationSharedPtr(shadowMatrix); shadow_params.shadowMatrix = pxr::HdxShadowMatrixComputationSharedPtr(shadow_matrix);
shadowParams_.bias = -1.0 * light->bias; shadow_params.bias = -1.0 * light->bias;
shadowParams_.blur = light->cascade_fade; shadow_params.blur = light->cascade_fade;
data_[pxr::HdLightTokens->shadowParams] = shadowParams_; data_[pxr::HdLightTokens->shadowParams] = shadow_params;
data_[pxr::HdLightTokens->shadowCollection] = pxr::HdRprimCollection( data_[pxr::HdLightTokens->shadowCollection] = pxr::HdRprimCollection(
pxr::HdTokens->geometry, pxr::HdReprSelector(pxr::HdReprTokens->refined)); pxr::HdTokens->geometry, pxr::HdReprSelector(pxr::HdReprTokens->refined));
} }