UE4 Terrain Blending: Part 1, Distance Fields - How, why, and why not by Elliot Gray

Recently I’ve been having a fiddle with terrain blending in ue4 using distance fields. Tech art is an interest and hobby of mine and I love digging in and getting my hands dirty in that side of development every now and then. I love the pretties.
Here’s a quick comparison:

(Original images if your browser doesn’t like the comparison: Blend, No Blend)

I was inspired to put together this material setup after playing yet another DICE/Frostbite game with impeccable terrain blended rock faces and wanted to see if I could get anywhere near as nice a result with ue4.

Here’s a different comparison showing a blend where cliffs dither into a slope based terrain material, super useful when adding rocky overhangs. Textures and meshes are just placeholders that I’ve been building the material with but I’m quite happy with how well the material works. (grey material on the terrain in the second image so you can see what’s terrain and what’s a mesh).

This is the first of probably 2 post&video combos as the ultimate goal is to modify unreal engine source so I can access the terrain height and splat textures at run time (something that isn’t currently possible). The material setup detailed in this first video is therefore using distance fields to drive blending.

A third method I may investigate is a nifty blueprint construction script that can essentially vertex paint a mesh we want to blend with terrain on placement (line trace from some verts to the terrain to get material info and height?). The benefit of a constructor based approach is that it wouldn’t require modification of engine source OR the use of distance fields to handle the blend.

Using distance fields to blend in this manner has plenty of caveats which I discuss in the video, but one I forgot to mention is that half of this technique (pixel depth offset dithering) only works correctly with TAA enabled. So definitely keep that in mind if you’re thinking of using it in a project. You can still blend the material layers but wouldn’t get the benefit of the super soft edges that the PDO method give you.

So yeah if you’re interested in the full breakdown of the distance field method here’s the video I put together. Check the description for helpful timestamps if you’re looking for a section in particular.

UE4 C++ Interfaces for Blueprint Quickstart by Elliot Gray

Yesterday, I spent wayyyyy too long trying to work out how to setup a C++ interface that could also be used in blueprint, because all of the existing documentation and wiki articles seem to be anywhere from moderately to extremely out of date.  This is a seconds long process so put together this quickstart guide to save anyone the infuriating search.

The super short version for those that already know interfaces and ue4 C++ is:

  1. Add new c++ class inheriting unrealinterface (right at the bottom of the new class wizard)

  2. In the .h file of your new class add whatever function you want tagged as a UFUNCTION as below:

UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "TastyInterface")
    bool FuntionYo();

That's literally it.  

Here's the video version that shows the whole process for anyone that needs the orientation.

Progressive Escalation: Level Design in DESPOILER (Part 1, The Shallows) by Elliot Gray


I've decided to write a series of blog posts on the development of despoiler and where better to start than the Level Design.  All levels were designed in despoiler to mesh with our game design to create the unique team objective focus of our arena racer.  I designed each of my levels as a unique sandbox that offers different and exciting ways to play.  I'll write a blog post in the future about the game-mode design specifically and why our currency is 100% physically represented as in-game objects (with physical representation and effects) but here's a tl;dr of how the game mode works to get you up to speed..

Pictured: Harvesting Scrap

DESPOILER is an arena racer with a unique escalation driven game-mode.  Not unlike a moba, each team starts out weak and as the game progresses teams grow in power leading to an end game that will look every different to the starting phase.  In DESPOILER players don't earn XP or gold as in a moba, but instead they scavenge 'Scrap' from around the map which is deposited at their base (harvested from abandoned structures around the map, pictured above).  As a team collects more scrap they unlock equippable upgrades and utilities for their team, and at the end of the game the team with the most scrap wins.  Re-spawning also costs your team a little scrap so some strategy and skill is required to most efficiently dismantle your opponent. 

Shallows was the first level I designed (and the second we got into the game).  This was the first level we were able to design with mostly final vehicle physics and control code in place and so it was a real joy to be able to play test frequently with the team and public which influenced iterative design greatly.  After sketching out a few different design ideas both on paper and in engine this was the initial iteration of shallows that we playtested on.

For this level, I wanted to focus on designing more specific paths through the map, in contrast with the sprawling open tundra of our first.  I focused heavily on designing good sightlines from anywhere on the map so a player always has the visual information about where they can fly next be it the enemy base, another path, or a scrap structure.

Players can always see a mmultitude traversal options they have ahead of them.

Testing early was great because while the goal of this level was to create a tighter experience than our first, very wide open level, in this intial version there just wasn't enough space for players to safely scavenge scrap early game in order to unlock the base level upgrades they need to be better equipped to take on the enemy. 

Shallows was expanded to allow safe early game scavenging

In this top down shot of the final level you can see how the level was expanded to give players the option to gather scrap early game in relative safety.  Once the safe scrap of a level is exhausted players will need to move into more dangerous territory, but they'll also have the upgrades and utilities unlocked to take on the enemy team and fight over the same reserves.  This progression from safely harvesting to risky harvesting to aggressive harvesting creates an escalation dynamic in player strategy as the game progresses, complementing the progression from low to high tier unlock-able upgrades.

Another core element of our level design language so to speak, was the idea of 'Nested Arenas".  Part of the fantasy of racing hovercraft is going fast, long sweeping turns, contrasted with agile and nimble piloting.  In all of our levels we design for this uniquely, but we always focus the combat areas (with risky scrap that's equidistant between both bases) in action hotspots.  These areas have ample cover for fights, multiple approaches and escapes with terrain features that skilled pilots can use to sneak up on or evade their enemies.

Mid Map "Nested arena"

This blog post is getting pretty long so I'm going to wrap up here for shallows but I hope you've found something interesting here about how we designed this level for our progression centric gameplay.  I'll dump a few gifs on the end here so you can get a sense for what it's like flying around the levels through arenas and flight-paths and how the sight-lines were designed to ensure players always had ample information on the moment to moment choices they can make when selecting a route through the level. Check back later for Part 2, The Wastes)

Elliot

Ps the Rock formations and texture work in this level are the beautiful work of Paolo Boissel and dayumm do they look stunning if I do say so myself.