diff --git a/Assets/backbox.hlsl b/Assets/backbox.hlsl index e4a5901..0fa122d 100644 --- a/Assets/backbox.hlsl +++ b/Assets/backbox.hlsl @@ -45,6 +45,6 @@ float4 ps(psIn input) : SV_TARGET { // Fresnel effect calculation float fresnel = 1.0 - saturate(dot(-view_dir, input.normal)); fresnel = pow(fresnel, 5.0); // Adjust power for different falloff rates - - return float4(fresnel * input.color.rgb, input.color.a); + float value = 0.5; + return float4(fresnel * input.color.rgb * value, input.color.a); } \ No newline at end of file diff --git a/Assets/meshes/assets.glb b/Assets/meshes/assets.glb index 6bdb72d..7a481c4 100644 --- a/Assets/meshes/assets.glb +++ b/Assets/meshes/assets.glb @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:13e516ec0d9a8855cbefcfa35219ad8e7a46fb4f9dd4b0cf5c712155316df16b -size 410016 +oid sha256:d3f5774cbab8eea4d3343b26fd6c5faeb8ae71c09fae06ed9b6e4fad745f0d82 +size 411484 diff --git a/Platforms/Android/AndroidManifest.xml b/Platforms/Android/AndroidManifest.xml index 4856438..d68f656 100644 --- a/Platforms/Android/AndroidManifest.xml +++ b/Platforms/Android/AndroidManifest.xml @@ -2,8 +2,8 @@ diff --git a/src/Arts.cs b/src/Arts.cs index a5c75f9..a7ab42e 100644 --- a/src/Arts.cs +++ b/src/Arts.cs @@ -9,7 +9,7 @@ static class Arts static Dictionary 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_box = new Material("unlit.hlsl"); static Material mat_backbox = new Material("backbox.hlsl"); static Material mat_justcolor = new Material("justcolor.hlsl"); @@ -30,10 +30,13 @@ static class Arts } } + mat_backbox.FaceCull = Cull.Front; mat_backbox.Transparency = Transparency.Add; mat_backbox.DepthTest = DepthTest.LessOrEq; mat_backbox.DepthWrite = false; + + mat_box.Chain = mat_backbox; } public static void Frame() @@ -62,11 +65,10 @@ static class Arts // box Hierarchy.Push(Mono.box_pose.ToMatrix(Mono.box_scale)); - meshes["InsideOut"].Draw(mat_unlit, Matrix.Identity); + // meshes["InsideOut"].Draw(mat_unlit, Matrix.Identity); meshes["InsideOut"].Draw( - mat_backbox, - Matrix.Identity, - new Color(0.2f, 0.2f, 0.2f) + mat_box, + Matrix.Identity ); meshes["Corrugation"].Draw( Mono.in_dist.state ? mat_justcolor : mat_unlit, @@ -161,18 +163,19 @@ static class Arts Maths.abs(hole.Value.y) * Maths.sign(hole.Key.y), Maths.abs(hole.Value.z) * Maths.sign(hole.Key.z) ); - 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 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; + // Vec3 hole_view_dir = Vec3.Direction(hole_world, Rig.head.position); + // bool back_hole = Vec3.Dot(hole_world_normal, hole_view_dir) < 0.0; + bool hole_flip = Vec3.Dot(hole_normal, hole.Value.ToVec3) < 0.0; - meshes["Hole"].Draw( - back_hole ? mat_backbox : mat_unlit, + meshes[hole_flip ? "Hole" : "HoleFlip"].Draw( + mat_box, Matrix.TRS( hole.Key.ToVec3, Quat.LookDir(hole.Value.ToVec3),