Ship Builder

Motivation:

Some of my favorite games are the ones where you build vehicles or buildings that you use to get stronger. For my second project, I knew that I wanted to follow this idea and make a building tool that would let you place pieces based on certain conditions and then bring everything together with some procedurally placed meshes.
Vision:
Right as I was starting this project, I was also working on a water shader for a game. Because of this, I thought of the idea of creating a boat tool to add something to the environment. I searched for references on Pinterest to inspire gameplay, but the main reference for my aesthetic decisions was based on the game Dredge.

Picture from the start of Dredge - Black Salt Games

Creation Process

Planing the building system:

To make the building process intuitive for game play I divided all building pieces into 4 groups:
  • Hull pieces – the base of the boat and other holding structure such as rooms.
  • Object pieces – all pieces with specific functionality such as engine,
  • Cable pieces – cables that lead electricity but don’t create any collision
  • Decoration pieces – to let the player decorate the boat and express themselves.

Unfortunately I only had time to implement the first two in the project.

I also created some rules for how these objects could be placed and modified:
  • Hull pieces could be placed, rotated and scaled inside some restrictions
  • Object pieces could placed on hull pieces and rotated but only without intersecting other objects
  • Cables would have ben drawn between 2 points with restriction on length
  • Decoration wouldn’t have had any restriction except being placed on itself

Generating the hull

Modifying the mesh:

To modify the mesh at runtime I used Unreal engines geometry scripts, this also gave me some basic geometry editing functions such as extrusion and booleans.

Boat Hull:

The boat hull was made from a base-mesh that was scaled and extruded based on parameters from my editing tool. I also added functionality to heighten the front and back of the ship though extrusion.
After taking all user parmeters I added a railing along the edge of the ship and created a UV projection from the side that gave the flat colors a slight gradient.

Railings:

To add railings I inset a face from the top of the mesh and extrude the polygons neighbouring that face upwards.

Color:

To give the mesh colors I create a UV projection from the side to add a gradient based on my color sheet. Thereafter I offset the vertices to their color region.

Materials and Shaders

Water:

To make the water I mainly took inspiration from Rime and the presentation Simonshreibt gave on its water on Unreal Fest 2018. Because of this I initially made the water waves with gerstner waves, but I found it difficult to achieve the result I wanted, so I instead created a offset texture to show the vertex offset at each position, I then scrolled 2 of these textures atop of each other and used them to calculate new normals for the surface.

Screenshot from Rime

Animated vertex offset

Water Foam:

Since the water was originally made for a custom engine I was unable to use sign distance fields (SDF’s) for the foam. Instead the distance were calculated based on water depth (from the camera view) and viewing angle.

Outline:

To make the outline I modified a shader from parallelcube. The main change is the diagonal lines when you can’t place a object. They are made by creating lines diagonal lines in screen space and then offsetting them along the perpendicular direction based on their distance from the camera. This creates this realy nice 3D effect.

Underwater:

Since the water shader was placed on a mesh, it meant that when the camera cliped through that mesh it would destroy the illusion. Because of this I created a shader that simulated the camera passing under the water surface based on its position and facing direction.

UI:

I wanted to learn more about how to create UI shaders in unreal so I took the opportunity to make the buttons wave. This was made with height offset based on a scrolling sinus wave in X (or U since its in UV space).

Takeaways

Conclusion:

From this project I’ve gained a lot of knowledge in Unreal Engines blueprints and geometry scripts. I’ve also improved my abilities in designing gameplay systems and implementing them in code. This project also challenged my planning and time management skills.

Result:

I’m satisfied with the result as much as I was planning for something more complete. The boat and create looks nice, and the water gives the scene a good feel. I also like flying around placing and moving objects in the scene, so I imagine I did quite well in designing that system.

If i had more time:

For this project I might continue working in my free time to get it closer to what I imagined in the beginning. So if I take the time I will be focusing on implementing more of the objects. It would also enjoy adding more gameplay functionality, right now the boat is only sitting there, but it would be fun if you were able to drive around, shoot etc. I might also redesign the generation of the hull with geometry scripts, as much as it works it is not set up in the right way to add more gameplay, and since the tool is experimental it lacks a lot of features that would make the building process easier.