Tuesday, 21 May 2024

Android Shader Editor - Test Shader

I wrote this GLSL test shader a couple of years ago when I was testing out the excellent Android shader editor app written by Markus Fisch.
His website can be found here

Friday, 3 May 2024

Asset Browser

During the development of Alien: Isolation the art director requested a tool to manage the game's 3d art content from within 3ds Max.
At the time there wasn't a 3rd party option which fulfilled the brief so I set about focusing my time on designing and creating one.
The resulting tool would allow the artist to create, organise and manage their 3d art assets and materials.
On disk, each asset's content was contained within its own folder.
Asset's could be submitted, sync'd and checked out in Perforce.
Artists would first create new assets within the Asset Browser. This would then generate all the minimum required files from which they would then further edit and add to.
As an example, a newly created 3d asset would, amongst its files, contain a 3ds Max file which itself would contain data for a simple cube mesh. The artist would then, via the Asset Browser, open this Max file for editing before resaving and re-exporting the data via the Asset Browser.
One of the most complex features to create was its ability to allow assets to be referenced within other assets. So, as an example, a room asset could consist of referenced wall panel assets.
The nested asset referencing data matched the file format our in-house editor used so it was possible for both 3ds Max and the editor to read and edit the same data.
When an asset was saved back to the library the Asset Browser would also auto-generate a thumbnail too. If it were a 3d mesh asset then a render of the 3d model was created. However, if it were a material asset then a sphere was rendered with the material displayed on it.
The Asset Browser became an integral part of the artists and designers content workflows and was used throughout the project's development. For Halo Wars 2 the same approach was used but I did a complete rewrite of the tool to make it faster, cleaner and with a few extra features which included a 'heatmap' view for 3d assets which showed small triangles as red all the way up to large triangles as blue, which served as a great high level visual means of checking the complexity of meshes.

Thursday, 2 May 2024

Total War: Three Kingdoms - Tech Tree Shaders

As well as creating tools for the project's I have worked on I have also been involved with developing shaders too.
During the development of Total War: Three Kingdoms I was asked to create a number of shaders to support the flowing ink art direction seen throughout the game.
The ink flowing shaders I worked on were primarily for the UI and had to both have an initial flowing reveal effect and then a continuous looping ambient motion.
To achieve the reveal flow effect I settled on using a number of layered gradient mask textures as well as a flow map texture to give it extra motion. This gave a lot more control to the artists on the resulting ink shape and the flowing motion.
The looping ambient motion for the ink was mainly controlled by a flow map with a scrolling noise texture offseting the pixels to give and extra bit of support motion.

The flowers had their own unique shader which took a sequence of hand painted animation frames and then faded between each one over time to give it a softer more whimsical look to align it with the project's overall art direction.
video's original source

Greeble Tool

During the development of Alien: Isolation and Halo Wars 2 I developed a 3ds Max tool which offered a way for the artists to store and share mesh pieces i.e. greebles
The focus for the tool's usage was to ensure it was as quick and easy as possible for the artist to store, search, share and import the mesh parts.
One of the features I added was the ability to add a new mesh part to the Greeble Tool's library directly from a selection of faces within the selected mesh.
I also added in a feature to automatically generate a thumbnail of the mesh part too, making it visually easier and clearer for artists to find the piece(s) they were after.
A tagging system was implemented over a tree view folder structure as this was deemed a quicker method for find the desired mesh part(s).
As all the mesh pieces stored in the Greeble Tool's library also had their UVs on them too it meant commonly used basic primitives could also be created with clean unwrapped UVs, saving the artists the time and energy having to do this same process over and over again.
The tool itself had the main logic written in Maxscript with the UI being built using dotnet controls.

Alpha Geometry Tool

Whilst working on Total War: Three Kingdoms an artist requested a 3ds Max tool which would select any faces on the mesh which were assigned a material set for alpha but whose pixels visually displayed no alpha i.e. a solid surface.
Once these faces had been found the tool would then assign them a new material which mirrored the alpha one but with the alpha switched off.
The overall aim was to improve the performance by reducing the amount of alpha'd geometry within then game.

Wednesday, 1 May 2024

Snapping Tools

On Total War: Three Kingdoms I was asked to create a 3ds Max tool to snap vertices to a virtual grid.
Snapping tools are available in 3ds Max but the request was to make a new set which were more reliable and intuitive to use.
One of the more novel features I added was to give the option to base the axis on the viewport and not the world matrix. As an example, a camera view-aligned to a left view would treat the X axis as a horizontal snap, as it also would from the front view.

Decal Tool

