24 #if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_PANDASPEEDTREE)
25 #error Buildsystem error: BUILDING_PANDASPEEDTREE not defined
28 ConfigureDef(config_speedtree);
29 NotifyCategoryDef(speedtree,
"");
31 ConfigureFn(config_speedtree) {
36 (
"speedtree-license",
"",
37 PRC_DESC(
"Specify the license string to pass to SpeedTreeNode::authorize() by default."));
42 PRC_DESC(
"Specifies the directory in which to locate SpeedTree's system "
43 "shaders at runtime. If this is empty, the default is based on "
44 "SPEEDTREE_BIN_DIR, as provided at compile time."));
48 (
"speedtree-textures-dir",
"",
49 PRC_DESC(
"Specifies the directory in which to locate textures referenced "
50 "by SRT files at runtime. The default is to search in the same "
51 "directory as the SRT file itself. Unfortunately, the model-path "
52 "cannot be searched, because SpeedTree only provides a single "
53 "directory option."));
56 (
"speedtree-max-anisotropy", 0.0,
57 PRC_DESC(
"Specifies the maximum anisotropy for SpeedTree textures."));
60 (
"speedtree-horizontal-billboards",
true,
61 PRC_DESC(
"Set this true to allow the use of horizontal billboards in "
62 "SpeedTree, or false to disallow them. Horizontal billboards "
63 "may be defined for some trees to provide a billboard LOD "
64 "when the tree is seen from above."));
67 (
"speedtree-alpha-test-scalar", 0.57,
68 PRC_DESC(
"Undocumented speedtree config."));
71 (
"speedtree-z-pre-pass",
false,
72 PRC_DESC(
"True if the SpeedTree renderer should perform a first pass "
73 "to fill the depth buffer before going back to draw pixels. "
74 "This can result in a cost savings if there is much overdraw and "
75 "if the pixel shader is particularly expensive, but in most cases "
76 "it will result in a cost penalty."));
79 (
"speedtree-max-billboard-images-by-base", 20,
80 PRC_DESC(
"Specifies the maximum number of billboard images used by any single "
84 (
"speedtree-visibility", 1000.0,
85 PRC_DESC(
"Undocumented SpeedTree parameter."));
88 (
"speedtree-global-light-scalar", 1.0,
89 PRC_DESC(
"Undocumented SpeedTree parameter."));
92 (
"speedtree-specular-lighting",
false,
93 PRC_DESC(
"True to enable specular lighting effects in SpeedTree."));
96 (
"speedtree-transmission-lighting",
false,
97 PRC_DESC(
"True to enable transmission lighting effects in SpeedTree."));
100 (
"speedtree-detail-layer",
false,
101 PRC_DESC(
"True to render the detail texture layer defined on tree and "
102 "terrain objects, false otherwise."));
105 (
"speedtree-detail-normal-mapping",
false,
106 PRC_DESC(
"True to render the detail normal maps defined on tree and "
107 "terrain objects, false otherwise."));
110 (
"speedtree-ambient-contrast",
false,
111 PRC_DESC(
"Undocumented SpeedTree parameter."));
114 (
"speedtree-transmission-scalar", 1.0f,
115 PRC_DESC(
"Undocumented SpeedTree parameter."));
118 (
"speedtree-fog-distance",
"2500 5000",
119 PRC_DESC(
"Specifies the nearest and farthest distance of the fog on trees "
123 (
"speedtree-fog-color",
"1.0 1.0 1.0",
124 PRC_DESC(
"Specifies the r g b color of SpeedTree fog."));
127 (
"speedtree-sky-color",
"0.2 0.3 0.5",
128 PRC_DESC(
"Specifies the r g b color of the SpeedTree sky, when the sky "
129 "is enabled. Currently unused."));
132 (
"speedtree-sky-fog",
"-0.5 1.0",
133 PRC_DESC(
"Specifies the range of fog in the sky. -1 is down, 1 is up."));
136 (
"speedtree-sun-color",
"1.0 1.0 0.85",
137 PRC_DESC(
"Specifies the r g b color of the SpeedTree sun, when the sun "
138 "is enabled. Currently unused."));
141 (
"speedtree-sun-size", 0.001,
142 PRC_DESC(
"Undocumented SpeedTree parameter."));
145 (
"speedtree-sun-spread-exponent", 200.0,
146 PRC_DESC(
"Undocumented SpeedTree parameter."));
149 (
"speedtree-sun-fog-bloom", 0.0,
150 PRC_DESC(
"Undocumented SpeedTree parameter."));
153 (
"speedtree-specular-color",
"1 1 1",
154 PRC_DESC(
"Specifies the r g b color of the specular reflections on SpeedTree "
158 (
"speedtree-emissive-color",
"0 0 0",
159 PRC_DESC(
"Specifies the r g b color of the emissive light effect on SpeedTree "
163 (
"speedtree-shadow-map-resolution", 0,
164 PRC_DESC(
"Specifies the resolution for rendering shadow maps. Should "
165 "be a power of 2. Specify 0 to disable shadowing in SpeedTree."));
168 (
"speedtree-cascading-shadow-splits",
"200 400 600",
169 PRC_DESC(
"Specifies the shadow split distance, in spatial units, for "
170 "each shadow map to be rendered. The number of values also "
171 "implies the number of shadow maps, to a maximum value compiled "
172 "within SpeedTree (typically 4)."));
175 (
"speedtree-smooth-shadows",
false,
176 PRC_DESC(
"True to enable a smoothing pass on the shadow maps."));
179 (
"speedtree-show-shadow-splits-on-terrain",
false,
180 PRC_DESC(
"Currently unsupported."));
183 (
"speedtree-wind-enabled",
true,
184 PRC_DESC(
"True to enable global wind in the SpeedTree world."));
187 (
"speedtree-frond-rippling",
true,
188 PRC_DESC(
"True to allow fronds to respond to the global wind."));
191 (
"speedtree-terrain-num-lods", 5,
192 PRC_DESC(
"Specifies the number of different LOD stages to use in "
193 "rendering terrain. Each stage has 75% few polygons than the "
194 "stage before. Increasing this number decreases the total "
195 "number of polygons onscreen, at the cost of visual quality of "
196 "distant terrain."));
199 (
"speedtree-terrain-resolution", 33,
200 PRC_DESC(
"Specifies the number of vertices per edge of each terrain grid "
201 "cell at the highest LOD. This must be a power of two plus 1."));
204 (
"speedtree-terrain-cell-size", 800,
205 PRC_DESC(
"Specifies the size in spatial units of one edge of a terrain "
206 "grid cell. This effects culling and resolution, but has nothing "
207 "to do with the scale of the heightmap or other maps."));
210 (
"speedtree-shadow-fade", 0.25,
211 PRC_DESC(
"Specifies the rate at which shadows fade to transparency in the "
215 (
"speedtree-show-overlays",
false,
216 PRC_DESC(
"True to draw onscreen overlays showing the generated "
220 (
"speedtree-max-num-visible-cells", 75,
221 PRC_DESC(
"Specifies the maximum number of cells in a single SpeedTree forest "
222 "frustum. This is used internally by SpeedTree's billboard system."));
225 (
"speedtree-cull-cell-size", 1200,
226 PRC_DESC(
"Specifies the size of a single SpeedTree cull cell, in Panda "
227 "units. Increasing this number decreases the number of "
228 "individual calls that must be made to render geometry, "
229 "while increasing the number of trees that are rendered "
233 (
"speedtree-area-scale", 3280.839895013,
234 PRC_DESC(
"This is the factor by which the \"area\" value in a SpeedTree "
235 "terrain.txt file is scaled (after taking its square root) "
236 "when loading a new terrain. The default is about 3281, which "
237 "scales from kilometers to feet. You should set a different "
238 "scale if you use units other than feet."));
241 (
"speedtree-follow-terrain",
true,
242 PRC_DESC(
"Set this true to have trees automatically snap to the terrain "
243 "height when loaded into a SpeedTree node with a configured "
244 "terrain. If this is false, you may still call "
245 "SpeedTreeNode::snap_to_terrain() afterwards."));
248 (
"speedtree-max-random-try-count", 1000,
249 PRC_DESC(
"This is a cheesy limit to detect bad parameters passed to "
250 "SpeedTreeNode::add_random_instances(). If this number of attempts "
251 "to find a legal place for a tree fail in a row, the parameters "
252 "are deemed to be in error, and the function fails."));
255 (
"speedtree-5-2-stf",
256 #
if SPEEDTREE_VERSION_MAJOR > 5 || (SPEEDTREE_VERSION_MAJOR == 5 && SPEEDTREE_VERSION_MINOR >= 2)
261 PRC_DESC(
"The format of the STF file changed in SpeedTree version 5.2. "
262 "Specify true here to read STF files in the new file format, or "
263 "false to read STF files in the pre-5.2 file format."));
274 static bool initialized =
false;
280 SpeedTreeNode::init_type();
281 STBasicTerrain::init_type();
282 STTerrain::init_type();
284 LoaderFileTypeSrt::init_type();
285 LoaderFileTypeStf::init_type();
296 class STCustomAllocator :
public SpeedTree::CAllocator {
298 void *Alloc(
size_t block_size) {
299 return PANDA_MALLOC_ARRAY(block_size);
302 void Free(
void *block) {
303 if (block !=
nullptr) {
304 PANDA_FREE_ARRAY(block);
311 static STCustomAllocator custom_allocator;
312 static SpeedTree::CAllocatorInterface allocator_interface(&custom_allocator);