From d6be9d3d349cd2972395d630954aae9449cddfcb Mon Sep 17 00:00:00 2001 From: spatialfree Date: Sun, 31 Oct 2021 02:45:29 -0400 Subject: [PATCH] can't get shader to load :( --- Assets/example.hlsl | 42 ++++++++++++++++++++++++++++++++++++++++++ Program.cs | 17 +++++++++++------ dof-dev.csproj | 19 ------------------- oriels.csproj | 27 +++++++++++++++++++++++++++ 4 files changed, 80 insertions(+), 25 deletions(-) create mode 100644 Assets/example.hlsl delete mode 100644 dof-dev.csproj create mode 100644 oriels.csproj diff --git a/Assets/example.hlsl b/Assets/example.hlsl new file mode 100644 index 0000000..1294b9f --- /dev/null +++ b/Assets/example.hlsl @@ -0,0 +1,42 @@ +#include "stereokit.hlsli" + +//--name = sk/unlit +//--color:color = 1, 1, 1, 1 +//--diffuse = white +float4 color; +Texture2D diffuse : register(t0); +SamplerState diffuse_s : register(s0); + + +struct vsIn { + float4 pos : SV_Position; + float3 norm : NORMAL0; + float2 uv : TEXCOORD0; + float4 col : COLOR0; +}; +struct psIn { + float4 pos : SV_POSITION; + 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; + + float3 world = mul(float4(input.pos.xyz, 1), sk_inst[id].world).xyz; + o.pos = mul(float4(world, 1), sk_viewproj[o.view_id]); + + o.uv = input.uv; + o.color = input.col * color * sk_inst[id].color; + return o; +} +float4 ps(psIn input) : SV_TARGET { + float4 col = diffuse.Sample(diffuse_s, input.uv); + + col = col * input.color; + + return col; +} \ No newline at end of file diff --git a/Program.cs b/Program.cs index 7d28e26..cfd09a5 100644 --- a/Program.cs +++ b/Program.cs @@ -1,14 +1,17 @@ +using System; using StereoKit; class Program { static void Main(string[] args) { - // System.Console.WriteLine("Test"); - SKSettings settings = new SKSettings(); - settings.appName = "oriels"; - settings.assetsFolder = "Assets"; - SK.Initialize(settings); + SKSettings settings = new SKSettings + { + appName = "oriels", + assetsFolder = "Assets", + }; + if (!SK.Initialize(settings)) + Environment.Exit(1); - Model cursor = Model.FromFile("cursor.glb"); + Model cursor = Model.FromFile("cursor.glb"); ColorCube cube = new ColorCube(); OrbitalView.strength = 4; @@ -17,6 +20,8 @@ class Program { ReachCursor reachCursor = new ReachCursor(); + Material addMat = new Material(Shader.FromFile("example.hlsl")); + while(SK.Step(() => { // Matrix orbitMatrix = OrbitalView.transform; // cube.Step(Matrix.S(Vec3.One * 0.2f) * orbitMatrix); diff --git a/dof-dev.csproj b/dof-dev.csproj deleted file mode 100644 index d5f6d70..0000000 --- a/dof-dev.csproj +++ /dev/null @@ -1,19 +0,0 @@ - - - - Exe - net50 - - - - - - - - - PreserveNewest - Assets/%(RecursiveDir)%(Filename)%(Extension) - - - - diff --git a/oriels.csproj b/oriels.csproj new file mode 100644 index 0000000..e8f69c5 --- /dev/null +++ b/oriels.csproj @@ -0,0 +1,27 @@ + + + + Exe + netcoreapp3.1 + + + + + + + + + PreserveNewest + + + + + + + + + + + + +