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

Method WritePBRLightShaderAttribs

PBR/src/GLTF_PBR_Renderer.cpp:830–873  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

828}
829
830void GLTF_PBR_Renderer::WritePBRLightShaderAttribs(const PBRLightShaderAttribsData& AttribsData,
831 HLSL::PBRLightAttribs* pShaderAttribs)
832{
833 VERIFY_EXPR(pShaderAttribs != nullptr);
834 VERIFY_EXPR(AttribsData.Light != nullptr);
835 const auto& Light = *AttribsData.Light;
836
837 pShaderAttribs->Type = static_cast<int>(Light.Type);
838
839 if (AttribsData.Position != nullptr)
840 {
841 pShaderAttribs->PosX = AttribsData.Position->x;
842 pShaderAttribs->PosY = AttribsData.Position->y;
843 pShaderAttribs->PosZ = AttribsData.Position->z;
844 }
845
846 if (AttribsData.Direction != nullptr)
847 {
848 pShaderAttribs->DirectionX = AttribsData.Direction->x;
849 pShaderAttribs->DirectionY = AttribsData.Direction->y;
850 pShaderAttribs->DirectionZ = AttribsData.Direction->z;
851 }
852
853 pShaderAttribs->ShadowMapIndex = AttribsData.ShadowMapIndex;
854
855 auto Intensity = Light.Intensity;
856 if (pShaderAttribs->Type != LIGHT_TYPE_DIRECTIONAL)
857 {
858 Intensity *= AttribsData.DistanceScale * AttribsData.DistanceScale;
859 }
860 pShaderAttribs->IntensityR = Light.Color.r * Intensity;
861 pShaderAttribs->IntensityG = Light.Color.g * Intensity;
862 pShaderAttribs->IntensityB = Light.Color.b * Intensity;
863
864 float Range = Light.Range * AttribsData.DistanceScale;
865 float Range2 = Range * Range;
866 pShaderAttribs->Range4 = Range2 * Range2;
867
868 float SpotAngleScale = 1.f / std::max(0.001f, std::cos(Light.InnerConeAngle) - std::cos(Light.OuterConeAngle));
869 float SpotAngleOffset = -std::cos(Light.OuterConeAngle) * SpotAngleScale;
870
871 pShaderAttribs->SpotAngleOffset = SpotAngleOffset;
872 pShaderAttribs->SpotAngleScale = SpotAngleScale;
873}
874
875} // namespace Diligent

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected