для этой страницы,
отображается код на другом
Migrating to UNIGINE from Unity: Content Creation
As well as in Unity software, mesh is the main graphics primitive in UNIGINE. Being imported to the project, an FBX asset appears as a container for all meshes it stores in the Asset Browser.
In Unity Editor, you access the content of an FBX asset using the arrow button next to it:
Both meshes and read-only materials appear as components of the asset.
In UNIGINE, you can do the same by right-clicking the asset and choosing Open:
Every separate object in the FBX model is represented by a .mesh runtime asset. Materials (if there are any, provided the Import Materials option was enabled) are generated in the materials folder next to the asset.
To create a node that uses the mesh or fbx asset you can simply drag it to the Editor Viewport the same way you would do in Unity Editor. In UNIGINE this will add a Mesh Static object to the world hierarchy.
Here Surfaces come into play. A surface encapsulates a sub-mesh having a certain material assigned (in third-party 3D editors) and has the name according to that material. For convenience, surfaces can be rearranged in a hierarchy and toggled on and off. Optimization settings you would set for the whole mesh in Unity Editor, such as contribution to lighting and probes, are available for each surface separately.
Levels of Detail (LOD)#
In Unity software, you are likely to be used to using the LOD Group component enabling you to operate several detail levels, the active LOD is defined by the threshold based on the ratio of the mesh's screen-space height to the total screen height.
In UNIGINE, levels of detail are configured based on distances — in a more low-level manner to make fine tuning available. Surfaces have visibility settings for this purpose. You can set the minimum and maximum visibility distances from the camera for each surface. For Cross Fading use the Minimum and Maximum Fade values.
FBX models containing bone-animated skinned meshes create animation clips when imported in both engines. In UNIGINE, such clips are represented by .anim assets.
Skinned Mesh object is an analog for Unity Skinned Mesh Renderer component for handling bone animations.
Unity software provides a sophisticated animation system (sometimes referred to as 'Mecanim'). It implies using Animator Controller — a state machine that manages animation states and transitions between them.
The UNIGINE's skinned animation system is focused on operating animation layers: you can configure multiple layers with various animation clips and perform blending between them by using API methods.
For more details refer to the following articles:
The same way Mesh Skinned object supports morphing. If a mesh has blend shapes (sometimes referred to as morph targets for some 3D editors) assigned in a third-party 3D modelling software, they will be available internally as surface morph targets (provided the Import Morph Targets was enabled for the imported asset).
Unity Skinned Mesh Renderer component lists the imported Blendshapes in the parameters:
In UNIGINE, multiple animation morph targets (i.e. morph layers) are created based on the available surface targets and blended manually using weights via API methods.
Follow the related tutorial for more details:
Materials and Shaders#
In Unity software, you are accustomed to create user materials that implement a certain shader, depending on the applicability of this shader to a Renderer component type. As an example, you use materials implementing physically based Standard surface shader (or Lit in URP/HDRP) to be used with Mesh Renderer.
In UNIGINE, material system is formed by base materials and user materials inherited from them.
A base material is a set of read-only material properties (basically flags, parameters and textures) referring to fragment, vertex and geometry shaders. Base material can be assigned to nodes (or surfaces) of the type it is bound to. UNIGINE provides a rich out-of-the-box library of base materials and standard shaders that can be used to create almost any appearance for all the types of nodes available in the engine.
We create user materials by inheriting them from base materials to override some properties passed to shaders on rendering. When creating a material in the Asset Browser, we choose the base material to inherit from, thus defining the type of objects the new material will support.
Furthermore, user materials can form a hierarchy for convenience. So, when parameters of the parent material are changed, overridden parameters of its children remain the same.
Lighting and Environment#
The same way as in Unity software, lighting in UNIGINE can be considered as either realtime or precomputed. A set of objects and tools enables you to get benefit from the both approaches.
In Unity software, light sources are represented by the Light component. UNIGINE provides several types of light sources similar to the ones of Unity software.
|Light Source||Unity software||UNIGINE|
A light source located at a point and sending light out in all directions equally.
A light source type providing a cone-shaped region of illumination.
|A type simulating an infinitely distant light source and casting parallel beams onto the scene.||
|An area light that illuminates objects in different directions at once.||
Area Light: Rectangle and Disc shape
|Emissive objects emitting light across their surface area.||
|Global flat filling lighting.||
In Unity software, light sources can be in Realtime, Mixed and Baked modes and cast realtime shadows by default. When it comes to light baking (including shadows), Unity workflow implies using Lightmaps. The way of considering GameObject's contribution to light baking is defined by its Static flag and a bunch of other parameters.
Considering the concept of realtime and precomputed shadows, UNIGINE provides both types of shadows from light sources.
Shadows are cast using a commonly used technique called "Shadow Mapping". All light sources can be either in Dynamic or Static mode according to which it is decided if shadow maps are computed in real time or saved in an asset, thus significantly reducing the number of polygons rendered each frame. Apparently, moving lights should be Dynamic, we can't precompute shadows cast from a moving light source.
The Mixed or Static Shadow Casting Mode of a light source filters the surfaces that cast shadows from it. By using the Mixed mode you can combine baked shadows from static geometry and realtime shadows cast by certain dynamic meshes. Use the Shadow Mode to decide whether the surface is static or dynamic.
To learn more about configuring different types of shadows, watch the dedicated video tutorial:
World light source, as well as Unity Directional light source, uses an advanced shadow mapping technique called Parallel-Split Shadow Mapping to handle shadows at large distances. The shadow settings are available per each light source.
For texture modulated lights Unity software has a special type of textures: Cookie.
In UNIGINE, you can use an arbitrary flat diffuse or albedo texture in the Texture parameter of a Projected Light. The same way you can apply texture modulation to an Omni Light by using a cubemap texture.
Modulation by texture
Modulation by cubemap
In Unity Editor, scene environment settings are placed in the Lighting window (menu: Window > Rendering > Lighting Settings). The Environment section contains settings for the skybox, diffuse lighting and environment reflections.
In UNIGINE, similar Environment Settings are available in the Render Settings (choose Window -> Settings in the main menu, then in the Settings window go to Runtime -> World -> Render -> Environment).
UNIGINE provides three environment presets, by configuring which you can create a smooth transition between different weather conditions.
In order to achieve physically correct atmosphere rendering, UNIGINE's environment system simulates Scattering by interpolating certain LUTs (Look-UP Textures). When configuring environment lighting you should consider all the settings combined. For more details visit the dedicated article.
You can set a cubemap texture as the Environment Texture (a Unity Skybox counterpart) for both sky color and reflections.
Additionally, Unity Editor allows to specify a different environment skybox for the camera by using the Skybox script.
In UNIGINE, you can use a Sky Object recreating the atmosphere in the scene. It can represent a hemisphere or a full sphere with a cubemap assigned, tiled with clouds texture to produce plausible and inexpensive dynamic clouds.
To simulate fog in Unity software, you are accustomed to use the Other Settings section of the Lighting window when using Forward Rendering Path, and the Deferred Fog feature from the Post Processing package when using Deferred Rendering.
For the same purpose in UNIGINE you can use Environment Haze in the Solid mode or, if the difference between haze and fog is crucial for your project, use Volumetric Objects — they are great for simulating light beams and shafts, fog and shaped clouds.
Unity software provides a set of advanced systems that model indirect lighting significantly improving the realistic look of the scene. So does UNIGINE. This section lists Unity GI techniques and ways to get the same or similar results in UNIGINE.
Unity software provides path-tracing-based lightmappers enabling to pre-calculate (bake) the brightness of surfaces in a scene and store the result in a light map for later use at run time. It requires non-overlapping UVs with small area and angle errors, and sufficient padding between the charts.
In UNIGINE, lightmaps are also supported and baked using the integrated GPU Lightmapper tool.
UNIGINE provides another advanced solution for static GI — Voxel Global Illumination provided by Voxel Probes.
A voxel probe is a box-shaped volume composed of voxels of fixed size, providing both pre-calculated indirect lighting and diffuse (blurred) reflections. One of advantages of this approach — there is no need in UV coordinates, any geometry will contribute to GI with no issues.
Light baking is performed using Bake Lighting Tool.
As concerns realtime, Unity real-time lightmaps are mainly useful for lights that are animated at run time. For such cases UNIGINE features the SSRTGI (Screen-Space Ray-Traced Global Illumination) technology enhancing overall connectedness of the scene a lot.
In Unity software, information about light passing through the empty space in the scene is handled by Light Probes. The primary use of light probes is to provide high quality lighting (including indirect bounced light) on moving objects in the scene.
In UNIGINE, you can achieve the same result by using a Voxel Probe. The Bake Internal Volume parameter enables to choose the quality and time required to bake GI for empty voxels (i.e. the voxels that do not cover any geometry).
An almost complete counterpart for Unity Reflection Probe is the Environment Probe. These reflection providers store a cubemap texture to be rendered on reflective surfaces.
The Static, Realtime and Custom modes are also available for environment probes:
Realtime Mode. The cubemap is grabbed each frame providing real time reflections and a massive load on the CPU.
Static Mode. The environment probe uses a pre-baked cubemap obtained using the Bake Lighting tool. This mode suits mostly static environments.
Custom Mode. The static mode with a custom cubemap texture assigned.
Box projection is supported as well:
Furthermore, spherical environment probes can be subject to Parallax effect controlled by the corresponding parameter. While the 0 value implies projecting the reflection on an infinitesimally far sphere, the value of 1 corresponds to the actual probe's bounding sphere taking into account the viewer's perspective.
Lately Planar Reflection Probes were added as a part of Unity High Definition Render Pipeline (HDRP). This component is responsible for providing dynamic planar reflections and shares many properties with the conventional Reflection Probe.
In UNIGINE, planar reflections are implemented as Planar Reflection Probes too.
Baked Ambient Occlusion#
Unity GI system is also equipped with Baked Ambient Occlusion, a part of pre-computed illumination which darkens creases, holes and surfaces that are close to each other. Unity Editor supports baking AO out of the box.
UNIGINE has no built-in baking tool for AO, nonetheless, it is possible to apply an additional ambient occlusion texture generated using third-party software in the mesh_base material settings.
Audio and Video#
In Unity software, Audio Source components play back Audio Clips. There must be an Audio Listener component, usually attached to the main camera by default, to make the sounds audible. The Spatial Blend parameter of the Audio Source component allows controlling the blending between 2D and 3D spatial sound.
In UNIGINE, Sounde Source node type is responsible for playing back an audio asset. It provides a surround effect the same way as it does Unity software. There is no such entity as the Unity Audio Listener — all sound sources that appear in the world are audible. While many parameters seem rather familiar to you, such settings as Doppler level, Attenuation (Rolloff) function and other, including Audio Mixer channels, are available only globally in the Sound section of the Settings window.
UNIGINE supports HRTF (Head Related Transfer Function) out of the box, so imitation of surround sound for stereo headsets is close to real life.
Another sound source entity in UNIGINE is the Ambient Source used to create a non-directional ambient background sound (e.g. background music). It has no position in the world and, therefore, can't be represented as a node. So it is available only via API.
Just like Reverb Zones in Unity software, UNIGINE's Sound Reverb objects represent reverberation zones where ambient sound effect appears provided the player is within the zone. With fine-tuned parameters a reverberation zone correctly reproduces the way the sound is reflected from surfaces, forming three main components:
- Early reflections
- Late reverberation
Besides that, a number of parameters can be changed to alter the type of environment being simulated. A number of presets may help you to quickly choose the most suitable type of environment to simulate:
By adjusting the Threshold parameter you can enable smooth sound transition when the listener moves from the outside area into the reverberation zone.
Unity software provides an advanced Video Player component capable of rendering videoclips of various formats to textures and other targets.
In UNIGINE, video playback is supported only in a virtual monitor as a part of GUI system. Currently only *.OGV files are supported.
Unity software provides mipmap-based Texture Streaming. This system reduces the total amount of memory Unity software needs for textures by loading only the mipmaps that are needed to render the current camera position in the scene.
The Texture Streaming settings are provided in Unity Quality Settings.
In UNIGINE, textures streaming is a part of the advanced Asynchronous Data Streaming system. This system is intended to reduce spikes caused by loading of graphic resources, such as meshes and textures. Only the resources that are required to render the current camera view are loaded; and unloaded as soon as other resources require to be loaded to video memory in order not to exceed the specified memory limits. Uploading is time-sliced so as to avoid spikes when the world is just loaded.
Settings for fine adjustment are available in the Streaming section of the Settings window:
Asynchronous Texture Upload#
Unity Asynchronous Texture Upload technique enables time-sliced upload of texture data to GPU.
UNIGINE's Asynchronous Data Streaming system uses pre-cached minimized copies of textures — Texture Cache. On world loading the texture cache is loaded first, giving a preliminary content for the scene, whilst full-size textures are being asynchronously loaded.
In Unity Editor you can bake static GameObjects with the Static Occluder flag enabled into View Volumes for Occlusion Culling to define the geometry that will block the GameObjects with the Static Occludee enabled from rendering. This technique extremely reduces the number of polygons rendered.
Also, it is normal for you, as a Unity user, to define View Volumes using Occlusion Areas and use Occlusion Portals to represent GameObjects that can be both open and closed in terms of blocking the sight, such as doors.
In UNIGINE, Occlusion Culling technique is represented by two methods:
Draw Call Batching#
Draw call batching in Unity software is a way to reduce the number of draw calls by combining static GameObjects sharing the same material into big meshes. In order to take advantage of static batching, one needs to enable the Batching Static flag of a GameObject:
As well as Unity software, UNIGINE performs Draw call batching: all opaque surfaces are automatically grouped and rendered in batches according to materials assigned, thus decreasing the number of DIP calls and, therefore, increasing the performance. This is why sometimes it is reasonable to create Texture Atlases, so even objects using different textures could share the same material in order to be subject to batching.
UNIGINE provides additional objects to take full advantage of mesh batching:
- Mesh Clutter is an object used to scatter a large number of identical meshes across the world. It is suitable for simulating vegetation a lot while keeping performance high.
- Mesh Cluster is an object that can contain a great number of identical meshes with the same material, which are managed as one object. Cluster meshes can be scattered either automatically, or each mesh can be positioned, rotated, and scaled manually.
Follow the Working with Large Number of Objects article for more details on using these objects.
In Unity software, you use Billboard Asset — a collection of pre-rendered images of a more complicated Mesh intended for use with the Billboard Renderer component — to replace the complex 3D mesh with a 2D billboard representation at some distance from the camera, thus reducing the load on GPU.
The most common way to generate a Billboard Asset is to use a third-party software or create Billboard Assets from script.
UNIGINE provides support for Billboards as well. In UNIGINE, a billboard is a rectangular flat object that always faces the camera so it is capable of representing some flat effects and objects that are barely seen from far off.
You can generate a billboard-based impostor using the Impostors Creator. This out-of-the-box tool creates a series of snapshots of the object while saving shading fidelity and combines them in a single Billboard object. Now you can use the impostor object as the lowest LOD for the mesh at a distance.
Impostor albedo texture
Object and Impostor wireframes
Tags and Layers#
In Unity Editor you are accustomed to assign Tags to GameObjects for user-defined classification of them. You also use Layers to define groups of GameObjects to be unapproachable by light sources and cameras, as well as for selective raycasting and collisions.
In UNIGINE, a high level of abstraction is omitted, both these systems are represented by the Bit Masking mechanism. Objects, cameras, materials and other entities have bit masks used by various effects and features to define their scope. Each bit in a bit mask can be named for convenience.
The masks are compared bitwise using logical conjunction, so if two masks have at least one matching bit enabled, they match and, therefore, the entity is subject to the effect.
For instance, you can filter out certain objects (e.g. tooltips) for reflections by adjusting the Reflection Viewport Masks:
For more details and usage examples:
All runtime spikes, bottlenecks and performance issues can be tracked using the built-in optimization tools:
Performance Profiler, an analog for Unity Profiler tool, displays performance data in a timeline in several modes.
Microprofile, an advanced CPU/GPU profiler with support for per-frame inspection.
Texture Profiler, a tool helping to check the memory consumption by textures.
- Content Optimization section.