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
|
// Fresnel effect calculation
|
||||||
float fresnel = 1.0 - saturate(dot(-view_dir, input.normal));
|
float fresnel = 1.0 - saturate(dot(-view_dir, input.normal));
|
||||||
fresnel = pow(fresnel, 5.0); // Adjust power for different falloff rates
|
fresnel = pow(fresnel, 5.0); // Adjust power for different falloff rates
|
||||||
|
float value = 0.5;
|
||||||
return float4(fresnel * input.color.rgb, input.color.a);
|
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
|
<manifest
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
package="com.dofdev.snake"
|
package="com.dofdev.snake"
|
||||||
android:versionCode="13"
|
android:versionCode="14"
|
||||||
android:versionName="1.21"
|
android:versionName="1.24"
|
||||||
android:installLocation="auto"
|
android:installLocation="auto"
|
||||||
>
|
>
|
||||||
<uses-sdk android:minSdkVersion="29" android:targetSdkVersion="32" />
|
<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 Dictionary<string, Mesh> meshes = new();
|
||||||
static Material mat_mono = new Material("mono.hlsl");
|
static Material mat_mono = new Material("mono.hlsl");
|
||||||
static Material mat_unlit = new Material("unlit.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_backbox = new Material("backbox.hlsl");
|
||||||
static Material mat_justcolor = new Material("justcolor.hlsl");
|
static Material mat_justcolor = new Material("justcolor.hlsl");
|
||||||
|
|
||||||
|
@ -30,10 +30,13 @@ static class Arts
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
mat_backbox.FaceCull = Cull.Front;
|
mat_backbox.FaceCull = Cull.Front;
|
||||||
mat_backbox.Transparency = Transparency.Add;
|
mat_backbox.Transparency = Transparency.Add;
|
||||||
mat_backbox.DepthTest = DepthTest.LessOrEq;
|
mat_backbox.DepthTest = DepthTest.LessOrEq;
|
||||||
mat_backbox.DepthWrite = false;
|
mat_backbox.DepthWrite = false;
|
||||||
|
|
||||||
|
mat_box.Chain = mat_backbox;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Frame()
|
public static void Frame()
|
||||||
|
@ -62,11 +65,10 @@ static class Arts
|
||||||
|
|
||||||
// box
|
// box
|
||||||
Hierarchy.Push(Mono.box_pose.ToMatrix(Mono.box_scale));
|
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(
|
meshes["InsideOut"].Draw(
|
||||||
mat_backbox,
|
mat_box,
|
||||||
Matrix.Identity,
|
Matrix.Identity
|
||||||
new Color(0.2f, 0.2f, 0.2f)
|
|
||||||
);
|
);
|
||||||
meshes["Corrugation"].Draw(
|
meshes["Corrugation"].Draw(
|
||||||
Mono.in_dist.state ? mat_justcolor : mat_unlit,
|
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.y) * Maths.sign(hole.Key.y),
|
||||||
Maths.abs(hole.Value.z) * Maths.sign(hole.Key.z)
|
Maths.abs(hole.Value.z) * Maths.sign(hole.Key.z)
|
||||||
);
|
);
|
||||||
Vec3 hole_world_normal = Mono.box_pose.orientation * hole_normal;
|
// Vec3 hole_world_normal = Mono.box_pose.orientation * hole_normal;
|
||||||
Vec3 hole_world = Mono.box_pose.ToMatrix(Mono.box_scale) * V.XYZ(
|
// Vec3 hole_world = Mono.box_pose.ToMatrix(Mono.box_scale) * V.XYZ(
|
||||||
hole.Key.x - hole.Value.x * 0.5f,
|
// hole.Key.x - hole.Value.x * 0.5f,
|
||||||
hole.Key.y - hole.Value.y * 0.5f,
|
// hole.Key.y - hole.Value.y * 0.5f,
|
||||||
hole.Key.z - hole.Value.z * 0.5f
|
// hole.Key.z - hole.Value.z * 0.5f
|
||||||
);
|
// );
|
||||||
// Vec3 cam_dir = (Rig.head.orientation * Vec3.Forward);
|
// Vec3 cam_dir = (Rig.head.orientation * Vec3.Forward);
|
||||||
Vec3 hole_view_dir = Vec3.Direction(hole_world, Rig.head.position);
|
// 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 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(
|
meshes[hole_flip ? "Hole" : "HoleFlip"].Draw(
|
||||||
back_hole ? mat_backbox : mat_unlit,
|
mat_box,
|
||||||
Matrix.TRS(
|
Matrix.TRS(
|
||||||
hole.Key.ToVec3,
|
hole.Key.ToVec3,
|
||||||
Quat.LookDir(hole.Value.ToVec3),
|
Quat.LookDir(hole.Value.ToVec3),
|
||||||
|
|
Loading…
Add table
Reference in a new issue