Tutorials » Rendering » How to render particles

The Untold Engine provides a Particle System which allows you to develop 3D particles as shown below:

Image

Note: Please make sure to read the Untold Engine Toolchain before continuing on with this tutorial. All images and .pex files must be converted to binary format (.u4d) using the Digital Asset Converter.

Particle Designer

To make it easier for you, the Untold Engine supports a third-party application known as Particle Designer. Particle Designer is a powerful particle effects editor.

Image

Particle Texture

To render a particle using the Untold Engine, you must provide a particle's texture. Fortunately, the Particle Designer gives you the ability to export the texture of the particle to the same folder that contains the particle's data. To do so, make sure to UNCHECK the Embed option.

Exporting Particle Emitter

To export the particle emitter parameters, select the appropriate parameters. Before you export the file, set the export type to PEX, as shown below. And then click on Export. A PEX file with your desired Emitter name will be generated. You will use this file shortly. Note, this file contains the PEX and the Texture data of the particle.

Image

Creating a Particle System

Before you can render particles, you must load the particle's data. The loading is done through the use of U4DEngine::U4DResourceLoader class. The class loads the binary files (.u4d) representing the particle's attributes as shown in (line 1a) and textures (line 1b).

Note: The Particle Designer exports the particle's data to a PEX file. However, before you can render particles using the Untold Engine, you must convert it to a binary file (.u4d) using the Digital Asset Converter.

Creating a Particle System using the Untold Engine is easy. Simply create an instance of U4DEngine::U4DParticleSystem as shown in line 2. Next, load the particle's name as shown in line 3. Load the attributes of the particle system into the GPU (Line 4). Add it to the scenegraph (line 5). And finally, initiate the particle's emission as shown in line 6.

//1. The U4DResourceLoader is in charge of loading the binary file containing the scene data
U4DEngine::U4DResourceLoader *resourceLoader=U4DEngine::U4DResourceLoader::sharedInstance();

//1a. Load particle file
resourceLoader->loadParticleData("particleemitter.u4d");

//1b. Load texture that contains the particle's texture
resourceLoader->loadTextureData("astronautTextures.u4d");

//2. Create a particle system
U4DEngine::U4DParticleSystem *particleSystem=new U4DEngine::U4DParticleSystem();

//3.Load the particle's attributes file and particle texture into the Particle System entity
if(particleSystem->loadParticle("particleemitter")){

    //4. load the attributes into the GPU
    particleSystem->loadRenderingInformation();

    //5.add the particle system to the scenegraph. If you are using a Skybox, make sure to set the proper order of the particle system in the scenegraph. In this instance,
    //I set the order to -5
    addChild(particleSystem,-5);

    //6. initiate the particle's emission
    particleSystem->play();

}

You can also set other parameters for the particle system, such as Enable Additive Rendering, noise and noise detail.

particleSystem->setEnableAdditiveRendering(true); //set true by default        
particleSystem->setEnableNoise(true); //set false by default
particleSystem->setNoiseDetail(2.0); //ranges from [2-16]