File: sampling.h

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 (27 lines) | stat: -rw-r--r-- 776 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
// Copyright 2021 Intel Corporation
// SPDX-License-Identifier: Apache-2.0

#pragma once

// utility library containing sampling functions

// convention is to return the sample (vec3f) generated from given vec2f
// 's'ample as last parameter sampling functions often come in pairs: sample and
// pdf (needed later for MIS) good reference is "Total Compendium" by Philip
// Dutre http://people.cs.kuleuven.be/~philip.dutre/GI/

#include "rkcommon/math/rkmath.h"

namespace ospray {

inline float uniformSampleConePDF(const float cosAngle)
{
  return rcp(float(two_pi) * (1.0f - cosAngle));
}

inline float uniformSampleRingPDF(const float radius, const float innerRadius)
{
  return rcp(float(pi) * ((radius * radius) - (innerRadius * innerRadius)));
}

} // namespace ospray