| 20 | namespace ospray { |
| 21 | |
| 22 | ispc::Light *PointLight::createSh( |
| 23 | uint32_t, const ispc::Instance *instance) const |
| 24 | { |
| 25 | ispc::PointLight *sh = |
| 26 | StructSharedCreate<ispc::PointLight>(getISPCDevice().getDRTDevice()); |
| 27 | |
| 28 | sh->super.isVisible = visible; |
| 29 | sh->super.instance = instance; |
| 30 | #ifndef OSPRAY_TARGET_SYCL |
| 31 | sh->super.sample = |
| 32 | reinterpret_cast<ispc::Light_SampleFunc>(ispc::PointLight_sample_addr()); |
| 33 | sh->super.eval = |
| 34 | reinterpret_cast<ispc::Light_EvalFunc>(ispc::PointLight_eval_addr()); |
| 35 | #endif |
| 36 | |
| 37 | sh->radiance = radiance; |
| 38 | sh->intensity = radIntensity; |
| 39 | sh->radius = radius; |
| 40 | sh->pre.position = position; |
| 41 | sh->pre.direction = normalize(direction); |
| 42 | intensityDistribution.setSh(sh->intensityDistribution); |
| 43 | |
| 44 | // Enable dynamic runtime instancing or apply static transformation |
| 45 | if (instance) { |
| 46 | sh->pre.c0 = intensityDistribution.c0; |
| 47 | if (instance->motionBlur) { |
| 48 | #ifndef OSPRAY_TARGET_SYCL |
| 49 | sh->super.sample = reinterpret_cast<ispc::Light_SampleFunc>( |
| 50 | ispc::PointLight_sample_instanced_addr()); |
| 51 | sh->super.eval = reinterpret_cast<ispc::Light_EvalFunc>( |
| 52 | ispc::PointLight_eval_instanced_addr()); |
| 53 | #endif |
| 54 | } else |
| 55 | ispc::PointLight_Transform(sh, instance->xfm, &sh->pre); |
| 56 | } else { |
| 57 | sh->pre.c90 = normalize(cross(intensityDistribution.c0, sh->pre.direction)); |
| 58 | sh->pre.c0 = cross(sh->pre.direction, sh->pre.c90); |
| 59 | } |
| 60 | |
| 61 | return &sh->super; |
| 62 | } |
| 63 | |
| 64 | std::string PointLight::toString() const |
| 65 | { |