Open comments for this post
Grass culling! All grass objects are now divided into chunks and sub chunks and sub chunks of those sub chunks. If a chunk is not in the view frustum, then it is culled. This greatly saves on performance. The grass is also a different color now. So is the ground.
Open comments for this post
Grass! I added a grass renderer component, and every entity with it is looped and their transform is added to a vector of grass matrices which are fed to the grass shader and drawn using instancing. You can also add grass through the map editor which is pretty cool. The grass vertex shader generates a random vector using simplex noise and uses that as the sway direction for the blade of grass. The grass fragment shader uses a gradient with three colors applied from bottom to top.
Open comments for this post
Map editor! I added an editor bool to the global engine state and that controls whether the editor GUI is drawn and whether the player system runs or not. I also added some stuff like moving objects by clicking on them and adding stuff to the scene like grass blades. The way that the mouse to world space conversion works is that the cursor position is multiplied with the inverse of the projection matrix and this gives a direction in world space which is used as a raycast and if it hits anything, the object will be spawned at the hit position.
Open comments for this post
I added fog and a sky texture. Most of the time in this devlog was spent on modelling an enemy but I felt like it wasn’t inspired enough and was too generic so I’ll come up with a better design tomorrow.
Open comments for this post
Inventory! The inventory system procedurally generates item slots and checks if the slots are hovered and if they are and there’s an item inside them, then clicking them will make the item follow the cursor and on release, they will check if the hovered slot can fit the item and adds it to that slot.
Open comments for this post
I fixed the texture importing from the FBX file. I was using a custom shader in blender for the skin and it wasn’t exporting the texture because of that. I also needed to adjust the export settings and changed the gamma settings on the texture importer.
Open comments for this post
I added a gun to the game! It uses the same inverse kinematics structure for the right hand as before but also supplies an aim direction to ApplyArmIK which controls where the hands will point to. The gun transform is directly controlled by the hand and points in the direction of the palm to the tip of the fingers. I also copied my OpenAL implementation from my previous engine and added a shooting sound whenever you shoot the gun.
Open comments for this post
I added inverse kinematics to the hands! This was pretty difficult to set up as I don’t have a visual viewport to see the bones of my rig in so I had to go in Blender and see all the names of the arm bones and propogate the IK solver points across all of them.
There’s also an IK solver class now which takes a base and a target. I also added slerping to the hand target to make it blend smoothly.
There are two variables, leftGuard and rightGuard which control whether a hand is affected by IK or not. And there’s also an IK weight factor which controls the transition between animation and IK to make it go between the two smoothly.
The left or right guard are disabled whenever you punch to make the arm actually go forward and use the regular animation.
I also added a stamina and health bar. They use a shader which fills up the texture with a color based on a number which is the health or stamina.
The health does nothing right now but stamina is drained by punching and regenerates on a rate that depends on what state you are in.
Open comments for this post
I added attacks to the game! You can now raise your guard by pressing G and jab on either side by pressing left or right click. There was a big issue with the animations before in that if you played an animation while an animation was already mid blend, the model would suddenly jerk to the new frame because the lerped position of the bones became different between the two animations. To fix this, I updated it so whenever you play an animation, the current bone matrices are stored in a vector and are used as the starting position of the blend to the new animation.
Open comments for this post
I added skeletal animation blending! This wasn’t needed before as there was only one animation (running) but I have added an idle and a flying animation. There’s a state machine for the animations that calls PlayBlend on the first frame of the state change. The way the blending works is that there’s a blend factor which goes from 0 to 1. It lerps from 0 to 1 on a set duration which you can specify for how fast or slow you want the animation to blend. It then lerps from all the positions, rotations and scales of the different bones of the two animations according to the blend factor. By the way, the flying animation is one frame pretty much so the blending is doing all the work in transitioning from and to it. The player also smoothly slerps to the direction you’re moving in, except if you’re moving backwards because that looks weird.
Open comments for this post
There were lots of issues with the model loading before and I managed to import an FBX file that I exported from a blender project and got it animating in the engine. But besides that I made a character controller, there’s a capsule rigidbody attached to the player and two components, a movement component and a camera controller component. The camera controller sets the camera on the player’s head and also a little bit in front of it so you don’t clip in the player’s head and the movement component allows you to move with WASD. The movement is utter garbage however as I only made it with forces, I will improve it and add drag later. Also the thought behind the player being visible is: 1. Because of immersion and 2. I want the game to be multiplayer and adding player models beforehand will be very useful.
Open comments for this post
Physics! I integrated the Jolt physics engine into the project. I’ve used Jolt for my other projects so it was pretty quick to get up and running. I made a debug renderer system which makes and draws a wireframe depending on the collider type. There are four types of colliders currently, box, capsule, sphere and mesh. The mesh collider is unfinished, I will implement that when I actually need to implement terrain meshes and colliders.
Open comments for this post
Skeletal animations! I reused an implementation of skeletal animations from one of my old projects. In the shadow mapping vertex shader, I have also added the transformation of vertices by bone matrices to capture the shadow of animated objects.
Open comments for this post
I’ve finished implementing PBR rendering with the Cook-Torrance BRDF. I’ve also added normal and roughness map support. Other maps are unnecessary for the renderer.
Open comments for this post
I’ve started work on the 3d engine for the game I’ll be making. For the first day, I’ve implemented cascaded shadow maps where there are multiple shadow maps taken at different distances to create a hierarchy of resolution. And I’ve also implemented blinn phong shading. I plan to change this to a PBR pipeline later down the road.