15 #include "config_speedtree.h" 16 #include "speedTreeNode.h" 17 #include "stBasicTerrain.h" 18 #include "stTerrain.h" 20 #include "loaderFileTypeSrt.h" 21 #include "loaderFileTypeStf.h" 22 #include "loaderFileTypeRegistry.h" 25 ConfigureDef(config_speedtree);
26 NotifyCategoryDef(speedtree,
"");
28 ConfigureFn(config_speedtree) {
33 (
"speedtree-license",
"",
34 PRC_DESC(
"Specify the license string to pass to SpeedTreeNode::authorize() by default."));
39 PRC_DESC(
"Specifies the directory in which to locate SpeedTree's system " 40 "shaders at runtime. If this is empty, the default is based on " 41 "SPEEDTREE_BIN_DIR, as provided at compile time."));
45 (
"speedtree-textures-dir",
"",
46 PRC_DESC(
"Specifies the directory in which to locate textures referenced " 47 "by SRT files at runtime. The default is to search in the same " 48 "directory as the SRT file itself. Unfortunately, the model-path " 49 "cannot be searched, because SpeedTree only provides a single " 50 "directory option."));
53 (
"speedtree-max-anisotropy", 0.0,
54 PRC_DESC(
"Specifies the maximum anisotropy for SpeedTree textures."));
57 (
"speedtree-horizontal-billboards",
true,
58 PRC_DESC(
"Set this true to allow the use of horizontal billboards in " 59 "SpeedTree, or false to disallow them. Horizontal billboards " 60 "may be defined for some trees to provide a billboard LOD " 61 "when the tree is seen from above."));
64 (
"speedtree-alpha-test-scalar", 0.57,
65 PRC_DESC(
"Undocumented speedtree config."));
68 (
"speedtree-z-pre-pass",
false,
69 PRC_DESC(
"True if the SpeedTree renderer should perform a first pass " 70 "to fill the depth buffer before going back to draw pixels. " 71 "This can result in a cost savings if there is much overdraw and " 72 "if the pixel shader is particularly expensive, but in most cases " 73 "it will result in a cost penalty."));
76 (
"speedtree-max-billboard-images-by-base", 20,
77 PRC_DESC(
"Specifies the maximum number of billboard images used by any single " 81 (
"speedtree-visibility", 1000.0,
82 PRC_DESC(
"Undocumented SpeedTree parameter."));
85 (
"speedtree-global-light-scalar", 1.0,
86 PRC_DESC(
"Undocumented SpeedTree parameter."));
89 (
"speedtree-specular-lighting",
false,
90 PRC_DESC(
"True to enable specular lighting effects in SpeedTree."));
93 (
"speedtree-transmission-lighting",
false,
94 PRC_DESC(
"True to enable transmission lighting effects in SpeedTree."));
97 (
"speedtree-detail-layer",
false,
98 PRC_DESC(
"True to render the detail texture layer defined on tree and " 99 "terrain objects, false otherwise."));
102 (
"speedtree-detail-normal-mapping",
false,
103 PRC_DESC(
"True to render the detail normal maps defined on tree and " 104 "terrain objects, false otherwise."));
107 (
"speedtree-ambient-contrast",
false,
108 PRC_DESC(
"Undocumented SpeedTree parameter."));
111 (
"speedtree-transmission-scalar", 1.0f,
112 PRC_DESC(
"Undocumented SpeedTree parameter."));
115 (
"speedtree-fog-distance",
"2500 5000",
116 PRC_DESC(
"Specifies the nearest and farthest distance of the fog on trees " 120 (
"speedtree-fog-color",
"1.0 1.0 1.0",
121 PRC_DESC(
"Specifies the r g b color of SpeedTree fog."));
124 (
"speedtree-sky-color",
"0.2 0.3 0.5",
125 PRC_DESC(
"Specifies the r g b color of the SpeedTree sky, when the sky " 126 "is enabled. Currently unused."));
129 (
"speedtree-sky-fog",
"-0.5 1.0",
130 PRC_DESC(
"Specifies the range of fog in the sky. -1 is down, 1 is up."));
133 (
"speedtree-sun-color",
"1.0 1.0 0.85",
134 PRC_DESC(
"Specifies the r g b color of the SpeedTree sun, when the sun " 135 "is enabled. Currently unused."));
138 (
"speedtree-sun-size", 0.001,
139 PRC_DESC(
"Undocumented SpeedTree parameter."));
142 (
"speedtree-sun-spread-exponent", 200.0,
143 PRC_DESC(
"Undocumented SpeedTree parameter."));
146 (
"speedtree-sun-fog-bloom", 0.0,
147 PRC_DESC(
"Undocumented SpeedTree parameter."));
150 (
"speedtree-specular-color",
"1 1 1",
151 PRC_DESC(
"Specifies the r g b color of the specular reflections on SpeedTree " 155 (
"speedtree-emissive-color",
"0 0 0",
156 PRC_DESC(
"Specifies the r g b color of the emissive light effect on SpeedTree " 160 (
"speedtree-shadow-map-resolution", 0,
161 PRC_DESC(
"Specifies the resolution for rendering shadow maps. Should " 162 "be a power of 2. Specify 0 to disable shadowing in SpeedTree."));
165 (
"speedtree-cascading-shadow-splits",
"200 400 600",
166 PRC_DESC(
"Specifies the shadow split distance, in spatial units, for " 167 "each shadow map to be rendered. The number of values also " 168 "implies the number of shadow maps, to a maximum value compiled " 169 "within SpeedTree (typically 4)."));
172 (
"speedtree-smooth-shadows",
false,
173 PRC_DESC(
"True to enable a smoothing pass on the shadow maps."));
176 (
"speedtree-show-shadow-splits-on-terrain",
false,
177 PRC_DESC(
"Currently unsupported."));
180 (
"speedtree-wind-enabled",
true,
181 PRC_DESC(
"True to enable global wind in the SpeedTree world."));
184 (
"speedtree-frond-rippling",
true,
185 PRC_DESC(
"True to allow fronds to respond to the global wind."));
188 (
"speedtree-terrain-num-lods", 5,
189 PRC_DESC(
"Specifies the number of different LOD stages to use in " 190 "rendering terrain. Each stage has 75% few polygons than the " 191 "stage before. Increasing this number decreases the total " 192 "number of polygons onscreen, at the cost of visual quality of " 193 "distant terrain."));
196 (
"speedtree-terrain-resolution", 33,
197 PRC_DESC(
"Specifies the number of vertices per edge of each terrain grid " 198 "cell at the highest LOD. This must be a power of two plus 1."));
201 (
"speedtree-terrain-cell-size", 800,
202 PRC_DESC(
"Specifies the size in spatial units of one edge of a terrain " 203 "grid cell. This effects culling and resolution, but has nothing " 204 "to do with the scale of the heightmap or other maps."));
207 (
"speedtree-shadow-fade", 0.25,
208 PRC_DESC(
"Specifies the rate at which shadows fade to transparency in the " 212 (
"speedtree-show-overlays",
false,
213 PRC_DESC(
"True to draw onscreen overlays showing the generated " 217 (
"speedtree-max-num-visible-cells", 75,
218 PRC_DESC(
"Specifies the maximum number of cells in a single SpeedTree forest " 219 "frustum. This is used internally by SpeedTree's billboard system."));
222 (
"speedtree-cull-cell-size", 1200,
223 PRC_DESC(
"Specifies the size of a single SpeedTree cull cell, in Panda " 224 "units. Increasing this number decreases the number of " 225 "individual calls that must be made to render geometry, " 226 "while increasing the number of trees that are rendered " 230 (
"speedtree-area-scale", 3280.839895013,
231 PRC_DESC(
"This is the factor by which the \"area\" value in a SpeedTree " 232 "terrain.txt file is scaled (after taking its square root) " 233 "when loading a new terrain. The default is about 3281, which " 234 "scales from kilometers to feet. You should set a different " 235 "scale if you use units other than feet."));
238 (
"speedtree-follow-terrain",
true,
239 PRC_DESC(
"Set this true to have trees automatically snap to the terrain " 240 "height when loaded into a SpeedTree node with a configured " 241 "terrain. If this is false, you may still call " 242 "SpeedTreeNode::snap_to_terrain() afterwards."));
245 (
"speedtree-max-random-try-count", 1000,
246 PRC_DESC(
"This is a cheesy limit to detect bad parameters passed to " 247 "SpeedTreeNode::add_random_instances(). If this number of attempts " 248 "to find a legal place for a tree fail in a row, the parameters " 249 "are deemed to be in error, and the function fails."));
252 (
"speedtree-5-2-stf",
253 #
if SPEEDTREE_VERSION_MAJOR > 5 || (SPEEDTREE_VERSION_MAJOR == 5 && SPEEDTREE_VERSION_MINOR >= 2)
258 PRC_DESC(
"The format of the STF file changed in SpeedTree version 5.2. " 259 "Specify true here to read STF files in the new file format, or " 260 "false to read STF files in the pre-5.2 file format."));
272 init_libspeedtree() {
273 static bool initialized =
false;
279 SpeedTreeNode::init_type();
280 STBasicTerrain::init_type();
281 STTerrain::init_type();
283 LoaderFileTypeSrt::init_type();
284 LoaderFileTypeStf::init_type();
297 void *Alloc(
size_t block_size) {
298 return PANDA_MALLOC_ARRAY(block_size);
301 void Free(
void *block) {
303 PANDA_FREE_ARRAY(block);
311 static SpeedTree::CAllocatorInterface allocator_interface(&custom_allocator);
This is a convenience class to specialize ConfigVariable as a Filename type.
This is a convenience class to specialize ConfigVariable as a boolean type.
static LoaderFileTypeRegistry * get_global_ptr()
Returns a pointer to the global LoaderFileTypeRegistry object.
This is a convenience class to specialize ConfigVariable as a set of floating-point types representin...
void register_type(LoaderFileType *type)
Defines a new LoaderFileType in the universe.
This is a convenience class to specialize ConfigVariable as a floating-point type.
The name of a file, such as a texture file or an Egg file.
This is a convenience class to specialize ConfigVariable as a string type.
This class maintains the set of all known LoaderFileTypes in the universe.
This is a convenience class to specialize ConfigVariable as an integer type.
static void register_with_read_factory()
Tells the BamReader how to create objects of type SpeedTreeNode.
This defines the Loader interface to read SpeedTree STF files–a simple text file that describes a fo...
This defines the Loader interface to read SpeedTree SRT files, which describe a single tree...
static Filename from_os_specific(const string &os_specific, Type type=T_general)
This named constructor returns a Panda-style filename (that is, using forward slashes, and no drive letter) based on the supplied filename string that describes a filename in the local system conventions (for instance, on Windows, it may use backslashes or begin with a drive letter and a colon).