chroma fresnel + greenyard
This commit is contained in:
parent
88c485cae6
commit
d69e6fc55d
12 changed files with 101 additions and 16 deletions
BIN
add/fantasy_skybox.glb
Normal file
BIN
add/fantasy_skybox.glb
Normal file
Binary file not shown.
BIN
add/fantasy_skybox.jpeg
Normal file
BIN
add/fantasy_skybox.jpeg
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.5 MiB |
BIN
add/greenyard.glb
Normal file
BIN
add/greenyard.glb
Normal file
Binary file not shown.
BIN
add/greenyard.jpeg
Normal file
BIN
add/greenyard.jpeg
Normal file
Binary file not shown.
After Width: | Height: | Size: 14 MiB |
|
@ -57,6 +57,8 @@ float remap_tri(float v)
|
||||||
|
|
||||||
float4 ps(psIn input) : SV_TARGET {
|
float4 ps(psIn input) : SV_TARGET {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// float4 c = input.col;
|
// float4 c = input.col;
|
||||||
// float3 rLocal = (input.world.xyz - _rGlovePos) / 2;
|
// float3 rLocal = (input.world.xyz - _rGlovePos) / 2;
|
||||||
// c.r = 1 - min(abs(rLocal.x), 1.0);
|
// c.r = 1 - min(abs(rLocal.x), 1.0);
|
||||||
|
@ -66,15 +68,14 @@ float4 ps(psIn input) : SV_TARGET {
|
||||||
// float m = min(c.r, min(c.g, c.b));
|
// float m = min(c.r, min(c.g, c.b));
|
||||||
// c.rgb *= m;
|
// c.rgb *= m;
|
||||||
|
|
||||||
float3 flatnorm = (input.col.rgb - float3(0.5, 0.5, 0.5)) * 2;
|
// float3 flatnorm = (input.col.rgb - float3(0.5, 0.5, 0.5)) * 2;
|
||||||
|
|
||||||
// flatnorm = normalize(mul(flatnorm, (float3x3)sk_inst[input.id].world));
|
// flatnorm = normalize(mul(flatnorm, (float3x3)sk_inst[input.id].world));
|
||||||
|
|
||||||
// float3 cross = input.camDir * input.norm;
|
// float3 cross = input.camDir * input.norm;
|
||||||
float dist = length(input.world.xyz - input.campos);
|
// float dist = length(input.world.xyz - input.campos);
|
||||||
float3 raydir = normalize(input.world.xyz - input.campos);
|
float3 raydir = normalize(input.world.xyz - input.campos);
|
||||||
|
|
||||||
float facing = 1 - dot(raydir, input.camdir);
|
// float facing = 1 - dot(raydir, input.camdir);
|
||||||
// facing = (1 + facing) / 2;
|
// facing = (1 + facing) / 2;
|
||||||
// facing = facing;
|
// facing = facing;
|
||||||
|
|
||||||
|
@ -91,7 +92,7 @@ float4 ps(psIn input) : SV_TARGET {
|
||||||
|
|
||||||
// d = remap_tri(d);
|
// d = remap_tri(d);
|
||||||
|
|
||||||
return float4(hsv2rgb(float3(h, 1, 1)), facing * facing * d * 24);
|
return float4(hsv2rgb(float3(h, 1, 1)), h * h);
|
||||||
|
|
||||||
// float4 col = float4(1, 1, 1, 0);
|
// float4 col = float4(1, 1, 1, 0);
|
||||||
// float n = saturate(dot(raydir, input.norm));
|
// float n = saturate(dot(raydir, input.norm));
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
#include "stereokit.hlsli"
|
#include "stereokit.hlsli"
|
||||||
|
|
||||||
// --name = dofdev/oriel
|
// --name = dofdev/oriel
|
||||||
//--diffuse = white
|
//--diffuse = white
|
||||||
|
|
||||||
|
float _lit;
|
||||||
|
float _lit2; // power of 2
|
||||||
float3 _center;
|
float3 _center;
|
||||||
float3 _dimensions;
|
float3 _dimensions;
|
||||||
float3 _light;
|
float3 _light;
|
||||||
|
@ -94,15 +96,17 @@ psOut ps(psIn input) {
|
||||||
clip(distance(input.campos, input.world) - distance(input.campos, origin));
|
clip(distance(input.campos, input.world) - distance(input.campos, origin));
|
||||||
|
|
||||||
float t = 1 - (1 + dot(input.normal, _light)) / 2;
|
float t = 1 - (1 + dot(input.normal, _light)) / 2;
|
||||||
o.color = float4(o.color.rgb * t, 1);
|
// o.color = float4(o.color.rgb * t, 1);
|
||||||
|
o.color = lerp(o.color, float4(o.color.rgb * t, 1), _lit);
|
||||||
|
|
||||||
// float3 localPos = mul(float4(input.world, 1), _matrix).xyz;
|
// float3 localPos = mul(float4(input.world, 1), _matrix).xyz;
|
||||||
// if (localPos.y < -_dimensions.y / 2) {
|
// if (localPos.y < -_dimensions.y / 2) {
|
||||||
// clip(-1);
|
// clip(-1);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
if (dot(direction, input.normal) > 0) {
|
// if (dot(direction, input.normal) > 0) {
|
||||||
o.color = float4(0.5, 0.5, 0.5, 1);
|
// o.color = float4(0.5, 0.5, 0.5, 1);
|
||||||
}
|
// }
|
||||||
|
|
||||||
return o;
|
return o;
|
||||||
}
|
}
|
||||||
|
|
51
app/Greenyard/Mono.cs
Normal file
51
app/Greenyard/Mono.cs
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
using Oriels;
|
||||||
|
|
||||||
|
namespace Greenyard;
|
||||||
|
public class Mono {
|
||||||
|
Model greenyardModel = Model.FromFile("greenyard.glb");
|
||||||
|
Mesh[] greenyard;
|
||||||
|
Material greenyardMat = new Material(Shader.FromFile("/shaders/oriel.hlsl"));
|
||||||
|
|
||||||
|
Vec3 offset = new Vec3(0, 0, 0);
|
||||||
|
|
||||||
|
public Mono() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Init() {
|
||||||
|
greenyard = new Mesh[12];
|
||||||
|
for (int i = 0; i < greenyard.Length; i++) {
|
||||||
|
greenyard[i] = greenyardModel.GetMesh("Object_" + (i + 2));
|
||||||
|
}
|
||||||
|
greenyardMat.SetMat(101, Cull.None, true);
|
||||||
|
greenyardMat.SetTexture("diffuse", Tex.FromFile("greenyard.jpeg"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Frame() {
|
||||||
|
Oriels.Rig rig = Oriels.Mono.inst.rig;
|
||||||
|
Oriels.Oriel oriel = Oriels.Mono.inst.oriel;
|
||||||
|
|
||||||
|
Matrix simMatrix = Matrix.TRS(
|
||||||
|
new Vec3(0, -oriel.bounds.dimensions.y / 2.01f, 0),
|
||||||
|
Quat.Identity,
|
||||||
|
Vec3.One * 0.1f * oriel.bounds.dimensions.y
|
||||||
|
);
|
||||||
|
|
||||||
|
// Render
|
||||||
|
greenyardMat.SetVector("_center", oriel.bounds.center);
|
||||||
|
greenyardMat.SetVector("_dimensions", oriel.bounds.dimensions);
|
||||||
|
greenyardMat.SetVector("_light", oriel.ori * new Vec3(0.6f, -0.9f, 0.3f));
|
||||||
|
greenyardMat.SetFloat("_lit", 0);
|
||||||
|
greenyardMat["_matrix"] = (Matrix)System.Numerics.Matrix4x4.Transpose(oriel.matrix);
|
||||||
|
for (int i = 0; i < greenyard.Length; i++) {
|
||||||
|
greenyard[i].Draw(greenyardMat,
|
||||||
|
Matrix.TRS(
|
||||||
|
offset,
|
||||||
|
Quat.Identity,
|
||||||
|
new Vec3(1f, 1f, 1f)
|
||||||
|
) * simMatrix * oriel.matrix.Inverse,
|
||||||
|
Color.White
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -37,13 +37,15 @@ public class Mono {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Init() {
|
public void Init() {
|
||||||
spaceMono.Init();
|
// spaceMono.Init();
|
||||||
|
greenyard.Init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// -------------------------------------------------
|
// -------------------------------------------------
|
||||||
|
|
||||||
Space.Mono spaceMono = new Space.Mono();
|
// Space.Mono spaceMono = new Space.Mono();
|
||||||
|
Greenyard.Mono greenyard = new Greenyard.Mono();
|
||||||
|
|
||||||
|
|
||||||
PullRequest.PID pid = new PullRequest.PID(8, 0.8f);
|
PullRequest.PID pid = new PullRequest.PID(8, 0.8f);
|
||||||
|
@ -69,7 +71,8 @@ public class Mono {
|
||||||
|
|
||||||
// -------------------------------------------------
|
// -------------------------------------------------
|
||||||
|
|
||||||
spaceMono.Frame();
|
// spaceMono.Frame();
|
||||||
|
greenyard.Frame();
|
||||||
|
|
||||||
// -------------------------------------------------
|
// -------------------------------------------------
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,8 @@ public class Oriel {
|
||||||
matPanes.SetMat(100, Cull.Front, false);
|
matPanes.SetMat(100, Cull.Front, false);
|
||||||
matOriel.SetMat(101, Cull.None, true);
|
matOriel.SetMat(101, Cull.None, true);
|
||||||
|
|
||||||
meshCube = model.GetMesh("oriel");
|
meshCube = Mesh.Cube;
|
||||||
|
// meshCube = model.GetMesh("oriel");
|
||||||
}
|
}
|
||||||
|
|
||||||
Vec3 detect = Vec3.Zero;
|
Vec3 detect = Vec3.Zero;
|
||||||
|
@ -154,6 +155,7 @@ public class Oriel {
|
||||||
matOriel.SetVector("_center", bounds.center);
|
matOriel.SetVector("_center", bounds.center);
|
||||||
matOriel.SetVector("_dimensions", bounds.dimensions);
|
matOriel.SetVector("_dimensions", bounds.dimensions);
|
||||||
matOriel.SetVector("_light", ori * new Vec3(0.6f, -0.9f, 0.3f));
|
matOriel.SetVector("_light", ori * new Vec3(0.6f, -0.9f, 0.3f));
|
||||||
|
matOriel.SetFloat("_lit", 1);
|
||||||
matOriel["_matrix"] = (Matrix)System.Numerics.Matrix4x4.Transpose(matrix);
|
matOriel["_matrix"] = (Matrix)System.Numerics.Matrix4x4.Transpose(matrix);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,4 +1,5 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using Oriels;
|
||||||
|
|
||||||
// [X] stretch cursor move
|
// [X] stretch cursor move
|
||||||
// [X] nodes *point of reference rather than interest for now
|
// [X] nodes *point of reference rather than interest for now
|
||||||
|
@ -20,6 +21,9 @@ public class Mono {
|
||||||
Oriels.PullRequest.PID pidZ = new Oriels.PullRequest.PID();
|
Oriels.PullRequest.PID pidZ = new Oriels.PullRequest.PID();
|
||||||
|
|
||||||
Mesh meshCube;
|
Mesh meshCube;
|
||||||
|
// Model skyboxModel = Model.FromFile("fantasy_skybox.glb");
|
||||||
|
// Mesh skybox;
|
||||||
|
// Material skyboxMat = new Material(Shader.FromFile("/shaders/oriel.hlsl"));
|
||||||
|
|
||||||
public Mono() {
|
public Mono() {
|
||||||
|
|
||||||
|
@ -42,6 +46,9 @@ public class Mono {
|
||||||
}
|
}
|
||||||
|
|
||||||
meshCube = Mesh.Cube;
|
meshCube = Mesh.Cube;
|
||||||
|
// skybox = skyboxModel.GetMesh("sky");
|
||||||
|
// skyboxMat.SetMat(101, Cull.None, true);
|
||||||
|
// skyboxMat.SetTexture("diffuse", Tex.FromFile("fantasy_skybox.jpeg"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Frame() {
|
public void Frame() {
|
||||||
|
@ -112,6 +119,23 @@ public class Mono {
|
||||||
new Color(1.0f, 0.0f, 0.05f)
|
new Color(1.0f, 0.0f, 0.05f)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
// skyboxMat.SetVector("_center", oriel.bounds.center);
|
||||||
|
// skyboxMat.SetVector("_dimensions", oriel.bounds.dimensions);
|
||||||
|
// skyboxMat.SetVector("_light", oriel.ori * new Vec3(0.6f, -0.9f, 0.3f));
|
||||||
|
// skyboxMat.SetFloat("_lit", 0);
|
||||||
|
// skyboxMat["_matrix"] = (Matrix)System.Numerics.Matrix4x4.Transpose(oriel.matrix);
|
||||||
|
// skybox.Draw(skyboxMat,
|
||||||
|
// Matrix.TRS(
|
||||||
|
// playerPos,
|
||||||
|
// Quat.Identity,
|
||||||
|
// new Vec3(10f, 10f, 10f)
|
||||||
|
// ) * simMatrix * oriel.matrix.Inverse,
|
||||||
|
// Color.White
|
||||||
|
// );
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// meshCube.Draw(oriel.matOriel,
|
// meshCube.Draw(oriel.matOriel,
|
||||||
// rGlove.virtualGlove.ToMatrix(new Vec3(0.025f, 0.1f, 0.1f) / 3 * 1.05f),
|
// rGlove.virtualGlove.ToMatrix(new Vec3(0.025f, 0.1f, 0.1f) / 3 * 1.05f),
|
||||||
// new Color(0.3f, 0.3f, 0.6f)
|
// new Color(0.3f, 0.3f, 0.6f)
|
||||||
|
|
|
@ -7,7 +7,7 @@ SKSettings settings = new SKSettings {
|
||||||
assetsFolder = "add",
|
assetsFolder = "add",
|
||||||
depthMode = DepthMode.D32,
|
depthMode = DepthMode.D32,
|
||||||
disableUnfocusedSleep = true,
|
disableUnfocusedSleep = true,
|
||||||
displayPreference = DisplayMode.Flatscreen,
|
// displayPreference = DisplayMode.Flatscreen,
|
||||||
};
|
};
|
||||||
if (!SK.Initialize(settings))
|
if (!SK.Initialize(settings))
|
||||||
Environment.Exit(1);
|
Environment.Exit(1);
|
||||||
|
|
BIN
res/fantasy_skybox.blend
Normal file
BIN
res/fantasy_skybox.blend
Normal file
Binary file not shown.
Loading…
Add table
Reference in a new issue