What To Do About Water

Recently I’ve been working on water, and the shaders and physics that go along with moving a character through it. Turns out writing a basic water shader and applying it to a plane is fairly simple. I followed a very well-made tutorial on Youtube which I’ll embed below. If you need a one-stop channel that will cover all your Godot specific needs I’d highly recommend GDQuest.

So, once you finish with the tutorial you’ll have a very nice floating body of water with some smooth waves and pleasant reflections. Well, it’s not quite a “body” of water yet.

Now what?

Since our water is just an undulating plane, we’ll need to think about how to implement and consider a few design decisions. For a more fully-realized body of water we’ll first look at lighting. We’ll need to look at two cases: how far down the player sees when looking into the water, and what the player sees when the camera is submerged in water. For the first case you’ll need to look no further than the GDQuest tutorial above. For the second case we’ll need to apply a shader to the entire viewport of our scene. Your scene tree will have this basic structure: your root node will have a ViewportContainer, which will contain a viewport, and that viewport will house everything else. Then all we need to do is apply a ShaderMaterial to the ViewportContainer and attach a script to that. In this case I use an Area node for our body of water, and if the camera is detected entering that body it supplies a boolean value to the shader to change the color of the screen texture in our viewport.

Things now look a bit darker underwater, but I’ll need to add some more convincing effects.

There’s still more work to be done of course. Underwater physics and (hopefully decent) character controller coming soon.

That’s Cool: Zelda 64: Dawn & Dusk

The Legend of Zelda 64 DD, or the Legend of Zelda Dawn Dusk, is a pretty surprising expansion for the original game. And yes, that’s DD as in the infamous peripheral for the Nintendo 64. The expansion runs on an emulator or the actual hardware if you’ve got a N64 and the DD attachment. The cool thing about this expansion is that using the DD and accompanying disk, you can expand usable storage for games up to 64MB. The original cartridge of Ocarina of Time was 64MB, and with DD you can double the amount of storage. If you’re familiar with Nintendo DEEP LORE, you’ll know that the 64DD was a commercial failure. The 64DD was meant to bridge the gap between cartridges and CD’s. Cartridges had fast memory access times and limited storage, while CD’s had slower access times but larger storage capacities. Thus the combined advantages would lead to bigger and better games. Unfortunately only 10 games were ever made for the system, and it never caught on with consumers. Originally, Ocarina of Time was going to released for the 64DD, but due to the game needing faster storage mediums it was eventually released on a 64MB cartridge. Fast-forward about two decades and we have Zelda 64 Dawn and Dusk.

Yep, that’s right. Child Link gets a smaller metal shield this time around.

The expansion features completely all new content, areas, music, and its story. It’s fairly short- if you give it a go you’ll find yourself finishing it in about two-to-three hours. My favorite area has got to be the Red Ice Caverns. The new music is in the area is great and fits the area perfectly, so much so that it sounds like it came from the original game (to be fair it’s probably because the soundfont of OoT is so instantly recognizable).

As far as Zelda romhacks go, this is one of the more polished and technically impressive I’ve played. I’d recommend this to anyone who’s a fan romhacks or just likes seeing new stuff being done on old hardware. If you want to give it a try, you can find out everything you’ll need to know on the game’s github page.

Fun with Shaders: An Introductory Look at Godot Engine’s Shading Language

In the field of Game Development, shaders are something that I’ve tended to shy away from. Usually I just get by with good old amateur programmer art and never bothered to learn how to use them, mostly due to lack of knowledge. What can they do? When should I use them? Why am I stuck using OpenGL2.1 on ancient hardware when learning the new OpenGL pipelines would be a lot less cruel? Well, times change and so does the computer hardware I use, so there’s no better time to get off my ass and get a good handle on shaders.

Getting Started

So, the first thing we need to understand is that a shader is a program that takes an input (vertices, images, time, ect) and produces an output. This output can be a 2D image, or even 3D geometry. Simple right?

To give a quick example, open up Godot (preferably 3.0) and create a Sprite node and give it a Texture. Find “CanvasItem” in the Sprite’s properties and add a new material shader. Once a material shader is added you can then assign a shader file.

The bottom pane will now display the Shader tab. Much like writing scripts for nodes, you can write shaders and apply them to the Shader property under CanvasItem in the Inspector. Unlike Godot Script, shaders are written in Godot Engine’s in-house shading language. With that in mind, it’s a good idea to take a look at the documentation, or at least have a tab open for reference. Good? Let’s get started.

The first line of any shader script is for specifying the shader type, of which there are three:

  • spatial- A shader type for 3D rendering.
  • canvas_item – A shader type for 2D rendering.
  • particles – A shader for particle effects.

