summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-x3ner.shader7
-rw-r--r--aperiodic_tiling.cginc19
-rwxr-xr-xfeatures.cginc4
-rwxr-xr-xglobals.cginc4
4 files changed, 26 insertions, 8 deletions
diff --git a/3ner.shader b/3ner.shader
index 8cc0c96..1dc06cf 100755
--- a/3ner.shader
+++ b/3ner.shader
@@ -934,6 +934,13 @@ Shader "yum_food/3ner"
_Logical_Time("Time", Float) = 0
[HideInInspector] m_end_Logical_Time("Logical Time", Float) = 0
//endex
+
+ //ifex _Aperiodic_Tiling_Enabled==0
+ [HideInInspector] m_start_Aperiodic_Tiling("Aperiodic Tiling", Float) = 0
+ [ThryToggle(_APERIODIC_TILING)] _Aperiodic_Tiling_Enabled("Enable", Float) = 0
+ _Aperiodic_Tiling_Scale("Scale", Float) = 1
+ [HideInInspector] m_end_Aperiodic_Tiling("Aperiodic Tiling", Float) = 0
+ //endex
//ifex _Custom31_World_Enabled==0
[HideInInspector] m_start_Custom31_World("C31 World Gimmicks", Float) = 0
diff --git a/aperiodic_tiling.cginc b/aperiodic_tiling.cginc
index fa69712..78c911d 100644
--- a/aperiodic_tiling.cginc
+++ b/aperiodic_tiling.cginc
@@ -7,23 +7,24 @@
// https://gglouser.github.io/cut-and-project-tiling/docs/intro.html#how-it-works
// https://www.youtube.com/watch?v=hwMAOFb6yvA
+#include "globals.cginc"
#include "math.cginc"
static const float M5 = sqrt(2.0 / 5.0);
-float4 basis_u5_03 = M5 * float4(
+static const float4 basis_u5_03 = M5 * float4(
cos(0 * TAU / 10),
cos(1 * TAU / 10),
cos(2 * TAU / 10),
cos(3 * TAU / 10));
-float basis_u5_44 = M5 * cos(4 * TAU / 10);
+static const float basis_u5_44 = M5 * cos(4 * TAU / 10);
-float4 basis_v5_03 = M5 * float4(
+static const float4 basis_v5_03 = M5 * float4(
sin(0 * TAU / 10),
sin(1 * TAU / 10),
sin(2 * TAU / 10),
sin(3 * TAU / 10));
-float basis_v5_44 = M5 * sin(4 * TAU / 10);
+static const float basis_v5_44 = M5 * sin(4 * TAU / 10);
float dot5(float4 a03, float a44, float4 b03, float b44) {
return dot(a03, b03) + a44 * b44;
@@ -47,8 +48,8 @@ float2x2 inv2x2(float2x2 m) {
float tile5(float4 p03, float p44, float2x2 m, float2 s,
float4 a03, float a44, float4 b03, float b44) {
float2 q = mul(s, m);
- p03 -= (1 - a03 - b03) * round(q.x * basis_u5_03 + q.y * basis_v5_03);
- p44 -= (1 - a44 - b44) * round(q.x * basis_u5_44 + q.y * basis_v5_44);
+ p03 -= (1.0 - a03 - b03) * round(q.x * basis_u5_03 + q.y * basis_v5_03);
+ p44 -= (1.0 - a44 - b44) * round(q.x * basis_u5_44 + q.y * basis_v5_44);
float2 f = abs(mul(m, proj5(p03, p44)) - s);
return max(0.0, 0.5 - max(f.x, f.y));
}
@@ -69,7 +70,7 @@ float t5(float4 p03, float p44, float4 a03, float a44, float4 b03, float b44) {
float3 dim5(float2 uv) {
float4 p03 = uv.x * basis_u5_03 + uv.y * basis_v5_03;
- float p44 = uv.x * basis_u5_44 + uv.y * basis_v5_44;
+ float p44 = uv.x * basis_u5_44 + uv.y * basis_v5_44;
float2 u = float2(0, 1);
float3 edge = float3(0.04, 0.1, 0.04);
@@ -91,8 +92,10 @@ float3 dim5(float2 uv) {
}
void apply_aperiodic_tiling(float2 uv, inout float3 albedo) {
+#if defined(_APERIODIC_TILING)
+ uv *= _Aperiodic_Tiling_Scale;
albedo = dim5(uv);
+#endif // _APERIODIC_TILING
}
#endif // __APERIODIC_TILING_INC
-
diff --git a/features.cginc b/features.cginc
index 9caebf1..283946b 100755
--- a/features.cginc
+++ b/features.cginc
@@ -134,6 +134,10 @@
#pragma shader_feature_local _LOGICAL_TIME
//endex
+//ifex _Aperiodic_Tiling_Enabled==0
+#pragma shader_feature_local _APERIODIC_TILING
+//endex
+
//ifex _Custom31_World_Enabled==0
#pragma shader_feature_local _CUSTOM31_WORLD
#pragma shader_feature_local _CUSTOM31_WORLD_HEXAGONS
diff --git a/globals.cginc b/globals.cginc
index 93c58e0..e186f0d 100755
--- a/globals.cginc
+++ b/globals.cginc
@@ -184,6 +184,10 @@ float _Center_Offset_Factor;
float _Logical_Time;
#endif // _LOGICAL_TIME
+#if defined(_APERIODIC_TILING)
+float _Aperiodic_Tiling_Scale;
+#endif // _APERIODIC_TILING
+
#if defined(_CUSTOM31_WORLD)
int _Custom31_World_Ray_March_Steps;
float _Custom31_World_Ray_March_Min_Dist;