Fermat
mesh_lights_impl.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 <lights.h>
32 #include <mesh/MeshStorage.h>
33 #include <cugar/basic/vector.h>
35 #include <cugar/bvh/bvh_node.h>
36 #include <uv_bvh.h>
37 #include <vtl_mesh_view.h>
38 
39 struct RenderingContext;
40 
42 {
44 
45  void init(const uint32 n_vpls, MeshView h_mesh, MeshView d_mesh, const MipMapView* h_textures, const MipMapView* d_textures, const uint32 instance = 0);
46  void init(const uint32 n_vpls, RenderingContext& renderer, const uint32 instance = 0);
47 
48  MeshLight view(const bool use_vpls) const
49  {
50  if (use_vpls)
51  return MeshLight(uint32(mesh_cdf.size()), cugar::raw_pointer(mesh_cdf), cugar::raw_pointer(mesh_inv_area), mesh, textures, uint32(vpls.size()), cugar::raw_pointer(vpl_cdf), cugar::raw_pointer(vpls), normalization_coeff);
52  else
53  return MeshLight(uint32(mesh_cdf.size()), cugar::raw_pointer(mesh_cdf), cugar::raw_pointer(mesh_inv_area), mesh, textures, 0, 0, NULL, normalization_coeff);
54  }
55 
56  uint32 get_bvh_nodes_count() const { return uint32(bvh_nodes.size()); }
57  uint32 get_bvh_clusters_count() const { return uint32(bvh_clusters.size()); }
58  const cugar::Bvh_node_3d* get_bvh_nodes() const { return cugar::raw_pointer(bvh_nodes); }
59  const uint32* get_bvh_parents() const { return cugar::raw_pointer(bvh_parents); }
60  const uint2* get_bvh_ranges() const { return cugar::raw_pointer(bvh_ranges); }
61  const uint32* get_bvh_clusters() const { return cugar::raw_pointer(bvh_clusters); }
62  const uint32* get_bvh_cluster_offsets() const { return cugar::raw_pointer(bvh_cluster_offsets); }
63 
66  MeshView mesh;
67  const MipMapView* textures;
70  float normalization_coeff;
71 
77  cugar::vector<cugar::device_tag, uint32> bvh_cluster_offsets;
78 };
79 
81 {
83 
84  void init(const uint32 n_vpls, MeshView h_mesh, MeshView d_mesh, const MipMapView* h_textures, const MipMapView* d_textures, const uint32 instance = 0);
85  void init(const uint32 n_vpls, RenderingContext& renderer, const uint32 instance = 0);
86 
87  VTLMeshView view() const
88  {
89  return VTLMeshView(
90  uint32( vtls.size() ),
91  cugar::raw_pointer( vtls ),
92  uvbvh.view(),
93  mesh,
94  textures );
95  }
96 
97  uint32 get_bvh_nodes_count() const { return uint32(bvh_nodes.size()); }
98  uint32 get_bvh_clusters_count() const { return uint32(bvh_clusters.size()); }
99  const cugar::Bvh_node_3d* get_bvh_nodes() const { return cugar::raw_pointer(bvh_nodes); }
100  const uint32* get_bvh_parents() const { return cugar::raw_pointer(bvh_parents); }
101  const uint2* get_bvh_ranges() const { return cugar::raw_pointer(bvh_ranges); }
102  const uint32* get_bvh_clusters() const { return cugar::raw_pointer(bvh_clusters); }
103  const uint32* get_bvh_cluster_offsets() const { return cugar::raw_pointer(bvh_cluster_offsets); }
104 
105  MeshView mesh;
106  const MipMapView* textures;
107 
109  float normalization_coeff;
110 
111  DeviceUVBvh uvbvh;
112 
117  cugar::vector<cugar::device_tag, uint32> bvh_cluster_offsets;
118 };
Entry point to the generic Bounding Volume Hierarchy library.
Definition: bvh_node.h:80
Definition: lights.h:299
T * raw_pointer(thrust::device_vector< T, Alloc > &vec)
Definition: thrust_view.h:69
Defines various spherical mappings.
Definition: mesh_lights_impl.h:41
Definition: vtl_mesh_view.h:40
Definition: MeshView.h:96
Definition: renderer.h:52
Definition: texture_view.h:73
Definition: mesh_lights_impl.h:80