Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEAT] Add Extrapolation and Vertex Late Latching #1

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions Assets/Examples/Chess Game/Chess Set Interaction - HMD.unity
Original file line number Diff line number Diff line change
Expand Up @@ -795,6 +795,16 @@ PrefabInstance:
propertyPath: _deviceOffsetMode
value: 2
objectReference: {fileID: 0}
- target: {fileID: 3557434566810426996, guid: 15d3b5cf5cea75344a4482323bc124a8,
type: 3}
propertyPath: _temporalWarpingMode
value: 3
objectReference: {fileID: 0}
- target: {fileID: 3557434566810426996, guid: 15d3b5cf5cea75344a4482323bc124a8,
type: 3}
propertyPath: _updateHandInPrecull
value: 1
objectReference: {fileID: 0}
- target: {fileID: 3557434566810426996, guid: 15d3b5cf5cea75344a4482323bc124a8,
type: 3}
propertyPath: _trackingOptimization
Expand Down Expand Up @@ -4529,6 +4539,11 @@ PrefabInstance:
propertyPath: m_LocalPosition.z
value: -0.0000000071013346
objectReference: {fileID: 0}
- target: {fileID: 3620868148920353184, guid: 1b43d6eb40db60b419700fd2677e79c4,
type: 3}
propertyPath: m_Materials.Array.data[0]
value:
objectReference: {fileID: 2100000, guid: 907d1e26cffb0664083284043d4a7822, type: 2}
- target: {fileID: 3648151112113200300, guid: 1b43d6eb40db60b419700fd2677e79c4,
type: 3}
propertyPath: m_LocalPosition.x
Expand Down Expand Up @@ -6809,6 +6824,11 @@ PrefabInstance:
propertyPath: m_LocalRotation.z
value: 0.019904897
objectReference: {fileID: 0}
- target: {fileID: 6196908724800935708, guid: 1b43d6eb40db60b419700fd2677e79c4,
type: 3}
propertyPath: m_Materials.Array.data[0]
value:
objectReference: {fileID: 2100000, guid: ee8a57eb89b08c64cbc006260083ddde, type: 2}
- target: {fileID: 6695673191794116165, guid: 1b43d6eb40db60b419700fd2677e79c4,
type: 3}
propertyPath: m_LocalPosition.x
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,5 +273,10 @@ public LeapQuaternion rotation
private Vector _xBasisScaled;
private Vector _yBasisScaled;
private Vector _zBasisScaled;

public override string ToString()
{
return "Translation: " + _translation + ", Quaternion: " + _quaternion + ", Scale" + _scale;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -299,13 +299,13 @@ public enum TrackingOptimizationMode

// Extrapolate on Android to compensate for the latency introduced by its graphics
// pipeline.
#if UNITY_ANDROID && !UNITY_EDITOR
protected int ExtrapolationAmount = 0; // 15;
//#if UNITY_ANDROID && !UNITY_EDITOR
protected int ExtrapolationAmount = 30;
protected int BounceAmount = 70;
#else
protected int ExtrapolationAmount = 0;
protected int BounceAmount = 0;
#endif
//#else
// protected int ExtrapolationAmount = 0;
// protected int BounceAmount = 0;
//#endif

protected Controller _leapController;
protected bool _isDestroyed;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

CGPROGRAM
#pragma surface surf Standard fullforwardshadows vertex:vert
#include "Assets/Plugins/LeapMotion/Core/Resources/LeapCG.cginc"
#include "../Resources/LeapCG.cginc"
#pragma target 3.0

int _isLeftHand;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
[HDR]_FresnelColor("Fresnel Color", Color) = (1,1,1,0)
_FresnelPower("Fresnel Power", Range(0,1)) = 1

[MaterialToggle] _isLeftHand("Is Left Hand?", Int) = 0

}

CGINCLUDE #include "UnityCG.cginc"
Expand Down Expand Up @@ -54,22 +56,46 @@
{
Cull Back
Blend Zero One

CGPROGRAM
#include "../../../../Core/Runtime/Resources/LeapCG.cginc"
#pragma vertex vert
#pragma fragment frag

int _isLeftHand;
v2f vert(appdata_base v)
{
v2f o;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_INITIALIZE_OUTPUT(v2f, o);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);

v.vertex = LeapGetLateVertexPos(v.vertex, _isLeftHand);
o.pos = UnityObjectToClipPos(v.vertex);
return o;
}

