testing
This commit is contained in:
parent
691e785195
commit
bc416b7a98
14 changed files with 158 additions and 78 deletions
10
README.md
10
README.md
|
@ -21,13 +21,3 @@ mapped by
|
|||
### <br> ⃝<br><br><br>
|
||||
|
||||
</div>
|
||||
|
||||
start()
|
||||
c# net6.0 sdk
|
||||
git &| github
|
||||
vim || vscode
|
||||
|
||||
dotnet restore
|
||||
|
||||
dotnet build
|
||||
dotnet run
|
||||
|
|
|
@ -21,6 +21,7 @@ struct vsIn {
|
|||
};
|
||||
struct psIn {
|
||||
float4 pos : SV_Position;
|
||||
float3 norm : NORMAL0;
|
||||
float2 uv : TEXCOORD0;
|
||||
float4 world : WORLD;
|
||||
float4 color : COLOR0;
|
||||
|
@ -38,11 +39,11 @@ psIn vs(vsIn input, uint id : SV_InstanceID) {
|
|||
o.world = mul(input.pos, sk_inst[id].world);
|
||||
o.pos = mul(o.world, sk_viewproj[o.view_id]);
|
||||
|
||||
float3 normal = normalize(mul(input.norm, (float3x3)sk_inst[id].world));
|
||||
o.norm = normalize(mul(input.norm, (float3x3)sk_inst[id].world));
|
||||
|
||||
o.uv = input.uv * tex_scale;
|
||||
o.color = color * input.col * sk_inst[id].color;
|
||||
o.color.rgb *= Lighting(normal);
|
||||
o.color.rgb *= Lighting(o.norm);
|
||||
return o;
|
||||
}
|
||||
|
||||
|
@ -62,5 +63,10 @@ float4 ps(psIn input) : SV_TARGET {
|
|||
|
||||
// dist magnitude from center X0Z
|
||||
float dist = max(1 - (length(input.world.xz) / 10.0), 0.0);
|
||||
return lerp(clearcolor, col, 1 - ((1 - dist) * (1 - dist)));
|
||||
float4 color = lerp(clearcolor, col, 1 - ((1 - dist) * (1 - dist)));
|
||||
|
||||
float glow = sk_finger_glow(input.world.xyz, input.norm);
|
||||
color.rgb += glow * 0.5;
|
||||
|
||||
return color;
|
||||
}
|
|
@ -2,22 +2,12 @@
|
|||
|
||||
//--name = dofdev/compositor
|
||||
|
||||
//--near = white
|
||||
//--far = white
|
||||
|
||||
Texture2D near : register(t0);
|
||||
SamplerState near_s : register(s0);
|
||||
|
||||
Texture2D far : register(t1);
|
||||
SamplerState far_s : register(s1);
|
||||
|
||||
struct vsIn {
|
||||
float4 pos : SV_Position;
|
||||
float3 norm : NORMAL0;
|
||||
float2 uv : TEXCOORD0;
|
||||
};
|
||||
struct psIn {
|
||||
float4 screen_pos : SV_Position;
|
||||
float4 pos : SV_Position;
|
||||
float3 world : WORLD;
|
||||
float2 uv : TEXCOORD0;
|
||||
|
@ -31,7 +21,7 @@ psIn vs(vsIn input, uint id : SV_InstanceID) {
|
|||
|
||||
o.world = mul(input.pos, sk_inst[id].world).xyz;
|
||||
o.pos = mul(float4(o.world, 1), sk_viewproj[o.view_id]);
|
||||
o.screen_pos = input.pos;
|
||||
// o.screen_pos = input.pos;
|
||||
|
||||
// float3 normal = normalize(mul(input.norm, (float3x3)sk_inst[id].world));
|
||||
|
||||
|
@ -41,23 +31,7 @@ psIn vs(vsIn input, uint id : SV_InstanceID) {
|
|||
return o;
|
||||
}
|
||||
|
||||
float far_clip = 1.0; // 1.0 for anything behind the near of the oriel is clipped
|
||||
float near_flatten = 1.0; // 1.0 for anything behind the near of the oriel having its depth be set to the near of the oriel
|
||||
|
||||
float front_clip = 1.0; // same as far_clip
|
||||
float front_flatten = 1.0; // same as near_flatten
|
||||
|
||||
static const float NEAR = 0.01;
|
||||
static const float FAR = 100.0;
|
||||
|
||||
// clip depth -> view depth
|
||||
float depth_cv(float d) {
|
||||
// 32 bit DepthTexture *clip space
|
||||
return (NEAR * FAR) / (FAR - d * (FAR - NEAR));
|
||||
}
|
||||
|
||||
float4 ps(psIn input) : SV_TARGET {
|
||||
|
||||
// uint stencil = tex.a * 255.0;
|
||||
// float2 screen_uv = input.pos.xy / input.pos.w; // flip y?
|
||||
// screen_uv.y = 1 - screen_uv.y;
|
||||
|
@ -70,7 +44,7 @@ float4 ps(psIn input) : SV_TARGET {
|
|||
// screen_uv.y *= sk_aspect_ratio(input.view_id);
|
||||
|
||||
|
||||
float oriel_n = depth_cv(near.Sample(near_s, screen_uv).r);
|
||||
// float oriel_n = depth_cv(near.Sample(near_s, screen_uv).r);
|
||||
// if (oriel_n < 1.0) {
|
||||
// discard;
|
||||
// }
|
||||
|
@ -95,9 +69,9 @@ float4 ps(psIn input) : SV_TARGET {
|
|||
// }
|
||||
|
||||
// screen space checkerboard using fmod
|
||||
float checkerboard = fmod(floor(input.uv.x * 8.0) + floor(input.uv.y * 8.0), 2);
|
||||
float checkeruv = fmod(floor(screen_uv.x * 8.0) + floor(screen_uv.y * 8.0), 2);
|
||||
return float4(checkerboard, screen_uv.y, checkeruv, 1);
|
||||
// float checkerboard = fmod(floor(input.uv.x * 8.0) + floor(input.uv.y * 8.0), 2);
|
||||
// float checkeruv = fmod(floor(screen_uv.x * 8.0) + floor(screen_uv.y * 8.0), 2);
|
||||
// return float4(checkerboard, screen_uv.y, checkeruv, 1);
|
||||
|
||||
|
||||
// // new depth
|
||||
|
@ -109,6 +83,5 @@ float4 ps(psIn input) : SV_TARGET {
|
|||
// out_depth = depth;
|
||||
// }
|
||||
|
||||
|
||||
return float4(1,0,1,1);
|
||||
}
|
|
@ -10,7 +10,7 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="StereoKit" Version="0.3.7-preview.1667" />
|
||||
<PackageReference Include="StereoKit" Version="0.3.8" />
|
||||
<!-- <PackageReference Include="System.Speech" Version="5.0.0" /> -->
|
||||
</ItemGroup>
|
||||
|
||||
|
|
25
oriels.sln
Normal file
25
oriels.sln
Normal file
|
@ -0,0 +1,25 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.5.002.0
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "oriels", "oriels.csproj", "{E7A7B19F-3A85-425C-ACAF-CAC44F70807E}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{E7A7B19F-3A85-425C-ACAF-CAC44F70807E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{E7A7B19F-3A85-425C-ACAF-CAC44F70807E}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{E7A7B19F-3A85-425C-ACAF-CAC44F70807E}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{E7A7B19F-3A85-425C-ACAF-CAC44F70807E}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {7B0AFE43-2999-40C1-9A5A-BB1D53BB2164}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
|
@ -2,11 +2,28 @@ namespace Oriels;
|
|||
public static class Functions {
|
||||
|
||||
// in SK >= 1.2.0 as Vec3.Direction()
|
||||
public static Vec3 Dir(Vec3 to, Vec3 from) {
|
||||
public static Vec3 dir(Vec3 to, Vec3 from) {
|
||||
return (to - from).Normalized;
|
||||
}
|
||||
|
||||
// deadzone
|
||||
// magnitude
|
||||
// extension
|
||||
|
||||
public static Vec3 reflect(Vec3 v, Vec3 n) {
|
||||
return v - 2 * Vec3.Dot(v, n) * n;
|
||||
}
|
||||
|
||||
|
||||
/* under construction
|
||||
claspΔ(aΔ, bΔ, t = 0.5) =>
|
||||
Δ = lerp(aΔ, bΔ, t) * sign(aΔ) == sign(bΔ) ? 1 : 0
|
||||
|
||||
|
||||
with your two index fingers on a larger object to really test this
|
||||
|
||||
*/
|
||||
// public static float claspΔ(float aΔ, float bΔ) {
|
||||
|
||||
// }
|
||||
}
|
16
src/Functions/clasp/pattern copy.txt
Normal file
16
src/Functions/clasp/pattern copy.txt
Normal file
|
@ -0,0 +1,16 @@
|
|||
# 2023.07.30 -> 2023.07.31 ->
|
||||
|
||||
input
|
||||
idxΔ
|
||||
thmΔ
|
||||
|
||||
data
|
||||
pinch_ptΔ
|
||||
|
||||
frame
|
||||
pinch_ptΔ = (idxΔ + thmΔ + thmΔ) / 3
|
||||
|
||||
in_sign(a, b) => sign(a) == sign(b) ? 1 : 0
|
||||
pinch_ptΔ.x *= in_sign(idxΔ.x, thmΔ.x)
|
||||
pinch_ptΔ.y *= in_sign(idxΔ.y, thmΔ.y)
|
||||
pinch_ptΔ.z *= in_sign(idxΔ.z, thmΔ.z)
|
4
src/Functions/clasp/pattern.txt
Normal file
4
src/Functions/clasp/pattern.txt
Normal file
|
@ -0,0 +1,4 @@
|
|||
# 2023.07.30 -> 2023.07.31 ->
|
||||
|
||||
claspΔ(aΔ, bΔ, t = 0.5) =>
|
||||
Δ = lerp(aΔ, bΔ, t) * sign(aΔ) == sign(bΔ) ? 1 : 0
|
0
src/Functions/stretch/pattern.txt
Normal file
0
src/Functions/stretch/pattern.txt
Normal file
|
@ -8,9 +8,9 @@ class RollsCursor : Interaction {
|
|||
|
||||
// data
|
||||
public Cursor cursor = new Cursor();
|
||||
PR.Delta fIdelta = new PR.Delta();
|
||||
PR.Delta fMdelta = new PR.Delta();
|
||||
PR.Delta fRdelta = new PR.Delta();
|
||||
PR.DeltaV fIdelta = new PR.DeltaV();
|
||||
PR.DeltaV fMdelta = new PR.DeltaV();
|
||||
PR.DeltaV fRdelta = new PR.DeltaV();
|
||||
|
||||
public void Init() { }
|
||||
|
||||
|
@ -37,11 +37,11 @@ class RollsCursor : Interaction {
|
|||
cursor.raw = hand.Get(FingerId.Index, JointId.Tip).position;
|
||||
}
|
||||
|
||||
fIdelta.Update(hand.Get(FingerId.Index, JointId.Tip).position);
|
||||
fMdelta.Update(hand.Get(FingerId.Middle, JointId.Tip).position);
|
||||
fRdelta.Update(hand.Get(FingerId.Ring, JointId.Tip).position);
|
||||
fIdelta.Step(hand.Get(FingerId.Index, JointId.Tip).position);
|
||||
fMdelta.Step(hand.Get(FingerId.Middle, JointId.Tip).position);
|
||||
fRdelta.Step(hand.Get(FingerId.Ring, JointId.Tip).position);
|
||||
|
||||
Vec3 delta = (fIdelta.value + fMdelta.value + fRdelta.value) / 3f;
|
||||
Vec3 delta = (fIdelta.delta + fMdelta.delta + fRdelta.delta) / 3f;
|
||||
cursor.raw += delta * reach.value;
|
||||
|
||||
Mesh.Sphere.Draw(mono.mat.holoframe, Matrix.TRS(cursor.raw, Quat.Identity, 0.01f), new Color(1, 0, 0));
|
||||
|
|
42
src/Mono.cs
42
src/Mono.cs
|
@ -56,6 +56,7 @@ public class Mono {
|
|||
bool shapeHeld = false;
|
||||
|
||||
|
||||
Pose testPose = new Pose(new Vec3(0, 1f, -1.5f), Quat.FromAngles(45, 0, 45));
|
||||
|
||||
|
||||
Spatial spatial = new (new Vec3(-1, 0.76f, 0.666f));
|
||||
|
@ -92,20 +93,49 @@ public class Mono {
|
|||
float strength = 6f;
|
||||
|
||||
Hand hand = Input.Hand(Handed.Right);
|
||||
Vec3 indexTip = hand.Get(FingerId.Index, JointId.Tip).position;
|
||||
// left and right 'click' ~ curl
|
||||
Btn lBtn = new Btn(); // ~ trigger ~ left click
|
||||
float indexCurl = rig.FingerFlex(hand, FingerId.Index, 0.15f);
|
||||
lBtn.Frame(indexCurl < 0.5f);
|
||||
|
||||
// stay in state until both ring and pinky finger 'agree' on curl or uncurl
|
||||
Btn rBtn = new Btn(); // ~ grip ~ right click
|
||||
float ringCurl = rig.FingerFlex(hand, FingerId.Ring, 0.15f);
|
||||
float pinkyCurl = rig.FingerFlex(hand, FingerId.Little, 0.15f);
|
||||
rBtn.Frame(ringCurl < 0.5f && pinkyCurl < 0.5f);
|
||||
|
||||
// cursor
|
||||
Vec3 midTip = hand.Get(FingerId.Middle, JointId.Tip).position;
|
||||
Vec3 thumbTip = hand.Get(FingerId.Thumb, JointId.Tip).position;
|
||||
|
||||
Vec3 delta = indexTip - thumbTip;
|
||||
Vec3 delta = midTip - thumbTip;
|
||||
float mag = delta.Magnitude;
|
||||
float pinch = MathF.Max(mag - deadzone, 0);
|
||||
|
||||
Vec3 dir = delta.Normalized;
|
||||
|
||||
cursor.raw = indexTip + dir * pinch * strength;
|
||||
cursor.raw = midTip + dir * pinch * strength;
|
||||
|
||||
Lines.Add(indexTip, thumbTip, new Color(0, 0, 1), 0.002f);
|
||||
Mesh.Sphere.Draw(mat.holo, Matrix.TS(cursor.pos, 0.01f), new Color(0.5f, 0.5f, 0.5f));
|
||||
// V.XYZ(0, 0, );
|
||||
Lines.Add(midTip, thumbTip, new Color(0, 0, 1), 0.002f);
|
||||
Mesh.Sphere.Draw(
|
||||
mat.holo,
|
||||
Matrix.TS(cursor.pos, 2*U.cm),
|
||||
new Color(
|
||||
lBtn.held ? 1.0f : 0.0f,
|
||||
0.5f,
|
||||
rBtn.held ? 1.0f : 0.0f
|
||||
)
|
||||
);
|
||||
|
||||
if (rBtn.held) {
|
||||
testPose.position = cursor.smooth;
|
||||
}
|
||||
Mesh.Cube.Draw(
|
||||
mat.holoframe,
|
||||
testPose.ToMatrix(5*U.cm),
|
||||
rBtn.held ? new Color(0.5f, 0.55f, 0.75f) :
|
||||
new Color(0.5f, 0.55f, 0.75f) * 0.3f
|
||||
);
|
||||
|
||||
drawerA.Frame(cursor, pinch);
|
||||
drawerB.Frame(cursor, pinch);
|
||||
|
|
23
src/PR.cs
23
src/PR.cs
|
@ -302,14 +302,29 @@ public static class PR {
|
|||
// }
|
||||
// }
|
||||
|
||||
public static float Diff(float a, float b) {
|
||||
return MathF.Abs(a - b);
|
||||
}
|
||||
|
||||
public class Delta {
|
||||
public Vec3 value { get; private set; }
|
||||
public float delta { get; private set; }
|
||||
|
||||
float last;
|
||||
public float Step(float current) {
|
||||
delta = current - last;
|
||||
last = current;
|
||||
return delta;
|
||||
}
|
||||
}
|
||||
|
||||
public class DeltaV {
|
||||
public Vec3 delta { get; private set; }
|
||||
|
||||
Vec3 last;
|
||||
public Vec3 Update(Vec3 current) {
|
||||
value = current - last;
|
||||
public Vec3 Step(Vec3 current) {
|
||||
delta = current - last;
|
||||
last = current;
|
||||
return value;
|
||||
return delta;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
14
src/Rig.cs
14
src/Rig.cs
|
@ -82,7 +82,7 @@ public class Rig {
|
|||
lWrist = new Pose(lCon.pos + lCon.ori * new Vec3(0, 0, 0.052f), lCon.ori);
|
||||
}
|
||||
|
||||
public float Flexion(Hand hand, FingerId id, float deadzone = 0.15f) {
|
||||
public float FingerFlex(Hand hand, FingerId id, float deadzone = 0.15f) {
|
||||
float fingerFlex = (Vec3.Dot(
|
||||
Vec3.Direction(
|
||||
hand.Get(id, JointId.Tip).position,
|
||||
|
@ -94,8 +94,10 @@ public class Rig {
|
|||
)
|
||||
) + 1f) / 2;
|
||||
float fingerTrim = 0f + deadzone; // 180°
|
||||
fingerFlex = Math.Max(fingerFlex - fingerTrim, 0f) / (1 - fingerTrim);
|
||||
return Math.Max(fingerFlex - fingerTrim, 0f) / (1 - fingerTrim);
|
||||
}
|
||||
|
||||
public float KnuckleFlex(Hand hand, FingerId id, float deadzone = 0.15f) {
|
||||
float knuckleFlex = (Vec3.Dot(
|
||||
Vec3.Direction(
|
||||
hand.Get(id, JointId.KnuckleMid).position,
|
||||
|
@ -107,10 +109,12 @@ public class Rig {
|
|||
)
|
||||
) + 1f) / 2;
|
||||
float knuckleTrim = 0.5f + deadzone; // 90°
|
||||
knuckleFlex = Math.Max(knuckleFlex - knuckleTrim, 0f) / (1 - knuckleTrim);
|
||||
return Math.Max(knuckleFlex - knuckleTrim, 0f) / (1 - knuckleTrim);
|
||||
}
|
||||
|
||||
float flexion = knuckleFlex + fingerFlex;
|
||||
return flexion * flexion;
|
||||
public float Flexion(Hand hand, FingerId id, float deadzone = 0.15f) {
|
||||
float flexion = KnuckleFlex(hand, id, deadzone) * FingerFlex(hand, id, deadzone);
|
||||
return flexion * flexion; // why assume this curve?
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ SKSettings settings = new SKSettings {
|
|||
assetsFolder = "add",
|
||||
depthMode = DepthMode.D32,
|
||||
disableUnfocusedSleep = true,
|
||||
displayPreference = DisplayMode.Flatscreen,
|
||||
// displayPreference = DisplayMode.Flatscreen,
|
||||
// disableFlatscreenMRSim = true,
|
||||
};
|
||||
if (!SK.Initialize(settings))
|
||||
|
|
Loading…
Add table
Reference in a new issue