Skip to content

Wideweb/game-engine

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

<Name> Engine

ECS based 3D game engine in C++ and Opengl ES.

Building

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

Editor Interface

By default, the editor consist of the following tabs:

  1. Scene
  2. Scene Hierarchy
  3. Scene Settings
  4. Camera
  5. Content Browser
  6. Console
  7. Inspector

Screenshot 2022-04-29 at 14 29 08

1. Scene

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.

Scene

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

2 Scene Hierarchy

All scene objects are listed in the scene hierarchy tab as a tree.

Scene Hierarchy

Here you can manage the parent relationship between objects:

sh-2

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:

Add Entity Component

Once you have added the behaviour to the scene object, it's settings will appear in the inspector section.

Inspector

3 Camera

Draws the scene from the game camera's view point

4 Content Browser

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).

5 Scene Settings

UI for Scene Settings:

Scene Settings UI

In the scene settings you can switch off/on and edit:

  1. Gamma Correction
  2. HDR
  3. SSAO
  4. Normal Mapping
  5. Fog
  6. Skybox
  7. 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:

Gamma Correction - UI

Scene when gamma is 1.0:

Screenshot 2022-05-05 at 21 33 19

Scene when gamma is 2.2:

Screenshot 2022-05-05 at 21 33 03

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:

HDR - Settings

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:

HDR - exposure 1.0

Scene when exposure is 0.2:

HDR - exposure 0.2

5.3 SSAO. Screen-Space Ambient Occlusion.

UI For SSAO:

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 without SSAO

Scene with 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:

Normal Mapping Off

Scene with Normal Mapping:

Normal Mapping On

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:

Fog - Settings

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:

Fog - Scene

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:

Skybox - background color

Property Function
Color The background color in RGB.

UI for Skybox When CubeMap is enabled:

Skybox - cubemap

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:

Skybox - cubemap scene

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:

Blinn-Phong

PBR:

PBR

6. Console

Displays errors:

Console

7. Inspector

Components:

  1. Transform
  2. Velocity
  3. Render 3D
  4. Skelet
  5. Rigitbody
  6. Box Collision
  7. Terrain Collision
  8. Particles
  9. Behaviour (Script)
  10. 2D Text
  11. Transform 2D
  12. Camera
  13. Directed Light

7.1 Transform.

UI for Transform:

Transform UI

7.2 Velocity.

UI for Velocity:

Velocity UI

7.3 Render 3D.

UI for Render 3D:

Render 3D UI

Material settings when PBR is enabled:

PBR Material

7.4 Skelet.

UI for Skelet:

Skelet UI

Screenshot 2022-05-09 at 18 11 18

7.5 Rigitbody.

UI for Rigitbody:

Rigitbody UI

Callback Function
Mass Quantity that determines the inertial and gravitational properties of the body.

7.6 Box Collision.

UI for Box Collision:

Box Collision UI

7.7 Terrain Collision.

UI for Terrain Collision:

Terrain Collision UI

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:

Terrain Edit

7.8 Particles.

UI for Particles:

Particles UI

Screenshot 2022-05-09 at 17 54 09

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:

Behaviour UI

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:

2D Text UI

Screenshot 2022-05-09 at 18 09 10

7.11 Transform 2D

UI for Transform 2D:

Transform 2D - UI

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:

Screenshot 2022-05-08 at 20 13 54

UI for Camera with orthogonal projection:

Screenshot 2022-05-08 at 20 36 52

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:

Screenshot 2022-05-08 at 20 07 56

Perspective Projection:

Screenshot 2022-05-08 at 20 10 41

7.13 Directed Light

UI for Directed Light:

Screenshot 2022-05-06 at 13 48 47

Object inside Shadow Frustum:

Screenshot 2022-05-08 at 23 51 58

Object outside Shadow Frustum:

Screenshot 2022-05-08 at 23 58 28

7.14 Spot Light

UI for Spot Light:

Screenshot 2022-05-17 at 18 01 13

Scene with Spot Light:

Screenshot 2022-05-17 at 17 43 40

Spot Light Area:

Screenshot 2022-05-19 at 11 57 08

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published