Actions

Tutorial

Heightmap

From MagicaVoxel Community Wiki

The Scene

  • Okay, so first up the finished shot. My ref throughout was the Death Stranding E3 2018 trailer here. This was an iso shot w/ uniform lighting, x8 bounce, number 7 blade, and max bloom to get the emission looking perfect
  • Tutorial 0.99.2 fawnrelic snap2019-02-02-01-10-54.png
  • Edit screens: roughly grouped into droid, base terrain, and foliage/extras/fx. You'll notice some wacky junk on the left which I'll come to next!
  • Tutorial 0.99.2 fawnrelic Untitled.pngTutorial 0.99.2 fawnrelic Untitled2.png
  • So after finishing the droid itself I decided to go fully ape shit and try to replicate the green icelandic/scandi landscape we see in the trailer, but had no idea how to start it. I figured I'd prepare a little asset library for myself so I could 'paint' a landscape with them. Here I've done grasses, rocks, and the lumpy mossy riverbank all with heatmaps! It was my first time trying heatmaps and it took a lot of experiments in photoshop, but I can't imagine doing it any other way.
  • Tutorial 0.99.2 fawnrelic snap2019-02-02-21-49-40.png
  • The river was also a heatmap! I wanted a very specific choppy water shape that I eventually got from the heatmap gods, I'll explain how if people want specifics later. I embedded my pre-made rocks and depicted churning water by painting white highlights. You'll notice a lightbox hovering off to the back, this was to get the right kinda sun-glare off the water while staying in uniform lighting for my overcast atmosphere.
  • Tutorial 0.99.2 fawnrelic snap2019-02-02-21-50-52.png
  • Finally(?) you'll notice an unseen person walking in front of the droid and casting a shadow in my finished shot, to depict Sam Bridges the Death Stranding protagonist leading the way. I pasted in my Ludens statue from a previous piece to cast a human shape shadow and give the impression of a fully-realised scene from the DS world. I had to paint him black because I was already using his shade of white as the lights on the droid and he turned into a lighthouse when i pasted him in. Apologies for the wall of text/pics!
  • Tutorial 0.99.2 fawnrelic snap2019-02-02-21-50-15.png


The method

  • 1 - Create a Notepad document in your Shaders folder (in your MV install) named "height" with the following text in it
  •  // console commands
     // 'xs height'
     // shader inputs
     // uniform vec3        iVolumeSize;    // volume size [1-126]
     // uniform float    iColorIndex;    // current color index [1-255]
     // uniform vec3        iMirror;    // current mirror mode [0-1]
     // uniform vec3        iAxis;        // current axis mode [0-1]
     // uniform float     iFrame;        // current anim frame index
     // uniform float    iNumFrames;    // total num of anim frames
     // uniform float    iIter;        // current iteration index
     // uniform vec4        iRand;        // random number
     // uniform float    iArgs[8];    // user args
     // built-in functions
     // float voxel( vec3 v );        // get voxel color index at position v
     // generate new voxel color index at position v
     float map( vec3 v ) {
       float height = 255.0 - voxel( vec3( v.xy, 0.0 ) ); // depends on palette
       height = height * 0.5f - 1.0; // map to range [0 - 126]
       return ( v.z <= height ? iColorIndex : 0.0 );
     }
    
  • 2 - Use photoshop or similar, make a new 126x126 square image with a black background, and paint patterns in grey on it. The lighter the shade of the pixel, the taller the resulting voxel will be. Here's what i painted for my river
  • Tutorial 0.99.2 fawnrelic heatmap8.png
  • 3 - Add a new object in MV with the + symbol, switch to palette 2 (that's IMPORTANT) and just drag your .png file you just made into the empty object. It'll drop in, but it'll shrink the object to fit it, so you'll need to make sure you have "126 126 126" in the top right and get a full cube again. Then rotate the object on whatever axis you need for your purposes. for terrain you want it on the 'floor' of the object etc.

    4 - Click into the command console (or hit F1) and type "xs height" to make the magic happen. A voxely shape will appear, which you can do whatever you like with. I often use the Scale tool on the right side to shrink down the Z axis and get the size I want. you can switch back to your original palette now too. I think I've remembered this all correctly, but other folks feel free to chip in.
  • you can also let Photoshop do the hard work for you by using filters and stuff. My grass in the piece above was made by simply running the 'noise' filter to get loads of white dots in a natural-looking pattern.
  • Tutorial 0.99.2 fawnrelic heatmap3.png
  • In case my pasted script gets scrambled up between my end and yours, here's the original tweet (which took me a long time to decipher), with a pic of the script.

fawnrelic, February 2019

MediaWiki spam blocked by CleanTalk.