half4 frag(v2f i) :COLOR { return half4(0,0,0,0); }
ENDCG
}
Pass
{
Cull Front

CGPROGRAM
#include "../../../../Core/Runtime/Resources/LeapCG.cginc"
#pragma vertex vert
#pragma fragment frag

int _isLeftHand;
v2f vert(appdata_base v)
{
v2f o;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_INITIALIZE_OUTPUT(v2f, o);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);

v.vertex = LeapGetLateVertexPos(v.vertex, _isLeftHand);
o.pos = UnityObjectToClipPos(v.vertex);
float3 norm = mul((float3x3)UNITY_MATRIX_IT_MV, v.normal);
float2 offset = TransformViewToProjection(norm.xy);
Expand All @@ -95,14 +121,17 @@
#include "UnityCG.cginc" // for UnityObjectToWorldNormal
#include "UnityLightingCommon.cginc" // for _LightColor0
#include "AutoLight.cginc"
#include "../../../../Core/Runtime/Resources/LeapCG.cginc"

int _isLeftHand;
v2f vert(appdata_base v)
{
v2f o;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_INITIALIZE_OUTPUT(v2f, o);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);

v.vertex = LeapGetLateVertexPos(v.vertex, _isLeftHand);
o.pos = UnityObjectToClipPos(v.vertex);
o.uv = v.texcoord;
half3 worldNormal = UnityObjectToWorldNormal(v.normal);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: OutlineLeft
m_Shader: {fileID: 4800000, guid: c5b35a4c19d643f4f87637cdd8587b98, type: 3}
m_ShaderKeywords: _ISLEFTHAND_ON _USEFRESNEL_ON _USELIGHTING_ON _USEOUTLINE_ON
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _BumpMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailAlbedoMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailMask:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailNormalMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _EmissionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 2800000, guid: e911cba1eec0c364681095f165f68321, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ParallaxMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- _BumpScale: 1
- _Cutoff: 0.5
- _DetailNormalMapScale: 1
- _DstBlend: 0
- _FresnelIntensity: 1
- _FresnelPower: 0.97
- _GlossMapScale: 1
- _Glossiness: 0.5
- _GlossyReflections: 1
- _LightIntensity: 1
- _Metallic: 0
- _Mode: 0
- _OcclusionStrength: 1
- _Outline: 0.002
- _Parallax: 0.02
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
- _UVSec: 0
- _ZWrite: 1
- _isLeftHand: 1
- _useFresnel: 1
- _useLighting: 1
- _useOutline: 1
m_Colors:
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _FresnelColor: {r: 22.408676, g: 22.408676, b: 22.408676, a: 0.09803922}
- _MainColor: {r: 2.670157, g: 2.670157, b: 2.670157, a: 0}
- _OutlineColor: {r: 1, g: 1, b: 1, a: 1}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: OutlineRight
m_Shader: {fileID: 4800000, guid: c5b35a4c19d643f4f87637cdd8587b98, type: 3}
m_ShaderKeywords: _USEFRESNEL_ON _USELIGHTING_ON _USEOUTLINE_ON
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _BumpMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailAlbedoMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailMask:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailNormalMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _EmissionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 2800000, guid: e911cba1eec0c364681095f165f68321, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ParallaxMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- _BumpScale: 1
- _Cutoff: 0.5
- _DetailNormalMapScale: 1
- _DstBlend: 0
- _FresnelIntensity: 1
- _FresnelPower: 0.97
- _GlossMapScale: 1
- _Glossiness: 0.5
- _GlossyReflections: 1
- _LightIntensity: 1
- _Metallic: 0
- _Mode: 0
- _OcclusionStrength: 1
- _Outline: 0.002
- _Parallax: 0.02
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
- _UVSec: 0
- _ZWrite: 1
- _isLeftHand: 0
- _useFresnel: 1
- _useLighting: 1
- _useOutline: 1
m_Colors:
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _FresnelColor: {r: 22.408676, g: 22.408676, b: 22.408676, a: 0.09803922}
- _MainColor: {r: 2.670157, g: 2.670157, b: 2.670157, a: 0}
- _OutlineColor: {r: 1, g: 1, b: 1, a: 1}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.