From 836dfefb8a116d135ea67467f7429f112d26845b Mon Sep 17 00:00:00 2001 From: spatialfree Date: Sat, 6 Nov 2021 05:09:05 -0400 Subject: [PATCH] oriel! --- Assets/oriel.glb | Bin 1904 -> 1684 bytes Assets/oriel.hlsl | 62 +++++++++++++++++++++++++++------------------- Program.cs | 27 +++++++++----------- oriels.csproj | 1 - oriels.xml | 6 ----- 5 files changed, 49 insertions(+), 47 deletions(-) delete mode 100644 oriels.xml diff --git a/Assets/oriel.glb b/Assets/oriel.glb index bf6ec3b7f61bcb13fb5c2f562ea9a8764988b42e..801ce6d18d8273b08469a367b184c5d245349a45 100644 GIT binary patch delta 143 zcmeysH-(okJtxGCiGhJ(3L6810rNz@6_Yy{(>MQNRAFLPP*B*cz@pE{*f2SORa~-x zfuX@3i1!0k1KD5)kt#!x%;cc_()5hH)MB9SYNe#a;#BASoctoU z#N?9vBA|f=dKLy?U}$J*WMFAzse>Wnhbg3E7^|a{3$+1emVu5^5zI2Un4Ss5cmq>Q zGXoPd6Vuv>8*_MpnqiK$GT1E3sKUhI!OXzmq#{Cfl>hXxcL{ zH0%e42M9EPNifj>6bAt?-2hTE*@jh_asT85R;9`RSOggvCJV5NGcs(}V9j9!03D@V AtpET3 diff --git a/Assets/oriel.hlsl b/Assets/oriel.hlsl index fd2a6dc..8d90c28 100644 --- a/Assets/oriel.hlsl +++ b/Assets/oriel.hlsl @@ -2,42 +2,54 @@ //--name = dofdev/oriel // float4 color; -// Texture2D diffuse : register(t0); -// SamplerState diffuse_s : register(s0); +float _height; +float _ypos; struct vsIn { - float4 pos : SV_POSITION; - float3 norm : NORMAL0; - float2 uv : TEXCOORD0; - float4 col : COLOR0; + float4 pos : SV_POSITION; + float3 norm : NORMAL0; + float2 uv : TEXCOORD0; + float4 col : COLOR0; }; struct psIn { - float4 pos : SV_POSITION; - float3 norm : NORMAL0; - float2 uv : TEXCOORD0; - // float1 depth : TEXCOORD1; - float4 color : COLOR0; - uint view_id : SV_RenderTargetArrayIndex; + float4 pos : SV_POSITION; + float3 world : NORMAL0; + float3 norm : NORMAL1; + float2 uv : TEXCOORD0; + float4 color : COLOR0; + uint view_id : SV_RenderTargetArrayIndex; }; psIn vs(vsIn input, uint id : SV_InstanceID) { - psIn o; - o.view_id = id % sk_view_count; - id = id / sk_view_count; + psIn o; + o.view_id = id % sk_view_count; + id = id / sk_view_count; - float3 world = mul(input.pos, sk_inst[id].world).xyz; - o.pos = mul(float4(world, 1), sk_viewproj[o.view_id]); - o.norm = normalize(mul(input.norm, (float3x3)sk_inst[id].world)); + o.world = mul(input.pos, sk_inst[id].world).xyz; + o.pos = mul(float4(o.world, 1), sk_viewproj[o.view_id]); + o.norm = normalize(mul(input.norm, (float3x3)sk_inst[id].world)); - o.uv = input.uv; - o.color = input.col; - float lighting = dot(o.norm, normalize(float3(0.3, -0.6, -0.1))); + o.uv = input.uv; + o.color = input.col; + float lighting = dot(o.norm, normalize(float3(-0.3, 0.6, 0.1))); + lighting = (clamp(lighting, 0, 1) * 0.8) + 0.2; o.color.rgb = o.color.rgb * lighting; - // o.depth = dot(float4(o.norm, 1), normalize(float4(world,1) - sk_camera_pos[o.view_id])); - return o; + return o; } float4 ps(psIn input) : SV_TARGET { - // clip(input.depth); - return input.color; + if (input.world.y - _ypos > (_height / 2.0) - 0.06) { + // brighten; + input.color.r += (1.0 - input.color.r) / 2.0; + input.color.g += (1.0 - input.color.g) / 2.0; + input.color.b += (1.0 - input.color.b) / 2.0; + return input.color; + } + // clamp how dark the object is *hsv + // float value = input.color.r * 0.3 + input.color.g * 0.59 + input.color.b * 0.11; + // blue tint + input.color.r /= 5.0; + input.color.g /= 5.0; + // input.color.a = 0.5; + return input.color; } \ No newline at end of file diff --git a/Program.cs b/Program.cs index 86a216c..78e739f 100644 --- a/Program.cs +++ b/Program.cs @@ -1,12 +1,8 @@ using System; using StereoKit; -using AutoUpdaterDotNET; class Program { static void Main(string[] args) { - // AutoUpdater.InstalledVersion = new Version("0.0.0.2"); - // AutoUpdater.Start("https://github.com/dofdev/oriels/blob/main/oriels.xml"); - SKSettings settings = new SKSettings { appName = "oriels", assetsFolder = "Assets", @@ -68,23 +64,24 @@ public class Oriel { public Bounds bounds; // render - Material mat = new Material(Shader.FromFile("oriel.hlsl")); - Mesh mesh = Mesh.GenerateCube(new Vec3(1, 1, 1)); - Model model = Model.FromFile("oriel.glb", Default.ShaderUnlit); - + Model model = Model.FromFile("oriel.glb", Shader.FromFile("oriel.hlsl")); + Vec3 _dimensions; public void Start() { bounds = new Bounds(Vec3.Zero, new Vec3(1f, 0.5f, 0.5f)); - - // Vertex[] verts = mesh.GetVerts(); - // for (int i = 0; i < verts.Length; i++) { - // verts[i].norm *= -1f; - // } - // mesh.SetVerts(verts); + _dimensions = bounds.dimensions; } public void Step() { + // circle around center + bounds.center = Quat.FromAngles(0, 0, Time.Totalf * 60) * Vec3.Up * 0.3f; + + + bounds.dimensions = _dimensions * (1f + (MathF.Sin(Time.Totalf * 3) * 0.3f)); + + model.GetMaterial(0).Transparency = Transparency.Blend; + model.GetMaterial(0).SetFloat("_height", bounds.dimensions.y); + model.GetMaterial(0).SetFloat("_ypos", bounds.center.y); model.Draw(Matrix.TRS(bounds.center, Quat.Identity, bounds.dimensions)); - // mesh.Draw(mat, Matrix.TRS(bounds.center, Quat.Identity, bounds.dimensions)); } } diff --git a/oriels.csproj b/oriels.csproj index dfb0833..d5ea7d6 100644 --- a/oriels.csproj +++ b/oriels.csproj @@ -7,7 +7,6 @@ - diff --git a/oriels.xml b/oriels.xml deleted file mode 100644 index b33aa3b..0000000 --- a/oriels.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - 0.0.0.1 - https://dofdev.org/res/oriels.zip - true - \ No newline at end of file