IMPORTANT: Creating custom materials is considered experimental and requires to enable “Developer Mode”. The new experimental material editor will be improved in the coming versions.
Overview
Each renderer has an associated material defining properties for this renderer:
Default_Billboard material applied to a billboard renderer
Materials ?
Materials are regular assets contained in the PopcornFX project, with the “.pkma” extension:
The following materials are available in all projects (one per renderer):
- Default_Billboard.pkma
- Default_Ribbon.pkma
- Default_Mesh.pkma
- Default_Light.pkma
- Default_Sound.pkma
Custom materials:
- Distortion_Billboard.pkma
- Distortion_Ribbon.pkma
- Transparent_Mesh.pkma
- Opaque_Billboard.pkma (new in 2.3.0)
- Opaque_Ribbon.pkma (new in 2.3.0)
Rendering features ?
PopcornFX SDK does not take care of rendering particles, so materials contain rendering features. They are higher level representations (hints) of how the particles are drawn. Here are a some example rendering features which could be available in a material:
- “Lit” – Particles rendered by this renderer are lit by engine lights
- “Soft particles” – Particles rendered by this renderer require depth distance fade
- “Transparent” – Particles are either additive, alpha blended or premultiplied alpha
We designed rendering features to be modular, cross-engine and simple enough for everyone to understand. Some game engines might support custom rendering capabilities for particles: rendering features are designed for that.
Note: PopcornFX is designed to be compatible with all game engines, so we limit the list of default rendering features to a set supported on all engine integrations we develop. Nothing stops a production to design custom rendering features, but it will break rendering compatibility with other game engines (and could prevent selling engine-agnostic content on a marketplace).
See rendering interface for more detail.
Renderer, Material, Rendering features
By default, all renderers select their default material (ie. Default_Billboard.pkma for a billboard renderer):
- Renderer specific properties
- Renderer features can be enabled/disabled
- Material file
- “Transparent” renderer feature is a “mandatory feature” in Default_Billboard.pkma, its properties are always displayed
- “Diffuse” renderer feature is a “mandatory feature” in Default_Billboard.pkma, its properties are always displayed
- “Atlas” renderer has been enabled in section #2, so its properties are displayed
- Renderer feature properties can add pins to renderers
Changing a renderer’s material changes the list of available rendering properties. Sections appear when rendering properties are enabled:
- Alpha remap properties appears when the feature is enabled
- Atlas properties appears when the feature is enabled
- Soft particle properties appear when the feature is enabled
- Different material selected changes the list of properties available for the renderer
Various rendering examples are available in the tutorials effect pack.
Materials / shaders
As renderer features are high level parameters and not shaders/material graphs, you might wonder how those renderer features are plugged in the final material/shader. Each PopcornFX integration handles that by remapping renderer features and their properties to the game engine material system.
UE4 billboard material:
- Diffuse texture, retrieved in the material via a Texture2D parameter named “DiffuseTexture”
- Particle color, retrieved using the “VertexColor” node
- Having an atlas provides the correct sub-UVs in the Texcoord node, ready for sampling.
- Linear atlas blending is enabled, another set of UVs is filled for the material
- Static switch set from c++ when linear atlas blending is enabled
- Lerp cursor is passed into DynamicParameter.x
Another example with a mesh material in UE4:
- Specular texture, retrieved in the material via a Texture2D parameter “SpecularTexture”
- Normal texture, retrieved in the material via a Texture2D parameter “NormalTexture”
- Static switch set from c++ when a valid specular map is available
- Static switch set from c++ when a valid normal map is available
Editor shaders
PopcornFX Editor does not have a material graph editor, but supports an HLSL-like editor:
The vertex and fragment shaders of a material can be edited in that editor (see Material editor).
Note: That shader code is editor only, it is not exported to UE4, Unity, Lumberyard or custom game engines.