Fermat
renderer.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 <buffers.h>
32 #include <framebuffer.h>
33 #include <texture.h>
34 #include <camera.h>
35 #include <ray.h>
36 #include <lights.h>
37 #include <mesh_lights.h>
38 #include <mesh/MeshStorage.h>
39 #include <vector>
40 #include <renderer_view.h>
41 #include <renderer_interface.h>
42 #include <tiled_sequence.h>
43 
46 
47 struct RTContext;
49 
52 struct FERMAT_API RenderingContext
53 {
54  typedef std::shared_ptr< MipMapStorage<HOST_BUFFER> > HostMipMapStoragePtr;
55  typedef std::shared_ptr< MipMapStorage<CUDA_BUFFER> > DeviceMipMapStoragePtr;
56 
60 
63  void init(int argc, char** argv);
64 
68  void render(const uint32 instance);
69 
72  void clear();
73 
76  void multiply_frame(const float scale);
77 
81  void rescale_frame(const uint32 instance);
82 
86  void clamp_frame(const float max_value);
87 
91  void update_variances(const uint32 instance);
92 
95  void update_model();
96 
100  void filter(const uint32 instance);
101 
104  uint2 res() const;
105 
108  RenderingContextView view(const uint32 instance);
109 
112  Camera& get_camera();
113 
116  uint32 get_directional_light_count() const;
117 
120  const DirectionalLight* get_host_directional_lights() const;
121 
124  const DirectionalLight* get_device_directional_lights() const;
125 
128  void set_directional_light_count(const uint32 count);
129 
132  void set_directional_light(const uint32 i, const DirectionalLight& light);
133 
136  uint2 get_res() const;
137 
140  float get_aspect_ratio() const;
141 
144  void set_aspect_ratio(const float v);
145 
148  float get_exposure() const;
149 
152  void set_exposure(const float v);
153 
156  float get_gamma() const;
157 
160  void set_gamma(const float v);
161 
164  ShadingMode& get_shading_mode();
165 
168  FBufferStorage& get_frame_buffer();
169 
172  uint8* get_device_rgba_buffer();
173 
176  uint32 get_texture_count() const;
177 
180  HostMipMapStoragePtr* get_host_textures();
181 
184  DeviceMipMapStoragePtr* get_device_textures();
185 
188  MipMapView* get_host_texture_views();
189 
192  MipMapView* get_device_texture_views();
193 
196  MeshStorage& get_host_mesh();
197 
200  DeviceMeshStorage& get_device_mesh();
201 
204  MeshLightsStorage& get_mesh_lights();
205 
208  RTContext* get_rt_context() const;
209 
212  RendererInterface* get_renderer() const;
213 
216  TiledSequence& get_sequence();
217 
220  uint32 register_renderer(const char* name, RendererFactoryFunction factory);
221 
224  cugar::Bbox3f compute_bbox();
225 
226 private:
227  RenderingContextImpl* m_impl;
228 };
229 
Definition: lights.h:249
Definition: framebuffer.h:295
Definition: renderer_impl.h:53
Definition: rt.h:55
Definition: mesh_lights.h:35
Definition: MeshStorage.h:44
Definition: tiled_sequence.h:131
Definition: camera.h:46
Definition: renderer_interface.h:45
Definition: renderer.h:52
Definition: texture_view.h:73
Definition: renderer_view.h:80
CUGAR_HOST_DEVICE Matrix< T, 4, 4 > scale(const Vector< T, 3 > &vec)
build a 3d scaling matrix
Definition: matrix_inline.h:539
Definition: MeshStorage.h:273