File: spectrum.ih

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 (63 lines) | stat: -rw-r--r-- 1,354 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
62
63
// Copyright 2009 Intel Corporation
// SPDX-License-Identifier: Apache-2.0

#pragma once

#include "math/spectrum.h"
#include "rkcommon/math/vec.ih"

#ifndef OSPRAY_TARGET_SYCL
typedef uniform float<SPECTRUM_SAMPLES> spectrum;
#endif

OSPRAY_BEGIN_ISPC_NAMESPACE

#ifdef ISPC
extern spectrum spectrum_sRGB_r;
extern spectrum spectrum_sRGB_g;
extern spectrum spectrum_sRGB_b;
#endif

inline uniform vec3f spectrum_sRGB(const uniform int l)
{
#ifdef OSPRAY_TARGET_SYCL
  const spectrum spectrum_sRGB_r = {0.0598548f,
      -0.0234574f,
      -0.220138f,
      -0.238902f,
      0.316327f,
      0.738315f,
      0.323302f,
      0.0446981f};

  const spectrum spectrum_sRGB_g = {-0.0567346f,
      -0.0160361f,
      0.223861f,
      0.531185f,
      0.337221f,
      0.0149718f,
      -0.0296053f,
      -0.00486239f};

  const spectrum spectrum_sRGB_b = {0.420693f,
      0.616597f,
      0.0796766f,
      -0.0496266f,
      -0.0473149f,
      -0.0167536f,
      -0.00295686f,
      -0.000314818f};
#endif
  return make_vec3f(spectrum_sRGB_r[l], spectrum_sRGB_g[l], spectrum_sRGB_b[l]);
}

// note: result can be <0 or >1
inline uniform vec3f spectrum2rgb(const spectrum &s)
{
  uniform vec3f rgb = make_vec3f(0.f);
  for (uniform int l = 0; l < SPECTRUM_SAMPLES; l++)
    rgb = rgb + s[l] * spectrum_sRGB(l);

  return rgb;
}
OSPRAY_END_ISPC_NAMESPACE