This commit is contained in:
ethan merchant 2023-07-18 16:40:21 -04:00
parent ea9c782fd9
commit 29fd414be1
8 changed files with 52 additions and 32 deletions

View file

@ -12,7 +12,7 @@ public class Oriel {
Monolith mono; Monolith mono;
public Bounds bounds; public Bounds bounds;
Material mat = new Material(Shader.FromFile("oriel.hlsl")); Material mat = new Material(Shader.FromFile("shaders/oriel.hlsl"));
Mesh mesh = Default.MeshCube; Mesh mesh = Default.MeshCube;
public float crown = 0.0666f; public float crown = 0.0666f;

View file

@ -35,18 +35,27 @@ psIn vs(vsIn input, uint id : SV_InstanceID) {
} }
float4 ps(psIn input) : SV_TARGET { float4 ps(psIn input) : SV_TARGET {
float depth = diffuse.Sample(diffuse_s, input.uv).r; float4 tex = diffuse.Sample(diffuse_s, input.uv);
return tex;
// 16 bit DepthTexture *non-linear* depth // 16 bit DepthTexture *non-linear* depth
// render depth for debug // render depth for debug by undoing the non-linear depth rcp
float reciprocal_value = tex.r;
float max_distance = 100.0;
if (depth > 0.0) { float depth = 1.0 / (reciprocal_value * (1.0 / max_distance) + 1.0);
depth = 1.0;
} return float4(depth, depth, depth, 1);
// if (depth > 0.0) {
// depth = 1.0;
// }
// depth = rcp(depth);
// float4 og = mul(float4(input.world, 1), sk_viewproj[input.view_id]); // float4 og = mul(float4(input.world, 1), sk_viewproj[input.view_id]);
// float depth = (og * rcp(og.w)).z; // float depth = (og * rcp(og.w)).z;
return float4(depth, depth, depth, 1); // return tex; // float4(tex.a, tex.a, tex.a, 1);
// float v = -rcp(-val.r); // float v = -rcp(-val.r);
// v = val.r; // v = val.r;
// return float4(v, v, v, 1); // return float4(v, v, v, 1);

View file

@ -8,7 +8,7 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="StereoKit" Version="0.3.7-preview.9" /> <PackageReference Include="StereoKit" Version="0.3.7-preview.1619" />
<!-- <PackageReference Include="System.Speech" Version="5.0.0" /> --> <!-- <PackageReference Include="System.Speech" Version="5.0.0" /> -->
</ItemGroup> </ItemGroup>

View file

@ -20,27 +20,27 @@ public class Mono {
thing = new Thing[] { thing = new Thing[] {
new Thing( new Thing(
model.GetMesh("Carpet"), model.GetMesh("Carpet"),
new Material(Shader.FromFile("oriel.hlsl")), new Material(Shader.FromFile("shaders/oriel.hlsl")),
"backrooms/Carpet.png" "backrooms/Carpet.png"
), ),
new Thing( new Thing(
model.GetMesh("Walls"), model.GetMesh("Walls"),
new Material(Shader.FromFile("oriel.hlsl")), new Material(Shader.FromFile("shaders/oriel.hlsl")),
"backrooms/Walls.png" "backrooms/Walls.png"
), ),
new Thing( new Thing(
model.GetMesh("Ceiling"), model.GetMesh("Ceiling"),
new Material(Shader.FromFile("oriel.hlsl")), new Material(Shader.FromFile("shaders/oriel.hlsl")),
"backrooms/Ceiling.png" "backrooms/Ceiling.png"
), ),
new Thing( new Thing(
model.GetMesh("Vents"), model.GetMesh("Vents"),
new Material(Shader.FromFile("oriel.hlsl")), new Material(Shader.FromFile("shaders/oriel.hlsl")),
"backrooms/Vents.png" "backrooms/Vents.png"
), ),
new Thing( new Thing(
model.GetMesh("Lights"), model.GetMesh("Lights"),
new Material(Shader.FromFile("oriel.hlsl")), new Material(Shader.FromFile("shaders/oriel.hlsl")),
"backrooms/Lights.png" "backrooms/Lights.png"
), ),
}; };

View file

@ -2,7 +2,7 @@ namespace Oriels;
public class ColorCube { public class ColorCube {
static Mesh cube = Default.MeshCube; static Mesh cube = Default.MeshCube;
static Material mat = new Material(Shader.FromFile("colorcube.hlsl")); static Material mat = new Material(Shader.FromFile("shaders/colorcube.hlsl"));
static Material unlit = Default.MaterialUnlit; static Material unlit = Default.MaterialUnlit;
public float thicc = 0.0025f; public float thicc = 0.0025f;
public float ogSize = 0.05f; public float ogSize = 0.05f;

View file

@ -8,15 +8,15 @@ public class Compositor {
Greenyard.Mono greenyard = new Greenyard.Mono(); Greenyard.Mono greenyard = new Greenyard.Mono();
// bool other = false; // bool other = false;
Tex tex; Tex tex, depth;
Material mat = new Material(Shader.FromFile("compositor.hlsl")); Material mat = new Material(Shader.FromFile("shaders/compositor.hlsl"));
public void Init() { public void Init() {
tex = new Tex(TexType.Rendertarget); tex = new Tex(TexType.Rendertarget);
tex.SetSize(512, 512); tex.SetSize(512, 512);
tex.AddZBuffer(TexFormat.Depth16); // DepthStencil depth = tex.AddZBuffer(TexFormat.Depth32); // DepthStencil
mat[MatParamName.DiffuseTex] = tex; mat[MatParamName.DiffuseTex] = depth;
mat.FaceCull = Cull.Front; mat.FaceCull = Cull.None;
// Renderer.Blit(tex, newMat) // Renderer.Blit(tex, newMat)
@ -28,17 +28,28 @@ public class Compositor {
public void Frame() { public void Frame() {
Mono mono = Mono.inst; Mono mono = Mono.inst;
// Renderer.RenderTo(tex, if (Input.Key(Key.Space).IsJustActive()) {
// Matrix.TR(V.XYZ(0, 1, 0), Quat.FromAngles(0, 180, 0)), // add the depth tex color.r's up and see if they are > 0
// Matrix.Perspective(60, 1, 0.1f, 100), float r = 0;
// RenderLayer.All // & ~RenderLayer.Layer1 Color32[] cols = depth.GetColors();
// ); for (int i = 0; i < cols.Length; i++) {
r += cols[i].r;
}
Console.WriteLine($"r: {r}");
}
Default.MeshQuad.Draw(mat,
Matrix.TRS(V.XYZ(-0.90f, 1.16f, 1.44f), Quat.LookDir(0.63f, 0.78f, 0.02f), 0.5f)
);
Renderer.RenderTo(tex,
Matrix.TR(V.XYZ(-0.90f, 1.16f, 1.44f), Quat.LookDir(0.63f, 0.78f, 0.02f)),
Matrix.Perspective(60, 1, 0.1f, 100),
RenderLayer.All, // & ~RenderLayer.Layer1
RenderClear.All,
default(Rect)
);
// Default.MeshQuad.Draw(mat,
// Matrix.TR(V.XYZ(0, 1, 0), Quat.FromAngles(0, 0, 0))
// );
// backrooms.oriel.Frame(); // backrooms.oriel.Frame();
// greenyard.oriel.Frame(); // greenyard.oriel.Frame();

View file

@ -3,9 +3,9 @@ namespace Oriels;
public class Oriel { public class Oriel {
Material matClear = new Material(Shader.Default); Material matClear = new Material(Shader.Default);
public Material matOriel = new Material(Shader.FromFile("oriel.hlsl")); public Material matOriel = new Material(Shader.FromFile("shaders/oriel.hlsl"));
Material matFrame = new Material(Shader.FromFile("frame.hlsl")); Material matFrame = new Material(Shader.FromFile("shaders/frame.hlsl"));
Material matPanes = new Material(Shader.FromFile("panes.hlsl")); Material matPanes = new Material(Shader.FromFile("shaders/panes.hlsl"));
public Matrix matrix, matrixInv; public Matrix matrix, matrixInv;
public Bounds bounds; public Bounds bounds;

View file

@ -10,7 +10,7 @@ public class Mono {
Model greenyardModel = Model.FromFile("greenyard.glb"); Model greenyardModel = Model.FromFile("greenyard.glb");
Mesh[] greenyard; Mesh[] greenyard;
Material greenyardMat = new Material(Shader.FromFile("/oriel.hlsl")); Material greenyardMat = new Material(Shader.FromFile("shaders/oriel.hlsl"));
Matrix matrix = Matrix.Identity; Matrix matrix = Matrix.Identity;
Vec3 offset = new Vec3(2, 1, -12); Vec3 offset = new Vec3(2, 1, -12);