35 if (blight ==
nullptr) {
43 pxr::UsdLuxLightAPI light_api(
prim_);
48 float light_surface_area = 1.0f;
50 if (
prim_.IsA<pxr::UsdLuxDiskLight>()) {
55 pxr::UsdLuxDiskLight disk_light(
prim_);
57 if (pxr::UsdAttribute radius_attr = disk_light.GetRadiusAttr()) {
59 if (radius_attr.Get(&radius, motionSampleTime)) {
65 const float radius = 0.5f * blight->
area_size;
66 light_surface_area = radius * radius *
M_PI;
68 else if (
prim_.IsA<pxr::UsdLuxRectLight>()) {
73 pxr::UsdLuxRectLight rect_light(
prim_);
75 if (pxr::UsdAttribute width_attr = rect_light.GetWidthAttr()) {
77 if (width_attr.Get(&width, motionSampleTime)) {
82 if (pxr::UsdAttribute height_attr = rect_light.GetHeightAttr()) {
84 if (height_attr.Get(&height, motionSampleTime)) {
92 else if (
prim_.IsA<pxr::UsdLuxSphereLight>()) {
96 pxr::UsdLuxSphereLight sphere_light(
prim_);
98 pxr::UsdAttribute treatAsPoint_attr = sphere_light.GetTreatAsPointAttr();
100 if (treatAsPoint_attr && treatAsPoint_attr.Get(&treatAsPoint, motionSampleTime) &&
105 else if (pxr::UsdAttribute radius_attr = sphere_light.GetRadiusAttr()) {
107 if (radius_attr.Get(&radius, motionSampleTime)) {
115 pxr::UsdLuxShapingAPI shaping_api = pxr::UsdLuxShapingAPI(
prim_);
116 if (shaping_api && shaping_api.GetShapingConeAngleAttr().IsAuthored()) {
119 if (pxr::UsdAttribute cone_angle_attr = shaping_api.GetShapingConeAngleAttr()) {
120 float cone_angle = 0.0f;
121 if (cone_angle_attr.Get(&cone_angle, motionSampleTime)) {
126 if (pxr::UsdAttribute cone_softness_attr = shaping_api.GetShapingConeSoftnessAttr()) {
127 float cone_softness = 0.0f;
128 if (cone_softness_attr.Get(&cone_softness, motionSampleTime)) {
134 else if (
prim_.IsA<pxr::UsdLuxDistantLight>()) {
137 pxr::UsdLuxDistantLight distant_light(
prim_);
139 if (pxr::UsdAttribute angle_attr = distant_light.GetAngleAttr()) {
141 if (angle_attr.Get(&angle, motionSampleTime)) {
149 if (pxr::UsdAttribute intensity_attr = light_api.GetIntensityAttr()) {
150 float intensity = 0.0f;
151 if (intensity_attr.Get(&intensity, motionSampleTime)) {
154 blight->
energy = intensity * 4.0f;
165 if (pxr::UsdAttribute exposure_attr = light_api.GetExposureAttr()) {
166 float exposure = 0.0f;
167 if (exposure_attr.Get(&exposure, motionSampleTime)) {
173 if (pxr::UsdAttribute color_attr = light_api.GetColorAttr()) {
175 if (color_attr.Get(&color, motionSampleTime)) {
176 blight->
r = color[0];
177 blight->
g = color[1];
178 blight->
b = color[2];
183 if (pxr::UsdAttribute diff_attr = light_api.GetDiffuseAttr()) {
184 float diff_fac = 1.0f;
185 if (diff_attr.Get(&diff_fac, motionSampleTime)) {
189 if (pxr::UsdAttribute spec_attr = light_api.GetSpecularAttr()) {
190 float spec_fac = 1.0f;
191 if (spec_attr.Get(&spec_fac, motionSampleTime)) {
200 if (pxr::UsdAttribute normalize_attr = light_api.GetNormalizeAttr()) {
201 normalize_attr.Get(&
normalize, motionSampleTime);
204 blight->
energy *= light_surface_area;