Now before we use this depth information, we need to take a snap shot of what’s behind the mesh. This is good! It’ll help with making the water distort in a pleasing way. You should note that the vertex offsetting from earlier is affecting the depth testing. Anything past this point, is not really a concern to the shader, but adjusting it’s value can produce varying degrees of water clearness. I’ve used a remap node to clamp past a certain distance to black. The scene depth is a node that produces a grey-scale image where everything white is really close to the mesh’s surface while everything far away is black. This is very important for the look of the water and is the cornerstone of almost every further step in the ocean’s final look. Let’s move on to the color!įirst, to get the color right, we need depth data. So the black becomes smooth, and the white/high parts of the wave become rough.Īnd that’s all we need for the surface detail of the ocean. Using this same map, I lerp between a flat surface and some scrolling normal map textures. (Checkerboard just to illustrate the mesh distortion)
The results are that the vertices bob up and down! I take this map, multiply it by a max wave height value, and also the normal direction of the ocean mesh. The black parts will be the lowest portions of my waves while the whites will be the highest. By blending a few distorted perlin noise maps and panning them in a defined direction, I end up with an undulating grey scale map. Thus it gets a pretty large budget! Let’s break it down a bit so you can see what’s going on.įirst we need to get the waves flowing right. The ocean is a very important character in Slime Rancher as it takes up a very large portion of the screen real estate. I want them to feel like actual substances but still evoke the game’s illustrative/painty style. Slime Rancher is also not a realistically rendered game, but that doesn’t mean I don’t want my materials to seem REAL. I use Shader Forge from the Unity asset store to do all my shader work. Like I said, shaders can get super complicated. So let’s take a look at the shader for Slime Rancher’s ocean. However, shaders are also super rewarding to work on! A simple change can have dramatic effects on your final result and seeing those happen in real time is very satisfying. With that in mind you have to be careful with your shader budget. Polygon count is no longer the main bottleneck for computers these days, but instead complicated shaders tend to be the big choke. Now first, I got to say, shaders can get super complicated. Particularly, the water shaders I’ve built for this game. Today I’d like to share a bit about shaders for you to enjoy. I’m Ian, and I’ve taken the task of leading the art on Slime Rancher.