Wednesday 31 May 2017

Game Engine 31/05/17

I've finished implementing shadows + deferred rendering and I had some frustrating errors relating to shadow acne and transforming camera view space to light space, but I managed to go fix it all.

Here is a video showing the new looks of the graphics:



For shader loading I wrote a "compiler" from a customised version of GLSL to normal GLSL.
For example, I can write this:


$$VERTEX
// This becomes the vertex shader

$Position$ in vec3 vertPosition; // Automatically assigns this attribute to the vertex position

void main() {
    [...]
}

$$FRAGMENT
// This becomes the fragment shader

out vec4 fragColor;

void main() {
    [...]
}

All of this makes it easier to write and store shaders (single file, instead of multiple).
I'm might add CSM (cascaded shadow mapping) as it is better for large terrains and spaces.

Tuesday 30 May 2017

Game Engine 30/05/17

Okay I just finished implementing SSAO (Screen Space Ambient Occlusion) with OpenGL and GLSL on my Game Engine and it's working pretty fine.

Now there is a feel of depth that wasn't before. Here are some images to compare before and after SSAO.

Before


 After

As you can see it's way better now but I think it still looks strange. I'm planning to add shadows to make it look nicer.

Monday 29 May 2017

Game Engine 29/05/17 - Part 2

Here goes the part 2 of my Game Engine showcase.

More systems and functionalities I have in my engine:
  • Framework: Basically this is the engine core, everything depends on this chunk of code to work, here we have things I already wrote about such as the FileSystem.
    • Locator: Maintains pointers to services, for example, the moment I startup the Graphics system, it provides itself to the Locator and the Locator stores a pointer to the system. Now when I call Locator::GetService<Graphics>(), I get the Graphics system in return.
    • Service: Used by Locator as described above.
  • Physics:
    • Physics: Manages Rigidbody's  and updates them.
    • Rigidbody -> Component: Applies basic physics to GameObject, for now its only used to apply forces to a GameObject, such as gravity and drag. I didn't add collisions because i wont need it for the game I'm making.
  • Collisions:
    • Collisions: Manages Collider's and updates them.
    • Collider -> Component: Tests collisions between other colliders, if there is a collision, notifies other components of the GameObject of it.
    • Derivatives of Collider: Tests for multiple shapes of collisions (BoxCollider).
Here is what I'm already able to do:



As you can see I can now load models (with skeletons, meshes, materials, textures and animations) and render them unto screen. In this case I'm not loading an animation, this animation is done on the fly.

It took me a week to only get skeletons up and running because there is little documentation on the internet about it.  What really helped me the most was this website I found after some digging. I had already done some stuff with skeletal animation a year ago and I had the same problems.

I'm planning to add deferred rendering which I will talk about in the next post.

If you have any questions or suggestions post them in the comments or contact me through email: riscado.antunes@gmail.com

Sunday 28 May 2017

Game Engine 28/05/17 - Part 1

I didn't upload messages to this blog for a long time because what i was making wasn't really visible.

Now I have made a lot of progress and I'm planning to start working on game logic in a week or two.

Here is what i've already done:

  • Messaging System:
    • MessageBus - Handles messages and sends them to the message listeners
    • MessageListener - Receives messages to MessageBus. Can also send messages to other listeners through MessageBus.
    • Message - Has a void smart pointer pointing to its data and also has a type. MessageListener's can subscribe to certain types of messages.
  • Resource System:
    • ResourceManager -> MessageListener - Stores resources and sends them as needed. A resource can be requested through messages.
    • Resource - Used to store data about many things such as Model's, ShaderProgram's, etc. Also used as an interface to load the data.
    • Multiple derivatives of Resource (ModelResource, ShaderResource, etc.).
    • ResourceRequest - Serves as an interface to sending messages and requesting resources, making it much easier.
    • FileManager - Platform independent class to read resource file tree and load files.
  • Graphics System:
    • Graphics - Handles Renderer's and everything relatable to graphics
    • Renderable - Anything that can be rendered unto screen (pure virtual class).
    • Renderer -> Component - Used to draw a Renderable (BTW Renderer's have layers, such as the Transparent layer, the Default layer, etc.).
    • Window - I'm using the SFML library for handling windows, UI, networking and other utils. If you haven't checked it out, you should, it's really useful for small projects.
    • I also have derivatives of Renderer (ModelRenderer, etc.).
    • That's it for now. I'm planning to add AO (Ambient Occlusion) in some time.
  • Scene System:
    • Scene - Handles GameObject's and Component's. Also updates Behaviour's.
    • GameObject - A bunch of Component's tied together with a Transform and a parent GameObject. Also serves as a mini MessageBus for components.
    • Transform - Specifies a transform for anything (Translation + Rotation + Scale).
    • Component - Basically every functionality of the Engine uses this. Basically, it's just a piece of code to be executed by some System (for example, Renderer -> Graphics).
    • Behaviour -> Component - Everything that is related to game logic derives from these. They are updated by Scene.
I also have made a basic Physics and Collisions systems, which I will write about in the next part.

Feel free to write suggestions in the comments or ask questions. You can also send an email to riscado.antunes@gmail.com if you want to ask anything.