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

// camera.ih Defines the abstract base class of an ISPC-side camera

#pragma once

#include "common/Ray.ih"
#include "common/RayCone.ih"
#include "rkcommon/math/box.ih"
// c++ shared
#include "CameraShared.h"

OSPRAY_BEGIN_ISPC_NAMESPACE

struct FeatureFlagsHandler;

// Specifies the input parameters (time, screen, and lens
// samples) required for 'initRay' to generate a primary ray
struct CameraSample
{
  vec2f screen; // normalized screen sample, in [0..1]
  vec2f lens;
  float time;
  vec2f pixel_center;
};

inline vec2f Camera_subRegion(const Camera *uniform self, const vec2f &screen)
{
  return lerp(screen, self->subImage.lower, self->subImage.upper);
}

inline float Camera_shutterTime(
    const Camera *uniform self, const vec2f &screen, float time)
{
  if (self->globalShutter)
    return lerp(time, self->shutter.lower, self->shutter.upper);

  time *= self->rollingShutterDuration;
  const float pos = self->rollingShutterHorizontal ? screen.x : screen.y;
  return clamp(time + lerp(pos, self->shutter.lower, self->shutter.upper));
}

OSPRAY_END_ISPC_NAMESPACE