2015年8月29日土曜日

Drone Space Defenseゲーム開発

Drone Space Defense開発チームがシリコンバレーでのDrone Space Defenseデモ後解散したので今後からは僕がゲーム開発に携わっていきます!
Drone Space Defenese プロトタイプ
ドローンのリアルタイム3Dマッピング

パソコンからのA.R. Drone PS3テレオペレーション
Drone Space Defenseでは今までDrone Space Defenseのプロトタイプ(ゲーム)の開発、ドローンの画像追跡、リアルタイム3Dマッピング、nodejsを使ったwebsocketサーバーの実装、ドローンをPS3で操作できるようにしたり、クラウド構築、ドローンシミュレータの設定をしていました!
 
ゲーム製作を本格的に始めてそろそろ12日目です!  
現在Unityというゲームエンジンで開発を進めています。





Unityボールゲームチュートリアル
Unityサバイバルゲームチュートリアル
Unityサバイバルゲームをブラウザにビルド

5日間はunityのチュートリアルのビデオ2本、ネットのC#で書くUnity入門とC#の並列プログラミング、非同期プログラミング技法の学習をしていました。


6日目はOculus Rift DK2がWindows10で認識されないためwindows8.1のダウングレードを行っていました。

画像処理を使った拡張現実のアセット


C#のOpenCvSharpで画像処理
Virtual Realityとwebカメラと地形データの統合
Drone Space Defense Oculus Rift バージョンのモックアップ
7日目にVRゲーム開発に取り組みました!12時間でunityのアセット調査、C#/Unityでの画像処理の調査・実験、12時間でDrone Space Defense Oculus対応のモックを完成させました。


Unreal Engine Oculus祭りで最新モックとプロトタイプの展示

8日目の午後はG-tune&AMD OcuFes2015夏に参加して他の開発者のVRアプリを楽しみ、夜はUnreal Engine主催のOculus祭り2015でDrone Space DefenseのOculus対応モックとDrone Space Defenseプロトタイプ2Dモニターバージョンの展示を行いました!
leap motion届く。



ゲームセット


VR Planetarium


9日目にはLeap Motionが届きました!Leap Motionは手をコンピュータの世界にもっていくことのできるVirtual Realityのデバイスです。Leap Motion + Oculus Riftのアプリケーションを色々動かしてみました。Leap Motionで広がるDrone Space Defenseの可能性を感じました。

UnityちゃんとJapanese Otaku CityとVR

10-12日目はUnreal Engine Oculus 祭り2015で指摘されたOculus酔いを解消しようとUnityとVRの最適化に取り組みました。Oculus酔いを解消するにはFPSの早さが関係するそうです。今回のモックはオブジェクトが3,4個くらいしかなかったので簡単な最適化を行ったところ75FPS以上出て問題解決なのですが、一般的なVRの最適化技術を習得しようとポリゴン数が多いUnityちゃん、Pocket QueryちゃんとJapanese Otaku City Assetを使ったものでVRのFPSを上げることに取り組みました。Oculus Riftの推奨FPSは75FPSで酔いを軽減するために必要です。
1. ビルドの最適化オプションをすべて適用したら、20FPS前後出た。
2. 光、空の焼きこみ、static/dynamic batching, forward light renderingを適用したがFPSが変わっていない。
Japanese Otaku CityのOcculusion Culling
3. Japanese Otaku City AssetのOcculusion Cullingをしたが重すぎてRAMメモリエラーになったので別のAssetに変更。
4. Occulusion Cullingをしたが、FPSに変化なし。
5.UnityのTarget.FrameRateを75にしたが、変化なし。
Profilerで解析
6. Unity ProfilerとUnity Frame Debuggerで解析を行ったところ、drawcall数が1000以上でshadow renderに最も時間とdrawcallが使われていることが判明(800 drawcallくらい)

7. Lightingのauto設定をすべて解除しすべてマニュアルでlightmapをビルドしたところ、drawcallが500-600減少。

bakeしたunityちゃんとpocket queryちゃん
8. 次の最大のオーバーヘッドはキャラクターのskin mesh rendering. (drawcall が400) mesh bakerを使いすべてのオブジェクト群のskin mesh renderingのdrawcallを10以下に。
快適FPS.

9. CPUは余裕の75FPS越え。GPUも50FPSくらい出るように。現在最大のオーバーヘッドがopaque.forward rendering(10ms)でOculus酔いの問題はOculus DK2の画面のブレだけに。これはOculus Tracking Cameraをつけるとブレが解消できる。 syncの時間はprofilerを閉じるとなくなるので実際は問題ない。
なぜかDraw Callが900.

10.Japanese Otaku City Assetに変更しJapanese Otaku City bake後Occulusion Cullingに成功。すべてのオブジェクトをbakeしたがなぜかDraw Callが900もある。原因はJapanese Otaku Cityのポリゴン数が多くDynamic Batchingをしてしまったため。これを解決するにはCuda Coreのより多いGPUかpolygon数の減少が必要。polygon数を減少させるには外部の3Dモデリングソフトを使用する必要がある。コンピュータグラフィクスを勉強中。
unity in android

AndroidのUnityプロジェクトにも現在挑戦中です!



2015年8月28日金曜日

Drone Space Defense Game Development(English)

Hello! Recently, the Drone Space Defense development team have been separated after the Sillicon Valley Demonstration, so now also I'm going to taking part in game development!
Drone Space Defense Monitor Version 2D Prototype
Realtime 3D Mapping from Drone Camera in Facebook HeadQuarters


