Arduino <3 Unity

I’ve recently bought myself an Arduino Uno R3 kit and I’ve built myself some simple projects to get a feeling of what is possible with this stuff! Having little to none experience with microcontrollers I must say the Arduino is quite simple to get into, and the community is awesome with ALOT of tutorials and questions answered online! Much like the Unity community! One of my first projects was to try to get the arduino to communicate with Unity! My plan was to make a gyro-accelerometer for use with my computer! 

For this I paired the Arduino with a  Wifi-Shield(ESP8266) and a GY-521(MPU6050) 6DOF gyro/accelerometer. I set the esp8266 to be a client, hooked up to my computer as the server. I used a free library for handeling the gyroscope which converts the gyro/accel raw data to quaternion rotation and sends it as a string on the serial line. The ESP8266 transmits the string over TCP to the server. 

In Unity i set up a TCPListener on a seperate Thread that continuesly reads the strings from the Arduino and converts string back to quaternion rotation.

In operation it looks like this:  

 The setup is not very accurate so not very useful, but fun project to get working! 

Now I’ve started working on something else! Bigger, better and more beautiful! 

Poly particles

I’m not sure this is a good idea or what, but I’ve made another shader, that takes a particle system and creates a low poly version of the particles.. Looks like this:

Screenshots: 

   
    
 
Screenshots are nice and all, but video says more than a thousand screenshots..

I guess it will probably be quite heavy, since it needs extra camera that renders a displacement texture.. But it does look good or what? 

Low poly models

When I’m not making games or shaders I enjoy building 3D models in Blender. I’m  quite addicted to the low poly, flat shaded style so it’s all that kind of models. Of course the fact that low poly is simpler and faster to make is important for me since I don’t have time for anything else.. Here are some in progress renders I’ve done lately..

Nisse and varg..  The santa-like nisse is rigged as well, I’ve used the character in a Unity test project..   

   
Uppsala temple (Viking age)       

  

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:evolved

Hi, folks! I’ve continued working on my water shader! I’ve added transparency and today I added impact waves to the shader, which I’m quite happy with managing to do! It’s limited to 10 simultaneous “impact waves” at the same time at the moment. But adding more is not a problem. The collision points and impact force is sent to shader from script. And waves are calculated in shader.
Have a look at what it looks like in action:

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

Slow, not stopped

Progress on Battle Maze has been really slow for quite a while, but not as slow as the updates on this site. I’ve gotten sidetracked by alot of other projects, and personal stuff. Projects I’ve been working on is updates to 3ounce and other apps I’ve made, and I started working on a new game that I probably will never finish. But I’m now back to working on Battle Maze again, and progressing slowly. I’ve decided to use the new UNET Networking API introduced in Unity 5.1 for network games in Battle Maze. So far it seems quite simple to set up, and things are actually working. Documentation of the new API is a little lacking at the moment though so I have to google-hunt a lot to find solutions for simple problems that pop up. But it’s getting there.. I think! I’ve changed alot of the way the game plays lately so I’ll come back with some screenshots and maybe videos soon!

Unity WP8 Shadow Problem

This weekend I recieved an update to Unity (v 4.5.4f1) and I decided to try out getting realtime shadows to work on the Windows Phone 8 Version of 3ounce. Since Unity actually claims “shadows on all platforms”, I still haven’t gotten shadows to work for my wp8 builds.. I’ve tried out every quality setting and tried building a simple scene just for testing purposes, but no go.. This really bothers me since I want my game to look the same for Android, iOS and Windows Phone.. What makes it worse is the fact that on the Windows phone Emulator it Works fine! So I’m guessing that some wp8-phone models could pull the shadows off just fine.. But some, including my Lumia 930 can’t handle shadows. What bugs me is the fact that when shadows isn’t working the entire light actually cast a gigantic shadow covering everything within the max shadow distance..

 

ShadowTest Editor

This is what the scene is supposed to look like (In editor)

ShadowTest wp8

This is what it looks like on my Lumia 930.

ShadowTest wp_emu

And on the Windows Phone Emulator….

I’m not sure if I want to disable shadows for all wp8 or have an option for switching shadows on/off in settings..

We’ll see what I end up With.. but the best thing would be for unity or Microsoft to fix whatever’s causing this..