ECS based 3D game engine in C++ and Opengl ES.
The following set of tools is required:
- gcc
- conan
- cmake
build steps:
- cd game-engine
- mkdir build
- cd build
- cmake .. -DCMAKE_BUILD_TYPE=Debug
- cmake --build .
run: ./EngineApp --edit
By default, the editor consist of the following tabs:
- Scene
- Scene Hierarchy
- Scene Settings
- Camera
- Content Browser
- Console
- Inspector
In the scene tab you can directly edit the contents of the scene: move, scale, rotate, add and remove objects. By default, the scene has directional light, camera and box.
1.1 Selection. Left-click on a scene object to select. Once it is selected you can see it's mesh and gizmo tools for edit. You can remove the selected object by backspace.
1.2 Navigation. Use the following keys for navigation:
- W - move forward
- S - move back
- A - move left
- D - move right
- E - move up
- Q - move down
- F - point camera at the selected object
- X - point camera towards the positive x-axis
- shift+X - point camera towards the negative x-axis
- Y - point camera towards the positive y-axis
- Shift+Y - point camera towards the negative y-axis
- Z - point camera towards the positive z-axis
- Shift+Z - point camera towards the negative z-axis
- Space - rotate camera around the selected object
1.3 Adding objects. To add an object, right-click on the scene and select from the following list:
- Cube
- Plane
- Empty
- Empty 2D
All scene objects are listed in the scene hierarchy tab as a tree.
Here you can manage the parent relationship between objects:
Once you have made the camera as a child object next to the box, the camera will move, rotate and scale with the box.
To add an additional behavior (component) to the object, right click on the object and select component from the list:
Once you have added the behaviour to the scene object, it's settings will appear in the inspector section.
Draws the scene from the game camera's view point
Displays files in the ./assets folder. Can be used to add:
- Objects (.fbx, .obj) to the scene. To add an object to the scene, simply drag it from the content browser onto the scene tab.
- Textures (.png, .jpg, .jpeg) to materials.
- Fonts (.ttf).
- Scripts (.Lua).
UI for Scene Settings:
In the scene settings you can switch off/on and edit:
- Gamma Correction
- HDR
- SSAO
- Normal Mapping
- Fog
- Skybox
- PBR
5.1 Gamma Correction. Allows you to apply monitor gamma inversion to the final color before displaying it on the monitor. A gamma of 2.2 is the default value and approximates the average gamma of most displays.
UI for Gamma Correction:
Scene when gamma is 1.0:
Scene when gamma is 2.2:
5.2 HDR. Use a wide range of brightness values to collect information about both bright and dark details of the scene.
UI for HDR:
Property | Function |
---|---|
Tone mapping | Algorithm for converting color values to fit them in the range from 0 to 1 without losing image details. |
Exposure | Controls the balance between the display quality of dark and bright areas of the image. |
Brightness Threshold | Brightness threshold, above which the fragment is considered bright. Bloom and Blur are applied to fragments that exceed this threshold. |
Bloom Scale | Сontrols the degree of bloom. |
Blur | Сontrols the degree of blur. |
Scene when exposure is 1.0:
Scene when exposure is 0.2:
5.3 SSAO. Screen-Space Ambient Occlusion.
UI For SSAO:
Property | Function |
---|---|
Kernel size | The number of sample points located inside a hemisphere oriented along the normal to the surface. Each sample point is used as an offset to the fragment's position in view space to obtain information about the surrounding geometry. |
Radius | Controls the radius of the hemisphere. |
Noise scale | Controls the tiling of texture that contains a set of random hemisphere rotation vectors around Z axis. |
Bias | The value is added to the original fragment depth. Allows to control how the SSAO effect looks, and also, in certain situations, removes problems with ripples in shadow areas. |
Scene without SSAO:
Scene with SSAO:
5.4 Normal Mapping. Allows you to provide the lighting algorithm with normals that are unique for each fragment.
Scene without Normal Mapping:
Scene with Normal Mapping:
5.5 Fog. Fog is the effect of overlaying a color onto objects dependant on the distance from the camera. Can be used to hide clipping of objects when a camera’s far clip plane has been moved forward for performance.
UI for Fog:
Property | Function |
---|---|
Color | The fog color in RGB. |
Dencity | Controls the dencity of the fog. |
Gradient | Controls the rate at which objects disappear in the fog. |
Scene with Fog:
5.6 Skybox. Skybox is a wrapper around entire scene that shows what the world looks like beyond geometry. Here you can specify the background color or set six faces of a cube.
UI for Skybox:
Property | Function |
---|---|
Color | The background color in RGB. |
UI for Skybox When CubeMap is enabled:
Property | Function |
---|---|
Upper Limit | The boundary up to which the fog is fade. Can take values [-1; 1]. Applicable if the fog is enabled. |
Lower Limit | The boundary after which the fog begins to fade. Can take values [-1; 1]. Applicable if the fog is enabled. |
Rotation | The initial value of the skybox rotation around the Y-axis. |
Rotation Speed | The speed in degrees at which the skybox should rotate around the Y-axis. |
Scene with Skybox:
5.7 PBR. Aims to mimic light in a physically plausible way. The algorithm used is based on the metal workflow that allows you to define metal, roughness and ambient occlusion maps for materials.
Blinn-Phong model:
PBR:
Displays errors:
Components:
- Transform
- Velocity
- Render 3D
- Skelet
- Rigitbody
- Box Collision
- Terrain Collision
- Particles
- Behaviour (Script)
- 2D Text
- Transform 2D
- Camera
- Directed Light
7.1 Transform.
UI for Transform:
7.2 Velocity.
UI for Velocity:
7.3 Render 3D.
UI for Render 3D:
Material settings when PBR is enabled:
7.4 Skelet.
UI for Skelet:
7.5 Rigitbody.
UI for Rigitbody:
Callback | Function |
---|---|
Mass | Quantity that determines the inertial and gravitational properties of the body. |
7.6 Box Collision.
UI for Box Collision:
7.7 Terrain Collision.
UI for Terrain Collision:
Field | Function |
---|---|
Coulms and Rows | Controls the detail (number of polygons) of the terrain. |
Brush Radius and Strength | Brush settings for terrain editing. |
Terrain editing with brush:
7.8 Particles.
UI for Particles:
7.9 Behaviour (Script). Updating an object in the game loop, the engine makes callbacks written in the form of a lua script. This gives you the ability to influence how game objects update over time.
Callback | Function |
---|---|
init | - |
update | On every game loop update. |
collide | On colliding with other objects in the game scene. |
UI for Behaviour:
To assign a lua script to a game object, drag the lua file from the content manager to the Script field. Example of lua script:
canJump = true;
function init(entity)
canJump = true;
end
function update(entity)
velocity = entity:getVelocityComponent();
skelet = entity:getSkeletComponent();
local run = false;
local rotate = false;
if Input.isKeyPressed(Input.Key.W) then
velocity.speed = -4.0;
run = true;
elseif Input.isKeyPressed(Input.Key.S) then
velocity.speed = 4.0;
run = true;
else
velocity.speed = 0;
run = false;
end
if Input.isKeyPressed(Input.Key.D) then
velocity.rotation.y = -1.0;
rotate = true;
elseif Input.isKeyPressed(Input.Key.A) then
velocity.rotation.y = 1.0;
rotate = true;
else
velocity.rotation.y = 0;
rotate = false;
end
if (Input.isKeyPressed(Input.Key.Space) and canJump) then
velocity.velocity.y = 2.0;
canJump = false;
end
if (run or rotate or not canJump) then
skelet.state:play("Armature|Run");
else
skelet.state:play("Armature|Idle");
end
end
function collide(entity, other)
local tag = other:getTagComponent().tag;
if (tag == "platform") then
canJump = true;
end
end
7.10 2D Text
UI for 2D Text:
7.11 Transform 2D
UI for Transform 2D:
Property | Function |
---|---|
NDC | Allows you to specify the position of the object in normalized device coordinates. This means that the coordinates must be between -1.0 and 1.0. |
Location | Object coordinates in screen space. |
Scale | Сontrols the stretching of the object. |
7.12 Camera
UI for Camera with perspective projection:
UI for Camera with orthogonal projection:
Property | Function |
---|---|
Projection | Projection type (perspective/orthogonal). |
Near and Far Plane | Near and far planes of a view frustum. All vertices located between the near and far plane and falling into the volume of the view frustum will be rendered. |
Field of View/Zoom | Determines how large the visible area is. Field of view is used for the perspective projection, zoom for orthogonal. There is an inverse relationship between the two fields: fieldOfView = 2 * atan(1.0f / zoom). |
Orthogonal Projection:
Perspective Projection:
7.13 Directed Light
UI for Directed Light:
Object inside Shadow Frustum:
Object outside Shadow Frustum:
7.14 Spot Light
UI for Spot Light:
Scene with Spot Light:
Spot Light Area: