A 3D graphics rendering project for PlayStation 4. Written in C++ with GNM and GNMX, implementations of model loading, cameras, control input, HUD, scenes, and lighting through PSSL. This creates a basic game engine, from which i created a simple score based archery game.
Role: Developer, Architect
Team: 1
Timeframe: 12 weeks
Engine: C++ (GNM, GNMX), PSSL
3D models are loaded from PTM files. The data is loaded from the file to the GPU, with checks carried out to confirm all required data is present. The data loaded can contain vertices, colour, triangles, UVs and normals. Colour data and normals can be generated on loading for the model to render correctly, but vertices, triangles and UVs must be present in the file for correct rendering.
It is also possible to generate a new PTM file for a model with all required data. If a model file doesn't contain normals, once these are generated they can be saved back to the original file or a new one to store them to be reused.
Input is received through a PlayStation 4 controller. Control buttons have three types: Pressed, Begin Pressed and Toggled. Pressed indicates whether the button is currently pressed down. Begin Pressed is true if the button is being pressed down and this is the first frame it has been down since the last time it was released. Toggled is when the input is swapped from the previous, being either pressed or released. The thumb sticks also have axis controls. An x and y value between -1 and 1 shows what direction the input is in. The axis have a customisable deadzone around 0, meaning that if a very small change is made it will not be registered. This is important for any error in control values.
Cameras are used to render the scene from a specific perspective. A scene can have multiple cameras in different positions. A camera's perspective can change during runtime to create the illusion of movement. As an example, a camera has been setup to move with the left stick and rotate around with the right stick. This is a first person view of the scene. A second camera can be selected with the triangle button.
A light is simply a point in the scene that changes its surroundings. Lights have a location and a colour and properties including direction (togglable), ambience, diffuse and specular, fixed attenuation, linear attenuation, quadratic attenuation. Lights can also be turned off, made infinite and directional.
Objects can use different materials to change the way they are affected by light. Materials contain a texture and a pipeline. They also have a colour which can be used by some pipelines. There are three pipelines objects can use to be rendered.
VVM shaders simply take the data from the model and render it. It uses the colour of the vertex as the colour, so doesn't take any information from the material except the pipeline type.
TDM shaders get their colour data from the texture that the material uses. The material colour is used to apply a tint to the texture, with white being its original colour.
TDT shaders function the same way as TDM, but have an additional gloss map texture. This allows variations to how shiny parts of a model look.
During development, all objects were created and updated in the main loop. However, when creating a large environment, this became difficult to manage. To make this easier to control, I created a scene system that contains each object. A current scene is set in the main loop, and all the objects within the scene are updated and rendered each frame in the loop. This makes the functionality present in the main file easier to follow and makes it easier to modify the scene without affecting any other part of the code.
To test out the game engine functionality, I created a simple mini game. This allows the player to move and look around, and shoot at a target - targets are spinning spheres. Each shot adds score to the player. There is a top down view of the targets that can be toggled to.