Foliage Generator Brief Overview

Creating anime-looking bushes and trees requires not only specific shading but also properly created models in regards to display of the shading. This also applies to creating 3D clouds.

Of course, this can be done using a 3D-editors’ particle systems by combining both big and small emitters, but the good-looking plants would easily have 50 thousand vertices per model.

So, another way is to create models from textured planes. The plants are usually modelled by placing (either carefully or haphazardly) the planes that contain the textures of the branches. The problem is that each of the quads has its own normal. After rotating and moving all the quads while forming, let’s say, a bush, all the normals would also be chaotically rotated and pointed in all imaginable directions. Thus, later in Unity, the shader would take each of the quads and apply its shading using data from all of these chaotic normals. Such a bush usually would not look well.

Knowing this, you’d make the normals look better by borrowing them from something more simple like a sphere. But creating a bush and its variations still would take much time. Also, changing the number of faces sound like a hassle.

Foliage Generator prefab/component allows you to create a plant or a cloud in a few minutes, and then make changes instantly. It automatically forms the model from the ‘branch’ of your choice, wraps its copies (as many of them as you’d need) around a carrier model and handles the normals.

After generating, the model appears in your project folder ready to be dragged onto the scene. Then you’ll need to just apply a material with the Foliage or Cloud3D shader containing a particle texture. We did all the foliage and 3D clouds models in the demo scenes this way. Quibli includes already made models, textures and materials.
Another beautiful thing is that Foliage Generator can take external models (there are nuances — described here) and prepare their normals and apply the particles for you.
Quibli Foliage Generator Interface

Quibli Foliage Generator Interface

Please, note that Foliage Generator doesn’t produce the trunks of the trees, neither does it create conventional flower plants. It works with included as well as external meshes and processes them so that the generated plants can work as stylized leafy parts of the foliage. However, using the proper textures and a bit non-literal approach, the floral decorations can be created with the Foliage Generator.

It is highly recommended that you opened, for example, the Plants demo scene, located any of the plants in the Hierarchy panel and experimented with its own Foliage Generator instance. Pressing Export Mesh, will update this model. This way you can get to know the parameters better. And, please, remember that all parameters have mouseover tooltips. If you find any of them unclear, please, shoot us an email an we’ll try to improve them.

Beginning to work with Foliage Generator

The Foliage Generator can be loaded into a scene in two ways.

Loading Method #1 — Prefab

To start working with the Foliage Generator as a Prefab, please do the following:

  1. Locate the Foliage Generator prefab in Project panel ▶︎ Assets folder ▶︎ Quibli folder ▶︎ Common Resources folder ▶︎ Prefabs folder;
  2. Drag it to the Hierarchy panel or directly into the scene;

Loading Method #2 — Component

Another way to add the Foliage Generator to the scene is to use it as a Component.

  1. Create an empty Game Object: right-click in the empty space in the Hierarchy panel ▶︎ select and click Create Empty;
  2. Select the created empty Game Object;
  3. In the Inspector panel, please, click Add Component;
  4. Search for ‘Foliage Generator’, or locate it manually under Scripts ▶︎ Dustyroom ▶︎ Foliage Generator. Click on it once found;
  5. It is ready to be tweaked.

Operating the Foliage Generator After Loading

When you have the Foliage Generator loaded to the scene, you’ll probably want to adjust the parameters or load an existing preset and will need to apply a material to an exported mesh — to finalize the plant model. Please, keep reading this chapter to get acquainted with the details of doing these steps.

  1. Adjust needed parameters or load a preset. The explanation of the parameters can be found below;
  2. Click Export Mesh button;
  3. Locate an exported model in the export target folder. The path to this folder is set in the Folder Path parameter in Parameters of Export;
  4. Add this model in your scene (it looks pink);
  5. Apply the material to it.

Parameters of the Foliage Generator

Generation Parameters

