hole flip trick, with box mat chain
This commit is contained in:
parent
470fa38107
commit
5f49d94910
4 changed files with 24 additions and 21 deletions
|
@ -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);
|
||||
}
|
BIN
Assets/meshes/assets.glb
(Stored with Git LFS)
BIN
Assets/meshes/assets.glb
(Stored with Git LFS)
Binary file not shown.
|
@ -2,8 +2,8 @@
|
|||
<manifest
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.dofdev.snake"
|
||||
android:versionCode="13"
|
||||
android:versionName="1.21"
|
||||
android:versionCode="14"
|
||||
android:versionName="1.24"
|
||||
android:installLocation="auto"
|
||||
>
|
||||
<uses-sdk android:minSdkVersion="29" android:targetSdkVersion="32" />
|
||||
|
|
33
src/Arts.cs
33
src/Arts.cs
|
@ -9,7 +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_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),
|
||||
|
|
Loading…
Add table
Reference in a new issue