SEED: Difference between revisions

From The DarkMod Wiki
Jump to navigationJump to search
Tels (talk | contribs)
add cull_range
 
(93 intermediate revisions by 2 users not shown)
Line 1: Line 1:
<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).


So there needs to be a way to dynamically only create the needed entities - and remove any no longer needed entities temporarily (but completely) from the gameworld. Of course, if nec., the formerly existing entities need to be recreated. In addition, we want some way to randomly place entities without having to specify their position/rotation for each entity.
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.  


The new '''LODE''' system provides exactly this.
=== What is it ===


It is foremost an entity manager that can:


== How to use ==
* '''[[SEED - Generating entities|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)
* '''[[SEED - Watching entities|Manage entities]]''' that were manually placed in the map
* '''[[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]])
* 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


[[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]]
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.


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


:'''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.
{{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.}}


* Now create the entities that you want to appear. Entities that use the [[LOD]] system should be prefered.
* Link each entity from the LODE entity by selecting first the LODE, then the entity, and then press {{CTRL}}+{{Key|K}}.
* Put the entities at the hight you want them to appear. Alternatively, use the spawnarg '''"lode_floor"''' on the entity (see below for more spawnargs).


{{clear}}
[[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]]


=== Area shape and blocking areas ===
* 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:seed'''
[[Image:No_lode.png|400px|thumb|right|A NO LODE 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 other shapes.
:'''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.


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.
* 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 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}}+{{Key|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!


{{clear}}
{{clear}}


== Spawnargs on the LODE ==
=== Area shape and blocking areas ===


These spawnargs can be set on the LODE itself and set defaults or influence overall strategies:
[[Image:No_lode.png|400px|thumb|right|A NO SEED entity blocking an area]]


=== seed ===
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.


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 generated different results everytime you load the map).
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.)


If set, the random number generator will always generate the same sequence, so you get still randomly distributed results, but they are always the same.
{{clear}}


=== spacing ===
== Important note ==


Default: '''0'''. Defines a minimum distance between placed entities. If set to > 0, implies collision check at creation time between all entities.
{{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.}}


=== 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.
== GUI Setting ==


== Spawnargs on Targets ==
The current "Object detail" setting influences LOD distances, and also ''slightly'' the '''density''' spawnarg.


These spawnargs can be set on the entities that the LODE targets:
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.


=== lode_floor ===
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''']].


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_score ===
== Spawnargs ==


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:
Please see the [[SEED - Spawnargs]] and [[SEED - Templates via Spawnargs]] articles for the spawnargs you can set.


* 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
== Script events ==
* Entity A: '''1''', Entity B: '''2''': Entity C: '''7''', Sum: '''10''', 1/9 of all entities will be of class A, 2/10 will be class B and 7/10 will be of class C


=== lode_spacing ===
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:
 
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_stack ===
 
{{red|Section not done yet.}}
 
=== lode_collide ===
 
{{red|Section not done yet.}}
 
=== 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 ==
=== disable() ===


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:
Disabled the thinking of this SEED. Spawned entities are no longer culled and culled entities no longer respawned.


=== Deactivate() ===
=== enable() ===


Deactivates the thinking of this LODE. Spawned entities stay where they are.
Enables the thinking of this SEED again. E.g. spawned entities are culled and respawned if necessary.


=== 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 ==
 
Not implemented yet, but 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_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. 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).
 
Implementation details: For each entity created, track the "bunchmaster". If "where we bunch to" has no bunchmaster, it becomes the new bunchmaster - second entity uses first as bunchmaster- This allows us to query "how many entities bunch up together at this spot"-
 
== See also ==
 
* [[LOD|LOD System]]


{{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.