Generation A group of parameters that control the creation of the plant mesh.

  • Carrier Mesh The triangles of this mesh are used for placement of the spawned Particles. Quibli comes with a handful of these. Also, of course, you can create your own ones. Think of it as a ‘core’ of the future plant/cloud model.
  • Particle Mesh The building block of the foliage. Multiple copies of this mesh are combined in the exported mesh. In other words, this is what would be a ‘branch’ of the plant. These particles aka branches are applied to the Carrier Mesh to form the resulting plant model. You can use the simplest Quad model from Unity or select one from Quibli’s package.
  • Carrier Scale Scaling applied to the Carrier Mesh when spawning Particles. The bigger the Carrier Mesh, the more pronounced the shape of the resulting plant model would be.
  • Particle Scale Scaling applied to each individual Particle. This parameter controls how large the ‘branch’/’puff’ of the plant/cloud model would be. The smaller the values the more detailed the resulting mesh is going to be. More so, if the Carrier Scale values are high, smaller branches will contribute to the overall shape of the Carrier Mesh. If the Particle Scale values are high, the resulting plant’s look would have less of the initial Carrier Mesh’s shape. Lower values (~0.05—1) are good for non-billboards and billboards in Each Face mode (which is set in Foliage Shader), higher values (~0.5—3) are suitable for billboards in Whole Object mode, explained here.
  • Particle Scale Variance Randomness of scale applied to each individual Particle.
  • Particles A number of Particles to generate. In other words, this parameter sets how many of the branches the plant will have. Higher values (~250—1000) are good for non-billboards and billboards in Each Face mode (which is set in Foliage Shader), lower values (~25—150) are suitable for billboards in Whole Object mode, explained here.
  • Placement Type Determines how to distribute the particles over the Carrier Mesh. Parameter has two options: Random and Uniform. Random populates the particles chaotically, Uniform distributes the particles evenly over the Carrier Mesh’s surface. It is an important parameter for billboarding, explained here.
    Foliage Generator Particles Placement Type menu

The Placement Type parameter in Uniform mode is useful when engaging Billboard RotationEach Face mode in the Foliage shader, described here.

The Placement TypeUniform mode is suitable for 3D clouds making, as the Billboard RotationEach Face mode is hardwired in Cloud3D shader.

  • Offset Along Normal ‘Inflates’ the mesh by moving each Particle along the Carrier Mesh normal by this value.
  • Fraction of Particles Defines which particles offset is applied to. The value of 1 means all particles are offset. Useful to create branches that stick out of the general foliage shape. This parameter is grayed out when Offset Along Normal is at the value of 0 — as soon as you change the latter, the former will become available for tweaking.
  • Particle Rotation Range How much Particle rotation can deviate from Carrier Mesh normals.
  • One Normal Per Particle If enabled, the vertices within each Particle will have the same normal values.

Billboard Whole Object Parameters

Billboard Whole Object is a group of parameters that prepare rotation of the Particles in order for the generated mesh to be used as a Billboard. Billboarding is explained here.

  • Particle Rotation Bias Forces the Particles to face the positive X axis.
  • Bias Toward Rotation Sets the rotation on the axis for the Particle Mesh.

TIP. Particle Rotation Bias is useful for billboard foliage. ‘Billboard’ means that the meshes always face the camera regardless of the camera’s position and rotation. It is a handy feature because you can make up the plant model from only a handful of planes to spare resources, and this plant will always create an impression of a more complex one.

Normal Noise Parameters

Normal Noise is a group of parameters that control the nonlinearities in the normals of the generated mesh.

  • Enable Turns the Normal Noise group on.
  • Frequency The period of the cycle at which the noise is sampled. In other words, how dense the noise is.
  • Amplitude The range of the noise from its minimum to its maximum effect.
  • Octaves The number of layers of details of the noise. Combining low-level with high-level details results in more natural-looking output.
  • Scale The scale of the internal noise map that controls the nonlinearities.
  • Seed A fixed ‘footprint’, or a ‘snapshot’ of the noise.

Parameters of Export

