1 
2 //
3 // This source file is part of appleseed.
4 // Visit https://appleseedhq.net/ for additional information and resources.
5 //
6 // This software is released under the MIT license.
7 //
8 // Copyright (c) 2010-2013 Francois Beaune, Jupiter Jazz Limited
9 // Copyright (c) 2014-2018 Francois Beaune, The appleseedhq Organization
10 //
11 // Permission is hereby granted, free of charge, to any person obtaining a copy
12 // of this software and associated documentation files (the "Software"), to deal
13 // in the Software without restriction, including without limitation the rights
14 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15 // copies of the Software, and to permit persons to whom the Software is
16 // furnished to do so, subject to the following conditions:
17 //
18 // The above copyright notice and this permission notice shall be included in
19 // all copies or substantial portions of the Software.
20 //
21 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
27 // THE SOFTWARE.
28 //
29 
30 #pragma once
31 
32 // appleseed.renderer headers.
33 #include "renderer/global/globaltypes.h"
34 
35 // appleseed.foundation headers.
36 #include "foundation/math/beziercurve.h"
37 #include "foundation/math/intersection/raytrianglemt.h"
38 #include "foundation/math/matrix.h"
39 
40 // Standard headers.
41 #include <cstddef>
42 
43 namespace renderer
44 {
45 
46 //
47 // Assembly tree settings.
48 //
49 
50 // Maximum number of assemblies per leaf.
51 const size_t AssemblyTreeMaxLeafSize = 1;
52 
53 // Relative cost of traversing an interior node.
54 const double AssemblyTreeInteriorNodeTraversalCost = 1.0;
55 
56 // Relative cost of intersecting an assembly.
57 const double AssemblyTreeTriangleIntersectionCost = 10.0;
58 
59 
60 //
61 // Triangle tree settings.
62 //
63 
64 // Triangle format used for storage.
65 typedef foundation::TriangleMT<GScalar> GTriangleType;
66 
67 // Triangle format used for intersection.
68 typedef foundation::TriangleMT<double> TriangleType;
69 typedef foundation::TriangleMTSupportPlane<double> TriangleSupportPlaneType;
70 
71 // Maximum number of triangles per leaf.
72 const size_t TriangleTreeDefaultMaxLeafSize = 2;
73 
74 // Relative cost of traversing an interior node.
75 const GScalar TriangleTreeDefaultInteriorNodeTraversalCost(1.0);
76 
77 // Relative cost of intersecting a triangle.
78 const GScalar TriangleTreeDefaultTriangleIntersectionCost(1.0);
79 
80 // Number of bins used during SBVH construction.
81 const size_t TriangleTreeDefaultBinCount = 256;
82 
83 // Define this symbol to enable reordering the nodes of triangle trees for better
84 // locality of reference. Requires a lot of temporary memory for minimal results.
85 #undef RENDERER_TRIANGLE_TREE_REORDER_NODES
86 
87 // Depth of a subtree in the van Emde Boas node layout.
88 const size_t TriangleTreeSubtreeDepth = 3;
89 
90 // Size of the triangle tree access cache.
91 const size_t TriangleTreeAccessCacheLines = 128;
92 const size_t TriangleTreeAccessCacheWays = 2;
93 
94 // Size of the stack (in number of nodes) used during traversal.
95 const size_t TriangleTreeStackSize = 64;
96 
97 
98 //
99 // Curve tree settings.
100 //
101 
102 // Curve formats used for storage and intersection.
103 typedef foundation::BezierCurve1<GScalar> Curve1Type;
104 typedef foundation::BezierCurve3<GScalar> Curve3Type;
105 
106 // Curve intersectors.
107 typedef foundation::BezierCurveIntersector<Curve1Type> Curve1IntersectorType;
108 typedef foundation::BezierCurveIntersector<Curve3Type> Curve3IntersectorType;
109 
110 // Matrix used in curve intersections
111 typedef foundation::Matrix<GScalar, 4, 4> CurveMatrixType;
112 
113 // Maximum number of curves per leaf.
114 const size_t CurveTreeDefaultMaxLeafSize = 1;
115 
116 // Relative cost of traversing an interior node.
117 const GScalar CurveTreeDefaultInteriorNodeTraversalCost(1.0);
118 
119 // Relative cost of intersecting a curve.
120 const GScalar CurveTreeDefaultCurveIntersectionCost(1.0);
121 
122 // Size of the curve tree access cache.
123 const size_t CurveTreeAccessCacheLines = 128;
124 const size_t CurveTreeAccessCacheWays = 2;
125 
126 // Size of the stack (in number of nodes) used during traversal.
127 const size_t CurveTreeStackSize = 64;
128 
129 
130 //
131 // Embree settings.
132 //
133 
134 #ifdef APPLESEED_WITH_EMBREE
135 
136 // Size of the EmbreeScene access cache.
137 const size_t EmbreeSceneAccessCacheLines = 128;
138 const size_t EmbreeSceneAccessCacheWays = 2;
139 
140 #endif
141 
142 //
143 // Miscellaneous settings.
144 //
145 
146 // If defined, an adaptive procedure is used to offset intersection points.
147 // If left undefined, a fixed, constant-time procedure is used. The adaptive
148 // procedure handles degenerate cases better but is slightly slower. It must
149 // be used when the triangle model is set to Moller-Trumbore (MT).
150 #define RENDERER_ADAPTIVE_OFFSET
151 
152 }   // namespace renderer
153