in depth
This commit is contained in:
parent
ea9c782fd9
commit
29fd414be1
8 changed files with 52 additions and 32 deletions
|
@ -12,7 +12,7 @@ public class Oriel {
|
|||
Monolith mono;
|
||||
|
||||
public Bounds bounds;
|
||||
Material mat = new Material(Shader.FromFile("oriel.hlsl"));
|
||||
Material mat = new Material(Shader.FromFile("shaders/oriel.hlsl"));
|
||||
Mesh mesh = Default.MeshCube;
|
||||
public float crown = 0.0666f;
|
||||
|
||||
|
|
|
@ -35,18 +35,27 @@ psIn vs(vsIn input, uint id : SV_InstanceID) {
|
|||
}
|
||||
|
||||
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
|
||||
// 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) {
|
||||
depth = 1.0;
|
||||
}
|
||||
float depth = 1.0 / (reciprocal_value * (1.0 / max_distance) + 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]);
|
||||
// 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);
|
||||
// v = val.r;
|
||||
// return float4(v, v, v, 1);
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<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" /> -->
|
||||
</ItemGroup>
|
||||
|
||||
|
|
|
@ -20,27 +20,27 @@ public class Mono {
|
|||
thing = new Thing[] {
|
||||
new Thing(
|
||||
model.GetMesh("Carpet"),
|
||||
new Material(Shader.FromFile("oriel.hlsl")),
|
||||
new Material(Shader.FromFile("shaders/oriel.hlsl")),
|
||||
"backrooms/Carpet.png"
|
||||
),
|
||||
new Thing(
|
||||
model.GetMesh("Walls"),
|
||||
new Material(Shader.FromFile("oriel.hlsl")),
|
||||
new Material(Shader.FromFile("shaders/oriel.hlsl")),
|
||||
"backrooms/Walls.png"
|
||||
),
|
||||
new Thing(
|
||||
model.GetMesh("Ceiling"),
|
||||
new Material(Shader.FromFile("oriel.hlsl")),
|
||||
new Material(Shader.FromFile("shaders/oriel.hlsl")),
|
||||
"backrooms/Ceiling.png"
|
||||
),
|
||||
new Thing(
|
||||
model.GetMesh("Vents"),
|
||||
new Material(Shader.FromFile("oriel.hlsl")),
|
||||
new Material(Shader.FromFile("shaders/oriel.hlsl")),
|
||||
"backrooms/Vents.png"
|
||||
),
|
||||
new Thing(
|
||||
model.GetMesh("Lights"),
|
||||
new Material(Shader.FromFile("oriel.hlsl")),
|
||||
new Material(Shader.FromFile("shaders/oriel.hlsl")),
|
||||
"backrooms/Lights.png"
|
||||
),
|
||||
};
|
||||
|
|
|
@ -2,7 +2,7 @@ namespace Oriels;
|
|||
|
||||
public class ColorCube {
|
||||
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;
|
||||
public float thicc = 0.0025f;
|
||||
public float ogSize = 0.05f;
|
||||
|
|
|
@ -8,15 +8,15 @@ public class Compositor {
|
|||
Greenyard.Mono greenyard = new Greenyard.Mono();
|
||||
// bool other = false;
|
||||
|
||||
Tex tex;
|
||||
Material mat = new Material(Shader.FromFile("compositor.hlsl"));
|
||||
Tex tex, depth;
|
||||
Material mat = new Material(Shader.FromFile("shaders/compositor.hlsl"));
|
||||
|
||||
public void Init() {
|
||||
tex = new Tex(TexType.Rendertarget);
|
||||
tex.SetSize(512, 512);
|
||||
tex.AddZBuffer(TexFormat.Depth16); // DepthStencil
|
||||
mat[MatParamName.DiffuseTex] = tex;
|
||||
mat.FaceCull = Cull.Front;
|
||||
depth = tex.AddZBuffer(TexFormat.Depth32); // DepthStencil
|
||||
mat[MatParamName.DiffuseTex] = depth;
|
||||
mat.FaceCull = Cull.None;
|
||||
|
||||
// Renderer.Blit(tex, newMat)
|
||||
|
||||
|
@ -28,17 +28,28 @@ public class Compositor {
|
|||
public void Frame() {
|
||||
Mono mono = Mono.inst;
|
||||
|
||||
// Renderer.RenderTo(tex,
|
||||
// Matrix.TR(V.XYZ(0, 1, 0), Quat.FromAngles(0, 180, 0)),
|
||||
// Matrix.Perspective(60, 1, 0.1f, 100),
|
||||
// RenderLayer.All // & ~RenderLayer.Layer1
|
||||
// );
|
||||
if (Input.Key(Key.Space).IsJustActive()) {
|
||||
// add the depth tex color.r's up and see if they are > 0
|
||||
float r = 0;
|
||||
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();
|
||||
// greenyard.oriel.Frame();
|
||||
|
|
|
@ -3,9 +3,9 @@ namespace Oriels;
|
|||
public class Oriel {
|
||||
Material matClear = new Material(Shader.Default);
|
||||
|
||||
public Material matOriel = new Material(Shader.FromFile("oriel.hlsl"));
|
||||
Material matFrame = new Material(Shader.FromFile("frame.hlsl"));
|
||||
Material matPanes = new Material(Shader.FromFile("panes.hlsl"));
|
||||
public Material matOriel = new Material(Shader.FromFile("shaders/oriel.hlsl"));
|
||||
Material matFrame = new Material(Shader.FromFile("shaders/frame.hlsl"));
|
||||
Material matPanes = new Material(Shader.FromFile("shaders/panes.hlsl"));
|
||||
|
||||
public Matrix matrix, matrixInv;
|
||||
public Bounds bounds;
|
||||
|
|
|
@ -10,7 +10,7 @@ public class Mono {
|
|||
|
||||
Model greenyardModel = Model.FromFile("greenyard.glb");
|
||||
Mesh[] greenyard;
|
||||
Material greenyardMat = new Material(Shader.FromFile("/oriel.hlsl"));
|
||||
Material greenyardMat = new Material(Shader.FromFile("shaders/oriel.hlsl"));
|
||||
|
||||
Matrix matrix = Matrix.Identity;
|
||||
Vec3 offset = new Vec3(2, 1, -12);
|
||||
|
|
Loading…
Add table
Reference in a new issue