This commit is contained in:
spatialfree 2021-11-06 05:09:05 -04:00
parent a01cebb0ec
commit 836dfefb8a
5 changed files with 49 additions and 47 deletions

Binary file not shown.

View file

@ -2,8 +2,8 @@
//--name = dofdev/oriel
// float4 color;
// Texture2D diffuse : register(t0);
// SamplerState diffuse_s : register(s0);
float _height;
float _ypos;
struct vsIn {
float4 pos : SV_POSITION;
@ -13,9 +13,9 @@ struct vsIn {
};
struct psIn {
float4 pos : SV_POSITION;
float3 norm : NORMAL0;
float3 world : NORMAL0;
float3 norm : NORMAL1;
float2 uv : TEXCOORD0;
// float1 depth : TEXCOORD1;
float4 color : COLOR0;
uint view_id : SV_RenderTargetArrayIndex;
};
@ -25,19 +25,31 @@ psIn vs(vsIn input, uint id : SV_InstanceID) {
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.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)));
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;
}
float4 ps(psIn input) : SV_TARGET {
// clip(input.depth);
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;
}

View file

@ -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));
}
}

View file

@ -7,7 +7,6 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Autoupdater.NET.Official" Version="1.7.0" />
<PackageReference Include="StereoKit" Version="0.3.4" />
</ItemGroup>

View file

@ -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>