There can be only one shader type for a shader, and the shader type determines what built-in functions you can use, among other things. In this example we’re working on a sprite, so we’ll use the canvas_item type. After specifying the shader type, we can then choose to specify several render modes with the render_mode keyword. You can find a very short list of available render modes for canvas shaders here. blend_mix is the default render mode, but we’ll put it in just to be complete.

Next we’ll take a look at processor functions. Processor functions are functions where the bulk of our shader work takes place. There are three processor functions, and they each apply shaders differently:

  • vertex() – As the name implies, the vertex processor functions runs on the vertices of a 2D or 3D object.
  • fragment() – Works on the pixels in between vertices. For 2D shaders, we’ll be focusing on this one the most.
  • light() – Similar to fragment as it affects every pixel, but it also takes into account every light source that hits an object.

All the processor functions are similar in that they all require a void return type. 

Fragment Shader

Let’s work with the fragment processor first. The simplest shading we can do is to take a color, a vector with four fields (red, blue, green, and alpha), and assign it to COLOR. Now COLOR is a built-in variable that represents our output. When this shader is used, our cyan-colored vec4 is written to every pixel of our sprite. Since shaders run on a GPU which have many cores, every pixel of our sprite is written to in parallel, as opposed to a serial manner like CPUs. This means that shaders can preform large-scale operations on graphics way faster than a typical CPU. Anyway, what if we want to keep the texture that was on our sprite?

Thankfully, keeping the texture of our sprite only takes an extra line of work. In the code snippet below we use the built-in texture method to write the texture data of our sprite to COLOR. Then in the second line we change COLOR by multiplying a vector with itself. Easy, right? The texture method requires only a texture, and the on-screen coordinates of that texture (UV).

COLOR = texture(TEXTURE,UV);
COLOR.rgba = COLOR.rgba * vec4(1,0,0,1);

Vertex Shader

Now let’s take a look at a simple vertex shader.

The vertex function is a pretty simple one-liner. We increment the coordinates of our texture, VERTEX.xy, with a built-in sine function and TIME. And like a good ol’ sine wave should, it goes back and forth.

We can also write our own functions. Here we have a gradient function that colors our texture based on it’s coordinates in the viewport.

shader_type canvas_item;
render_mode blend_mix;

