pruned in prep for multi oriel

This commit is contained in:
spatialfree 2022-06-17 19:03:45 -04:00
parent 7349b53ef1
commit cef21cb106
58 changed files with 95 additions and 37788 deletions

28
.old/shader-snips.hlsl Normal file
View file

@ -0,0 +1,28 @@
// float3 local = input.world - _center;
// clip(sign(_size - local.x) * sign(_size - local.y) * sign(_size - local.z));
// clip(sign(local.x + _size) * sign(local.y + _size) * sign(local.z + _size));
// scale RGB by perceived luminance
// float value = (c.r + c.r + c.g + c.g + c.g + c.b) / 6;
// c *= value;
// if (trunc(H * 100) % 2 == 0) {
// c = float3(1, 1, 1) - c;
// }
// float3 local = (input.world - _center) / _size * 2;
// float2 plane = float2(local.x, local.y);
// float H = acos(normalize(plane).y) / 3.141592653589793;
// if (sign(plane.x) < 0) {
// H = (1 - H + 1) / 2;
// } else {
// H = H / 2;
// }
// float C = distance(float2(0, 0), plane);
// float L = (1 + local.z) / 2;
// float3 c = HCLtoRGB(H, C, (L + 0.05) / 1.05);
// c *= L;

View file

@ -1,3 +0,0 @@
git fetch
git pull
Micro.bat

View file

