Tag Archives: shaders

Universal poly water

So I’ve rebuilt my low poly water shader from scratch! The reason for the rebuild is that the shader I had, and have shared on here was quite limited platform wise, only worked in forward rendering and on DX11 capable hardware, which felt veeery limiting.. So fast forward to today, and I’ve got my New Universal Shader running on everything! With reflections working on supported platforms, and also I now detect where water is shallow to get the foamy look along the shore..

Edit: This is what it can look like in action:

Screenshots from iPhone: 


  

It looks awesome on the iPhone, but no reflections on my iPhone 5 (Edit: Reflections are working!)..  Which only supports Open GL ES2.0 i think.. Will test on 6S soon. On tvOS it does not look that nice,  but I think that has something to do with the way lighting is done on that platform, not sure! (Edit: It now looks really good! Quality settings was wrong!)

Custom shaders and shadows

Since I’m quite new to this shader business I’m bumping into problems here and there, and this time I’m really struggling with solving it.

I’ve made this shader that I’ve gotten to cast shadows with a custom ShadowCaster pass but I’m still not able to get it to collect shadows in any way. I’ve tried getting the fallback to handle the ShadowCollector pass, I’ve tried diffent ways to write the shadowcollector pass, and I’ve tried setting the Queue to geometry and RenderType to Opaque instead of Transparent..

Shader coding in Unity is hard, because there isn’t much info to be found anywhere about how things work and how it should be done. Does anyone out there have any tips on how I can get this to work?

See the code below or download the shader here.

Low poly water shader

Edit: I’ve added a link to a downloadable version of the shader! Copying the code from this post does crazy stuff to the symbols..

The side tracking specialist strikes again.

I’ve been working on another project lately and ended up in need of low poly flat shaded animated water.

I tried editing the mesh at runtime by script. Using the method mentioned by joni.giuro here: http://forum.unity3d.com/threads/low-poly-water-help.276685/

But when using the standard plane with this script, basically 200 triangles and when you’ve separeted all vertices (600), FPS drops down from 1500 without script to 190 with script applied. If you add more planes or models with more triangles you quickly get to a point where you get 1 FPS. So I needed something else.

That’s when I figured I’d try my luck with shaders.

Tried googling for solutions, but nothing was to be found so I needed to build my own. With no experience in shader programming this proved to be harder than I expected. But fast forward through some horrible looking results to today. Now I’ve gotten to a point where I can take any plane (not having to worry about splitting verts) applying my shader and getting this:

Almost no hit on FPS with fully animated low poly flat shaded water with specular color. And with this solution:

I can add looots of planes with this shader with almost no hit on FPS. Here I’ve added got 30 standard Unity planes with 200 tris each, all animating off into the distance.

Here’s a video of it in motion:

So how is this done, you say?

Code below.

It’s not perfect but it works! F.ex. I’ve left the UV coords in there but don’t need them for this. And I’m not entirely happy with the waves just yet.. But here you go.

Link to downloadable version