From NeoAxis 3D Engine Wiki
|Language:||English • Russian||Status:||Approved|
Decals are a special geometry class used for increasing environment detail without adding it to textures.
Decals are usually used for rendering bullet marks, blood traces and explosion burns.
A NeoAxis decal is a geometry with an applied material. For example, a decal used to render a bullet hole usually includes two triangles. The decal geometry is created dynamically stretching on static solid objects (walls and floors).
New types of decals can be created and adjusted in the Resource Editor just as any game object.
Apart from single decals the NeoAxis Engine has also got a class implementing decal management. It is called DecalCreator and can be used for creating numerous decals (e.g. to create explosion burns). It also estimates if a decal should be applied to a certain surface. Objects of the DecalCreator type are used in all standard weaponry of NeoAxis Engine to render bullet marks (e.g. DefaultBulletDecalCreator.type in the "Data\Types\Decals\DefaultBulletDecal" folder).
This object is usually attached to a bullet (a game bullet type). You can find examples in the SDK. For example, Types\Bullets\ShotgunBullet\ShotgunBullet.type.
|ApplyToMapObjects||Sets whether decals will be applied to objects of the MapObject class. By default they are only applied to StaticMesh and terrain.|
|DepthRenderOffset||Surface indent for decal creation. If the z-fighting problem occurs this parameter should be increased.|
|FadeTime||The time for decal’s smooth vanishing.|
|LifeTime||Decal’s lifetime. If this is set to 0 the decal will not be removed.|
|Materials||Decal materials list.|
|MaxCount||The maximal number of generated decals of a certain type. If this is set to 0 the number of decals will not be limited.
This parameter is used to optimize rendering. For example, there is no need to keep all bullet marks on the map. You need only the last ones. By setting this parameter to 50, you will have no more than 50 bullet marks on the map. The old decals will automatically be removed.
|OmniMaxDistance||Is only used when SpreadType is set to Omni. Determines the maximal distance at which a decal can be created.|
|Size||The size of the generated decal.|
|SpreadType|| The way a decal is created. There are two possible values:
|AllowEmptyName||Whether the entity can has an empty name.|
|ClassInfo||The class information of type.|
|CreatebleInMapEditor||Whether the entity can created in the Map Editor.|
|Name||The name of type.|
|NetworkType||The network type of entity. Allow to choose one of the following values: NotSynchronized (not synchronized), ClientOnly (synchronized on the client only), ServerOnly (syncrhonized on the server only), Synchonized (completely synchronized).|
|AttachedObjects||The collection of attached objects.|
|PhysicModel||The name of physic model.|
Tutorial: Creating a New Decal Type
In this tutorial you will learn to create your own decals to use them as bullet marks.
Creating Decal Materials
Material is the basis for any decal. And the basis for any material is a texture. The material determines how a decal will look like.
Let us try to create a material. For example you can create green decals that will look like radioactive material stains.
To do this launch the Resource Editor.
First create a folder for the new decal. Open the Types folder, right-click on Decals and select the New Directory option in the context menu.
Give the name New Decal to the created folder. Right-click on it and select the New Resource option.
In the New Resource window set the type of the object being created to Material. Press the Continue button.
In the New Material Wizard window specify the name of the new material (NewDecal) and its type (ShaderBaseMaterial). Press the Next button.
Double-click on material file to open the edit mode.
Now apply a decal texture to the material by pressing the "..." button of the Diffuse1Map parameter in the Diffuse scrollbar.
For example, choose the standard texture for bullet marks by means of DefaultBulletDecal. It is located in Types\Decals\DefaultBulletDecal folder.
The texture has an alpha-channel which is not yet used in material. You have to turn it on first. To do this set the parameter Blending to AlphaBlend in the _ShaderBase scrollbar.
Finally, to make the bullet marks glow like radioactive substance set the EmissionColor parameter’s value (in the Emission scrollbar) to green (Green - 255).
The material has been created. Now you only need to save it.
Creating a Game Object
Now you have to create a game object which is not simply a decal but a decal creator (decal manager). It enables to generate of decals. The creator estimates whether decals can be created at a certain surface and then creates them.
Create a new resource by right-clicking on the NewDecal folder and selecting the New Resource option. Select Entity Type in the window that will appear. Then press the Continue button.
In the Entity creation window specify new object's name (NewDecalCreator) and type (DecalCreator). Now press the Next button.
Go to edit mode by double-clicking on NewDecalCreator.type file.
As it was said before, material is the main component of a decal. So, you will need to add it to the decal creator. Press the "..." button of the Materials parameter.
In the window that will appear select Add.
Now, specify the name of the file to contain the new material. Click the "..." of the MaterialName parameter.
Now select the created material (NewDecal.highMaterial) and press the Ok button.
In the window with the material list press the Ok button to finish adding the material to the decal creator.
Now you have to adjust other parameters of the decal creator. Set the FadeTime parameter to 2, the MaxCount (maximal decal number) parameter to 10 and the Size parameter to 0.2.
Now save the created game type.
Attaching Decals To a Bullet
This is the easiest part of the tutorial. You will have to attach the created decal creator to a bullet.
For instance, use the NeoAxis standard shotgun shot. Double-click on the ShotgunGravityBullet.type file in the Types\Bullets\ShotgunGravityBullet folder.
The bullet mark appears when the bullet is removed. Thus, the decal creator is added to the DieObjects list including all the objects that are to be created as this object is removed. Press the "..." button of the DieObjects parameter.
There is already a decal creator attached to ShotgunGravityBullet. You need, however, to change it.. Select DefaultBulletCreator in the Members list and press the "..." button of the Type parameter.
In the window that will appear select NewDecalCreator.type you have created and press the Ok button.
The changes have been made. Now you can press the Ok button in the DieObjects window.
Save the edited ShotgunGravityBullet.type.
Now you can start testing. Launch the Game.exe file (from the Game\Bin folder). Load the PhysicsDemo map to test the radioactive traces you have created. Take the shotgun and shoot the wall with alternative fire (right mouse button). You should get marks that will look like this.
Making Decals by means of Map Editor
Making decals in the Map Editor is not supported at this time.