MCPcopy Create free account
hub / github.com/DiligentGraphics/DiligentFX / Sync

Method Sync

Hydrogent/src/HnLight.cpp:427–635  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

425}
426
427void HnLight::Sync(pxr::HdSceneDelegate* SceneDelegate,
428 pxr::HdRenderParam* RenderParam,
429 pxr::HdDirtyBits* DirtyBits)
430{
431 if (*DirtyBits == pxr::HdLight::Clean)
432 return;
433
434 const pxr::SdfPath& Id = GetId();
435
436 bool LightDirty = false;
437
438 {
439 bool IsVisible = SceneDelegate->GetVisible(Id);
440 if (IsVisible != m_IsVisible)
441 {
442 m_IsVisible = IsVisible;
443 LightDirty = true;
444 m_IsShadowMapDirty = true;
445 }
446 }
447
448 bool ShadowTransformDirty = false;
449 if (*DirtyBits & DirtyTransform)
450 {
451 const pxr::GfMatrix4d Transform = SceneDelegate->GetTransform(Id);
452
453 const float3 Position = ToFloat3(Transform.ExtractTranslation());
454 if (Position != m_Position)
455 {
456 m_Position = Position;
457 LightDirty = true;
458 }
459
460 // Convention is to emit light along -Z
461 const pxr::GfVec4d zDir = Transform.GetRow(2);
462 const float3 Direction = -ToFloat3(pxr::GfVec3d{zDir[0], zDir[1], zDir[2]});
463 if (Direction != m_Direction)
464 {
465 m_Direction = Direction;
466
467 float3 LightSpaceX, LightSpaceY, LightSpaceZ;
468 BasisFromDirection(m_Direction, true, LightSpaceX, LightSpaceY, LightSpaceZ);
469 m_ViewMatrix = float4x4::ViewFromBasis(LightSpaceX, LightSpaceY, LightSpaceZ);
470
471 LightDirty = true;
472 }
473
474 ShadowTransformDirty = true;
475
476 *DirtyBits &= ~DirtyTransform;
477 }
478
479 if (*DirtyBits & DirtyParams)
480 {
481 auto LightType = GLTF::Light::TYPE::UNKNOWN;
482 if (m_TypeId == pxr::HdPrimTypeTokens->distantLight)
483 {
484 LightType = GLTF::Light::TYPE::DIRECTIONAL;

Callers

nothing calls this directly

Calls 8

ToFloat3Function · 0.85
GetTextureFileFunction · 0.85
GetTransformMethod · 0.80
GetMetersPerUnitMethod · 0.80
GetShadowMapManagerMethod · 0.80
GetLightParamValueMethod · 0.80
MakeAttribDirtyMethod · 0.80
AllocateMethod · 0.45

Tested by

no test coverage detected