vec4 gradient(vec2 fragcoord) {
	vec2 grad = fragcoord.xy/vec2(1024.0,600.0);
	return vec4(grad.x,grad.y,0.0,1.0);

void fragment() {
	COLOR = gradient(FRAGCOORD.xy);

We start by taking the coordinates of our fragment and normalizing it by the size of the viewport, which for the default Godot 2D scene is 1024×600 (Surprisingly, there’s no built-in variable available for getting the viewport size in the canvas_item shader type. We can pass variables that aren’t built-in to our shader scripts, we’ll get to that). This operation gives us a vec2 which we can use to create a gradient.

Try putting grad.x or grad.y into a different order in the vec4 to get different colors. I manually resized our sprite to match the size of the viewport. If you don’t resize it you’ll get an unimpressive image.

Creating Interactive Shaders

A nice feature of the Godot Engine is that we can pass in variables from Godot Scripts into our Shader Scripts. In the example below, the gdscript sets two values in our shader script with the set_shader_param() method. We can also use get_shader_param(), which we can use to retrieve uniform values.

Or, like in our gradient example above, we can get the size of the viewport without hard-coding it in our script, like so:

Make sure to take advantage of Godot’s built in help.

I’ve also made it so that the sprite’s texture scales with the viewport for a little bit of interactivity.

Yours should look better. I just limited the colors because I wanted a smaller gif. If I ever get webm encoding/ffmpeg set up on Windows I’m sure I can get this down to <1MB.

The set_shader_param() function is an incredible tool when it comes to getting outside information to shader scripts, and can add a good deal of functionality for games.

Dragon Quest XI Reveiw: The Tried and True Electric Boogaloo

Beachfront of Puerto Valor, one of the many locales in the game.
Beachfront of Puerto Valor, one of the many locales in the game.

Despite their exhaustive tendencies, old school JRPGs are something that I don’t think I’ll ever tire from. Graphically they’ve advanced leaps and bounds throughout the years, but every time I take the plunge into a new one I’m always greeted by the same familiar hallmarks: classic turn-based combat, in-game menus, and copious amounts of text box dialogue. Dragon Quest XI has enough fetch-questing, giant world tree climbing, whale flying, and legendary sword forging tropes palatable for only the most indentured players of the genre. There are just some integral, cardinal truths, to the genre that never seem to lose their charm. 

First Impressions

I’m going to preface this by saying that Dragon Quest XI is somehow the only game in the series I’ve played in its twenty some-odd year run, aside from playing a few hours of the OG Dragon Quest on a refurbished NES ages ago. As the saying goes, there’s no better time than the present, and what better way to get introduced to the most popular RPG series to come out of Japan than to start with it’s eleventh mainline iteration? Well, introduced is probably the wrong word it use here. I’ve known Dragon Quest for a long time – or it’s systems at least. I’ve played enough Final Fantasy’s, Tale’s of…, Breath of Fire’s, and Wild Arm’s to know exactly what it had in store for me. After a pleasant opening cinematic I settled in to get anothe 40+ hour world-saving adventure under my belt.

One of the first things that smacked me in the face while starting the game was the voice acting. I was really hoping that the game would come with both English and Japanese audio (better brush up on that Nihongo you dirty baka gaijin), but to my disappointment there’s only English audio that ranges from ehhh to good enough. For some reason, the Japanse release opted to forgo voice acting, while the Western releases come complete with full English voice acting for battles, cutscenes, and some in-game skits. Did I mention that it’s English with a cockney accent? You had better like various exclamations of “Crikey!” and very liberal uses of “auld” and “aught”. I really feel like I shouldn’t hate it as much as I do, but I kinda like my JRPGs to be, uh, Japanese. That’s not to say I don’t like English voice acting, but on a scale from Xenoblade Chroncles to Xenoblade Chronicles 2, it was definitely leaning towards the latter.

Still yammering on about the voice acting, there’s some interesting choices when it comes to voicing different characters throughout the game’s world, Erdrea. Many of the locales you’ll visit will be whimsically modeled after different real world cultures, and are usually loaded with an almost overbearing amount of wordplay and puns. For example, you’ll visit the the mountainous Kingdom of Hotto, known for its forged steel, hotsprings, and populace which all speak in haiku. Then you have Gallopolis, the Arabian desert kingdom. Gondolia, the Italian port city where people just drop Italian words every other sentance to remind you that you’re playing a fantasy JRPG. Same with Honolulu Lonalulu. There’s also the Kingdom of Sniflehiem, which is situated in the frozen north of the world. The different lands you visit in the comes off as incredibly stereotypical and so on the nose it could only be described as a lazy cultural caricature, and it’s only made worse by the accents. I don’t mind the visual gags. I get it, Gondolia is modeled after a Venetian fishing town and has canals with gondolas. The added voice acting was just a bit too much for me. The entire aesthetic of Dragon Quest is steeped in these gags, from the world itself, to the creature names, abilities, item descriptions, quest names, item names, and it just doesn’t end. A real love it or hate it sense of humor, to say the least. Although, while I never really got used to the voice acting, I eventually did warm up to the mountanous tons of puns.

A screenshot of the battle system. Four heroes face off against two hoodlums. That is, two axe wielding monsters wearing... hoods.
Get it? HOOD-lum? Yeah there’s more where that came from. Bonus points if you can guess what the Cruelcumbers look like.

If I had to use one word to describe Dragon Quest, it’d be comfy. The music is bright and cheery, soft and warming, and bombastic when it needs to be. The art direction colorful and cartoony. The character design by Akira Toriyama instinctively gives me Dragon Ball vibes, so I’m already in the mood for an adventure. All the classic RPG tropes I’ve grown to know and love (or tolerate) are present. The protagonist is the chosen one to banish an ancient evil from the land, the greatest kingdom in the land that’s supposed to aid you brands you as the bringer of darkness, you meet friends in strange locales, and you collect six shiny McGuffin orbs to visit a giant tree named – what else? – Yggdrasil. Oh, also you get thrown in prison. It’s a very by the numbers plot, and while anyone with any experience in the genre will easily predict the twists and turns. Well, I can’t completely say everthing was oldhat. At one point your band of heroes travels to the town of Octagonia to enter a masked fighting tournemant and instead find themselves in the middle of a kidnapping/performance enhancing drug ring. Can’t say I saw that coming. For the most part however, instead of shying away from its roots, the game digs even deeper and leans into the cliches full force. It’s interesting because any other game that has themes of heroic battles of light and dark or moments of a party overcoming obstacles through the Power of Friendship™ would come across as lazy and a bit childish. Don’t get me wrong, it does tread in that territory at a few points. But the game has prepared you for such a fun and cheery time with it’s visuals and barrage of puns that you just can’t help and enjoy the schlocky moments, because as wish-fulfilling as it is we all want to save the world from the clutches of evil.

The Gameplay

Much like the narrative, it compliments the aesthetic well. Dragon Quest XI has a very gradual difficulty curve where grinding isn’t mandatory, and the player has full control over what, where, and when you choose to fight (with the exception of overworld sea travel). In battle, you can swap out party members at any point and experience is shared between all party members as long as they’re alive by the end of the battle. You can choose to control your party members manually or have them be AI controlled. You can fast travel to any place you’ve been to before on the world map or escape dungeons with no strings attached. No quests are timed or missable, so you don’t have to anxiously scrub the world after every major event to maintain a completionist run. You can build your party members with different skills and stats, and respec them at any time for chump change. It’s an easy game for the most part, and I’m fine with that. And hey, if you prefer the harder difficulty, that’s available too. It’s incredibly refreshing to not have to stop progression in a game at some arbitrary point in the game just to grind, or have the anxiety of missable quests or content, or worry about nerfing a potentially great party member because I neglected to research their optimal build beforehand. Much like the aesthetic and narrative, it’s easygoing and carefree; a fun Sunday joyride that you can take however you like. The flexibility and quality of life improvements the game affords also go a long way into postgame content that has challenge and depth. You’ll want to do quite a bit of character respecc’ing and some metal slime hunting for EXP. Maybe you’ll rebuild Erik from dual-wielding knives to high-speed, high-crit, sword skills. Rebuild Sylvando to use whips for great crowd-control attacks. You’re encouraged to try anything and everything; gold, equipment, skill points are no object. Just like the narrative and dialogue, it’s all just easygoing fun.

A screenshot of the main character facing the camera. An unfortunate texture glitch occurred and his face is completely black, save for his eyes.
Here’s a very unfortunate texture glitch.

The Party

Getting this out of the way now, from most to least favorite: Sylvando, the flamboyant comic-relief character who turns out to be the best bro, Veronica, the magically-stunted loli mage with an attitude, Hendrick, the indestructible no-fun-allowed knight, Erik the sarcastic best friend rouge, Jade, femme fatale warrior princess, Rab the pervy sage, and Serena the healer. As far as the motley crew of RPG parties go they are exotic as any other, but the character interactions were surprisingly sparse. Throughout the course of game you never really get a chance to interact with your party; there’s an option to use “Party Talk” in the menu which will give you dialogue from them at any time, but it’s really uninteresting. 90% of the dialogue can be boiled down to just “We’re in a weird spot huh?” or “Let’s figure out what’s going on.” This seems like a lot of missed potential to me, especially since I’ve played other RPG’s with similar systems that are way more rewarding. Persona 2: Innocent Sin for example places your party members in the current room you’re exploring, and talking to them can result in skits or background knowledge on a character you wouldn’t have known otherwise. In one instance, you learn that Michel, one of your best friends and the lead singer of his own band Gas Chamber, has an emotionally abuse relationship with his father. How does this get revealed? Well, if you go to the sushi shop owned by Michel’s father you get treated to a scene where Michel is berated by his father for pursuing his dream of becoming a talented musician and dressing like a punk. It’s not a major plot element or anything, but it makes you understand the character more and their motivations (I’d highly recommend Persona 2, the gameplay is dated and unforgiving, but I really like how character focused the game is). For another quick example look to the Tales of… series. If you’re in the right place at the right time AND with the right party members you’ll be treated to voiced skits. These are usually vehicles for exposition and jokes, but can offer some world building and character development on the side. Point is, Dragon Quest XI really falters with this, which is really surprising considering how much charm and care this game shows on a surface level. The best character development you can hope for is their arcs to go through the motions in the main story. The only notable exception I remember finding is some text from a bookshelf telling the tale of how Sylvando, and his right hand man Davé, prank the navy by dyeing the sails of all their ships neon pink. Speaking of Sylvando, he’s the most developed and most relevant character in the game by far. Born and raised as a knight by his father in the town of Puerto Valor, Slyvando abandons his path to knighthood in order to pursue his passion: making people smile as a circus preformer. You recruit him in Gallopolis, where he leaves his troupe and decides to join your party because no one’s gonna smile if you can’t stop the ancient evil. As the plot progresses things unfortunately get worse before they get better, and Erdrea lies on the brink of destruction. What does Slyvando do? Parade across the land in a feathered mariachi uniform of course. No matter how dark life gets, you just need to keep on smiling. You just can’t not enjoy a character like that.

The ever determined Slyvando.
"But I wasn't going to let that stop me! Oh no! This was my calling--to make the whole world happy! I would be a knight in smiling armour!"
Shine on you crazy diamond.

Closing Thoughts

Essentially the JRPG equivalent of a best-of hits album, Dragon Quest XI is an endearing trip which hits all the classic genre high notes, all on the back of a flying whale. Coming back to a game like this after years of not playing many JRPGs is definitely strange. One part comforting and one part melancolic. Imagine coming back to your hometown after years of being away: on some level you’re enjoying your nostalgia, while on the other you might simultaniously be saddened when nothing has changed. Like a timeless portrait I’m comforted by the familiarity of Dragon Quest’s charm and my own nostalgia, but it’s painted by the same tried and true numbers that have been used in the genre for the past decades.  However, much like Slyvando, Dragon Quest XI is just a game that wants to make you smile, and sometimes that’s just what you need.