Fermat
bpt_context.h
1 /*
2  * Fermat
3  *
4  * Copyright (c) 2016-2019, NVIDIA CORPORATION. All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions are met:
8  * * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * * Redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution.
13  * * Neither the name of the NVIDIA CORPORATION nor the
14  * names of its contributors may be used to endorse or promote products
15  * derived from this software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20  * DISCLAIMED. IN NO EVENT SHALL NVIDIA CORPORATION BE LIABLE FOR ANY
21  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  */
28 
29 #pragma once
30 
31 #include <vertex_storage.h>
32 #include <cugar/linalg/vector.h>
33 #include <camera.h>
34 #include <ray_queues.h>
35 #include <bpt_queues.h>
36 
39 
42 
53 template <typename TBPTOptions>
55 {
56  BPTContextBase() :
57  in_bounce(0) {}
58 
60  const RenderingContextView& _renderer,
61  const VertexStorageView& _light_vertices,
62  const BPTQueuesView& _queues,
63  const TBPTOptions _options = TBPTOptions()) :
64  in_bounce(0),
65  light_vertices(_light_vertices),
66  in_queue(_queues.in_queue),
67  shadow_queue(_queues.shadow_queue),
68  scatter_queue(_queues.scatter_queue),
69  options(_options)
70  {
71  set_camera(_renderer.camera, _renderer.res_x, _renderer.res_y, _renderer.aspect);
72  }
73 
74  // precompute some camera-related quantities
75  void set_camera(const Camera& camera, const uint32 res_x, const uint32 res_y, const float aspect_ratio)
76  {
77  camera_frame(camera, aspect_ratio, camera_U, camera_V, camera_W);
78 
79  camera_W_len = cugar::length(camera_W);
80 
81  //camera_square_focal_length = camera.square_pixel_focal_length(res_x, res_y);
82  camera_square_focal_length = camera.square_screen_focal_length();
83  }
84 
85  uint32 in_bounce;
86  RayQueue in_queue;
87  RayQueue shadow_queue;
88  RayQueue scatter_queue;
89 
90  VertexStorageView light_vertices;
91 
92  cugar::Vector3f camera_U;
93  cugar::Vector3f camera_V;
94  cugar::Vector3f camera_W;
95  float camera_W_len;
96  float camera_square_focal_length;
97 
98  TBPTOptions options;
99 };
101 
Definition: bpt_queues.h:42
Definition: ray_queues.h:57
Definition: vertex_storage.h:51
FERMAT_HOST_DEVICE void camera_frame(cugar::Vector3f eye, cugar::Vector3f lookat, cugar::Vector3f up, float hfov, float aspect_ratio, cugar::Vector3f &U, cugar::Vector3f &V, cugar::Vector3f &W)
Definition: camera.h:142
Definition: camera.h:46
Definition: bpt_context.h:54
Definition: renderer_view.h:80
CUGAR_FORCEINLINE CUGAR_HOST_DEVICE uint32 length(const vector_view< Iterator > &vec)
Definition: vector_view.h:228