SEED: Difference between revisions

From The DarkMod Wiki
Jump to navigationJump to search
(add angle image)
 
(45 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{infobox|Note: This is a design document and not actually implemented or available yet!}}
<center>[[Image:Lode pond map.jpg|400px|In the editor]] => [[Image:Lode pond map 3.jpg|350px|In game]]</center>
 
{{clear}}
 


== Introduction ==
== Introduction ==


The new and improved [[LOD|LOD System]] for TDM v1.03 lets you place entities in your map that reduce their own complexity when being far away from the player. However, there are still some huge drawbacks to this technique:
The new and improved [[LOD|LOD System]] for TDM v1.04 lets you place entities in your map that reduce their own complexity when being far away from the player. However, there are still some huge drawbacks to this technique:


* manually placing thousands of entities is very tedious and error prone
* manually placing thousands of entities is very tedious and error prone
* 3000 entities "thinking" (deciding what LOD they have) takes about 7% of performance, even when they are not visible
* 3000 entities "thinking" (deciding what LOD they have) takes about 7% of performance, even when they are not visible
* The overall entity limit of 8192 entities - even if only ever 100 entities are visible to the player, you would not be able to create a forest with 10000 objects (trees, treestumps, flower patches and rocks etc.)
* The overall entity '''limit of 8192 entities''' - even if only ever 100 entities are visible to the player, you would not be able to create a forest with 10000 objects (trees, treestumps, flower patches and rocks etc.), unless you combine them manually into ''func_statics''.
* While it is possible to combine multiple brushes/patches into one ''func_static'' to improve performance (less drawcalls), this is not possible for static models (trees, chairs etc) unless you do so in a modelling program (like Blender). But even when you do so, the created models are either too generic or too specific (they are recognizable by the player because they always appear in the same relative position to each other).


To overcome these limitations, the new '''LODE''' (Level Of Detail Entity manager) system was created by Tels in June/July 2010.
To overcome these limitations, the new '''SEED''' (System for Environmental Entity Distribution) system was created by Tels between June and October 2010, and has been continually improved since then.  


=== What is it ===
=== What is it ===
Line 15: Line 19:
It is foremost an entity manager that can:
It is foremost an entity manager that can:


* Create entities from "templates" (even multiple)
* '''[[SEED - Generating entities|Generate entities]]''' from "templates" (even multiple templates at the same time)
* Place created entities on random positions with random rotations
* Place created entities on random positions with random rotations (and random vertex colors)
* Only creates the entities that are "near" the player (saving memory and CPU time)
* Only creates (spawns) the entities that are "near" the player (saving memory and CPU time)
* Can create entities depending on the surface of the floor (no trees on metal, or only pebbles on sand etc.)
* Removes entities "far" from the player, thus overcomes the [[entity limit]]
* Removes entities "far" from the player, thus overcomes the entity limit
* Create entities depending on the surface of the floor (no trees on metal, or only pebbles on sand etc.), or based on an image map (greyscale image)
* Can also manage entities that were manually placed in the map
* '''[[SEED - Watching entities|Manage entities]]''' that were manually placed in the map
* Is tied in with the "Object detail" menu setting
* '''[[SEED - Combining entities|Combine]]''' many entities into one rendermodel (with a matching physics object built from multiple clipmodels), speeding up drawing thousands of things on the screen at the same time dramatically (this also helps overcome the [[entity limit]])
* Works entirely automatic
* Is tied in with the "Object detail" menu setting (so the player can control the amount of detail, depending on the speed of his machine)
* Works entirely automatic, but has still a lot of manual control for the mapper


The system also includes support for inhibitors, e.g. areas that are clear of generated entities. This way a forest clearing can be specified with only two entities, instead of being pieced together from multiple generators.
The system also includes support for inhibitors, e.g. areas that are clear of generated entities. This way a forest clearing can be specified with only a few entities, instead of being pieced together from multiple generators.


== How to use it ==
== How to use it ==


{{infobox|'''IMPORTANT'''<br>The current system '''only''' supports axis-aligned boxes. If you rotate the entity in DR, it will simply cover the area that the bounds of the rotated brush include! To rotate the LODE around the z-axis, you '''must''' set an "angle" spawnarg instead.
{{infobox|'''IMPORTANT'''<br>The current system '''only''' supports axis-aligned boxes. If you rotate the entity in DR, it will simply cover the area that the bounds of the rotated brush include! To rotate the SEED around the z-axis, you '''must''' set an "angle" spawnarg instead.}}
 
In addition, the placement of entities is relative to the origin of the LODE entity. If you resize the entity in the editor, the origin can move from the center to some side. In this case select the entity, press {{key|CTRL}}+{{key|v}} to enter Vertic Mode and then move the origin back to the center (which you can easily identify, because linked entities will be drawn with their link exactly from the center).}}