A.R. Drone PS3 Teleoperation from Computer

Before, I made the Drone Space Defense Main prototype(game) ,realtime 3d mapping system using ROS, image tracking drones with OpenCV, websocket server coding with node.js,  drone ps3 teleoperation server setup, drone image streaming mjpeg server setup, drone simulator setup for the Drone Space Defense development.

  
Currently I'm developing game in Unity Game Engine. I start working on game development, and this is my 12th day of game development.
Unity Ball Game Tutorial

Unity Survival Game Tutorial
Built Unity Survival Game in Unity Web Player

1-5th day:  I did the 2 Video Unity Tutorial, and the Web Unity tutorial using C#.

               Also, I studied multithread programming and asynchronous programming in C#.
 
6th day : I started working on Oculus Rift. Unfortunately, I'm using Windows 10, and Oculus Rift didn't work on windows10 because of GPU version, so I had to downgrade the Operating System
.
Cool image Processing assets of Unity. Unfortunately the asset dll crashes with oculus dll so I couldn't do Oculus integration.
Image Processing(Canny Edge) with OpenCvSharp. It can use C++/C like programming style.
Working on WebCamTexture and Oculus Rift.

Prototype/Mockup of Drone Space Defense Oculus Rift Version.
7th day : I started working on VR game development. I searched some useful asset in Unity, gathering information in Unity, and finding some useful image processing tool in C# for 12 hours.
And in the last 12 hours, I made the prototype of the Drone Space Defense Oculus Rift Version. I had little time to sleep this day, because tomorrow night I am going to do a booth in Oculus Rift Festival in Japan.
Booth of Drone Space Defense at Unreal Engine Japan Oculus Festival 2015
8th day : In noon, I went to the G-tune& AMD Japan OcuFes 2015 Summer and enjoyed Virtural Reality Applications. In night, I did a booth in the Unreal Engine Japan Oculus Festival 2015 with my new prototype(oculus supported) and the 2d monitor version prototype of Drone Space Defense. 2 prototypes.

Leap Motion arrived!

Gaming Set(actually, drone is added to the full game set)
I think this is great VR application using Leap Motion! VR Planetarium
9th day : Leap Motion arrived. I did some setups of leap motion and playing with leap motion. I feel great potential of Drone Space Defense using leap motion.
UnityChan, Japanese Otaku City and Oculus Rift




10-12th day : I had a report in the Unreal Engine booth that my Oculus Rift Prototype will get motion sick . I searched what causes the motion sick of Oculus Rift, and it was the delay. Looks like Oculus Rift prefers more than 75 fps.Solving my prototype motion sickness was not so hard, because I have few objects in that protype. But I want to get the skill to solve this problem generally. This time I used Unity-chan animation character and ZENRIN japanese otaku city assets which both have enormous amount of polygon and meshes, texture. I checked the Unity reference to do optimization.
1. I did all checks in Unity Optimization Build Options. I got around 20 FPS.
2. I used bake lights, baked skyboxes, forward light rendering, 0 light pixeling. The FPS seems to be unchanged.
Working on Occulusion Culling of Japanese Otaku City

3. I tried to do Occulusion Culling of Japanese Otaku city, but it crushed of RAM error because it was too heavy to process. I stopped using Japanese Otaku city and used some other object groups.
4. I did Occulusion Culling, but the FPS didn't seem to be changed.
5. I set the target frame rate of Unity to 75 FPS. But this didn't work too.
Profiling my game performance.
6. I started using Unity Profiler and Unity Frame debugger. I found that more than 1000 drawcall are used. I searched about drawcalls and look more carefully of the Unity Profiler. Shadow was the biggest overhead.
Cutting 600 drawcalls by using baked lightmaps.
7. I found that lightmap setting was auto and I changed to manual mode and bake it. I could cut 600 drawcalls.
Mesh skin baking unityChan, pocket query chan, and terrain. Their overall drawcall is below 10.
8. Next time the character object skin rendering was the biggest drawcall(about 400) and overhead. I used mesh baker unity asset to combine meshes and textures and made their overall draw call below 10.
Great FPS.
9. This time CPU FPS was way bigger than 75 FPS and GPU is over than 50 FPS. The display GPU synchronization  is the overhead of the profiler so this overhead doesn't happen in real problem.  Now the biggest overhead is opaque rendering(10ms) and the main problem is oculus screen blurring getting motion sick. This problem can be solved using tracking camera of oculus.
Why baked Japanese Otaku city is taking drawcalls?
10. I solved this scene optimization and changed the terrain asset to Gigantic Mesh Japanese Otaku City and did a baking. This time I succeed in Occulusion Culling. The FPS was below 30. I searched by frame debugging and unity wasn't doing static batching because the number of vertices was too big. It seems this problem can be solved by larger core GPU(my GPU is NVIDIA 940M for laptop and the CUDA Core number is 384) by larger batch processing or downsampling polygons. And about the down sampling, I have to use external 3d modeling software. So I started learning 3d graphics now.
unity working on nexus 5 lolipop.
Also I started working on getting android sensor information with unity.

Check out for my latest updates in Drone Space Defense FB Page !

2015年6月17日水曜日

ロボット会社RTでロボット研究開発執筆

4月8日からロボット会社のブログに執筆させて頂いています。
5月のロボカップジャパンオープンはこの会社のロボットを貸して頂けたため、高校生でも一人参加することが出来ました!新リーグであるSPLリーグの活動など現在3回投稿しています。
RTcorporationはロボットの受託開発やロボットショップを行っている国際的な日本の会社です。