Posts tagged as 'Shaders'

Work
January 13, 2015  by  

As I quickly learned, there are a ton of techniques and tools used for creating water in Unity. The Standard Assets package includes pretty much everything you need to get the basics done, but there’s loads of third party tools availble to extend that functionality. There’s tools like Flow and SmartWater, and there’s also lots of interesting optimizations, like creating custom water meshes. But, to my dismay, almost everything out there is designed for 3D environments.

Granted, it probably would have been possible to adapt some of these tools to achieve an acceptable 2D top-down water effect, but it would almost certainly involve code changes and creating a new shader or two. I was looking for a solution that would be simple to implement, well documented, and that didn’t involve adapting a lot of 3D objects or concepts. Here’s a summary of what I was looking for:

  • Don’t need to interact with lighting
  • Don’t need reflections
  • Needs support for a transparency mask. Because we don’t have any 3D terrain in a true 2D game, we need a mask to define where the water is drawn, and at what opacity.
  • Multi-directional and multi-speed flow map support (different areas of the same water texture can flow in different directions and at different speeds).
  • A flow map generator/editor that can be used within Unity, so I don’t have to create them by hand in Photoshop

A few third party tools looked promising, like Flow, but they clearly designed for a 3D environment, and were a little lacking on documentation and examples. I wasn’t about to blow good money on something that I wasn’t even certain would support what I was trying to achieve. Since I was unable to find any sure-fire solutions on the asset store, I set out to create my own.

Continue Reading…


Work
December 19, 2014  by  

When working on my 2D lighting system, I needed to create some shadows. Shadows for sprites can easily be created by skewing the sprite and drawing it in all black. How much you skew depends on the position in relation to the light source. I already had a lighting and shadow system working in XNA, and now I just needed to get it working in Unity.

My first thought was to perfrom a skew from within Unity, in C#, like I did in XNA. As it turns out, you can’t (you can skew GUI elements, but not actual game objects). If you want to skew game objects, you need to skew the mesh itself, which I did actually get to work. However, this solution was a little ugly, and I’m not sure about the performance ramifications when recalculating every frame. So, I set off to find a more elegant solution.

Continue Reading…