Waterfall Splash

I added a splash to the waterfall.

waterfall splash

It’s a basically a vertex shader that uses a sine wave with a varying amplitude. The jagged effect is because the plane only has about 10 vertices on the top side, so there’s not enough to smooth it out.

The aesthetic definitely clashes with everything else, but it’s mostly just a placeholder for now.

Think of it like a scaffolding. Will be tweaking it with different textures and styles moving forward.

Wind Waker Waterfall or: Adventures in Shader Writing

60GBK5I
I spent the past two days trying to figure out how to implement a wind waker style waterfall in the game.

I hadn’t written a shader in quite a long time, so my shader writing skills were very rough. I’d compare it to learning to write shaders from scratch, but it wasn’t that bad. I had forgotten how to declare variables and the specific order in which parts of code need to be in for the shader, but most of the stuff came back relatively quickly.

In the future, I’d like to try to stay in shape by writing shaders on a more regular basis.

Anyway, I thought it’d be a good idea in any case to take some time to write down what I’ve learned, for when I forget later.

First, some resources:

Cg Programming / Unity Wiki - Probably the best tutorial on writing shaders for Unity. Plenty of examples that you can use to study from and tweak.

Vertex Shaders in Unity A great intro and breakdown of shaders in Unity. I think there’s some issues with terminology, specifically with the post using the term ‘vertex shaders’ incorrectly, but overall, it’s pretty good.

Also, Visual Studio and Monodevelop doesn’t do text highlight for shader code by default, which makes writing shaders unnecessarily more difficult.

There’s a Visual Studio extension called NShader which adds highlighting, but unfortunately it hasn’t been updated for a while, and doesn’t work with Visual Studio 2013.

Fortunately, someone over at the Unity forums upgraded NShader to work with Visual Studio 2013.

The instructions aren’t great though.

In the thread, someone says:

if it doesn’t work. go to the folder where it is installed.
C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\Extensions\some random numbers
now copy the downloaded files into that folder.

now go to regedit and search for
HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\12.0\FontAndColors\Cache
and delete it.

start up vs.

 

The “some random numbers” part tripped me up. Basically, in the folder ‘Extensions’, there are several folders that are each named a random collection of letters and numbers. You have to open each one to figure out which one is the NShader one. It’s pretty obvious once you do, as it’ll be a bunch of NShader files. Now, copy the downloaded files into this folder, and then do the search on regedit and delete the cache file.

Attempt #1

vertex_displacement_shader

What tripped me up was that I had forgotten how to incorporate time to control a variable.

It’s basically _Time, a float4, which is actually this: (t/20, t, t*2, t*3)

So if you want to use time, you can just write: _Time.y

Anyway, here are a bunch of shaderLab built in values.

Attempt #2

vertex_displacement_shader_napoleon-dynamite

This reminds me of Napoleon Dynamite dancing.

Attempt #3

vertex_wave
I got sine wave offset on vertex displacement working!

Transparency

jD6Dz5r

I wrote a separate shader that handles texture trasparency.

Result

The final version it was just a matter of combining the sine wave offset, transparency, and finally a scrolling texture:wind_waker_style_waterfall

Bonsai Tree Design

Continuing to work on bonsai tree designs. My plan at the moment is to create 100 of these, and then pick the best ones to randomly place throughout the game.

Some people have suggested writing a script to generate these trees, but the thing is, I still haven’t figured out the pattern behind the bonsai trees, and I think it’d actually be more work to come up with that script and tweak it.

Besides, it is pretty fun to make these.

Here are some images:

A21L9t7 2 3

Also, if you ever work with reference images, I highly recommend getting Kuadro. It’s an image viewer for windows.

It’s incredibly useful, and lets you do things like set an image to be “always on top”, so you don’t have to switch between applications when modeling and drawing something. It’s basically an app that I’ve wanted for the past 2 years.

4

Waterfall

Also, finally found the style of waterfall that will be in the game.

This one from Wind Waker is really close:

5

Here’s a thread about recreating it in Unreal: http://www.polycount.com/forum/showthread.php?t=98578

Here’s a thread on doing it in Unity: http://forum.unity3d.com/threads/the-legend-of-zelda-wind-waker-styled-water.298724/

I put together a rough mock up of it to see how it’d look in the game. The color is all off, but I think it’s promising:

6

Also, Wind Waker seems like an incredible technical achievement for its time: http://simonschreibt.de/gat/zelda-wind-waker-hyrule-travel-guide/#history