Fermat
renderer_view.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 <framebuffer.h>
32 #include <texture.h>
33 #include <camera.h>
34 #include <ray.h>
35 #include <lights.h>
36 #include <mesh_lights.h>
37 #include <mesh/MeshStorage.h>
38 
41 
42 //#define SHADOW_BIAS 0.0f
43 //#define SHADOW_TMIN 1.0e-4f
44 #define SHADOW_BIAS 1.0e-4f
45 #define SHADOW_TMIN 0.0f
46 
47 enum RendererType
48 {
49  kPT = 0,
50  kBPT = 1,
51  kCMLT = 2,
52  kMLT = 3,
53  kPSSMLT = 4,
54  kRPT = 5,
55  kPSFPT = 6,
56  kRLPT = 7,
57  kTRPT = 8,
58  kGamePT = 9,
59  kUserRenderer = 10,
60 };
61 
62 enum ShadingMode {
63  kShaded = 0,
64  kUV = 1,
65  kUVStretch = 2,
66  kCharts = 3,
67  kAlbedo = 4,
68  kDiffuseAlbedo = 5,
69  kSpecularAlbedo = 6,
70  kDiffuseColor = 7,
71  kSpecularColor = 8,
72  kDirectLighting = 9,
73  kFiltered = 10,
74  kVariance = 11,
75  kNormal = 12,
76  kAux0 = 13,
77 };
78 
79 
81 {
82  FERMAT_HOST_DEVICE RenderingContextView() {}
83 #if !defined(OPTIX_COMPILATION)
84  FERMAT_HOST_DEVICE RenderingContextView(
85  Camera _camera,
86  const uint32 _dir_lights_count,
87  const DirectionalLight* _dir_lights,
88  MeshView _mesh,
89  MeshLight _mesh_light,
90  MeshLight _mesh_vpls,
91  const MipMapView* _textures,
92  const uint32 _ltc_size,
93  const float4* _ltc_M,
94  const float4* _ltc_Minv,
95  const float* _ltc_A,
96  const float* _glossy_reflectance,
97  const uint32_t _x,
98  const uint32_t _y,
99  const float _aspect,
100  const float _exposure,
101  const float _gamma,
102  const float _shading_rate,
103  const ShadingMode _shading_mode,
104  const FBufferView _fb,
105  const uint32 _instance)
106  : camera(_camera), camera_sampler(_camera, _aspect), dir_lights_count(_dir_lights_count), dir_lights(_dir_lights), mesh(_mesh), mesh_light(_mesh_light), mesh_vpls(_mesh_vpls), textures(_textures), ltc_M(_ltc_M), ltc_Minv(_ltc_Minv), ltc_A(_ltc_A), ltc_size(_ltc_size), glossy_reflectance(_glossy_reflectance), res_x(_x), res_y(_y), aspect(_aspect), exposure(_exposure), gamma(_gamma), shading_rate(_shading_rate), shading_mode(_shading_mode), fb(_fb), instance(_instance) {}
107 #endif
108 
109  Camera camera;
110  CameraSampler camera_sampler;
111  uint32_t dir_lights_count;
112  const DirectionalLight* dir_lights;
113  MeshView mesh;
114  MeshLight mesh_light;
115  MeshLight mesh_vpls;
116  const MipMapView* textures;
117  const float4* ltc_M;
118  const float4* ltc_Minv;
119  const float* ltc_A;
120  uint32 ltc_size;
121  const float* glossy_reflectance;
122  uint32_t res_x;
123  uint32_t res_y;
124  float aspect;
125  float exposure;
126  float gamma;
127  float shading_rate;
128  ShadingMode shading_mode;
129  FBufferView fb;
130  uint32 instance;
131 };
132 
134 {
135  static const uint32_t DIFFUSE_C = 0;
136  static const uint32_t DIFFUSE_A = 1;
137  static const uint32_t SPECULAR_C = 2;
138  static const uint32_t SPECULAR_A = 3;
139  static const uint32_t DIRECT_C = 4;
140  static const uint32_t COMPOSITED_C = 5;
141  static const uint32_t FILTERED_C = 6;
142  static const uint32_t LUMINANCE = 7;
143  static const uint32_t VARIANCE = 7;
144  static const uint32_t NUM_CHANNELS = 8;
145 };
146 
Definition: lights.h:299
Definition: lights.h:249
Definition: framebuffer.h:274
Definition: renderer_view.h:133
Definition: camera.h:256
Definition: camera.h:46
Definition: MeshView.h:96
Definition: texture_view.h:73
Definition: renderer_view.h:80