Recommended
PDF
【Unite 2018 Tokyo】そろそろ楽がしたい!新アセットバンドルワークフロー&リソースマネージャー詳細解説
PDF
【Unity道場 2月】シェーダを書けるプログラマになろう
PDF
【Unite Tokyo 2018】カスタムシェーダーでモバイルでも最先端グラフィックスな格闘ゲームを!
PDF
【Unite Tokyo 2019】〈七つの大罪〉をゲームで!高品質グラフィックを具現化するための技法と開発最適化のご紹介
PDF
Unity道場京都スペシャル トゥーンシェーディングとノンフォトリアリスティック風絵づくり入門_
PDF
C++0x in programming competition
PDF
2012 03-03-titanium plusquicktigame2d
PPT
C++0x in programming competition
PDF
20分くらいでわかった気分になれるC++20コルーチン
PDF
【Unite Tokyo 2018 Training Day】C#JobSystem & ECSでCPUを極限まで使い倒そう ~C# JobSystem 編~
PDF
Continuation with Boost.Context
PDF
PDF
PDF
PPT
shared_ptr & weak_ptr (ppt 初版, DL 専用)
PDF
PDF
PDF
PDF
PDF
Segue, Landscape, Touch events, Alpha and User Defined Runtime Attributes
PDF
PPTX
Brief introduction of Boost.ICL
PDF
はじめようARCore: Motion Tracking & Image Tracking編
PDF
PDF
ARコンテンツ作成勉強会 in 宮崎: はじめようARCore
PDF
iPad ProのLiDARスキャナ・サンプルを試す
PDF
PDF
ARCore/Tangoと簡易ヘッドセットHoloKitで光学シースルーAR
PDF
波に乗ってUnity3Dを使ってみているんだが (Ameba x Pixiv 合同勉強会LT)
PDF
UNITY5の地味だけど現場で 役に立つ新機能紹介 & 拡充されるクラウドサービス
More Related Content
PDF
【Unite 2018 Tokyo】そろそろ楽がしたい!新アセットバンドルワークフロー&リソースマネージャー詳細解説
PDF
【Unity道場 2月】シェーダを書けるプログラマになろう
PDF
【Unite Tokyo 2018】カスタムシェーダーでモバイルでも最先端グラフィックスな格闘ゲームを!
PDF
【Unite Tokyo 2019】〈七つの大罪〉をゲームで!高品質グラフィックを具現化するための技法と開発最適化のご紹介
PDF
Unity道場京都スペシャル トゥーンシェーディングとノンフォトリアリスティック風絵づくり入門_
PDF
C++0x in programming competition
PDF
2012 03-03-titanium plusquicktigame2d
PPT
C++0x in programming competition
What's hot
PDF
20分くらいでわかった気分になれるC++20コルーチン
PDF
【Unite Tokyo 2018 Training Day】C#JobSystem & ECSでCPUを極限まで使い倒そう ~C# JobSystem 編~
PDF
Continuation with Boost.Context
PDF
PDF
PDF
PPT
shared_ptr & weak_ptr (ppt 初版, DL 専用)
PDF
PDF
PDF
PDF
PDF
Segue, Landscape, Touch events, Alpha and User Defined Runtime Attributes
PDF
PPTX
Brief introduction of Boost.ICL
Similar to 深掘りARKit
PDF
はじめようARCore: Motion Tracking & Image Tracking編
PDF
PDF
ARコンテンツ作成勉強会 in 宮崎: はじめようARCore
PDF
iPad ProのLiDARスキャナ・サンプルを試す
PDF
PDF
ARCore/Tangoと簡易ヘッドセットHoloKitで光学シースルーAR
PDF
波に乗ってUnity3Dを使ってみているんだが (Ameba x Pixiv 合同勉強会LT)
PDF
UNITY5の地味だけど現場で 役に立つ新機能紹介 & 拡充されるクラウドサービス
PPTX
PPTX
PPTX
猫でも分かるUE4を使ったARコンテンツ作り方 初級編 ver 1.0.0
PPTX
Introduction to AR Foundation
PPTX
UE4.18でのARKitチュートリアル - UE4勉強会in大阪#3
PDF
PDF
HoloLensハンズオン:AirTap & SpatialMapping編
KEY
PPTX
PDF
PDF
PDF
More from Naoji Taniguchi
PDF
deep learningによるCTスキャン画像シーケンスの3次元セグメンテーションからのMixed Realityでの活用
PDF
Deep Learningを使って前立腺のセグメンテーションからVR化
PDF
PPTX
PPTX
Practical game development with Stingray 2
PPTX
Practical game development with Stingray
PDF
Practical use of game engine in CG and Robotics
PDF
PDF
デブサミ2015版「VRを使った データビジュアライゼーションの 可能性について」
PDF
VRを使ったData Visualizationの可能性について
PDF
VRを使ったビジュアライゼーションの可能性について @Unite 2015 Tokyo
PDF
PDF
PDF
PDF
医療×AIシンポジウム -医療×AI推進人材を考える-
PDF
PDF
Science museum with_sketch
PDF
キングサーモンプロジェクト スタートアップ・エコシステム 東京コンソーシアム 学生向け講演資料
PPTX
PPTX
深掘りARKit 1. 2. 4. 5. 7. 9. 10. 11. 12. 13. 14. 15. 16. 17. 19. void Update () {
if (m_camera != null)
{
// JUST WORKS!
Matrix4x4 matrix = m_session.GetCameraPose();
m_camera.transform.localPosition = UnityARMatrixOps.GetPosition(matrix);
m_camera.transform.localRotation = UnityARMatrixOps.GetRotation (matrix);
m_camera.projectionMatrix = m_session.GetCameraProjection ();
}
}
ARKitからカメラの位置情報を取得してUnityのカメラにセット
UnityARCameraManager.cs
ARKitからカメラのProjectionMatrixを取得してUnityのカメラにセット
20. void UpdateCameraClipPlanes()
{
currentNearZ = attachedCamera.nearClipPlane;
currentFarZ = attachedCamera.farClipPlane;
UnityARSessionNativeInterface.GetARSessionNativeInterface ().SetCameraClipPlanes (currentNearZ,
currentFarZ);
}
// Update is called once per frame
void Update () {
if (currentNearZ != attachedCamera.nearClipPlane || currentFarZ != attachedCamera.farClipPlane)
{
UpdateCameraClipPlanes ();
}
}
UnityのカメラのNear, Farを取得してARKitのカメラにセット
UnityARCameraNearFar.cs
21. 22. 24. 25. 26. 27. void InitializeCommandBuffer()
{
m_VideoCommandBuffer = new CommandBuffer();
m_VideoCommandBuffer.Blit(null, BuiltinRenderTextureType.CurrentActive, m_ClearMaterial);
GetComponent<Camera>().AddCommandBuffer(CameraEvent.BeforeForwardOpaque,
m_VideoCommandBuffer);
bCommandBufferInitialized = true;
}
UnityのCommandBufferの機能を使って描画コマンドを挿⼊
UnityARVideo.cs
28. 29. public void OnPreRender()
{
………
// Texture Y
_videoTextureY = Texture2D.CreateExternalTexture(currentResolution.width,
currentResolution.height,
TextureFormat.R8, false, false, (System.IntPtr)handles.textureY);
_videoTextureY.filterMode = FilterMode.Bilinear;
_videoTextureY.wrapMode = TextureWrapMode.Repeat;
_videoTextureY.UpdateExternalTexture(handles.textureY);
// Texture CbCr
_videoTextureCbCr = Texture2D.CreateExternalTexture(currentResolution.width,
currentResolution.height,
TextureFormat.RG16, false, false, (System.IntPtr)handles.textureCbCr);
_videoTextureCbCr.filterMode = FilterMode.Bilinear;
_videoTextureCbCr.wrapMode = TextureWrapMode.Repeat;
_videoTextureCbCr.UpdateExternalTexture(handles.textureCbCr);
m_ClearMaterial.SetTexture("_textureY", _videoTextureY);
m_ClearMaterial.SetTexture("_textureCbCr", _videoTextureCbCr);
……
ビデオストリームをテクスチャーとしてセット
UnityARVideo.cs
30. 31. 33. 34. namespace UnityEngine.XR.iOS
{
public class UnityARGeneratePlane : MonoBehaviour
{
public GameObject planePrefab;
private UnityARAnchorManager unityARAnchorManager;
// Use this for initialization
void Start () {
unityARAnchorManager = new UnityARAnchorManager();
UnityARUtility.InitializePlanePrefab (planePrefab);
}
void OnDestroy()
{
unityARAnchorManager.Destroy ();
}
void OnGUI()
{
List<ARPlaneAnchorGameObject> arpags = unityARAnchorManager.GetCurrentPlaneAnchors ();
if (arpags.Count >= 1) {
//ARPlaneAnchor ap = arpags [0].planeAnchor;
//GUI.Box (new Rect (100, 100, 800, 60), string.Format ("Center: x:{0}, y:{1}, z:
{2}", ap.center.x, ap.center.y, ap.center.z));
//GUI.Box(new Rect(100, 200, 800, 60), string.Format ("Extent: x:{0}, y:{1}, z:
{2}", ap.extent.x, ap.extent.y, ap.extent.z));
}
UnityARAnchorManagerを作る
UnityARGeneratePlane.cs
位置検出したら返ってくる
35. 37. namespace UnityEngine.XR.iOS
{
public class UnityARHitTestExample : MonoBehaviour
{
public Transform m_HitTransform;
bool HitTestWithResultType (ARPoint point, ARHitTestResultType resultTypes)
{
List<ARHitTestResult> hitResults =
UnityARSessionNativeInterface.GetARSessionNativeInterface ().HitTest (point, resultTypes);
if (hitResults.Count > 0) {
foreach (var hitResult in hitResults) {
Debug.Log ("Got hit!");
m_HitTransform.position = UnityARMatrixOps.GetPosition
(hitResult.worldTransform);
m_HitTransform.rotation = UnityARMatrixOps.GetRotation
(hitResult.worldTransform);
Debug.Log (string.Format ("x:{ 0:0.######} y:{ 1:0.######} z:{ 2:0.######}",
m_HitTransform.position.x, m_HitTransform.position.y, m_HitTransform.position.z));
return true;
}
}
return false;
}
iPhoneの画⾯上の点を指定してARKitのヒット
テストを呼ぶ
UnityARHitTestExample.cs
Hit Testの結果をチェック
38. 39. 41. 43. 44. 45. struct v2f
{
float4 pos : SV_POSITION;
LIGHTING_COORDS(0,1)
};
v2f vert(appdata_base v) {
v2f o;
o.pos = UnityObjectToClipPos (v.vertex);
// 5.) The TRANSFER_VERTEX_TO_FRAGMENT macro populates the chosen LIGHTING_COORDS
in the v2f structure
// with appropriate values to sample from the shadow/lighting map
TRANSFER_VERTEX_TO_FRAGMENT(o);
return o;
}
fixed4 frag(v2f i) : COLOR {
// 6.) The LIGHT_ATTENUATION samples the shadowmap (using the coordinates
calculated by TRANSFER_VERTEX_TO_FRAGMENT
// and stored in the structure defined by LIGHTING_COORDS), and returns the value
as a float.
float attenuation = LIGHT_ATTENUATION(i);
return fixed4(1.0,1.0,1.0,1.0) * attenuation;
}
ShadowMapを取得
MobileARShadow.shader
48. 49. 50. 51. 52. 53. 54. 55. ZWrite On
ZTest LEqual
ColorMask 0
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
struct appdata
{
float4 vertex : POSITION;
} ;
struct v2f
{
float4 position : SV_POSITION;
} ;
v2f vert (appdata input)
{
v2f output;
output.position = UnityObjectToClipPos(input.vertex);
return output;
}
fixed4 frag (v2f input) : SV_Target
{
return fixed4(0.5, 0.3, 0.0, 1.0);
}
Zは描画
MobileOcclusion.shader
Colorは更新しない
56. 57. 58. 60. 61. public void Start()
{
l = GetComponent<Light>();
UnityARSessionNativeInterface.ARFrameUpdatedEvent += UpdateLightEstimation;
}
void UpdateLightEstimation(UnityARCamera camera)
{
// Convert ARKit intensity to Unity intensity
// ARKit ambient intensity ranges 0-2000
// Unity ambient intensity ranges 0-8 (for over-bright lights)
float newai = camera.lightEstimation.ambientIntensity;
l.intensity = newai / 1000.0f;
//Unity Light has functionality to filter the light color to correct temperature
//https://docs.unity3d.com/ScriptReference/Light-colorTemperature.html
l.colorTemperature = camera.lightEstimation.ambientColorTemperature;
}
イベントを登録
UnityARKitAmbient.cs
ライトの⾊温度を変更
62. 63. 64. 65.