holes backface when box face does
This commit is contained in:
parent
2eb15dd992
commit
470fa38107
1 changed files with 16 additions and 9 deletions
25
src/Arts.cs
25
src/Arts.cs
|
@ -9,6 +9,7 @@ static class Arts
|
|||
static Dictionary<string, Mesh> meshes = new();
|
||||
static Material mat_mono = new Material("mono.hlsl");
|
||||
static Material mat_unlit = new Material("unlit.hlsl");
|
||||
// [!] have backfaces on a mat run a separate backbox/face shader]? *to try and reduce drawcalls
|
||||
static Material mat_backbox = new Material("backbox.hlsl");
|
||||
static Material mat_justcolor = new Material("justcolor.hlsl");
|
||||
|
||||
|
@ -155,17 +156,23 @@ static class Arts
|
|||
// holes
|
||||
foreach (KeyValuePair<XYZi, XYZi> hole in Mono.holes)
|
||||
{
|
||||
meshes["Hole"].Draw(
|
||||
mat_unlit,
|
||||
Matrix.TRS(
|
||||
hole.Key.ToVec3,
|
||||
Quat.LookDir(hole.Value.ToVec3),
|
||||
1
|
||||
)
|
||||
Vec3 hole_normal = V.XYZ(
|
||||
Maths.abs(hole.Value.x) * Maths.sign(hole.Key.x),
|
||||
Maths.abs(hole.Value.y) * Maths.sign(hole.Key.y),
|
||||
Maths.abs(hole.Value.z) * Maths.sign(hole.Key.z)
|
||||
);
|
||||
// [!] have backfaces on a mat run a separate backbox/face shader]? *to try and reduce drawcalls
|
||||
Vec3 hole_world_normal = Mono.box_pose.orientation * hole_normal;
|
||||
Vec3 hole_world = Mono.box_pose.ToMatrix(Mono.box_scale) * V.XYZ(
|
||||
hole.Key.x - hole.Value.x * 0.5f,
|
||||
hole.Key.y - hole.Value.y * 0.5f,
|
||||
hole.Key.z - hole.Value.z * 0.5f
|
||||
);
|
||||
// Vec3 cam_dir = (Rig.head.orientation * Vec3.Forward);
|
||||
Vec3 hole_view_dir = Vec3.Direction(hole_world, Rig.head.position);
|
||||
bool back_hole = Vec3.Dot(hole_world_normal, hole_view_dir) < 0.0;
|
||||
|
||||
meshes["Hole"].Draw(
|
||||
mat_backbox,
|
||||
back_hole ? mat_backbox : mat_unlit,
|
||||
Matrix.TRS(
|
||||
hole.Key.ToVec3,
|
||||
Quat.LookDir(hole.Value.ToVec3),
|
||||
|
|
Loading…
Add table
Reference in a new issue