LoginSignup
3
4

More than 5 years have passed since last update.

UnityでLive2Dの描画順を変える:RenderTextureを利用して描画する

Last updated at Posted at 2015-05-13

概要

UnityでLive2Dの描画をするにあたって描画順の制御に工夫がいるよう.
RenderTextureを使って回避するというメモ.
Live2D_SDK_Unity_2.0.08_1_jp/sample/Simpleにいくつか設定を追加して,
RenderTextureを利用してキャラを描画し,描画順の制御を試みた.
※以下を読まなくても,SDKにsample/RenderTextureというサンプルがある.

Live2Dの描画設定(詳しくはこちら)は二つあり,それぞれにメリット・デメリットがある.
それぞれ困りそうなところは,
L2D_RENDER_DRAW_MESH_NOW:layerを設定できないなど
L2D_RENDER_DRAW_MESH:非推奨(Unityの非推奨のAPIを使っており今後も使えるかわからない

開発環境

  • Live2D_SDK_Unity_2.0.08_1_jp
  • Unity 5.0.1f1

Render Texture

オフスクリーンレンダリングのようなもの
カメラが写している情報をTextureにする
詳しくはここを参照

手順

以下の三つを追加して,Live2Dのモデルをカメラで写してオブジェクトに貼るイメージ
* Render Texture
* カメラ
* レンダーテクスチャを適用するためのオブジェクト(Plane)

プロジェクトを開いて,
1. Project > Create > Render TextureでRender Textureを作る
2. Render Textureを選択してInspectorでサイズを1024*1024に設定
3. GameObject > Create General > CameraでCameraを作る
4. 2で作ったカメラのTarget Textureに1で作ったレンダーテクスチャを設定
5. Hierarchy > Create > 3D Object > PlaneでPlaneを作る
6. Planeに1で作ったレンダーテクスチャを設定,ShaderはUnlit/Textureにする

参考

http://docs.unity3d.com/ja/current/Manual/class-RenderTexture.html

3
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
4