File: Scale.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 (79 lines) | stat: -rw-r--r-- 1,820 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
// Copyright 2009 Intel Corporation
// SPDX-License-Identifier: Apache-2.0

#pragma once

#include "BSDF.ih"

OSPRAY_BEGIN_ISPC_NAMESPACE

struct Scale
{
  BSDF super;

  const varying BSDF *uniform base;
  float factor;
};

inline BSDF_EvalRes Scale_eval(const varying BSDF *uniform super,
    const vec3f &wo,
    const vec3f &wi,
    const uniform FeatureFlagsHandler &ffh)
{
  const varying Scale *uniform self = (const varying Scale *uniform)super;

  BSDF_EvalRes res = BSDF_dispatch_eval_base(self->base, wo, wi, ffh);
  res.value = res.value * self->factor;

  return res;
}

inline BSDF_SampleRes Scale_sample(const varying BSDF *uniform super,
    const vec3f &wo,
    const vec2f &s,
    float ss,
    const uniform FeatureFlagsHandler &ffh)
{
  const varying Scale *uniform self = (const varying Scale *uniform)super;

  BSDF_SampleRes res = BSDF_dispatch_sample_base(self->base, wo, s, ss, ffh);
  res.weight = res.weight * self->factor;

  return res;
}

inline void Scale_Constructor(varying Scale *uniform self,
    const varying linear3f *uniform frame,
    const varying BSDF *uniform base,
    float factor)
{
  BSDF_Constructor(&self->super,
      base->albedo * factor,
      base->bsdfType,
      BSDF_TYPE_SCALE,
#ifdef OSPRAY_TARGET_SYCL
      NULL,
      NULL,
#else
      Scale_eval,
      Scale_sample,
#endif
      frame);
  self->base = base;
  self->factor = factor;
}

inline varying BSDF *uniform Scale_create(uniform ShadingContext *uniform ctx,
    const varying BSDF *uniform base,
    float factor)
{
  varying Scale *uniform self =
      (varying Scale * uniform) ShadingContext_alloc(ctx, sizeof(Scale));
  Scale_Constructor(self,
      LinearSpace3f_create(ctx, make_LinearSpace3f_varying_identity()),
      base,
      factor);
  return &self->super;
}

OSPRAY_END_ISPC_NAMESPACE