File: MaterialDispatch.ispc

package info (click to toggle)
ospray 3.2.0-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 10,040 kB
  • sloc: cpp: 80,569; ansic: 951; sh: 805; makefile: 171; python: 69
file content (155 lines) | stat: -rw-r--r-- 6,096 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
// Copyright 2022 Intel Corporation
// SPDX-License-Identifier: Apache-2.0

#include "Material.ih"
#include "MaterialDispatch.ih"

#include "common/FeatureFlagsEnum.h"
#include "render/materials/Alloy.ih"
#include "render/materials/CarPaint.ih"
#include "render/materials/Glass.ih"
#include "render/materials/Luminous.ih"
#include "render/materials/Metal.ih"
#include "render/materials/MetallicPaint.ih"
#include "render/materials/Mix.ih"
#include "render/materials/OBJ.ih"
#include "render/materials/Plastic.ih"
#include "render/materials/Principled.ih"
#include "render/materials/ThinGlass.ih"
#include "render/materials/Velvet.ih"

OSPRAY_BEGIN_ISPC_NAMESPACE

SYCL_EXTERNAL __noinline const varying BSDF *uniform Material_dispatch_getBSDF(
    const uniform Material *uniform self,
    uniform ShadingContext *uniform ctx,
    const DifferentialGeometry &dg,
    const Ray &ray,
    const Medium &currentMedium,
    const uniform FeatureFlagsHandler &ffh)
{
  const uniform FeatureFlagsOther ffo = getFeatureFlagsOther(ffh);
  if ((self->type == MATERIAL_TYPE_ALLOY) && (ffo & FFO_MATERIAL_ALLOY)) {
    return Alloy_getBSDF(self, ctx, dg, ray, currentMedium, ffh);
  } else if ((self->type == MATERIAL_TYPE_CARPAINT)
      && (ffo & FFO_MATERIAL_CARPAINT)) {
    return CarPaint_getBSDF(self, ctx, dg, ray, currentMedium, ffh);
  } else if ((self->type == MATERIAL_TYPE_GLASS)
      && (ffo & FFO_MATERIAL_GLASS)) {
    return Glass_getBSDF(self, ctx, dg, ray, currentMedium, ffh);
  } else if ((self->type == MATERIAL_TYPE_LUMINOUS)
      && (ffo & FFO_MATERIAL_LUMINOUS)) {
    return Luminous_getBSDF(self, ctx, dg, ray, currentMedium, ffh);
  } else if ((self->type == MATERIAL_TYPE_METAL)
      && (ffo & FFO_MATERIAL_METAL)) {
    return Metal_getBSDF(self, ctx, dg, ray, currentMedium, ffh);
  } else if ((self->type == MATERIAL_TYPE_METALLICPAINT)
      && (ffo & FFO_MATERIAL_METALLICPAINT)) {
    return MetallicPaint_getBSDF(self, ctx, dg, ray, currentMedium, ffh);
  } else if ((self->type == MATERIAL_TYPE_OBJ) && (ffo & FFO_MATERIAL_OBJ)) {
    return OBJ_getBSDF(self, ctx, dg, ray, currentMedium, ffh);
  } else if ((self->type == MATERIAL_TYPE_PLASTIC)
      && (ffo & FFO_MATERIAL_PLASTIC)) {
    return Plastic_getBSDF(self, ctx, dg, ray, currentMedium, ffh);
  } else if ((self->type == MATERIAL_TYPE_PRINCIPLED)
      && (ffo & FFO_MATERIAL_PRINCIPLED)) {
    return Principled_getBSDF(self, ctx, dg, ray, currentMedium, ffh);
  } else if ((self->type == MATERIAL_TYPE_THINGLASS)
      && (ffo & FFO_MATERIAL_THINGLASS)) {
    return ThinGlass_getBSDF(self, ctx, dg, ray, currentMedium, ffh);
  } else if ((self->type == MATERIAL_TYPE_VELVET)
      && (ffo & FFO_MATERIAL_VELVET)) {
    return Velvet_getBSDF(self, ctx, dg, ray, currentMedium, ffh);
  }
#ifndef OSPRAY_TARGET_SYCL
  else if ((self->type == MATERIAL_TYPE_MIX) && (ffo & FFO_MATERIAL_MIX)) {
    return Mix_getBSDF(self, ctx, dg, ray, currentMedium, ffh);
  } else {
    return self->getBSDF(self, ctx, dg, ray, currentMedium, ffh);
  }
#endif
  return NULL;
}