[[Image:Lode.png|400px|right|thumb|A LODE entity in the editor]] [[Image:Lode_pine.png|400px|right|thumb|An entity targeted by the LODE]]
[[Image:Lode.png|400px|right|thumb|A SEED entity in the editor]] [[Image:Lode_pine.png|400px|right|thumb|An entity targeted by the SEED]]


* In [[DarkRadiant]], create a brush the size of the area you want to cover
* In [[DarkRadiant]], create a brush the size of the area you want to cover
* With that brush still selected, {{RMB}} and select '''Create entity''' and select '''Darkmod/Info/atdm:lode'''
* With that brush still selected, {{RMB}} and select '''Create entity''' and select '''Darkmod/Info/atdm:seed'''


:'''Note:'''<br> If you want to resize the LODE entity after creating it, select it with {{SHIFT}} + {{LMB}} and press {{Key|TAB}} to select the brush, then resize it normally.
:'''Note:'''<br> If you want to resize the SEED entity after creating it, select it with {{SHIFT}} + {{LMB}} and press {{Key|TAB}} to select the brush, then resize it normally.


* Now create the entities that you want to appear. (These entities are sometimes called "targets (because the LODE targets them) or templates (because they are just a blueprint for other entities that should be created). What types of entities can you use?
* Now '''either add''' the appropriate [[SEED - Templates via Spawnargs|'''templates via spawnargs''']] on the SEED, '''or create''' the entities that you want to appear and then link them from the SEED. (These entities are sometimes called "targets (because the SEED targets them) or templates (because they are just a blueprint for other entities that should be created). What types of entities can you use?
** Place any entity by with {{RMB}} -> 'Create Entity'. Entities that use the [[LOD]] system should be prefered.
** Place any entity by with {{RMB}} -> 'Create Entity'. Entities that use the [[LOD]] system should be preferred.
** Draw brushes/patches in DR, then turn them into a func_static.
** Draw brushes/patches in DR, then turn them into a func_static.
** You can also place a model in DR, then use/öink it as entity.
** You can also place a model in DR, then use/link it as entity.
* Link each entity from the LODE entity by selecting first the LODE, then the entity, and then press {{CTRL}}+{{Key|K}}.
* Link each entity from the SEED entity by selecting first the SEED, then the entity, and then press {{CTRL}}+{{Key|K}}.
* Put the entities at the height you want them to appear. Alternatively, use the spawnarg '''"lode_floor"''' on the entity (see below for more spawnargs). The X/Y or rotation position of the entity does not matter, but you can f.i. use different skins.
* Put the entities at the height you want them to appear. Alternatively, use the spawnarg '''"seed_floor"''' on the entity (see below for more spawnargs). The X/Y or rotation position of the entity does not matter, but you can f.i. use different skins.
* Remember to '''dmap''' whenever you add, delete or change the position/size of a LODE!
* Remember to '''dmap''' whenever you '''add, delete or change''' the position/size of a SEED!


{{clear}}
{{clear}}
Line 52: Line 55:
=== Area shape and blocking areas ===
=== Area shape and blocking areas ===


  [[Image:No_lode.png|400px|thumb|right|A NO LODE entity blocking an area]]
  [[Image:No_lode.png|400px|thumb|right|A NO SEED entity blocking an area]]


At the moment the area covered by the entity is always treated as a (possible rotated) box. That means you cannot get f.i. triangle shaped areas (yet). However, it is possible to block some areas inside the covered area from getting any entities via '''Darkmod/Info/atdm:no_lode''' entities. With this "boolean subtract" you can create "holes" or even more complex shapes.
At the moment the area covered by the entity is always treated as a (possibly rotated) box. That means you cannot get f.i. triangle shaped areas (yet). However, it is possible to block some areas inside the covered area from getting any entities via '''Darkmod/Info/atdm:no_seed''' entities. With this "boolean subtract" you can create "holes" or even more complex shapes.


To get this to work, place '''atdm::no_lode''' entities and then link them from the LODE. If you want to have one LODE inhibitor to block more than one intersecting LODE, simply link it from both. See screenshot at right for an example.
To get this to work, place '''atdm::no_seed''' entities and then target them from the SEED. If you want one SEED inhibitor to block more than one intersecting SEED, simply target it from both. See screenshot at right for an example. If you have more than one inhibitor inside a SEED, target each from the seed ("target0", "target1", etc.)


{{clear}}
{{clear}}
Line 62: Line 65:
== Important note ==
== Important note ==


{{infobox|The current system '''only''' supports axis-aligned boxes. If you rotate the entity in DR, it will simply cover the area that the bounds of the rotated brush include! To rotate the LODE around the z-axis, you '''must''' set an "angle" spawnarg instead.
{{infobox|The current system '''only''' supports axis-aligned boxes. If you rotate the entity in DR, it will simply cover the area that the bounds of the rotated brush include! To rotate the SEED around the z-axis, you '''must''' set an "angle" spawnarg instead.}}


In addition, the placement of entities is relative to the origin of the LODE entity. If you resize the entity in the editor, the origin can move from the center to some side. In this case select the entity, press {{key|CTRL}}+{{key|v}} to enter Vertic Mode and then move the origin back to the center (which you can easily identify, because linked entities will be drawn with their link exactly from the center).}}


== GUI Setting ==
== GUI Setting ==
Line 72: Line 74:
We want to avoid overly complicated settings like some other games have, where you can control the density, the visibility distance, the texture quality etc all on their own. But rendering slightly less mushrooms for a playable framerate is still a good idea, so LOD distance and density are coupled.
We want to avoid overly complicated settings like some other games have, where you can control the density, the visibility distance, the texture quality etc all on their own. But rendering slightly less mushrooms for a playable framerate is still a good idea, so LOD distance and density are coupled.


If you want a LODE that always creates the same number of entities (e.g. does not scale wit the GUI setting), see '''[[#lod_scaling_limit]]'''.  
If you want a SEED that always creates the same number of entities (e.g. does not scale wit the GUI setting), see [[LODE_-_Spawnargs#lod_scaling_limit|'''lod_scaling_limit''']].  


== Spawnargs on the LODE ==


These spawnargs can be set on the LODE itself and set defaults or influence overall strategies:
== Spawnargs ==


=== angle ===
Please see the [[SEED - Spawnargs]] and [[SEED - Templates via Spawnargs]] articles for the spawnargs you can set.


Rotates the LODE shape around the z-axis. F.i. angle=45 would create a rectangle rotated by 45°.
== Script events ==


{{infobox|Note: '''Do not rotate the LODE entity or LODE brush inside DR itself, this will only increase the LODE bounds, but not actually rotate the LODE shape!'''}}
There exist a few script events that can be used either from scripts, or by setting up a trigger that links to an '''atdm:target_callobjectfunction''' with the spawnarg '''call''' set to one of the script functions below:
 
[[Image:Lode angle.jpg|center|thumb|500px|The angle spawnarg]]{{clear}}
=== bunching ===
 
Default: "0" (Off). Number from 0.0 to 1.0, giving the probability that a randomly created entities "bunches" up with an already existing entity. Can be overriden for each entity class with '''lode_bunching'''.
 
<!--Other related settings: "lode_max_bunched" (limit number of entities per bunch), and "lode_bunch_spacing_min" and "lode_bunch_spacing_max" (how much space leave between bunched-up entities). -->
 
{{clear}}
 
=== cull_range ===
 
Default: '''150''' units. Entities further away from the player than '''hide_distance''' (as defined on each LOD entity) + '''cull_range''' will be removed from the game world. When they come closer to  '''hide_distance + (cull_range / 2)''', they will respawn automatically.
 
Can be overriden on a per entity-class basis with '''lode_cull_range'''.
 
Set to '''0''' to disable any entity culling for this LODE. This should be only used for LODEs with a small number of entities, otherwise you can easily run out of entity slots.
 
=== debug ===
 
Debug level, default: '''0'''. If > 0, more debug messages are printed to the console. Warning: Can generate massive amounts of output!
 
=== density ===
 
Default: '''1.0'''. A factor multiplied with the number of entities generated if '''max_entities''' is 0.
 
[[Image:LODE density.jpg|thumb|800px|center|The density spawnarg controls how many entities are generated when max_entities is 0.]]
 
{{infobox|'''Note:''' The '''density''' is slightly influenced by the menu setting "Object Detail". Make sure you test your map with the "Normal" setting. If you can, test as well as the "Lowest" and "Highest" to get a feeling for the extremes that can appear.}}
 
{{clear}}
 
=== falloff ===
 
Default: '''none'''. Defines a function that influences the probability that an entity will be generated. If set to '''none''', all positions are equally likely, resulting in a square shape. All other values (except "func") create a ellips defined by the corners of the LODE and distribute the entities inside that shape.
 
The value can be set on a per-class base with '''lode_falloff'''.
 
Possible values:
 
* none - entities all over the square, none outside
* cutoff - no falloff, but entities restricted inside the ellipse formed by LODE corners
* square - elliptical like cutoff, but square falloff from the center
* exp - elliptical like cutoff, but exponential falloff from the center
* func - a function calculated from parameters, see [[LODE - Falloff function]] for details and images.
 
[[Image:Lode falloff.jpg|thumb|800px|center|The falloff spawnarg controls the distribution of the entities.]]
 
=== falloff_map ===
 
Specifies the path to an image map (8bit greyscale TGA), where black is 0% and white is 100% spawn probability.
 
Example:
 
"falloff_map" "textures/lode/grassland.tga"
 
Note: The image base map is combined with whatever distribution you set with '''falloff''', also inhibitors are still taken into account.
 
=== floor ===
 
Default: '''0''' (Off). If set to '''1''', all generated entities will be ''floored'', that is their position will be adjusted so that they touch whatever is under them. They start out at the height the template entity is placed in the editor. This works with dynamically created terrain or terrain consisting of irregular heights like when it was made from patches. See also '''lode_collide''' and '''lode_stack'''.
 
Finding the height where the entity is placed is a three-step process, and the '''"floor"''' (or '''"lode_floor"''' per class) disables/enables the second step. Here is how it works:


First, the entities are placed in whatever height you place the template in the editor. This way you can control their maximum height - entities will only sink down from there (unless the "max_sink/min_sink" spawnargs are negative, then entities will raise from this point on).
=== disable() ===


[[Image:Lode no floor step 1.png|thumb|800px|center|Step 1: With '''floor off''': Placing entities at the editor height.]]
Disabled the thinking of this SEED. Spawned entities are no longer culled and culled entities no longer respawned.
[[Image:Lode floor step 1.png|thumb|800px|center|Step 1: With '''floor on''': Placing entities at the editor height.]]


{{clear}}
=== enable() ===


If '''"floor"''' is true, then the second step will place entities downwards so their '''origin''' touches the terrain. Note that nothing happens when '''"floor"''' is off!
Enables the thinking of this SEED again. E.g. spawned entities are culled and respawned if necessary.
 
[[Image:Lode floor step 2.png|thumb|800px|center|Step 2: With '''floor on''': Touch down to the terrain.]]
 
{{clear}}
 
In the third step random sinking/raising of the entities is done according to the '''"sink_min"''' and '''"skin_max"''' spawnargs:
 
[[Image:Lode floor step 3.png|thumb|800px|center|Step 3: With '''floor on''': Random sinking.]]
[[Image:Lode no floor step 3.png|thumb|800px|center|Step 3: With '''floor off''': Random sinking.]]
 
{{clear}}
 
=== lod_scaling_limit ===
 
Default: '''10'''. Integer.
 
The '''max_entities''' number scales slightly with the GUI setting "Object details". This is generally a good thing, as it allows the player to lower/raise the details according to his machine. However, in specific circumstances you want a LODE control exactly so many entities as specified. This spawnarg gives the limit ''under'' that the scaling for the entity count will be skipped.
 
Example: You want to a LODE that always creates exactly 16 crates: Set the following spawnargs:
 
<pre>
"lod_scaling_limit" "16"
"max_entities"      "16"
</pre>
 
=== lod_scale_density ===
 
Default: '''1'''. Boolean.
 
The '''density''' scales slightly with the GUI setting "Object details". This is generally a good thing, as it allows the player to lower/raise the details according to his machine. However, in specific circumstances you want a LODE to create an entity pattern that is not influenced by the menu setting, f.i. because it looks out-of-place with too many or too little entities. This spawnarg gives you the ability to turn the scaling off.
 
Note: Should only be used very seldom.
 
=== max_entities ===
 
Default: '''0'''. The maximum number of entities generated. If 0 (the default), then the number will be computed from the aprox. area the LODE covers, taking into account the '''density''' spawnarg. Can be overridden by each entity class with '''lode_max_entities'''.
 
Note that the LODE might generate less entitis, f.i. when entities do not all fit into the LODE area, or the inhibitors inhibit too many entities.
 
=== probability ===
 
Default 1.0. Is used as default probability for entities to spawn on certain surface types, but only when you define '''lode_material_xyz''' spawnargs on the template/target entities. See there for an explanation on how this lets you spawn entities only on some surfaces but not on others.
 
=== remove ===
 
Default: '''0'''. Boolean, if set to 1, the LODE will spawn all entities immediately (instead of spawning only the ones that are visible to the player) and then remove itself.
 
=== rotate_min/rotate_max ===
 
Default: '''0 0 0''' and '''5 360 5'''. The range for each axis on how much the entity will be randomly rotated around it. In the order "Ymin Zmin Xmin" and "Ymax Zmax Xmax" (or pitch, yaw, roll (yzx), where the actual rotation order will be yaw, pitch, roll, e.g. "zyx").
 
The default makes entities yaw randomly between 0 and 360 degress around Z (turn), and pitch/roll between 0 and 5 degrees on the other two axes. Can also be overwritten on each class with '''lode_rotate_min''' and '''lode_rotate_max'''.
 
=== seed ===
 
Default: '''0'''. The random seed. If not set or set to 0, a random value will be used (this is the recommended way, as it generates different results every time you start the map anew, but still keeps the entities when you f.i. save and then load a game).
 
If set to > 0, the random number generator will always generate the same sequence, so you get still randomly distributed results, but they are always the same.
 
=== sink_min/sink_max ===
 
Default: Both to '''0'''. In Units.
 
Define the range (minimum/maximum) of how much entities randomly sink into the floor. Can be overridden on a per-class case with '''lode_sink_min''' and '''lode_sink_max'''. This is in addition to the "base line floor" of the entity, which is either determined by the placement of the template entity in DR (if '''"lode_floor"''' is false), or by the point where the entity origin touches the ground (if '''"lode_floor"''' is true).
 
This can f.i. be used to let all floored entities sink 1 or 2 units into the ground, to avoid that the entity, if placed on a step incline, sinks at one side into the ground, but stands "on air" on the other side.
 
Note: If '''sink_max''' is smaller than '''sink_min''', it will be set to '''sink_min'''.
 
Usages:
 
* '''sink_min''' = 0, '''sink_max''' = 0 - all entities are at the same "height"
* '''sink_min''' = 5, '''sink_max''' = 5 - all entities sink 5 units "down"
* '''sink_min''' = 1, '''sink_max''' = 15 - all entities sink between 1 and 15 units "down"
* '''sink_min''' = -10, '''sink_max''' = -5 - all entities raise between 5 and 10 units "up" (note seemingly reversed numbers)
 
"Down" here refers to the gravity normal of the Lode, e.g. at the moment just down the z-axis.
 
=== spacing ===
 
Default: '''0'''. Defines a minimum distance between placed entities. If set to > 0, implies collision check at creation time between all entities.
 
== Spawnargs on the Inhibitors (atdm:no_lode) ==
 
At the moment you cannot set spawnargs on inhibitors. This will be added later.
<!--
 
=== falloff ===
 
Default is '''none'''. Defines the falloff for this inhibitor. Works in reverse to '''falloff''' on the lode, that is the inhibition is strongest at the center and falls off to the border.
 
Possible values:
 
* none - no entities anywhere
* linear - linear
* square - squared
* exp - exponential
 
See also: '''shape'''.
 
{{clear}}
 
=== noinhibit ===
 
Lists a class of entities that this node does not inhibit from spawning inside a LODE. Multiple can be given with "noinhibit1" etc. Example:
 
<pre>
"noinhibit"  "atdm:nature_grass"
"noinhibit1" "atdm:nature_dense"
"noinhibit2" "atdm:nature_bush_small"
</pre>
 
=== inhibit ===
 
If set, any '''noinhibit''' spawnargs are ignored. Lists a class of entities that (and only that) this node will inhibit from spawning inside a LODE. Multiple can be given with "inhibit1" etc. Example:
 
<pre>
"inhibit"  "atdm:nature_pine"
"inhibit1" "atdm:nature_rock"
</pre>
 
-->
 
== Spawnargs on Targets ==
 
These spawnargs can be set on the entities that the LODE targets:
 
=== lode_cull_range ===
 
Default: To whatever the LODE specifies, which defaults to '''150''' units. Entities further away from the player than '''hide_distance''' (as defined on each LOD entity) + '''lode_cull_range''' will be removed from the game world. When they come closer to  '''hide_distance + (lode_cull_range / 2)''', they will respawn automatically.
 
To disable culling of entities set to 0.
 
=== lode_watch_brethren ===
 
Boolean, default: '''0''' (false).
 
If set, instead of taking this entity as a template to create new entities, this tells the LODE entity that all entities inside the LODE and of the same entityDefName as this one should be "watched" over by the LODE.
 
That means it will add these entities to its entity watch list, and do the LOD changes as well as cull/respawn them if nec.
 
The other "lode_*" spawnargs (like '''lode_floor''', '''lode_spacing''' etc.) are ignored on the target entity. The only relevant spawnargs are '''lod_*''' and '''hide_distance''' - these cause the LOD system to kick in. Also, do not forget to put a '''hide_distance''' on the target entity, or the LODE will never cull the entities it watches.
 
=== lode_falloff ===
 
Default: Whatever the LODE specifies, or '''none'''. Defines a function that influences the probability that an entity will be generated. If set to '''none''', all positions are equally likely, resulting in a square shape. The other values (except "func") create a ellipe defined by the corners of the LODE and distribute the entities inside that shape.
 
Possible values:
 
* none - entities all over the square, none outside
* cutoff - no falloff, but entities restricted inside ellipse formed by LODE corners
* square - elliptical like cutoff, but square falloff from the center
* exp - elliptical like cutoff, but exponential falloff from the center
* func - a function calculated from parameters, see [[LODE - Falloff function]] for details and images.
 
[[Image:Lode falloff.jpg|thumb|800px|center|The falloff spawnarg controls the distribution of the entities.]]
 
=== lode_floor ===
 
Default: '''0''' (Off). If set to '''1''', all entities of this class will be floored, that is their position will be adjusted so that they touch whatever is under them. This works with dynamically created terrain or terrain consisting of irregular heights like when it was made from patches. See also '''lode_collide''' and '''lode_stack'''.
 
=== lode_max_entities ===
 
Default: '''0'''. The maximum number of entities generated. If 0 (the default), then the number will be computed from the accordingly to the '''lode_score''' of this class and the '''max_entities''' from the LODE. If greater than zero, only so many entities will be generated and the spawnarg '''lode_score''' will be ignored for this class.
 
Note that the LODE might generate less entities, f.i. when entities do not all fit into the LODE area, or the inhibitors inhibit too many entities.
 
=== lode_score ===
 
Sets the score for this entity class. All scores will be summed together, and the score for each class will be the percentage of entities of this class to create. Some examples:
 
* Entity A: '''4''', Entity B: '''5''': Sum: '''9''', 4/9 of all entities will be of class A, and 5/9 will be class B
* Entity A: '''1''', Entity B: '''2''': Entity C: '''7''', Sum: '''10''', 1/10 of all entities will be of class A, 2/10 will be class B and 7/10 will be of class C
 
=== lode_spacing ===
 
Defines a minimum distance between placed entities of this class. Overrides the default setting from "spacing" on the LODE. If set to > 0, implies collision check at creation time between all entities of this class.
 
=== lode_rotate_min/lode_rotate_max ===
 
Default: Same as the LODE specifies (which defaults to '''0 0 0''' and '''5 360 5''').
 
The range for each axis on how much the entity will be randomly rotated around it. I the order "Ymin Zmin Xmin" and "Ymax Zmax Xmax" (or pitch, yaw, roll (yzx), where the actual rotation order will be yaw, pitch, roll, e.g. "zyx").
 
The default makes entities rotate randomly between 0 and 360 degress around Z (turn), and tilt between 0 and 5 degrees on the other two axes. Use '''0 0 0''' and '''0 360 0''' for entities that should be perfectly upright.
 
=== lode_bunching ===
 
Default: What the LODE specifies with '''bunching'''. Number from 0.0 to 1.0, giving the probability that a randomly created entities "bunches" up with an already existing entity. Can be override per entity class with '''lode_bunching'''.
 
<!--Other related settings: "lode_max_bunched" (limit number of entities per bunch), and "lode_bunch_spacing_min" and "lode_bunch_spacing_max" (how much space leave between bunched-up entities). -->
=== lode_noinhibit ===
 
Default: '''0''' (false). Boolean.
 
If set to '''1''' (true), entities of this class will not be inhibited by any inhibitor linked to this LODE. Can be used f.i. to add grass and trees to an area, but make it so that trees are inhibited in certain areas, but grass never is.
 
For more control over non-inhibition of entities, see the section [[#Spawnargs on the Inhibitors (atdm:no_lode)]].
 
=== lode_sink_min/lode_sink_max ===
 
Default: Both to what the LODE specifies with '''sink_min''' and '''sink_max'''. In Units.
 
Define the range (minimum/maximum) of how much entities randomly sink into the floor. This is in addition to the "base line floor" of the entity, which is either determined by the placement of the template entity in DR (if '''"lode_floor"''' is false), or by the point where the entity origin touches the ground (if '''"lode_floor"''' is true).
 
This can f.i. be used to let all floored entities sink 1 or 2 units into the ground, to avoid that the entity, if placed on a step incline, sinks at one side into the ground, but stands "on air" on the other side.
 
Note: If '''lode_sink_max''' is smaller than '''lode_sink_min''', it will be set to '''lode_sink_min'''.
 
Usages:
 
* '''lode_sink_min''' = 0, '''lode_sink_max''' = 0 - all entities are at the same "height"
* '''lode_sink_min''' = 5, '''lode_sink_max''' = 5 - all entities sink 5 units "down"
* '''lode_sink_min''' = 1, '''lode_sink_max''' = 15 - all entities sink between 1 and 15 units "down"
* '''lode_sink_min''' = -10, '''lode_sink_max''' = -5 - all entities raise between 5 and 10 units "up" (note seemingly reversed numbers to make min smaller than max)
 
"Down" here refers to the gravity normal of the Lode, e.g. at the moment just down the z-axis.
 
=== lode_material_xyz ===
 
Defines the probability that an entity will spawn on the given material. If used, the "lode_probability" spawnarg will also be queried and used. Example:
 
<pre>
"lode_material_grass" "1.0"
"lode_material_dirt" "0.5"
"lode_probability" "0"
</pre>
 
This would spawn the entity always on grass, only half the time on dirt, and never on anything else (the "lode_probability" "0").
 
The other way round is also possible:
 
<pre>
"lode_material_stone" "0"
"lode_material_metal" "0"
"lode_probability" "1.0"
</pre>
 
Meaning: Never spawn on metal or stone, but always on anything else.
 
=== lode_probability ===
 
Default 1.0. Is used as default probability for entities to spawn on certain surface types, but only when you define '''material_xyz''' spawnargs. See there for an explanation on how this lets you spawn entities only on some surfaces but not on others.
 
=== lode_stack ===
 
{{red|Section not done yet.}}
 
=== lode_collide ===
 
{{red|Section not done yet.}}
 
=== skin ===
[[Image:Lod lily.jpg|right|thumb|300px|Lily model with original plus two other skins]]
Setting a skin on the entity will use this skin on all entities created from this template. If this entity has '''lode_watch_brethren''' set, then the individual '''skin''' spawnarg is ignored, instead the skins of all entities being watched over will be preserved.
 
To get multiple, random skins, use one of the following methods:
 
* add multiple skin spawnargs with suffixes like '''skin''', '''skin_1''', '''skin_2''' etc. Note that the final skin will be randomly chosen, but distributed equally. E.g. if you have three skin spawnargs, roughly 1/3 of all entities will get the first skin, 1/3 the second and 1/3 the third.
* add multiple copies of the same entities and link them from the LODE. Each copy can have a different (or possible more, see above) '''skin''' spawnarg. You can then use '''lode_score''' to influence the distribution of the different skins.
 
Note: If you want random skins plus the original, unskinned model, simply omit the '''skin''' spawnarg and just set the '''skin_X''' spawnargs, the original skin will then be added automatically:
 
{{clear}}
 
=== Other LOD spawnargs ===
 
You can of course use other LOD spawnargs on the entities that the LODE creates. See [[LOD]] for a list.
 
== Script events ==
 
There exist a few script events that can be used either from scripts, or by setting up a trigger that links to an '''atdm:target_callobjectfunction''' with the spawnarg '''call''' set to one of the script functions below:
 
=== Deactivate() ===
 
Deactivates the thinking of this LODE. Spawned entities stay where they are.


=== Activate() ===
=== Activate() ===


Activates the LODE (e.g. it starts to think) again. If nec., the LODE will also spawn and unhide any entities that it needs.
Activates the SEED, e.g. if '''wait_for_trigger''' is true, it starts spawning entities.


=== CullAll() ===
=== CullAll() ===


Removes all entities under control of this LODE from the game. Only useful if either the player is very far away, or if you have called '''Deactivate()''' before - otherwise the entities might be spawned again in the next frame.
Removes all entities under control of this SEED from the game. Only useful if either the player is very far away, or if you have called '''disable()''' before - otherwise the entities might be spawned again in the next frame.
 
 
== Ideas ==
 
Worth considering:
 
=== lode_strategy ===
 
How the entities will be placed. Default: "random", but can be "grid" (needs a way to specifiy grid-size, grid spacing, and random-offset from grid position).
 
=== lode_oriented_z ===
 
If true, orient the entity perpendicular to the floor, before applying the random rotation values. Good for things that should stand on step inclines.
 
=== add example atdm:lode entities ===
 
== See also ==
 
* [[LOD|LOD System]]
* [[LODE Usage]] - Example on how to use LODE in real-map scenarios
* [[LODE - Falloff function]] - How to use "falloff" "func" to get more complicated distribution patterns
* [[LODE - Known bugs]]
* [[LODE - FAQ]]


{{editing}} {{scripting}}
{{seed}}

Latest revision as of 01:01, 24 March 2015

In the editor => In game


Introduction

The new and improved LOD System for TDM v1.04 lets you place entities in your map that reduce their own complexity when being far away from the player. However, there are still some huge drawbacks to this technique:

  • manually placing thousands of entities is very tedious and error prone
  • 3000 entities "thinking" (deciding what LOD they have) takes about 7% of performance, even when they are not visible
  • The overall entity limit of 8192 entities - even if only ever 100 entities are visible to the player, you would not be able to create a forest with 10000 objects (trees, treestumps, flower patches and rocks etc.), unless you combine them manually into func_statics.
  • While it is possible to combine multiple brushes/patches into one func_static to improve performance (less drawcalls), this is not possible for static models (trees, chairs etc) unless you do so in a modelling program (like Blender). But even when you do so, the created models are either too generic or too specific (they are recognizable by the player because they always appear in the same relative position to each other).

To overcome these limitations, the new SEED (System for Environmental Entity Distribution) system was created by Tels between June and October 2010, and has been continually improved since then.

What is it

It is foremost an entity manager that can:

  • Generate entities from "templates" (even multiple templates at the same time)
  • Place created entities on random positions with random rotations (and random vertex colors)
  • Only creates (spawns) the entities that are "near" the player (saving memory and CPU time)
  • Removes entities "far" from the player, thus overcomes the entity limit
  • Create entities depending on the surface of the floor (no trees on metal, or only pebbles on sand etc.), or based on an image map (greyscale image)
  • Manage entities that were manually placed in the map
  • Combine many entities into one rendermodel (with a matching physics object built from multiple clipmodels), speeding up drawing thousands of things on the screen at the same time dramatically (this also helps overcome the entity limit)
  • Is tied in with the "Object detail" menu setting (so the player can control the amount of detail, depending on the speed of his machine)
  • Works entirely automatic, but has still a lot of manual control for the mapper

The system also includes support for inhibitors, e.g. areas that are clear of generated entities. This way a forest clearing can be specified with only a few entities, instead of being pieced together from multiple generators.

How to use it

IMPORTANT
The current system only supports axis-aligned boxes. If you rotate the entity in DR, it will simply cover the area that the bounds of the rotated brush include! To rotate the SEED around the z-axis, you must set an "angle" spawnarg instead.


A SEED entity in the editor
An entity targeted by the SEED
  • In DarkRadiant, create a brush the size of the area you want to cover
  • With that brush still selected, Click the right mouse button and select Create entity and select Darkmod/Info/atdm:seed
Note:
If you want to resize the SEED entity after creating it, select it with SHIFT + Click the left mouse button and press TAB to select the brush, then resize it normally.
  • Now either add the appropriate templates via spawnargs on the SEED, or create the entities that you want to appear and then link them from the SEED. (These entities are sometimes called "targets (because the SEED targets them) or templates (because they are just a blueprint for other entities that should be created). What types of entities can you use?
    • Place any entity by with Click the right mouse button -> 'Create Entity'. Entities that use the LOD system should be preferred.
    • Draw brushes/patches in DR, then turn them into a func_static.
    • You can also place a model in DR, then use/link it as entity.
  • Link each entity from the SEED entity by selecting first the SEED, then the entity, and then press CTRL+K.
  • Put the entities at the height you want them to appear. Alternatively, use the spawnarg "seed_floor" on the entity (see below for more spawnargs). The X/Y or rotation position of the entity does not matter, but you can f.i. use different skins.
  • Remember to dmap whenever you add, delete or change the position/size of a SEED!

Area shape and blocking areas

A NO SEED entity blocking an area

At the moment the area covered by the entity is always treated as a (possibly rotated) box. That means you cannot get f.i. triangle shaped areas (yet). However, it is possible to block some areas inside the covered area from getting any entities via Darkmod/Info/atdm:no_seed entities. With this "boolean subtract" you can create "holes" or even more complex shapes.

To get this to work, place atdm::no_seed entities and then target them from the SEED. If you want one SEED inhibitor to block more than one intersecting SEED, simply target it from both. See screenshot at right for an example. If you have more than one inhibitor inside a SEED, target each from the seed ("target0", "target1", etc.)

Important note

The current system only supports axis-aligned boxes. If you rotate the entity in DR, it will simply cover the area that the bounds of the rotated brush include! To rotate the SEED around the z-axis, you must set an "angle" spawnarg instead.


GUI Setting

The current "Object detail" setting influences LOD distances, and also slightly the density spawnarg.

We want to avoid overly complicated settings like some other games have, where you can control the density, the visibility distance, the texture quality etc all on their own. But rendering slightly less mushrooms for a playable framerate is still a good idea, so LOD distance and density are coupled.

If you want a SEED that always creates the same number of entities (e.g. does not scale wit the GUI setting), see lod_scaling_limit.


Spawnargs

Please see the SEED - Spawnargs and SEED - Templates via Spawnargs articles for the spawnargs you can set.

Script events

There exist a few script events that can be used either from scripts, or by setting up a trigger that links to an atdm:target_callobjectfunction with the spawnarg call set to one of the script functions below:

disable()

Disabled the thinking of this SEED. Spawned entities are no longer culled and culled entities no longer respawned.

enable()

Enables the thinking of this SEED again. E.g. spawned entities are culled and respawned if necessary.

Activate()

Activates the SEED, e.g. if wait_for_trigger is true, it starts spawning entities.

CullAll()

Removes all entities under control of this SEED from the game. Only useful if either the player is very far away, or if you have called disable() before - otherwise the entities might be spawned again in the next frame.