Folliage Replicator Help
by Infinitum3D · in Torque Game Engine · 03/31/2007 (12:23 pm) · 6 replies
03-28-2007: Torque 101: Folliage Replicator
I've been playing with the folliage replicator for adding grasslands and folliage details to the world. Some of the properties I understand, some I don't.
Can anyone add to this? I'd like to submit it as a resource when all the details are in.
----------------------------------
Sim Base:
canSaveDynamicFields - is checked by default. Don't know why.
internalName... - is blank by default. Don't know why.
Transform: This is positioning information
position - is the location of the replicator center (I think).
rotation - you can change the rotation of your area, but it really screws up things. If the Z axis is not 0 then you get a flickering effect to the folliage. Leave it as 1 0 0 0
scale - I just leave it as 1 1 1. you can change the size of your area using x,y coordinates which we'll get into in a minute.
Debugging:
UseDebugInfo - unchecked by default. Don't know why. Things in italics come from the fxGrassTGE1.4 install.txt file.
This flag allows you to see relevant debugging information. For the moment I have enabled the ability to see the quad-tree boxes themselves. There are other things that can be enabled but I have decided to make them part of the code e.g. you need to uncomment lines within the code to enable them.
DebugBoxHeight - default as 1. Don't know why.
This field was requested by Phil Carlisle to enable you to control the height of the
quad-tree boxes shown on-screen. The value here is an interpolation.
1 = Top of quad-tree box / 0 = Bottom / .5 = Half way / etc.
This is to make it easier to see where the quad-boxes are when you have a big difference
between the lowest and highest billboards.
HideFolliage - unchecked by default.
This option allows you to temporary hide the replicated objects. This could be handy if the replicated objects are obscuring some detail you are editing. For instance, you may be hiding a secret key in the forest ... :)
ShowPlacementArea - checked by default.
The elliptical placement area that the replicator uses to replicate objects is not obvious from the configuration options. When this is turned on and you are within the editor, then a rather groovey coloured band sweeps around the circumference of the elliptical area selected. You can change this area and position by moving the replicator to see the exact bounds to which objects will be contained. Note, you can only see this band when you are within the editor and the replicator object is within the cameras' view.
PlacementAreaHeight - default is 25.
You can configure the placement band (see - 'ShowPlacementArea') to different heights. The band is clipped by objects within the scene and it can be hard to see sometimes particularly on hilly terrain. The 'height' is centered along the Z(0) axis of the replicator object.
PlacementColor - is 0.4 0 0.8 1 by default.
You can configure the placement band colour. The band defaults to a set colour and when using multiple replicators it it nice to configure each to it's own colour to differentiate each repliactor.
Media:
Seed - defaults as something huge like 814556372. I changed this to 10 for my first replicator, 20 for my second, 30 for my third, etc. Why? Because in the demo that's what they did, and it works.
This value is the Seed value for the random number generator. Changing this value results in a different distribution of pseudo-random numbers. You can change this value to almost anything if you are not happy with the placement of objects that has been choosen. Also, if you populate with multiple replicators then give each a different number. Note that a small value change here results in a completely different set of placements.
I've been playing with the folliage replicator for adding grasslands and folliage details to the world. Some of the properties I understand, some I don't.
Can anyone add to this? I'd like to submit it as a resource when all the details are in.
----------------------------------
Sim Base:
canSaveDynamicFields - is checked by default. Don't know why.
internalName... - is blank by default. Don't know why.
Transform: This is positioning information
position - is the location of the replicator center (I think).
rotation - you can change the rotation of your area, but it really screws up things. If the Z axis is not 0 then you get a flickering effect to the folliage. Leave it as 1 0 0 0
scale - I just leave it as 1 1 1. you can change the size of your area using x,y coordinates which we'll get into in a minute.
Debugging:
UseDebugInfo - unchecked by default. Don't know why. Things in italics come from the fxGrassTGE1.4 install.txt file.
This flag allows you to see relevant debugging information. For the moment I have enabled the ability to see the quad-tree boxes themselves. There are other things that can be enabled but I have decided to make them part of the code e.g. you need to uncomment lines within the code to enable them.
DebugBoxHeight - default as 1. Don't know why.
This field was requested by Phil Carlisle to enable you to control the height of the
quad-tree boxes shown on-screen. The value here is an interpolation.
1 = Top of quad-tree box / 0 = Bottom / .5 = Half way / etc.
This is to make it easier to see where the quad-boxes are when you have a big difference
between the lowest and highest billboards.
HideFolliage - unchecked by default.
This option allows you to temporary hide the replicated objects. This could be handy if the replicated objects are obscuring some detail you are editing. For instance, you may be hiding a secret key in the forest ... :)
ShowPlacementArea - checked by default.
The elliptical placement area that the replicator uses to replicate objects is not obvious from the configuration options. When this is turned on and you are within the editor, then a rather groovey coloured band sweeps around the circumference of the elliptical area selected. You can change this area and position by moving the replicator to see the exact bounds to which objects will be contained. Note, you can only see this band when you are within the editor and the replicator object is within the cameras' view.
PlacementAreaHeight - default is 25.
You can configure the placement band (see - 'ShowPlacementArea') to different heights. The band is clipped by objects within the scene and it can be hard to see sometimes particularly on hilly terrain. The 'height' is centered along the Z(0) axis of the replicator object.
PlacementColor - is 0.4 0 0.8 1 by default.
You can configure the placement band colour. The band defaults to a set colour and when using multiple replicators it it nice to configure each to it's own colour to differentiate each repliactor.
Media:
Seed - defaults as something huge like 814556372. I changed this to 10 for my first replicator, 20 for my second, 30 for my third, etc. Why? Because in the demo that's what they did, and it works.
This value is the Seed value for the random number generator. Changing this value results in a different distribution of pseudo-random numbers. You can change this value to almost anything if you are not happy with the placement of objects that has been choosen. Also, if you populate with multiple replicators then give each a different number. Note that a small value change here results in a completely different set of placements.
#2
Controls the point at which the Grass will be completely faded-in.
ViewClosest = "1";
Controls the point nearest to the camera at which the Grass will start fading-out. This can be use to stop Grass entering the cabin when a vehicle like the Racing demo.
FadeInRegion = "10";
FadeOutRegion = "1";
Controls the distances which the fade-in/out will take place. A larger value will result in a slower/longer fade-in/out. The FadeIn/Out extend the ViewDistance/ViewCloset parameters.
AlphaCutoff = "0.2";
Allows you to control the alpha level at which the rendering takes place. This can be very handy in feathering the edges of the Grass.
GroundAlpha = "1";
Allows you to control the alpha level at the base of the billboard. This allows you to reduce the harsh intersection that grass elements have with the terrain.
Animation:
SwayOn = "0"; Checked allows the folliage to sway back and forth.
SwaySync = "0"; Checked has all folliage in this replicator swaying in rhythm
SwayMagSide = "0.1"; Distance of sway from side to side
SwayMagFront = "0.2"; Distance of sway front to back
MinSwayTime = "3"; time period of sway measured in seconds. Lower number sways faster than larger number.
MaxSwayTime = "10";
Lighting:
LightOn = "0"; Checked turns on the animation lighting.
LightSync = "0"; All folliage in this replication has the same lighting
MinLuminance = "0.7"; from zero (0) to one (1)
MaxLuminance = "1"; from zero (0) to one (1)
LightTime = "5"; Time it takes to change from MinLuminance to MaxLuminance measured in seconds
Restrictions:
AllowOnTerrain = "1";
AllowOnInteriors = "0"; If this is checked (or 1) then your folliage will be shown on DIF structures. Usually not a good idea.
AllowOnStatics = "0"; If this is checked (or 1) then your folliage will be shown on StaticShapes (I think). Usually not a good idea.
When the replicator is choosing positions to place Grass you can choose whether to allow or disallow four different object types onto which they can be placed. This provides a very powerful means of placement. replaces the previous option.
AllowOnWater = "0"; If this is checked (or 1) then your folliage will be shown under Water surfaces.
AllowWaterSurface = "0"; Cool for things floating on water, like lilypads or algae.
When the replicator is allowed to placed the objects on water then this option controls whether the objects are allowed to be placed on the surface or the underlying terrain.
AllowedTerrainSlope = "90"; This is theangle of terrain which will allow folliage to be displayed. If you set it at 0, then only flat surface will display folliage. I recommend setting it to less than 45. In my game, it's set at 5.
When placing objects onto the terrain (or other objects) the replicator will ensure that it meets the slope requirements. You can control the maximum slope (from the 'Up' vector 'Z' in degrees). 90degrees gives almost no restriction but something like 15degrees only allows objects to be placed on fairly flat terrain.
Thanks to whoever wrote the Replicator and it's ReadMe files. It's very useful!!!
Tony
03/31/2007 (12:23 pm)
ViewDistance = "50";Controls the point at which the Grass will be completely faded-in.
ViewClosest = "1";
Controls the point nearest to the camera at which the Grass will start fading-out. This can be use to stop Grass entering the cabin when a vehicle like the Racing demo.
FadeInRegion = "10";
FadeOutRegion = "1";
Controls the distances which the fade-in/out will take place. A larger value will result in a slower/longer fade-in/out. The FadeIn/Out extend the ViewDistance/ViewCloset parameters.
AlphaCutoff = "0.2";
Allows you to control the alpha level at which the rendering takes place. This can be very handy in feathering the edges of the Grass.
GroundAlpha = "1";
Allows you to control the alpha level at the base of the billboard. This allows you to reduce the harsh intersection that grass elements have with the terrain.
Animation:
SwayOn = "0"; Checked allows the folliage to sway back and forth.
SwaySync = "0"; Checked has all folliage in this replicator swaying in rhythm
SwayMagSide = "0.1"; Distance of sway from side to side
SwayMagFront = "0.2"; Distance of sway front to back
MinSwayTime = "3"; time period of sway measured in seconds. Lower number sways faster than larger number.
MaxSwayTime = "10";
Lighting:
LightOn = "0"; Checked turns on the animation lighting.
LightSync = "0"; All folliage in this replication has the same lighting
MinLuminance = "0.7"; from zero (0) to one (1)
MaxLuminance = "1"; from zero (0) to one (1)
LightTime = "5"; Time it takes to change from MinLuminance to MaxLuminance measured in seconds
Restrictions:
AllowOnTerrain = "1";
AllowOnInteriors = "0"; If this is checked (or 1) then your folliage will be shown on DIF structures. Usually not a good idea.
AllowOnStatics = "0"; If this is checked (or 1) then your folliage will be shown on StaticShapes (I think). Usually not a good idea.
When the replicator is choosing positions to place Grass you can choose whether to allow or disallow four different object types onto which they can be placed. This provides a very powerful means of placement.
AllowOnWater = "0"; If this is checked (or 1) then your folliage will be shown under Water surfaces.
AllowWaterSurface = "0"; Cool for things floating on water, like lilypads or algae.
When the replicator is allowed to placed the objects on water then this option controls whether the objects are allowed to be placed on the surface or the underlying terrain.
AllowedTerrainSlope = "90"; This is theangle of terrain which will allow folliage to be displayed. If you set it at 0, then only flat surface will display folliage. I recommend setting it to less than 45. In my game, it's set at 5.
When placing objects onto the terrain (or other objects) the replicator will ensure that it meets the slope requirements. You can control the maximum slope (from the 'Up' vector 'Z' in degrees). 90degrees gives almost no restriction but something like 15degrees only allows objects to be placed on fairly flat terrain.
Thanks to whoever wrote the Replicator and it's ReadMe files. It's very useful!!!
Tony
#3
03/31/2007 (3:32 pm)
I don't have much to add, but it would be great to see this on TDN. Thanks for doing it, it's very useful.
#4
canSaveDynamicFields - is checked by default. Don't know why.
I think this lets you use and add extra variables to an object in your scripts even if they aren't part of the c++ object, which is a very handy feature in torque. I believe this is enabled for most things by default.
FolliageCount - this can be just about any number from 1 to 15,500 or maybe even bigger. Sometimes I must have made it too big because no folliage was displayed. I think it has something to do with the size of the replicator area.
The quantity of replicated Grass items you require. Make sure your graphics card can handle it or you'll end up with 1fps (or less!)
If i remember right, the foiliage placement involves picking lots of spots based on the seed number and doing a couple ray traces or collision checks or something to see if the plant can go there. This probably only applies to 3d plants. Anyways this could potentially slow down your computer exponentially while loading plants as it runs out of space and does more and more failed checks for clearance for each new plant. So I'm sure there are instances in which you would want that number much much lower, but this is probably one of those those things best to derive through playtesting anyways.
Thanks for doing all of this documentation.
04/01/2007 (3:23 am)
Sim Base:canSaveDynamicFields - is checked by default. Don't know why.
I think this lets you use and add extra variables to an object in your scripts even if they aren't part of the c++ object, which is a very handy feature in torque. I believe this is enabled for most things by default.
FolliageCount - this can be just about any number from 1 to 15,500 or maybe even bigger. Sometimes I must have made it too big because no folliage was displayed. I think it has something to do with the size of the replicator area.
The quantity of replicated Grass items you require. Make sure your graphics card can handle it or you'll end up with 1fps (or less!)
If i remember right, the foiliage placement involves picking lots of spots based on the seed number and doing a couple ray traces or collision checks or something to see if the plant can go there. This probably only applies to 3d plants. Anyways this could potentially slow down your computer exponentially while loading plants as it runs out of space and does more and more failed checks for clearance for each new plant. So I'm sure there are instances in which you would want that number much much lower, but this is probably one of those those things best to derive through playtesting anyways.
Thanks for doing all of this documentation.
#5
The amount of time that foliage takes to render is directly related to a few factors:
* Size of the area in which foliage is to be placed
* Number of foliage billboards to replicate
* Foliage placement restrictions
* Number of times to retry placing foliage when a suitable position cannot be found
The last item in bold is usually the load time killer. Placing a large number of billboards in a small area, with a high retry count, and lots of restrictions will take the longest to replicate. Conversely, placing the same amount of foliage within a larger area with the same retry count will yield better results.
Reducing the foliage retry count will make load times faster, but the amount of foliage replicated may be significantly less than the amount specified in FoliageCount.
It's one of the true "season to taste" widgets in the Torque toolbox. It may take a few hours to find the right balance between load times and foliage coverage.
04/01/2007 (3:17 pm)
Just to refine what Stephen posted....The amount of time that foliage takes to render is directly related to a few factors:
* Size of the area in which foliage is to be placed
* Number of foliage billboards to replicate
* Foliage placement restrictions
* Number of times to retry placing foliage when a suitable position cannot be found
The last item in bold is usually the load time killer. Placing a large number of billboards in a small area, with a high retry count, and lots of restrictions will take the longest to replicate. Conversely, placing the same amount of foliage within a larger area with the same retry count will yield better results.
Reducing the foliage retry count will make load times faster, but the amount of foliage replicated may be significantly less than the amount specified in FoliageCount.
It's one of the true "season to taste" widgets in the Torque toolbox. It may take a few hours to find the right balance between load times and foliage coverage.
#6
04/04/2007 (1:07 am)
Great posts here guys! Thanks for the explanation!
Torque Owner Infinitum3D
This allows you to select any texture file. Valid paths include the mod directory, so something like "fps/data/mycoolgrass1" would do fine. Sorry, no compound textures at the moment but that is coming. For the moment, simply use multiple replicator objects.
FolliageCount - this can be just about any number from 1 to 15,500 or maybe even bigger. Sometimes I must have made it too big because no folliage was displayed. I think it has something to do with the size of the replicator area.
The quantity of replicated Grass items you require. Make sure your graphics card can handle it or you'll end up with 1fps (or less!)
FoliageRetries - DKW
When the replicator is tasked with finding a home for each Grass item, it will look at the configuration options described within the replicator and attempt to find a random position to place it. It will choose random locations and then see if they fit the configuration constraints, if not then it will try again. The replicator will attempt this
Area:
InnerRadiusX = "0"; You can make your foliage area a solid circle, or a ring, using these settings
InnerRadiusY = "0"; Set your InnerRadiusX,Y to zero(0) for a solid circle. For a ring, make them larger. Naturally, these have to be lower than the OuterRadiusX,Y.
The placement area for grass elementsis centered around the replicator position based upon an elliptical ring-area whose inner bound is defined with
OuterRadiusX = "70"; Mathematically, you can determine the Area of your circle A=2pir then you can decide how many replications (folliageCount) to use to fill it.
OuterRadiusY = "70";
The placement area for grass elementsis centered around the replicator position based upon an elliptical ring-area whose outer bound is defined with
Dimensions:
MinWidth = "1"; This is the minimum width of the folliageFile.png that will be displayed.
MaxWidth = "2"; If you want all the plants displayed as the same size, set all these to 1.
MinHeight = "1"; If you want some variation to plant dimensions, change them.
MaxHeight = "3"; They default to MinW=1, MaxW=3, MinH=1, MaxH=5
When placing Grass onto the terrain, the Grass can be optionally scaled randomly from Min to Max in Width/Height.
FixAspectRatio = "1"; defaults to true (checked) DKW
Keeps the aspect ratio of the original texture correct. The Height is choosen according to the above settings and is also used for the width as well to keep the aspect ratio correct.
FixSizeToMax = "0"; defaults to false (unchecked) I'm assuming this means you don't want all folliage to be the max size.
Fixes the size to the
OffsetZ = "0"; defaults to zero (0).
When placeing Grass onto the terrain, sometimes they do not quite meet the ground. Also, when they are allowed to be place on steep slopes they can sometimes stick out of the terrain looks damn silly. Use -Z values to lower Grass and +Z to raise them.
RandomFlip = "1"; defaults to true. I think this means some images will be mirrored. This is good. That gives a little more variability to the display.
Randomly flips the the billboard horizontally. This can add a little more variety to the billboard images. Obviously this is only effective on non-horizontally-symmetric textures.
Culling: Culling usually means some sort of polygon or diplay reduction, which will benefit performance.
UseCulling = "1"; defaults to true. I think that means it only displays folliage that can be seen. Folliage will not be displayed behind DIF's or behind the camera FOV
Turns-on the culling facility. If you are using the replicator to create only a few items or only in a very small area them the culling algorithm can actually slow things down slightly. This gives you the ability to turn it off although you should avoid this unless you are sure you know what you're doing!
CullResolution = "64";
The culling algorithm is difficult to explain but it is essential to understanding how to efficiently control large quantities of billboards. Without culling *all* grass elementsare tested to see if they are in view and if so they are rendered. If your grass elementsare spread out over a large distance then chances are that you won't be able to view many of them but they are still tested to see if they are in view. The culling algorithm avoids this and only tests the ones that are in view. How can it know this without testing them, chicken and the egg I hear you shout! Well, the replicator creates a structured database of grass elementsand their positions at the level startup phases. Basically the algorithm splits up your total defined area (see 'RadiusOuterX/Y') into quadrants the smallests of which is this field 'CullResolution'. Above these are progressively larger blocks which cover each lower quadrant. Imagine a cube of blocks where each block has four smaller blocks directly below it repreating for many levels until each small block is your resolution. Teh algorithm can check the larger block first and check to see if it's in view. If it's not it can effectively ignore all the smaller sub-areas below it therefore removing the need to check them. I told you this was difficult to explain!
Basically, the rule is that the replicator will split up the replicated area into blocks the size of 'CullResolution'. The larger your area, the more time and memory are needed to create this structure. Try to keep the 'CullResolution' large enough so that good-size blocks of Grass can be checked quickly but not too large that the blocks are as big as your viewing frustum. Also, your viewing frustum is not simply the 'VisibleDistance' as set in the "Sky" object but the smaller of that or the 'ViewDistance'+'FadeInRegion' as set in this object.
As an example:-
The 'VisibleDistance' is 500,
The 'RadiusOuterX/Y' are 512 (an area 1024 squared),
The 'ViewDistance' is 250 and the 'FadeInRegion' is '50'.
A good setting fr this scene would be 64 as the area is quite large (1024 squared) and results in 1024/64 highest resolution blocks.
IMPORTANT NOTE:-
The algorithm is more memory efficient if the 'CullResolution' can divide the largest diameter of the replicator evenly.
Also I have clamped 'CullResolution' so that you cannot set it higher than half the largest diameter or lower than 8.
Values lower than 8 can result in hundreds of megabytes being allocated for sizable areas!
Use
If you are confused by this field then please drop me an email and I will try to explain it better.
Values of 16/32/64/128/256 are good depending upon your area/visible distance.
This algorithm allows you to maintain *massive* quantities of Grass easily but you must be aware of the memory usage. To this end, the replicator dumps various information to the console each time it creates Grass (@startup & Editor/Apply). You get information such as Node allocations/Time Taken for analysis and approximate memory usages.