diff --git a/add/fantasy_skybox.glb b/add/fantasy_skybox.glb new file mode 100644 index 0000000..427620f Binary files /dev/null and b/add/fantasy_skybox.glb differ diff --git a/add/fantasy_skybox.jpeg b/add/fantasy_skybox.jpeg new file mode 100644 index 0000000..3f779f3 Binary files /dev/null and b/add/fantasy_skybox.jpeg differ diff --git a/add/greenyard.glb b/add/greenyard.glb new file mode 100644 index 0000000..66d05b7 Binary files /dev/null and b/add/greenyard.glb differ diff --git a/add/greenyard.jpeg b/add/greenyard.jpeg new file mode 100644 index 0000000..bc309bd Binary files /dev/null and b/add/greenyard.jpeg differ diff --git a/add/shaders/frame.hlsl b/add/shaders/frame.hlsl index 9402cc1..a468a83 100644 --- a/add/shaders/frame.hlsl +++ b/add/shaders/frame.hlsl @@ -57,6 +57,8 @@ float remap_tri(float v) float4 ps(psIn input) : SV_TARGET { + + // float4 c = input.col; // float3 rLocal = (input.world.xyz - _rGlovePos) / 2; // c.r = 1 - min(abs(rLocal.x), 1.0); @@ -66,15 +68,14 @@ float4 ps(psIn input) : SV_TARGET { // float m = min(c.r, min(c.g, c.b)); // c.rgb *= m; - float3 flatnorm = (input.col.rgb - float3(0.5, 0.5, 0.5)) * 2; - + // float3 flatnorm = (input.col.rgb - float3(0.5, 0.5, 0.5)) * 2; // flatnorm = normalize(mul(flatnorm, (float3x3)sk_inst[input.id].world)); // float3 cross = input.camDir * input.norm; - float dist = length(input.world.xyz - input.campos); + // float dist = length(input.world.xyz - input.campos); float3 raydir = normalize(input.world.xyz - input.campos); - float facing = 1 - dot(raydir, input.camdir); + // float facing = 1 - dot(raydir, input.camdir); // facing = (1 + facing) / 2; // facing = facing; @@ -91,7 +92,7 @@ float4 ps(psIn input) : SV_TARGET { // d = remap_tri(d); - return float4(hsv2rgb(float3(h, 1, 1)), facing * facing * d * 24); + return float4(hsv2rgb(float3(h, 1, 1)), h * h); // float4 col = float4(1, 1, 1, 0); // float n = saturate(dot(raydir, input.norm)); diff --git a/add/shaders/oriel.hlsl b/add/shaders/oriel.hlsl index be1d9d0..e9e263e 100644 --- a/add/shaders/oriel.hlsl +++ b/add/shaders/oriel.hlsl @@ -1,8 +1,10 @@ #include "stereokit.hlsli" -// --name = dofdev/oriel -//--diffuse = white +// --name = dofdev/oriel +//--diffuse = white +float _lit; +float _lit2; // power of 2 float3 _center; float3 _dimensions; float3 _light; @@ -94,15 +96,17 @@ psOut ps(psIn input) { clip(distance(input.campos, input.world) - distance(input.campos, origin)); float t = 1 - (1 + dot(input.normal, _light)) / 2; - o.color = float4(o.color.rgb * t, 1); + // o.color = float4(o.color.rgb * t, 1); + o.color = lerp(o.color, float4(o.color.rgb * t, 1), _lit); // float3 localPos = mul(float4(input.world, 1), _matrix).xyz; // if (localPos.y < -_dimensions.y / 2) { // clip(-1); // } - if (dot(direction, input.normal) > 0) { - o.color = float4(0.5, 0.5, 0.5, 1); - } + // if (dot(direction, input.normal) > 0) { + // o.color = float4(0.5, 0.5, 0.5, 1); + // } + return o; } diff --git a/app/Greenyard/Mono.cs b/app/Greenyard/Mono.cs new file mode 100644 index 0000000..2b29c59 --- /dev/null +++ b/app/Greenyard/Mono.cs @@ -0,0 +1,51 @@ +using Oriels; + +namespace Greenyard; +public class Mono { + Model greenyardModel = Model.FromFile("greenyard.glb"); + Mesh[] greenyard; + Material greenyardMat = new Material(Shader.FromFile("/shaders/oriel.hlsl")); + + Vec3 offset = new Vec3(0, 0, 0); + + public Mono() { + + } + + public void Init() { + greenyard = new Mesh[12]; + for (int i = 0; i < greenyard.Length; i++) { + greenyard[i] = greenyardModel.GetMesh("Object_" + (i + 2)); + } + greenyardMat.SetMat(101, Cull.None, true); + greenyardMat.SetTexture("diffuse", Tex.FromFile("greenyard.jpeg")); + } + + public void Frame() { + Oriels.Rig rig = Oriels.Mono.inst.rig; + Oriels.Oriel oriel = Oriels.Mono.inst.oriel; + + Matrix simMatrix = Matrix.TRS( + new Vec3(0, -oriel.bounds.dimensions.y / 2.01f, 0), + Quat.Identity, + Vec3.One * 0.1f * oriel.bounds.dimensions.y + ); + + // Render + greenyardMat.SetVector("_center", oriel.bounds.center); + greenyardMat.SetVector("_dimensions", oriel.bounds.dimensions); + greenyardMat.SetVector("_light", oriel.ori * new Vec3(0.6f, -0.9f, 0.3f)); + greenyardMat.SetFloat("_lit", 0); + greenyardMat["_matrix"] = (Matrix)System.Numerics.Matrix4x4.Transpose(oriel.matrix); + for (int i = 0; i < greenyard.Length; i++) { + greenyard[i].Draw(greenyardMat, + Matrix.TRS( + offset, + Quat.Identity, + new Vec3(1f, 1f, 1f) + ) * simMatrix * oriel.matrix.Inverse, + Color.White + ); + } + } +} \ No newline at end of file diff --git a/app/Mono.cs b/app/Mono.cs index 3e1b6ba..48ae80d 100644 --- a/app/Mono.cs +++ b/app/Mono.cs @@ -37,13 +37,15 @@ public class Mono { } public void Init() { - spaceMono.Init(); + // spaceMono.Init(); + greenyard.Init(); } // ------------------------------------------------- - Space.Mono spaceMono = new Space.Mono(); + // Space.Mono spaceMono = new Space.Mono(); + Greenyard.Mono greenyard = new Greenyard.Mono(); PullRequest.PID pid = new PullRequest.PID(8, 0.8f); @@ -69,7 +71,8 @@ public class Mono { // ------------------------------------------------- - spaceMono.Frame(); + // spaceMono.Frame(); + greenyard.Frame(); // ------------------------------------------------- diff --git a/app/Oriel.cs b/app/Oriel.cs index 3ad8c1a..75a4523 100644 --- a/app/Oriel.cs +++ b/app/Oriel.cs @@ -34,7 +34,8 @@ public class Oriel { matPanes.SetMat(100, Cull.Front, false); matOriel.SetMat(101, Cull.None, true); - meshCube = model.GetMesh("oriel"); + meshCube = Mesh.Cube; + // meshCube = model.GetMesh("oriel"); } Vec3 detect = Vec3.Zero; @@ -154,6 +155,7 @@ public class Oriel { matOriel.SetVector("_center", bounds.center); matOriel.SetVector("_dimensions", bounds.dimensions); matOriel.SetVector("_light", ori * new Vec3(0.6f, -0.9f, 0.3f)); + matOriel.SetFloat("_lit", 1); matOriel["_matrix"] = (Matrix)System.Numerics.Matrix4x4.Transpose(matrix); } } \ No newline at end of file diff --git a/app/Space/Mono.cs b/app/Space/Mono.cs index 23a676f..06395df 100644 --- a/app/Space/Mono.cs +++ b/app/Space/Mono.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using Oriels; // [X] stretch cursor move // [X] nodes *point of reference rather than interest for now @@ -20,6 +21,9 @@ public class Mono { Oriels.PullRequest.PID pidZ = new Oriels.PullRequest.PID(); Mesh meshCube; + // Model skyboxModel = Model.FromFile("fantasy_skybox.glb"); + // Mesh skybox; + // Material skyboxMat = new Material(Shader.FromFile("/shaders/oriel.hlsl")); public Mono() { @@ -42,6 +46,9 @@ public class Mono { } meshCube = Mesh.Cube; + // skybox = skyboxModel.GetMesh("sky"); + // skyboxMat.SetMat(101, Cull.None, true); + // skyboxMat.SetTexture("diffuse", Tex.FromFile("fantasy_skybox.jpeg")); } public void Frame() { @@ -112,6 +119,23 @@ public class Mono { new Color(1.0f, 0.0f, 0.05f) ); + + // skyboxMat.SetVector("_center", oriel.bounds.center); + // skyboxMat.SetVector("_dimensions", oriel.bounds.dimensions); + // skyboxMat.SetVector("_light", oriel.ori * new Vec3(0.6f, -0.9f, 0.3f)); + // skyboxMat.SetFloat("_lit", 0); + // skyboxMat["_matrix"] = (Matrix)System.Numerics.Matrix4x4.Transpose(oriel.matrix); + // skybox.Draw(skyboxMat, + // Matrix.TRS( + // playerPos, + // Quat.Identity, + // new Vec3(10f, 10f, 10f) + // ) * simMatrix * oriel.matrix.Inverse, + // Color.White + // ); + + + // meshCube.Draw(oriel.matOriel, // rGlove.virtualGlove.ToMatrix(new Vec3(0.025f, 0.1f, 0.1f) / 3 * 1.05f), // new Color(0.3f, 0.3f, 0.6f) diff --git a/app/_Init.cs b/app/_Init.cs index c60f344..3eb1b28 100644 --- a/app/_Init.cs +++ b/app/_Init.cs @@ -7,7 +7,7 @@ SKSettings settings = new SKSettings { assetsFolder = "add", depthMode = DepthMode.D32, disableUnfocusedSleep = true, - displayPreference = DisplayMode.Flatscreen, + // displayPreference = DisplayMode.Flatscreen, }; if (!SK.Initialize(settings)) Environment.Exit(1); diff --git a/res/fantasy_skybox.blend b/res/fantasy_skybox.blend new file mode 100644 index 0000000..6819c24 Binary files /dev/null and b/res/fantasy_skybox.blend differ