June Monthly Recap
Added 2023-07-07 01:30:28 +0000 UTCThis is the first of the new monthly Patreon updates which we will be doing on top of the live posts on Discord. We ran a poll in Discord and found that although most people prefer live updates, a sizeable chunk of patrons would also like lengthier text posts once a month here. Unfortunately not much was done last month since we were deploying the Next Fest demo update, involving a lot of bug patching and customer support ^^ But still, a few things
We are currently working on the introductory map for EA. The setting is ancient Uvar Din, the lush planet from which Mozah's species originate. The visuals are inspired by Yangshuo County, the location which was used to photograph the famous DOOM mountain skybox!
source here!
Our own rendition was rendered in blender with a few manual touch-ups in Gimp. Here are some different in-progress versions:
Progressive visual tests rendered in blender.
The goal with this intro level is to have an extended tutorial with actual gameplay segments in it. One of the shortcomings of the demo's VR tutorial course is that it leaves no space for the players to apply what they are learning. The exam at the end was intentionally overly difficult, to try to demonstrate the attitude of the game. I'm still happy about that, but I think it also should have had some exploratory segments ahead of it. That's what we're doing here!
Editor screen captures of the environments for the tutorial level.
In the process of working on this level, I had to develop a new piece of technology to decorate these natural environments. Grass! So, how do we do it? Coming up with a method to make grass look correct for a software renderer sprite-based game is a little complicated. Camera-oriented billboards could work but you can only have so many before it starts to look silly, crossed quads with an alpha clip texture would look more like a Playstation-era game and using meshes just looks too modern. In the end, we decided on a technique that the Brush Burial developer came up with. If you don't know about that game, you can check it out here, it's pretty neat!
The quad-stacked grass captures cast shadows perfectly, giving it a volumetric look!
How it basically works is that the geometry for the floor gets duplicated, and a noise texture is used on each layered quad to render some blades. This gives the grass the appearance of voxels at a very low rendering cost. So, that looks nice, but it isn't enough! We're not just going to sit up here and manually create all those quads where we want grass. So I came up with a nifty tool which allows painting grass on top of meshes inside the Unity Editor!

Demo of the new grass painting tool.
This really was quite a lot of work. We needed to generate a UV map for the mesh which could be used to supply the GrassMap(tm). To do this, I simply used Unity's Unwrapping.GenerateSecondaryUVSet function. It is used to generate lightmap UVs which have the same requirements as the grass map: more or less consistent texel size across the mesh and no overlaps. After that, I had to write the painting tool itself... To create that soft, faded brush, I had to find a way to calculate the distance between the world space point under the cursor and each pixel on the grass map. First, a ray is traced from the camera to the mesh to find the intersection point, then a triangle distance function is used to collect all faces within a certain distance of that point. I then use reversed barycentric interpolation to calculate the distance for each pixel on the UV map within those triangles. Barycentric interpolation is how texture mapping is done in rasterized renderers. So, since that's the function you use to decide which texture pixels go where on the screen, reversing it tells you the position of a given texture pixel in the world!
Doing all this is a bit performance intensive but thankfully I had just written a BVH acceleration class to speed up some of our collision testing, so I just recycled that. After all that work, a mesh is generated which contains only triangles that have been painted over. That's pretty simple, using the barycentric function from earlier we can get the UV coordinates for all points within a given triangle, so I just loop through the texture pixels and see if any of them are greater than zero in the red channel.
The final step is to generate texture UVs for the actual grass diffuse texture. I came up with an algorithm similar to triplanar mapping. First, we pick a point and assign the UV of 0,0 to it. Then, we get the normal for that vertex and calculate a tangent by finding the world-aligned vector with the largest dot product to the normal. That's the world-aligned vector most orthogonal to the normal. We also need a bi-normal, which is the cross product of the normal and our new tangent vector. We then calculate the distance of each vertex connected to the start vertex against two planes, one aligned with the tangent and one with the binormal. This distance is used to calculate the UV coordinates of the connecting vertices. Works... most of the time ^^
The end result is visually stunning and super easy to use! It really spruces up the environments, as you can see below.

Here are some more shots of that area after being decorated with more plants:

I will be posting some more detailed updates on the demo map in Discord over the next few days. I'm currently struggling with making the cliffs look both convincing as real natural structures but also functional for gameplay. We have some pretty strict requirements for this area since it's a tutorial which teaches the player movement, so we need to have lots of flat, unbroken surfaces to wall jump from, and the cliff walls need to curve inwards at the top so the player can't wall-jump their way out of the course. Neither of these things are particularly suitable for a real mountain! You can see in the following screenshot that it looks a bit like minecraft cliff generation at the moment:

Ah, and in the midst of all this, we were live-patching the demo update, attending PC Gaming Show and Next Fest... And we have also been moving! So, unpacking boxes, building furniture, setting up appliances, discovering bad plumbing everywhere... So, hopefully by next week I should be able to get some meaningful work done ^^
See you next month!
-Dizzie