File: Subdivision.ispc

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

// ospray
#include "Geometry.ih"
#include "common/Data.ih"
// c++ shared
#include "SubdivisionShared.h"

OSPRAY_BEGIN_ISPC_NAMESPACE

void Subdivision_postIntersect(const Geometry *uniform _self,
    varying DifferentialGeometry &dg,
    const varying Ray &ray,
    uniform int64 flags)
{
  Subdivision *uniform self = (Subdivision * uniform) _self;
  dg.Ng = dg.Ns = ray.Ng;

  flags &= self->flagMask;

  if (flags & DG_NS) {
    vec3f dPdu, dPdv;
    rtcInterpolateV1(self->geom,
        ray.primID,
        ray.u,
        ray.v,
        RTC_BUFFER_TYPE_VERTEX,
        0,
        NULL,
        &dPdu.x,
        &dPdv.x,
        3);
    dg.Ns = cross(dPdu, dPdv);
  }

  if (flags & DG_COLOR) {
    rtcInterpolateV0(self->geom,
        ray.primID,
        ray.u,
        ray.v,
        RTC_BUFFER_TYPE_VERTEX_ATTRIBUTE,
        0,
        &dg.color.x,
        4);
  }

  if (flags & DG_TEXCOORD) {
    rtcInterpolateV0(self->geom,
        ray.primID,
        ray.u,
        ray.v,
        RTC_BUFFER_TYPE_VERTEX_ATTRIBUTE,
        1,
        &dg.st.x,
        2);
  }
}

export void *uniform Subdivision_postIntersect_addr()
{
  return (void *uniform)Subdivision_postIntersect;
}

OSPRAY_END_ISPC_NAMESPACE