Export is a set of parameters for controlling the export process of the generated mesh.

  • Folder Path This is where the generated model will go once you export it. You can type in any path starting with ‘Quibli’, or leave it blank to export the mesh into the Assets folder. If the target folder doesn’t exist, the script will create it. For instance, all common generated models are here (copy and paste this path in the File Name Prefix field):
    Quibli/Demos/[Common]/Models/Foliage Generator Exported Meshes
  • File Name Prefix is a part of the title of the model that is going to be generated.
  • Append Mesh Name Adds the Carrier Mesh name to the name of the exported mesh.
  • Append Take Number Adds the value from the Take Number field to the exported filename.
  • Take Number This is the current iteration number of the model. Only used if “Append Take Number” is enabled.
  • Append Timestamp Enables the option to add time to the name of a generated mesh.
  • Export On Edit If enabled, the mesh will be automatically updated and overwritten upon every change of any of the parameters of the Foliage Generator. It is useful for a rapid preview of the changes to the parameters.
  • Debug / Export Debug Mesh This is the tick box, which lets you export the initial Carrier Mesh without the branches / Particle Meshes but with all the processing applied to it. It is useful if you need to see what’s going on if you are struggling with the shape and look of the filial generated foliage model.
  • Export Mesh This is a button, which generates the final foliage model. Once generated, it is placed in the folder selected in the Folder Path parameter’s field. To use this mesh in your scene, drag and drop it from that folder to the scene. The model will look pink at first, because so far it has no material applied onto it. You can use the ready materials from the Demo scenes or create your own. Shading the exported models is described here.

Every time you press the Export Mesh button, the generated model is slightly different, as each time the new seed of random is used.

When a model is generated, the Foliage Generator gives this model a name, which consists of prefixes like ‘Carrier Mesh’, a word from the ‘File Name Prefix’ field and an optional time stamp. Pressing Export Mesh will always create a new model every time you use a different Carrier Mesh (because the exported name will be different). Otherwise, Export Mesh will just overwrite the existing model and will update it in a scene.

TIP. It is convenient to use presets with Foliage Generator: every time you export a nice model, save the parameters for later. After changing everything up on the Foliage Generator interface you can always load a preset (preferably previously titled in a proper way) to fix that bush that bothers you, as long as the name of the existing mesh is going to be the same as the name of the re-exported mesh.

How to Create a Basic Plant/Cloud

A brief tutorial on creating and shading a basic plant in non-billboard, billboard ‘Each Face’ and billboard ‘Whole Object’ modes

Creating a finished model consists of two steps:

  1. Generate the mesh from Mesh Carrier and Mesh Particles using Foliage Generator, export it. The exported model will have only the Particles visible, the Carrier Mesh won’t be exported.
  2. Shade the plant model using Foliage Shader, where you apply the colors, textures of branches to the Particles, wind and make the model a billboard or a non-billboard. For the 3D cloud models, please use the Cloud3D shader. The Cloud3D shader has an embedded billboarding (Each Face type, we’ll explain it later in this documentation).

When creating a plant (or a cloud — they have common creation approach) model, we suggest to think in advance how many particles it should have, where it will be placed in the scene and how large the Particles and Carrier Mesh are going to be. It is important, because in the end the mesh will be made either as billboard or non-billboard/regular mesh. In addition to this, billboarding is the way to create uniquely looking plants/clouds, which are impossible to create otherwise.
If you are going after a non-billboard model, the number of Particles is going to be high (something like 500—1000) — to cover whole Carrier Mesh surface area without gaps. The size of Particles is usually small (around 0.05—1) — should the particles be high, the non-pleasant plane intersections will be visible. These ranges apply to billboards in Each Face mode as well.
If you are making a model as a billboard in Whole Object mode, the Particles may be bigger and you can have much less of them: you won’t see the _Particles from the sides and the intersections won’t be as much obvious. For such billboards, the shader will take this handful of Particles and ‘squash’ them in the camera direction, which will create an illusion of the full-bodied model.

Below you can see how billboard and non-billboard behave with camera’s rotation and position change. This behavior is set in Foliage shader.

Billboard: Nothing Billboard: Each Face Billboard: Whole Object

Billboard approach