SYCL_EXTERNAL __noinline vec3f Material_dispatch_getTransparency(
    const uniform Material *uniform self,
    const DifferentialGeometry &dg,
    const Ray &ray,
    const Medium &currentMedium,
    const uniform FeatureFlagsHandler &ffh)
{
  const uniform FeatureFlagsOther ffo = getFeatureFlagsOther(ffh);
  if ((self->type == MATERIAL_TYPE_GLASS) && (ffo & FFO_MATERIAL_GLASS)) {
    return Glass_getTransparency(self, dg, ray, currentMedium, ffh);
  } else if ((self->type == MATERIAL_TYPE_LUMINOUS)
      && (ffo & FFO_MATERIAL_LUMINOUS)) {
    return Luminous_getTransparency(self, dg, ray, currentMedium, ffh);
  } else if ((self->type == MATERIAL_TYPE_OBJ) && (ffo & FFO_MATERIAL_OBJ)) {
    return OBJ_getTransparency(self, dg, ray, currentMedium, ffh);
  } else if ((self->type == MATERIAL_TYPE_PRINCIPLED)
      && (ffo & FFO_MATERIAL_PRINCIPLED)) {
    return Principled_getTransparency(self, dg, ray, currentMedium, ffh);
  } else if ((self->type == MATERIAL_TYPE_THINGLASS)
      && (ffo & FFO_MATERIAL_THINGLASS)) {
    return ThinGlass_getTransparency(self, dg, ray, currentMedium, ffh);
  }
#ifndef OSPRAY_TARGET_SYCL
  else if ((self->type == MATERIAL_TYPE_MIX) && (ffo & FFO_MATERIAL_MIX)) {
    return Mix_getTransparency(self, dg, ray, currentMedium, ffh);
  } else {
    return self->getTransparency(self, dg, ray, currentMedium, ffh);
  }
#else
  else {
    return Material_getTransparency(self, dg, ray, currentMedium, ffh);
  }
#endif
}

SYCL_EXTERNAL __noinline void Material_dispatch_selectNextMedium(
    const uniform Material *uniform self,
    const DifferentialGeometry &dg,
    Medium &currentMedium,
    const uniform FeatureFlagsHandler &ffh)
{
  const uniform FeatureFlagsOther ffo = getFeatureFlagsOther(ffh);
  if ((self->type == MATERIAL_TYPE_GLASS) && (ffo & FFO_MATERIAL_GLASS)) {
    Glass_selectNextMedium(self, dg, currentMedium);
  } else if ((self->type == MATERIAL_TYPE_PRINCIPLED)
      && (ffo & FFO_MATERIAL_PRINCIPLED)) {
    Principled_selectNextMedium(self, dg, currentMedium);
  } else {
#ifndef OSPRAY_TARGET_SYCL
    self->selectNextMedium(self, dg, currentMedium);
#else
    Material_selectNextMedium(self, dg, currentMedium);
#endif
  }
}

SYCL_EXTERNAL __noinline vec3f Material_dispatch_getEmission(
    const Material *uniform self,
    const varying DifferentialGeometry &dg,
    const uniform FeatureFlagsHandler &ffh)
{
  const uniform FeatureFlagsOther ffo = getFeatureFlagsOther(ffh);
  if ((self->type == MATERIAL_TYPE_LUMINOUS) && (ffo & FFO_MATERIAL_LUMINOUS)) {
    return Luminous_getEmission(self, dg, ffh);
  } else if ((self->type == MATERIAL_TYPE_PRINCIPLED)
      && (ffo & FFO_MATERIAL_PRINCIPLED)) {
    return Principled_getEmission(self, dg, ffh);
  }
#ifndef OSPRAY_TARGET_SYCL
  else if ((self->type == MATERIAL_TYPE_MIX) && (ffo & FFO_MATERIAL_MIX)) {
    return Mix_getEmission(self, dg, ffh);
  } else {
    return self->getEmission(self, dg, ffh);
  }
#else
  else {
    return Material_getEmission(self, dg, ffh);
  }
#endif
}

OSPRAY_END_ISPC_NAMESPACE