Lenia: replace kernel with one from the paper, replace glider with a new life form
This commit is contained in:
parent
481a12ecee
commit
05e0789077
9 changed files with 71 additions and 73 deletions
Binary file not shown.
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 3.4 KiB |
|
@ -31,7 +31,7 @@ TextureImporter:
|
|||
maxTextureSize: 2048
|
||||
textureSettings:
|
||||
serializedVersion: 2
|
||||
filterMode: 0
|
||||
filterMode: 1
|
||||
aniso: 1
|
||||
mipBias: 0
|
||||
wrapU: 0
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
_LastFrame ("Texture", 2D) = "white" {}
|
||||
_GrowtCenter ("Growth fn center (mu)", Range(0, 1)) = 0.2
|
||||
_GrowthWidth ("Growth fn width (sigma / std deviation)", Range(0, 1)) = 0.07
|
||||
_Speed ("Speed factor", Range(0.3, 5)) = 1
|
||||
_Speed ("Speed factor", Range(0.01, 0.5)) = 0.05
|
||||
}
|
||||
SubShader
|
||||
{
|
||||
|
@ -22,16 +22,13 @@
|
|||
|
||||
#define WIDTH 512
|
||||
|
||||
struct appdata
|
||||
{
|
||||
struct appdata {
|
||||
float4 vertex : POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
struct v2f {
|
||||
float2 uv : TEXCOORD0;
|
||||
|
||||
float4 vertex : SV_POSITION;
|
||||
};
|
||||
|
||||
|
@ -40,8 +37,7 @@
|
|||
float _GrowthWidth;
|
||||
float _Speed;
|
||||
|
||||
v2f vert (appdata v)
|
||||
{
|
||||
v2f vert (appdata v) {
|
||||
v2f o;
|
||||
o.vertex = UnityObjectToClipPos(v.vertex);
|
||||
o.uv = v.uv;
|
||||
|
@ -63,7 +59,7 @@
|
|||
// return exp(alpha - alpha/(4.0 * r * (1.0 - r)));
|
||||
}
|
||||
|
||||
inline float activation(float neighbors) {
|
||||
float activation(float neighbors) {
|
||||
// return old_state * (neighbors > 2 && neighbors < 5) +
|
||||
// ((1 - old_state) * neighbors == 3);
|
||||
|
||||
|
@ -76,14 +72,13 @@
|
|||
return exp(-((u-mu) * (u-mu)) / (2 * sigma * sigma)) * 2.0 - 1.0;
|
||||
}
|
||||
|
||||
inline float value(uint2 p, int dx, int dy) {
|
||||
float value(uint2 p, int dx, int dy) {
|
||||
const uint x = (p.x + dx) % WIDTH;
|
||||
const uint y = (p.y + dy) % WIDTH;
|
||||
return _LastFrame[uint2(x, y)].r;
|
||||
}
|
||||
|
||||
fixed4 frag (v2f i) : SV_Target
|
||||
{
|
||||
float4 frag (v2f i) : SV_Target {
|
||||
if(_ProjectionParams.z > 1) discard;
|
||||
|
||||
// Defines RADIUS Kernel total_max
|
||||
|
@ -104,7 +99,7 @@
|
|||
float old_state = value(p, 0, 0) ;
|
||||
float count = total / total_max;
|
||||
|
||||
const float step = _Speed * unity_DeltaTime.x;
|
||||
const float step = _Speed * unity_DeltaTime.x * 60;
|
||||
float state = activation(count) * step + old_state;
|
||||
state = clamp(state, 0, 1);
|
||||
|
||||
|
|
|
@ -1,28 +1,26 @@
|
|||
// generated by the rust program
|
||||
#define RADIUS 20
|
||||
const half Kernel[21][20] = {
|
||||
{0.00, 0.04, 0.10, 0.20, 0.38, 0.60, 0.80, 0.96, 0.98, 0.88, 0.68, 0.46, 0.26, 0.12, 0.06, 0.02, 0.00, 0.00, 0.00, 0.00, },
|
||||
{0.02, 0.04, 0.10, 0.22, 0.40, 0.60, 0.82, 0.96, 0.98, 0.88, 0.68, 0.44, 0.26, 0.12, 0.06, 0.02, 0.00, 0.00, 0.00, 0.00, },
|
||||
{0.04, 0.08, 0.16, 0.28, 0.46, 0.66, 0.86, 0.98, 0.98, 0.84, 0.64, 0.42, 0.24, 0.12, 0.04, 0.02, 0.00, 0.00, 0.00, 0.00, },
|
||||
{0.10, 0.16, 0.24, 0.38, 0.56, 0.74, 0.92, 0.98, 0.94, 0.80, 0.58, 0.38, 0.22, 0.10, 0.04, 0.00, 0.00, 0.00, 0.00, 0.00, },
|
||||
{0.22, 0.28, 0.38, 0.52, 0.68, 0.84, 0.96, 0.98, 0.90, 0.74, 0.52, 0.32, 0.18, 0.08, 0.02, 0.00, 0.00, 0.00, 0.00, 0.00, },
|
||||
{0.40, 0.46, 0.56, 0.68, 0.82, 0.94, 0.98, 0.96, 0.82, 0.64, 0.44, 0.26, 0.14, 0.06, 0.02, 0.00, 0.00, 0.00, 0.00, 0.00, },
|
||||
{0.60, 0.66, 0.74, 0.84, 0.94, 0.98, 0.98, 0.88, 0.72, 0.54, 0.34, 0.20, 0.10, 0.04, 0.02, 0.00, 0.00, 0.00, 0.00, 0.00, },
|
||||
{0.82, 0.86, 0.92, 0.96, 0.98, 0.98, 0.90, 0.76, 0.58, 0.42, 0.26, 0.14, 0.06, 0.02, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, },
|
||||
{0.96, 0.98, 0.98, 0.98, 0.96, 0.88, 0.76, 0.60, 0.44, 0.30, 0.18, 0.10, 0.04, 0.02, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, },
|
||||
{0.98, 0.98, 0.94, 0.90, 0.82, 0.72, 0.58, 0.44, 0.32, 0.20, 0.10, 0.06, 0.02, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, },
|
||||
{0.88, 0.84, 0.80, 0.74, 0.64, 0.54, 0.42, 0.30, 0.20, 0.12, 0.06, 0.02, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, },
|
||||
{0.68, 0.64, 0.58, 0.52, 0.44, 0.34, 0.26, 0.18, 0.10, 0.06, 0.02, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, },
|
||||
{0.44, 0.42, 0.38, 0.32, 0.26, 0.20, 0.14, 0.10, 0.06, 0.02, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, },
|
||||
{0.26, 0.24, 0.22, 0.18, 0.14, 0.10, 0.06, 0.04, 0.02, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, },
|
||||
{0.12, 0.12, 0.10, 0.08, 0.06, 0.04, 0.02, 0.02, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, },
|
||||
{0.06, 0.04, 0.04, 0.02, 0.02, 0.02, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, },
|
||||
{0.02, 0.02, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, },
|
||||
{0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, },
|
||||
{0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, },
|
||||
{0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, },
|
||||
{0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, },
|
||||
#define RADIUS 18
|
||||
const float Kernel[19][18] = {
|
||||
{0.00, 0.00, 0.04, 0.16, 0.37, 0.60, 0.81, 0.95, 1.00, 0.95, 0.81, 0.60, 0.37, 0.16, 0.04, 0.00, 0.00, 0.00, },
|
||||
{0.00, 0.00, 0.05, 0.18, 0.39, 0.62, 0.82, 0.95, 0.99, 0.94, 0.80, 0.59, 0.36, 0.16, 0.03, 0.00, 0.00, 0.00, },
|
||||
{0.00, 0.02, 0.10, 0.25, 0.46, 0.67, 0.85, 0.97, 0.99, 0.93, 0.77, 0.56, 0.33, 0.14, 0.03, 0.00, 0.00, 0.00, },
|
||||
{0.05, 0.10, 0.21, 0.37, 0.56, 0.75, 0.90, 0.98, 0.98, 0.90, 0.73, 0.52, 0.29, 0.11, 0.02, 0.00, 0.00, 0.00, },
|
||||
{0.18, 0.25, 0.37, 0.52, 0.69, 0.84, 0.95, 0.99, 0.96, 0.85, 0.67, 0.45, 0.24, 0.08, 0.01, 0.00, 0.00, 0.00, },
|
||||
{0.39, 0.46, 0.56, 0.69, 0.82, 0.93, 0.99, 0.99, 0.91, 0.77, 0.58, 0.37, 0.18, 0.05, 0.00, 0.00, 0.00, 0.00, },
|
||||
{0.62, 0.67, 0.75, 0.84, 0.93, 0.98, 0.99, 0.95, 0.84, 0.68, 0.48, 0.28, 0.11, 0.02, 0.00, 0.00, 0.00, 0.00, },
|
||||
{0.82, 0.85, 0.90, 0.95, 0.99, 0.99, 0.96, 0.87, 0.73, 0.55, 0.36, 0.18, 0.06, 0.00, 0.00, 0.00, 0.00, 0.00, },
|
||||
{0.95, 0.97, 0.98, 0.99, 0.99, 0.95, 0.87, 0.75, 0.59, 0.41, 0.24, 0.10, 0.02, 0.00, 0.00, 0.00, 0.00, 0.00, },
|
||||
{0.99, 0.99, 0.98, 0.96, 0.91, 0.84, 0.73, 0.59, 0.43, 0.27, 0.13, 0.04, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, },
|
||||
{0.94, 0.93, 0.90, 0.85, 0.77, 0.68, 0.55, 0.41, 0.27, 0.14, 0.05, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, },
|
||||
{0.80, 0.77, 0.73, 0.67, 0.58, 0.48, 0.36, 0.24, 0.13, 0.05, 0.01, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, },
|
||||
{0.59, 0.56, 0.52, 0.45, 0.37, 0.28, 0.18, 0.10, 0.04, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, },
|
||||
{0.36, 0.33, 0.29, 0.24, 0.18, 0.11, 0.06, 0.02, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, },
|
||||
{0.16, 0.14, 0.11, 0.08, 0.05, 0.02, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, },
|
||||
{0.03, 0.03, 0.02, 0.01, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, },
|
||||
{0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, },
|
||||
{0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, },
|
||||
{0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, },
|
||||
};
|
||||
const float total_max = 356.63977;
|
||||
// Total texture lookups: 206 * 4 + 1 = 825
|
||||
const float total_max = 386.71994;
|
||||
// Total texture lookups: 185 * 4 + 1 = 741
|
||||
// (lookups multiplied by 0.0 get optimised away by the shader compiler, and this giant table generally only exists at compile time)
|
||||
|
|
|
@ -70,8 +70,8 @@ Material:
|
|||
- _GlossMapScale: 1
|
||||
- _Glossiness: 0.5
|
||||
- _GlossyReflections: 1
|
||||
- _GrowtCenter: 0.14
|
||||
- _GrowthWidth: 0.013
|
||||
- _GrowtCenter: 0.28
|
||||
- _GrowthWidth: 0.04
|
||||
- _KOffset: 0.436
|
||||
- _KSharpness: 28.3
|
||||
- _Metallic: 0
|
||||
|
@ -81,7 +81,7 @@ Material:
|
|||
- _Radius: 13
|
||||
- _SmoothnessTextureChannel: 0
|
||||
- _SpecularHighlights: 1
|
||||
- _Speed: 2
|
||||
- _Speed: 0.05
|
||||
- _SrcBlend: 1
|
||||
- _UVSec: 0
|
||||
- _ZWrite: 1
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue