Friday, June 22, 2012

Unity GPU Noise (Part 5)

And somehow 9 months have passed...

To be honest, I had a lot going on in my life since my last post.  My development laptop got stolen, my work laptop's hard drive failed, and other, more personal, things happened, which I won't get into.  As a result of the theft, I lost some of my work.  Not too much, just a week or two, but enough to make me unmotivated to return to my project and do the same work again.

About a week ago, I decided to finally dive back into it all.  I installed the latest Unity on my desktop and dusted off my old USB flash drive with the old copy of GPU Noise on it.  I decided to redo almost everything in the project to base it off of the texture-less implementations of noise in order to make it as easy and cross-platform as possible to implement in Unity (and hand off to other developers).

It was pretty smooth going, for the most part.  Based on my prior experience, I knew what I was doing.  The only big problem I ran into was trying to port mod from GLSL over to Cg.  I first used fmod in Cg, but that made the results all messed up.  I finally found this answer that explains the problem and how to fix it.  Once I implemented my own mod function in the same manner as GLSL's, everything was fine again.

Regarding the Android front, I'm not sure if it was something that got fixed in the Cg compiler between Unity versions, but all of my noise functions seemed to run on Android, for the most part.  The only issue I ran into is when I tried doing the 3D Voronoi displacement, the functions consumed too much processing and crashed the device.  This is because the displacement example has to call the function twice, which is a lot of processing.

Another Android "issue" I had was the performance of my devices.  I have an HTC EVO 3D and an ASUS Transformer Prime.  My EVO got about 47 FPS running the simple Perlin displacement.  I assumed the Transformer Prime would do better, but it only got 9 FPS.  Apparently the Adreno 220 outperforms the Tegra 3.  I ran some other benchmarks which came to the same conclusion.  I even looked at the Unity SystemInfo objects on both devices and I was really surprised to see the that Transformer Prime only has 61 MB of video memory while the EVO 3D has 216 MB.  I was greatly disappointed to see how poorly my Tegra 3 tablet performed.  I'll continue to investigate the issue in order to see if there's something I can do to improve its performance.

Just tonight I finally submitted my GPU Noise project to the Unity Asset Store.  If all goes well, it should be appearing on the store in a week or less.  Here's hoping!

Check out the latest demo!

Until next time!


Anonymous said...

very interesting. The displacement mapping works on my gtx 260 graphics card, which is DX9. Why is it showing displacement maps without DX11?

Patrick McCarthy said...

Displacement maps work fine in DX9. In fact, the demo was made in Unity 3.x, which doesn't even support DX11.

Displacement maps just need Vertex Texture Fetch through the tex2dlod() function which was added in Shader Model 3. (DX10 is Shader Model 4, and DX11 is Shader Model 5).