@ -1,11 +0,0 @@
Model Information:
* title: Megaman X4 - Cyber Space
* source: https://sketchfab.com/3d-models/megaman-x4-cyber-space-5fdca251c4734ec49e77c72903b1d234
* author: Sah Niemeyer (https://sketchfab.com/sahailaway)
Model License:
* license type: CC-BY-4.0 (http://creativecommons.org/licenses/by/4.0/)
* requirements: Author must be credited. Commercial use is allowed.
If you use this 3D model in your project be sure to copy paste this credit wherever you share it:
This work is based on "Megaman X4 - Cyber Space" (https://sketchfab.com/3d-models/megaman-x4-cyber-space-5fdca251c4734ec49e77c72903b1d234) by Sah Niemeyer (https://sketchfab.com/sahailaway) licensed under CC-BY-4.0 (http://creativecommons.org/licenses/by/4.0/)

Binary file not shown.

File diff suppressed because it is too large Load diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 160 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 109 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 515 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 540 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 832 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1,011 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 988 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 618 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2 MiB

View file

@ -1,11 +0,0 @@
Model Information:
* title: White Hart House
* source: https://sketchfab.com/3d-models/white-hart-house-7f4084ed27634b0596061a6f9811cb64
* author: 9of9 (https://sketchfab.com/9of9)
Model License:
* license type: CC-BY-4.0 (http://creativecommons.org/licenses/by/4.0/)
* requirements: Author must be credited. Commercial use is allowed.
If you use this 3D model in your project be sure to copy paste this credit wherever you share it:
This work is based on "White Hart House" (https://sketchfab.com/3d-models/white-hart-house-7f4084ed27634b0596061a6f9811cb64) by 9of9 (https://sketchfab.com/9of9) licensed under CC-BY-4.0 (http://creativecommons.org/licenses/by/4.0/)

Binary file not shown.

View file

@ -1,23 +1,30 @@
#include "stereokit.hlsli"
// --name = dofdev/oriel
float3 _center;
float3 _dimensions;
float3 _light;
float4x4 _matrix;
//--diffuse = white
float3 _center;
float3 _dimensions;
float3 _light;
float4x4 _matrix;
Texture2D diffuse : register(t0);
SamplerState diffuse_s : register(s0);
struct vsIn {
float4 position : SV_POSITION;
float3 normal : NORMAL;
float2 uv : TEXCOORD0;
float3 color : COLOR0;
};
struct psIn {
float4 position : SV_POSITION;
float2 uv : TEXCOORD0;
float3 world : WORLD;
float3 normal : NORMAL;
float4 color : COLOR0;
float3 camdir : TEXCOORD0;
float3 campos : TEXCOORD1;
float3 camdir : TEXCOORD1;
float3 campos : TEXCOORD2;
uint view_id : SV_RenderTargetArrayIndex;
};
struct psOut {
@ -35,6 +42,7 @@ psIn vs(vsIn input, uint id : SV_InstanceID) {
o.world = mul(input.position, sk_inst[id].world).xyz;
o.position = mul(float4(o.world, 1), sk_viewproj[o.view_id]);
o.normal = normalize(mul(input.normal, (float3x3)sk_inst[id].world));
o.uv = input.uv;
o.color = float4(input.color * sk_inst[id].color.rgb, 1);
return o;
@ -64,7 +72,6 @@ float raymarch(float3 origin, float3 direction) {
for (int i = 0; i < 256; i++) {
float3 pos = origin + dist * direction;
float step = sdBox(pos, _dimensions / 2.0);
// float step = sdSphere(pos, _dimensions.y / 2.0);
if (step < 0.0001 || dist > 100) break; // 100 == distmax
dist += step;
}
@ -74,12 +81,11 @@ float raymarch(float3 origin, float3 direction) {
psOut ps(psIn input) {
psOut o;
o.color = input.color;
o.color = input.color * diffuse.Sample(diffuse_s, input.uv);
o.depth = input.position.z;
float3 origin = input.campos;
float3 direction = normalize(input.world - origin);
// origin = ;
float ol = raymarch(origin, direction);
clip(100 - (ol + 1));
@ -87,18 +93,14 @@ psOut ps(psIn input) {
clip(distance(input.campos, input.world) - distance(input.campos, origin));
// normalize(input.world - _center)
float t = 1 - (1 + dot(input.normal, _light)) / 2;
// float3 light = lerp(float3(0.05, 0.05, 0.1), float3(0.95, 0.95, 0.9), t);
// o.color = float4(o.color.rgb * light, 1);
o.color = float4(o.color.rgb * t, 1);
// backface
float3 localPos = mul(float4(input.world, 1), _matrix).xyz;
// localPos.y < -_dimensions.y / 2.99
if (localPos.y < -_dimensions.y / 2.99) {
if (localPos.y < -_dimensions.y / 2) {
clip(-1);
}
@ -107,33 +109,3 @@ psOut ps(psIn input) {
}
return o;
}
// float3 local = input.world - _center;
// clip(sign(_size - local.x) * sign(_size - local.y) * sign(_size - local.z));
// clip(sign(local.x + _size) * sign(local.y + _size) * sign(local.z + _size));
// scale RGB by perceived luminance
// float value = (c.r + c.r + c.g + c.g + c.g + c.b) / 6;
// c *= value;
// if (trunc(H * 100) % 2 == 0) {
// c = float3(1, 1, 1) - c;
// }
// float3 local = (input.world - _center) / _size * 2;
// float2 plane = float2(local.x, local.y);
// float H = acos(normalize(plane).y) / 3.141592653589793;
// if (sign(plane.x) < 0) {
// H = (1 - H + 1) / 2;
// } else {
// H = H / 2;
// }
// float C = distance(float2(0, 0), plane);
// float L = (1 + local.z) / 2;
// float3 c = HCLtoRGB(H, C, (L + 0.05) / 1.05);
// c *= L;

View file

@ -8,10 +8,11 @@ struct vsIn {
float3 norm : NORMAL;
};
struct psIn {
float4 pos : SV_POSITION;
float4 col : COLOR;
float4 world : WORLD;
uint view_id : SV_RenderTargetArrayIndex;
float4 pos : SV_POSITION;
float4 col : COLOR;
float4 camDir : POSITION0;
float4 world : WORLD;
uint view_id : SV_RenderTargetArrayIndex;
};
psIn vs(vsIn input, uint id : SV_InstanceID) {
@ -27,7 +28,7 @@ psIn vs(vsIn input, uint id : SV_InstanceID) {
// float4 viewPosition = mul(input.pos, sk_view[o.view_id]);
// o.pos = mul(viewPosition, sk_proj[o.view_id]);
o.camDir = sk_camera_dir[0];
o.world = mul(input.pos, sk_inst[id].world);
@ -39,16 +40,18 @@ psIn vs(vsIn input, uint id : SV_InstanceID) {
float4 ps(psIn input) : SV_TARGET {
float4 c = input.col;
float3 rLocal = (input.world.xyz - _rGlovePos) * 6;
c.r = 1 - min(abs(rLocal.x), 1.0);
c.g = 1 - min(abs(rLocal.y), 1.0);
c.b = 1 - min(abs(rLocal.z), 1.0);
// float3 rLocal = (input.world.xyz - _rGlovePos) / 2;
// c.r = 1 - min(abs(rLocal.x), 1.0);
// c.g = 1 - min(abs(rLocal.y), 1.0);
// c.b = 1 - min(abs(rLocal.z), 1.0);
float m = min(c.r, min(c.g, c.b));
c.rgb *= m;
// if (m == 0) {
// }
// float m = min(c.r, min(c.g, c.b));
// c.rgb *= m;
c.r = input.camDir.x;
c.g = input.camDir.y;
c.b = input.camDir.z;
c.a = 0.3;
return c;
}

View file

@ -1,16 +1,5 @@
using System;
using StereoKit;
interface IApp<T> {
void Step();
}
public class App {
public App() {
}
public void Step() {
}
interface IApp { // <T> ?
void Initialize();
void Update();
void Shutdown();
}

View file

@ -12,7 +12,6 @@ if (!SK.Initialize(settings))
Input.HandSolid(Handed.Max, false);
Input.HandVisible(Handed.Max, true);
// TextStyle style = Text.MakeStyle(Font.FromFile("DMMono-Regular.ttf"), 0.1f, Color.White);
Mono mono = Mono.inst;
while (SK.Step(() => {
@ -58,6 +57,7 @@ public class Mono {
Vec3 boardDir = Vec3.Forward;
public void Step() {
rig.Step();
scene.Step();
@ -69,70 +69,12 @@ public class Mono {
// cubicCon.Step();
// Vec3 fullstick = rig.Fullstick(false);
// colorCube.Palm(lCon.device);
oriel.Step();
////
// °board [ pseudo code ]
// // handling = 200±
// // speed = 10±
// // board.dir = Vec3.fwd
// -------------------------------------------------
// // con.grip.frameDown:
// // handle = con
// // board.pos = FloorCenter
// // newDir = handle.pos.X0Z - board.pos.X0Z
// // board.dir = newDir.MagSq > 0.001f ? newDir.normalized : board.dir
// // board.ori = Quat.LookDir(board.dir)
// // twist = handle.grip * -(Quat.LookDir(board.dir).Inverse * handle.backhandDir).x
// // rig.ori *= Quat(0, twist * handling * delta, 0)
// // accel = handle.trigger
// // rig.pos += board.dir * accel * speed * delta
// // °board [ implementation ]
// float handling = 200;
// float speed = 10;
// Vec3 boardPos = rig.FloorCenter;
// Vec3 newDir = rig.HandleCon.pos.X0Z - boardPos.X0Z;
// boardDir = newDir.MagnitudeSq > 0.001f ? newDir.Normalized : boardDir;
// Quat boardOri = Quat.LookDir(boardDir);
// float twist = rig.HandleCon.device.grip * -(Quat.LookDir(boardDir).Inverse * rig.HandleCon.backhandDir).x;
// rig.ori *= Quat.FromAngles(0f, twist * handling * Time.Elapsedf, 0f);
// float accel = rig.HandleCon.device.trigger;
// rig.pos += boardDir * accel * speed * Time.Elapsedf;
// // Lines.Add(rig.HandleCon.pos, rig.HandleCon.pos + rig.HandleCon.backhandDir, Color.White, 0.01f);
// Mesh.Cube.Draw(Material.Default, Matrix.TRS(boardPos, boardOri, new Vec3(0.18f, 0.06f, 0.6f)));
// DEPRECATED
// PullRequest.Slerp(boardDir.Normalized, handleDelta.Normalized, handleDelta.Magnitude * handling * Time.Elapsedf) : boardDir;
// Quat from = Quat.LookAt(rig.Head.position, rig.HandleCon.pos);
// Lines.Add(rig.HandleCon.pos, rig.HandleCon.pos + from * Vec3.Up, Color.Black, 0.01f);
// does the FloorCenter move with the CameraRoot?
// having a board underneath my feet and a virtual handlebar in my hand
// did a lot to improve the quality of the experience (+immersion -sickness)
// the ability and quality at which this can be propagated is higher than I first imagined
// next?
// lean turning (head moving in relation to hand, doesn't that happen a little already?)
// -------------------------------------------------

View file

@ -4,12 +4,11 @@ using System.Collections.Generic;
using StereoKit;
public class Oriel {
static Material matFrame = new Material(Shader.FromFile("wireframe.hlsl"));
static Material matPanes = new Material(Shader.FromFile("panes.hlsl"));
static Material matOriel = new Material(Shader.FromFile("oriel.hlsl"));
static Model modelArena = Model.FromFile("megaman/scene.gltf");
static Material matFrame = new Material(Shader.FromFile("shaders/wireframe.hlsl"));
static Material matPanes = new Material(Shader.FromFile("shaders/panes.hlsl"));
static Material matOriel = new Material(Shader.FromFile("shaders/oriel.hlsl"));
static Model model = Model.FromFile("colorball.glb");
Mesh meshCube, meshFrame;
Mesh meshCube;
public Bounds bounds;
public Quat ori;
@ -18,9 +17,6 @@ public class Oriel {
public bool drawAxis = false;
bool adjusting = false;
// bool scalingOriel = false;
// bool draggingOriel = false;
// bool rotatingOriel = false;
Quat qOffset = Quat.Identity;
Vec3 vOffset = Vec3.Zero;
Vec3 lOffset = Vec3.Zero;
@ -37,41 +33,13 @@ public class Oriel {
matrix = Matrix.TR(bounds.center, ori).Inverse;
matFrame.SetMat(102, Cull.None, true);
matFrame.Transparency = Transparency.Add;
matPanes.SetMat(100, Cull.Front, false);
matOriel.SetMat(101, Cull.None, true);
meshFrame = model.GetMesh("Wireframe");
// meshFrame = model.GetMesh("Wireframe");
meshCube = Mesh.Cube;
meshCube = Mesh.Sphere;
Gen();
}
@ -146,10 +114,6 @@ public class Oriel {
detect.z == 0 ? 1 : 0
);
// Quat q = Quat.FromAngles(up * Vec2.AngleBetween(dir.XZ, detect.XZ));
// a quick reset function, as the rotation gets fucked
Quat q = Quat.LookAt(Vec3.Zero, dir, up);
if (!adjusting) {
@ -169,24 +133,13 @@ public class Oriel {
}
// meet the user halfway, as there is a lot of context provided with where they grab the oriel
// instead of a discrete handle and interaction
// circle around center
// bounds.center = Vec3.Forward * 3 + Quat.FromAngles(0, 0, Time.Totalf * 60) * Vec3.Up * 0.3f;
// bounds.dimensions.y = _dimensions.y * (1f + (MathF.Sin(Time.Totalf * 3) * 0.6f));
matrix = Matrix.TR(bounds.center, ori).Inverse;
matFrame.Wireframe = true;
// matFrame.Wireframe = true;
matFrame.DepthTest = DepthTest.Always;
matFrame.SetVector("_rGlovePos", rGlovePos);
// meshFrame.Draw(matFrame,
// meshCube.Draw(matFrame,
// Matrix.TRS(bounds.center, ori, bounds.dimensions),
// new Color(0.1f, 0.1f, 0.1f)
// );
@ -198,10 +151,10 @@ public class Oriel {
// matPanes.DepthTest = DepthTest.Greater;
matPanes["_matrix"] = (Matrix)System.Numerics.Matrix4x4.Transpose(matrix);
// meshCube.Draw(matPanes,
// Matrix.TRS(bounds.center, ori, bounds.dimensions),
// new Color(0.0f, 0.0f, 0.5f)
// );
meshCube.Draw(matPanes,
Matrix.TRS(bounds.center, ori, bounds.dimensions),
new Color(0.0f, 0.0f, 0.5f)
);
matOriel.SetVector("_center", bounds.center);
matOriel.SetVector("_dimensions", bounds.dimensions);
@ -210,32 +163,10 @@ public class Oriel {
// modelArena.Draw(Matrix.TRS(
// new Vec3(-1, -0.6f, 1.8f),
// Quat.FromAngles(0, -90, 0),
// Vec3.One * 0.002f
// ));
// APP
// placeholder "app"
Vec3 playerWorldPos = playerPos * 0.5f * bounds.dimensions.y;
Matrix orielSimMatrix = Matrix.TRS(
// new Vec3(0, -bounds.dimensions.y / 2, -playerWorldPos.z),
new Vec3(0, -bounds.dimensions.y / 3, -playerWorldPos.z),
new Vec3(0, -bounds.dimensions.y / 2.01f, -playerWorldPos.z),
Quat.Identity,
Vec3.One * 0.5f * bounds.dimensions.y
);
@ -248,6 +179,9 @@ public class Oriel {
);
}
Mesh.Quad.Draw(matOriel,
Matrix.TRS(Vec3.Zero, Quat.FromAngles(90, 0, 0), Vec3.One * 100f) * orielSimMatrix * matrix.Inverse,
new Color(1.0f, 1.0f, 1.0f) * 0.3f

View file

@ -99,11 +99,6 @@ public static class PullRequest {
return Vec3.Lerp(a * (float)Math.Sin(theta - theta * t) / sinTheta, b * (float)Math.Sin(theta * t) / sinTheta, t);
}
static Pose _pose = new Pose();
public static Pose WorldPose(this Pose pose, float scale = 1) {
return pose;
}
[Serializable]
public class Noise {
const uint CAP = 4294967295;

View file

@ -14,14 +14,11 @@ public class Scene {
BufferData data = new BufferData();
Material matFloor = new Material(Shader.Default);
// Model room = Model.FromFile("room/room.glb", Shader.FromFile("room.hlsl"));
Model shed = Model.FromFile("shed/shed.glb", Shader.FromFile("room.hlsl"));
// Model skatepark = Model.FromFile("skatepark/scene.gltf", Shader.FromFile("room.hlsl"));
Model shed = Model.FromFile("shed/shed.glb", Shader.FromFile("/shaders/room.hlsl"));
Solid floor;
public Scene() {
// Shader.FromFile("room.hlsl")
buffer = new MaterialBuffer<BufferData>(3); // index
@ -53,21 +50,12 @@ public class Scene {
// data.dimensions = Vec3.Zero;
buffer.Set(data);
// PullRequest.BlockOut(floor.GetPose().ToMatrix(floorScale), Color.White * 0.333f, matFloor);

View file

@ -19,19 +19,19 @@
</ItemGroup>
<ItemGroup>
<None Remove="add/oriel.hlsl" />
<None Remove="add/colorcube.hlsl" />
<None Remove="add/panes.hlsl" />
<None Remove="add/wireframe.hlsl" />
<None Remove="add/room.hlsl" />
<None Remove="add/shaders/oriel.hlsl" />
<None Remove="add/shaders/colorcube.hlsl" />
<None Remove="add/shaders/panes.hlsl" />
<None Remove="add/shaders/wireframe.hlsl" />
<None Remove="add/shaders/room.hlsl" />
</ItemGroup>
<ItemGroup>
<SKShader Include="add/oriel.hlsl" />
<SKShader Include="add/colorcube.hlsl" />
<SKShader Include="add/panes.hlsl" />
<SKShader Include="add/wireframe.hlsl" />
<SKShader Include="add/room.hlsl" />
<SKShader Include="add/shaders/oriel.hlsl" />
<SKShader Include="add/shaders/colorcube.hlsl" />
<SKShader Include="add/shaders/panes.hlsl" />
<SKShader Include="add/shaders/wireframe.hlsl" />
<SKShader Include="add/shaders/room.hlsl" />
</ItemGroup>
</Project>

Binary file not shown.