Billboard means that the whole object or just its particles/branches always look into camera. Whether it’s a whole object or only its particles is determined by the Foliage Shader’s Global Billboard parameters, as well as by some of the Generation Parameters here, in the Foliage Generator. Particularly,

  • In Foliage Generator:
    • Particle placement type Particle Placement Type
      You’ll need to choose between Random placed branches: for chaotic branch distribution, or Uniform placed branches: for the branches to be placed on the faces of the Carrier Mesh. Please, look into the descriptions of these parameters, described above. For 3D cloud creation, we suggest using Uniform mode.

    • Billboard whole object group of parameters (Particle Rotation Bias and Bias Toward Rotation) Billboard Whole Object group
      If you want the whole mesh to be looking into the camera, set Particle Rotation Bias to the maximum right position. It will force the branches always look where the following parameter, Bias Toward Rotation, is set. Here you don’t have to change anything from zeroes if you have already camera-facing Mesh Particle, which you can see in the small mesh preview icon in the parameter’s interface. If it is facing any other direction, you’ll need to rotate it using Bias Toward Rotation parameter’s axis.

  • In Foliage Shader:
    • Billboard Rotation parameters, described in detail on the Foliage Shader page here.
      Particle Placement Type
      If you want the whole mesh to be looking into the camera, please, choose Whole Object. Usually, for the construction of such billboard models you’ll need only up to 25—150 large (value of ~1) Particles, which is relatively low poly, if you use a Quad as a Particle Mesh (Carrier Mesh and Particle Mesh are described above in the Generation Parameters).
      If you want the mesh itself NOT to be rotating, but rather its particles/branches, please, choose Each Face mode. It is better to use Each Face mode in conjunction with Uniform Particle Placement Type parameter of the Foliage Generator, described above.

Non-Billboard approach

Non-Billboard foresees the commonly understood behavior of the meshes: they do not rotate with camera movement and they usually require more particles in order to cover its whole surface area, unlike the billboards, where only the front (in ‘Whole Object’ Billboard mode) or only the particles/branches (in ‘Each Face’ Billboard mode) of the model will always be visible to the camera.

Shading Generated Model

The Foliage Generator and Foliage shader with Cloud3D shader are best buddies. These shaders work specifically on the models created by the Foliage Generator. Particularly, Billboarding has to be set in both Foliage Generator and Foliage Shader.

The Foliage Generator script makes up a mesh ready to be imported in your scene, but to finalize its look, the material is needed.

  • For foliage Use the specialized Foliage shader. Its niche controls give access to finer details in regards to finalizing the shaping of the models look, and not only the coloring. It has a Wind set of parameters, the color controls are more streamlined for working with Foliage, a separate slot for alpha clipping map. The beautiful thing is that this shader can also turn the foliage models not made by the Foliage Generator into plants. More on this you can find in Foliage shader chapter.
  • For the clouds, use Cloud3D shader.

When you drag the exported plant or cloud model into the scene, you’ll notice that it is pink, which tells that it is has no material yet. You can create a Foliage or Cloud3D material or choose one the bundled materials coming with Quibli, and either drag it onto the model, or select a material in the model’s Mesh Renderer.

Using Your Own Models

Foliage Generator can process external models that are used as Carrier Meshes (more about what is a Carrier Mesh is here). Foliage Generator processes the normals and UVs of those meshes according to the parameters you set in its interface, so that the applied particles would look suitable.

Distribution of the polygons for custom Carrier Meshes
For custom Carrier meshes, it is recommended to use the models that have as even quad distribution as possible. Such models would carry the particles evenly, so that the exported meshes won’t have unfilled gaps on their surface.

Another important moment in choosing a custom Carrier Mesh is to look if it is convex. Even if the model is concave, it is still better to not use the solidified thin models that have big parts of surface closely located. In the example below you can see that outer and inner surface parts of the vase are located very closely to each other. In the end Foliage Generator will place branches on both outer and inner parts of the vase, and in addition to that, they will be crossing each other.

Try not using thin solidified models
Please, try not using thin solidified models, as the particles will be on both sides and they may be crossing each other badly.

Next Steps After Using Foliage Generator

Updating Existing Exported Models

If you didn’t change the name of the exported model after you created and used it, and given that you didn’t change any parameters that contribute to the name of the exported mesh in the ongoing Foliage Generator interface (see the descriptions of the parameters above), you can always come back to the Foliage Generator in any of the scenes (load the script anywhere, anytime) and update the exported mesh — change the Particle Scale or Particles parameters, for example, as soon as the model is exported, it will update existing one. That’s where saving presets of the Foliage Generator is useful. Please, see the screenshot below.

Using the Preset menu for the Foliage Generator

Using the Preset menu for the Foliage Generator

Comments