oriel!
This commit is contained in:
parent
a01cebb0ec
commit
836dfefb8a
5 changed files with 49 additions and 47 deletions
BIN
Assets/oriel.glb
BIN
Assets/oriel.glb
Binary file not shown.
|
@ -2,42 +2,54 @@
|
||||||
|
|
||||||
//--name = dofdev/oriel
|
//--name = dofdev/oriel
|
||||||
// float4 color;
|
// float4 color;
|
||||||
// Texture2D diffuse : register(t0);
|
float _height;
|
||||||
// SamplerState diffuse_s : register(s0);
|
float _ypos;
|
||||||
|
|
||||||
struct vsIn {
|
struct vsIn {
|
||||||
float4 pos : SV_POSITION;
|
float4 pos : SV_POSITION;
|
||||||
float3 norm : NORMAL0;
|
float3 norm : NORMAL0;
|
||||||
float2 uv : TEXCOORD0;
|
float2 uv : TEXCOORD0;
|
||||||
float4 col : COLOR0;
|
float4 col : COLOR0;
|
||||||
};
|
};
|
||||||
struct psIn {
|
struct psIn {
|
||||||
float4 pos : SV_POSITION;
|
float4 pos : SV_POSITION;
|
||||||
float3 norm : NORMAL0;
|
float3 world : NORMAL0;
|
||||||
float2 uv : TEXCOORD0;
|
float3 norm : NORMAL1;
|
||||||
// float1 depth : TEXCOORD1;
|
float2 uv : TEXCOORD0;
|
||||||
float4 color : COLOR0;
|
float4 color : COLOR0;
|
||||||
uint view_id : SV_RenderTargetArrayIndex;
|
uint view_id : SV_RenderTargetArrayIndex;
|
||||||
};
|
};
|
||||||
|
|
||||||
psIn vs(vsIn input, uint id : SV_InstanceID) {
|
psIn vs(vsIn input, uint id : SV_InstanceID) {
|
||||||
psIn o;
|
psIn o;
|
||||||
o.view_id = id % sk_view_count;
|
o.view_id = id % sk_view_count;
|
||||||
id = id / sk_view_count;
|
id = id / sk_view_count;
|
||||||
|
|
||||||
float3 world = mul(input.pos, sk_inst[id].world).xyz;
|
o.world = mul(input.pos, sk_inst[id].world).xyz;
|
||||||
o.pos = mul(float4(world, 1), sk_viewproj[o.view_id]);
|
o.pos = mul(float4(o.world, 1), sk_viewproj[o.view_id]);
|
||||||
o.norm = normalize(mul(input.norm, (float3x3)sk_inst[id].world));
|
o.norm = normalize(mul(input.norm, (float3x3)sk_inst[id].world));
|
||||||
|
|
||||||
o.uv = input.uv;
|
o.uv = input.uv;
|
||||||
o.color = input.col;
|
o.color = input.col;
|
||||||
float lighting = dot(o.norm, normalize(float3(0.3, -0.6, -0.1)));
|
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.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 {
|
float4 ps(psIn input) : SV_TARGET {
|
||||||
// clip(input.depth);
|
if (input.world.y - _ypos > (_height / 2.0) - 0.06) {
|
||||||
return input.color;
|
// 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;
|
||||||
}
|
}
|
27
Program.cs
27
Program.cs
|
@ -1,12 +1,8 @@
|
||||||
using System;
|
using System;
|
||||||
using StereoKit;
|
using StereoKit;
|
||||||
using AutoUpdaterDotNET;
|
|
||||||
|
|
||||||
class Program {
|
class Program {
|
||||||
static void Main(string[] args) {
|
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 {
|
SKSettings settings = new SKSettings {
|
||||||
appName = "oriels",
|
appName = "oriels",
|
||||||
assetsFolder = "Assets",
|
assetsFolder = "Assets",
|
||||||
|
@ -68,23 +64,24 @@ public class Oriel {
|
||||||
public Bounds bounds;
|
public Bounds bounds;
|
||||||
|
|
||||||
// render
|
// render
|
||||||
Material mat = new Material(Shader.FromFile("oriel.hlsl"));
|
Model model = Model.FromFile("oriel.glb", Shader.FromFile("oriel.hlsl"));
|
||||||
Mesh mesh = Mesh.GenerateCube(new Vec3(1, 1, 1));
|
Vec3 _dimensions;
|
||||||
Model model = Model.FromFile("oriel.glb", Default.ShaderUnlit);
|
|
||||||
|
|
||||||
public void Start() {
|
public void Start() {
|
||||||
bounds = new Bounds(Vec3.Zero, new Vec3(1f, 0.5f, 0.5f));
|
bounds = new Bounds(Vec3.Zero, new Vec3(1f, 0.5f, 0.5f));
|
||||||
|
_dimensions = bounds.dimensions;
|
||||||
// Vertex[] verts = mesh.GetVerts();
|
|
||||||
// for (int i = 0; i < verts.Length; i++) {
|
|
||||||
// verts[i].norm *= -1f;
|
|
||||||
// }
|
|
||||||
// mesh.SetVerts(verts);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Step() {
|
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));
|
model.Draw(Matrix.TRS(bounds.center, Quat.Identity, bounds.dimensions));
|
||||||
// mesh.Draw(mat, Matrix.TRS(bounds.center, Quat.Identity, bounds.dimensions));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Autoupdater.NET.Official" Version="1.7.0" />
|
|
||||||
<PackageReference Include="StereoKit" Version="0.3.4" />
|
<PackageReference Include="StereoKit" Version="0.3.4" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<item>
|
|
||||||
<version>0.0.0.1</version>
|
|
||||||
<url>https://dofdev.org/res/oriels.zip</url>
|
|
||||||
<mandatory>true</mandatory>
|
|
||||||
</item>
|
|
Loading…
Add table
Reference in a new issue