On Alien: Isolation the environment models had decals overlayed onto their surfaces to add in extra details and iconography.
There were a few options available to the artists for applying decals onto their meshes and one of them was via the 3ds Max Decal Tool I wrote.
Within the 3d assets content library were also folders dedicated to holding decal material assets.
Each decal asset was a t-page texture which itself contained multiple decals where, for each decal, a bounding box was defined.
When the Decal Tool was launched it scanned the 3d assets library and built a tree view containing all the found decal assets (see the left-side panel in the image below).
When the artist then clicked on any of the decal assets, from within the tree view panel, the associated texture would be displayed within the texture display panel. Within here the artist was free to then click on any of the one of the decals to select them.
With a target mesh selected in the 3ds Max viewport, and a decal selected within the Decal Tool, the artist would then click the 'PREVIEW MODE' button.
A UV mapping gizmo then appears on the mesh, with the selected decal projected onto its surface. Within this mode the UV mapping gizmo can be freely moved across the surface, in real-time, to visually determine where the decal will finally be created.
Once the artist was happy with the placement of the decal within the Preview Mode, the 'Paste Decal' button is clicked to generate the decal on the mesh surface as an optimised piece of geometry.

Property Editor

One of the first 3ds Max tools I wrote, which was officially rolled out to the team, was the Property Editor.
It was during my time on Viking: Battle for Asgard where the tool was first used during its development. After this project the Property Editor was also adopted for use on the Alien: Isolation project.
The role of this tool was to create, manage and edit metadata on meshes within a 3ds Max scene, which would then be used to determine information about the 3d assets once they reached the game.
The Property Editor was written in Maxscript and initially hooked into ActiveX to offer a much better UI experience for the user over what Maxscript's native UI commands would have offered.
During Alien: Isolation 3ds Max discontinued supporting ActiveX and switched to dotnet which required the Property Editor to be updated to support this change. It was a pain this happened, with little warning, but it did give me the opportunity to become familiar with dotnet and all the amazing options it offered.
The metadata available for meshes, via the Property Editor, wasn't hardcoded but instead imported from a config file created and maintained by the coders. This had the benefit of ensuring the tool was always in sync with any changes made to the officially available metadata the game used.
The UI for the tool was designed to be as user friendly as possible. This included a multi-edit mode where metadata values could be updated across multiple meshes at any one time.

Copy Vertex Data

On both the console games (e.g. Alien: Isolation) and Total War games (e.g. Total War: Three Kingdoms) there has commonly been a request to have the ability to copy vertex data from one mesh to another with differing geometry.
A good example would be the copying of vertex data (usually colour or alpha) down a LOD chain where the geometry differs but visually they still have to look alike.
The brute force solution for this is to take each vertex on the target mesh, then find the closest vertex on the source mesh before copying over the relevant vertex data.
However, this approach becomes exponentially slower to calculate as the vertex count rises on the source and/or target mesh.
The real problem to solve here is to try and achieve the same results the brute force approach gives but in a much qmore optimal way.
The solution I implemented was to initially do a mesh element matching pass i.e. run the same closest-neighbour approach but with elements instead of vertices.
Once there was an element correlation between the source and target meshes it was then just a matter of running the brute force approach but, this time, with a lot less vertices to check and match up.

Select Occluded Faces Tool

During my time on Total War: Three Kingdoms a request came in from the art team to have a 3ds Max tool which would select all hidden faces on a mesh.
This surprisingly turned out to be a very interesting problem to solve. On the surface, it deceptively appeared to be a simple solve but in reality it was quite complex and required some creative ideas to solve it.
I tried a number of ideas, from voxelising the mesh, to firing rays out from each face to calculate whether they're covered by other parts of the geometry, but both didn't give accurate results and/or would take far too long to calculate.
The final chosen solution first involved ensuring the mesh was automatically UV unwrapped so each face had a unique area allocated to it on a texture page.
The second stage was to the render out an ambient occlusion map.
Once the AO map had been created it was just a simple matter of going through each triangle and checking to see if all the AO pixels covering it were black. If they were then it was safe to assume the face was fully hidden (occluded) and therefore could be added to the final occluded face selection.
The tool also offered the option to adjust the accuracy level. This just meant it would give more leniency when checking if all the pixels were black on each triangle i.e. pixels lighter than pure black.
There was also another option to pick a 'terrain' mesh. This would be a grid grid with height offsets. Any faces from the selected mesh which fell under this terrain mesh would also be included in the final occluded face selection.

Quad LOD

One unpopular but necessary area of 3d asset development is the creation of mesh LODs.
Due to the custom normals style direction for Alien: Isolation (see Normal Align Tool post ) the usual 3rd party / 3ds Max inbuilt LOD auto-generation tools weren't up to generating acceptable LODs - especially on the hard surface meshes.
However, the familiar custom normals used across the Alien: Isolation 3d asset meshes created a window of opportunity to create a tool specifically focused on creating cleaner LODs using this extra available information.
I have always enjoyed the challenge of resolving complex problems like this and really enjoyed the challenge of creating a tool to creating better results compared to the 3rd party alternatives at the time.
Quad LOD first identified where normals had be altered on a mesh. This then gave a indication of where the chamfer geometry existed on the mesh. As this geometry served as detailed information the player would only really appreciate and see up close the tool would remove these chamfers and switch them out for a hard edge.
The second pass was for Quad LOD to identify edge loops which defined a subtle curved surface. Once it had identifed these it would then remove every other edge loop across the surfaces to effectively reduce the geometry whilst maintaining the overall silhouette and form.
Overall Quad LOD was able to generate clean resulting LODs which weren't dissimilar to what an artist would create. This gave the extra advantage of offering further manual edits to the LOD meshes if required.