File: AmbientLight.cpp

package info (click to toggle)
ospray 3.2.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 10,048 kB
  • sloc: cpp: 80,569; ansic: 951; sh: 805; makefile: 170; python: 69
file content (61 lines) | stat: -rw-r--r-- 1,646 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// Copyright 2009 Intel Corporation
// SPDX-License-Identifier: Apache-2.0

#include "AmbientLight.h"
#include "common/StructShared.h"
#ifndef OSPRAY_TARGET_SYCL
#include "lights/AmbientLight_ispc.h"
#else
namespace ispc {
void *AmbientLight_sample_addr();
void *AmbientLight_eval_addr();
} // namespace ispc
#endif
// ispc shared
#include "AmbientLightShared.h"

namespace ospray {

ispc::Light *AmbientLight::createSh(
    uint32_t, const ispc::Instance *instance) const
{
  ispc::AmbientLight *sh =
      StructSharedCreate<ispc::AmbientLight>(getISPCDevice().getDRTDevice());
#ifndef OSPRAY_TARGET_SYCL
  sh->super.sample = reinterpret_cast<ispc::Light_SampleFunc>(
      ispc::AmbientLight_sample_addr());
  sh->super.eval =
      reinterpret_cast<ispc::Light_EvalFunc>(ispc::AmbientLight_eval_addr());
#endif
  sh->super.isVisible = visible;
  sh->super.instance = instance;
  sh->radiance = radiance;
  return &sh->super;
}

std::string AmbientLight::toString() const
{
  return "ospray::AmbientLight";
}

void AmbientLight::commit()
{
  Light::commit();
  queryIntensityQuantityType(OSP_INTENSITY_QUANTITY_RADIANCE);
  processIntensityQuantityType();
}

void AmbientLight::processIntensityQuantityType()
{
  // validate the correctness of the light quantity type
  if (intensityQuantity == OSP_INTENSITY_QUANTITY_IRRADIANCE) {
    radiance = coloredIntensity / M_PI;
  } else if (intensityQuantity == OSP_INTENSITY_QUANTITY_RADIANCE) {
    radiance = coloredIntensity;
  } else {
    postStatusMsg(OSP_LOG_WARNING)
        << toString() << " unsupported 'intensityQuantity' value";
    radiance = vec3f(0.0f);
  }
}
} // namespace ospray