Compare commits
4 commits
e8ebac67fb
...
a17640b7cc
Author | SHA1 | Date | |
---|---|---|---|
a17640b7cc | |||
16ac2515e4 | |||
111f4a21af | |||
dce6916eb1 |
9 changed files with 176 additions and 171 deletions
|
@ -847,7 +847,7 @@ GameObject:
|
||||||
m_Icon: {fileID: 0}
|
m_Icon: {fileID: 0}
|
||||||
m_NavMeshLayer: 0
|
m_NavMeshLayer: 0
|
||||||
m_StaticEditorFlags: 0
|
m_StaticEditorFlags: 0
|
||||||
m_IsActive: 1
|
m_IsActive: 0
|
||||||
--- !u!65 &1377711729
|
--- !u!65 &1377711729
|
||||||
BoxCollider:
|
BoxCollider:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
@ -1550,7 +1550,7 @@ Transform:
|
||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
m_GameObject: {fileID: 2044521647}
|
m_GameObject: {fileID: 2044521647}
|
||||||
m_LocalRotation: {x: 0, y: 1, z: 0, w: 0}
|
m_LocalRotation: {x: 0, y: 1, z: 0, w: 0}
|
||||||
m_LocalPosition: {x: -2.402, y: 0.506, z: 0.292}
|
m_LocalPosition: {x: -2.402, y: 0.506, z: 0.196}
|
||||||
m_LocalScale: {x: 0.125, y: 0.125, z: 0.125}
|
m_LocalScale: {x: 0.125, y: 0.125, z: 0.125}
|
||||||
m_Children: []
|
m_Children: []
|
||||||
m_Father: {fileID: 0}
|
m_Father: {fileID: 0}
|
||||||
|
@ -1579,7 +1579,7 @@ GameObject:
|
||||||
m_Icon: {fileID: 0}
|
m_Icon: {fileID: 0}
|
||||||
m_NavMeshLayer: 0
|
m_NavMeshLayer: 0
|
||||||
m_StaticEditorFlags: 0
|
m_StaticEditorFlags: 0
|
||||||
m_IsActive: 0
|
m_IsActive: 1
|
||||||
--- !u!114 &2129299479
|
--- !u!114 &2129299479
|
||||||
MonoBehaviour:
|
MonoBehaviour:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
_LastFrame ("Texture", 2D) = "white" {}
|
_LastFrame ("Texture", 2D) = "white" {}
|
||||||
_GrowtCenter ("Growth fn center (mu)", Range(0, 1)) = 0.2
|
_GrowtCenter ("Growth fn center (mu)", Range(0, 1)) = 0.2
|
||||||
_GrowthWidth ("Growth fn width (sigma / std deviation)", Range(0, 1)) = 0.07
|
_GrowthWidth ("Growth fn width (sigma / std deviation)", Range(0, 1)) = 0.07
|
||||||
_Speed ("Speed factor", Range(0.001, 0.5)) = 0.1
|
_Speed ("Speed factor", Range(0.3, 5)) = 1
|
||||||
}
|
}
|
||||||
SubShader
|
SubShader
|
||||||
{
|
{
|
||||||
|
@ -74,8 +74,6 @@
|
||||||
return exp(-((u-mu) * (u-mu)) / (2 * sigma * sigma)) * 2.0 - 1.0;
|
return exp(-((u-mu) * (u-mu)) / (2 * sigma * sigma)) * 2.0 - 1.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
inline half value(float2 center, float x, float y) {
|
inline half value(float2 center, float x, float y) {
|
||||||
return tex2D(_LastFrame, center + float2(x, y)).r;
|
return tex2D(_LastFrame, center + float2(x, y)).r;
|
||||||
}
|
}
|
||||||
|
@ -86,14 +84,14 @@
|
||||||
|
|
||||||
const float resolution = 512.0;
|
const float resolution = 512.0;
|
||||||
const float d = 1.0 / resolution;
|
const float d = 1.0 / resolution;
|
||||||
// Defines RADIUS Radius Kernel total_max
|
// Defines RADIUS Kernel total_max
|
||||||
#include "lenia_generated_kernel.cginc"
|
#include "lenia_generated_kernel.cginc"
|
||||||
|
|
||||||
float total = 0.0;
|
float total = 0.0;
|
||||||
[unroll(RADIUS)]
|
[unroll(RADIUS)]
|
||||||
for (int y = 0; y < Radius; y++) {
|
for (int y = 0; y < RADIUS; y++) {
|
||||||
[unroll(RADIUS)]
|
[unroll(RADIUS)]
|
||||||
for (int x = 1; x <= Radius; x++) {
|
for (int x = 1; x <= RADIUS; x++) {
|
||||||
const float xx = (float)x * d;
|
const float xx = (float)x * d;
|
||||||
const float yy = (float)y * d;
|
const float yy = (float)y * d;
|
||||||
total += value(i.uv, xx, yy) * Kernel[y][x-1];
|
total += value(i.uv, xx, yy) * Kernel[y][x-1];
|
||||||
|
@ -102,23 +100,11 @@
|
||||||
total += value(i.uv, yy, -xx) * Kernel[y][x-1];
|
total += value(i.uv, yy, -xx) * Kernel[y][x-1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// */
|
|
||||||
/*
|
|
||||||
float total_max = 0;
|
|
||||||
float total = 0;
|
|
||||||
for (int x = -Radius; x <= Radius; x++) {
|
|
||||||
for (int y = -Radius; y <= Radius; y++) {
|
|
||||||
float dist = sqrt(x*x+y*y);
|
|
||||||
float kval = kernel(dist);
|
|
||||||
total_max += kval;
|
|
||||||
total += value(i.uv, x*d, y*d) * kval;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// */
|
|
||||||
float old_state = value(i.uv, 0.0, 0.0) ;
|
float old_state = value(i.uv, 0.0, 0.0) ;
|
||||||
float count = total / total_max;
|
float count = total / total_max;
|
||||||
|
|
||||||
float state = activation(count) * _Speed + old_state;
|
const float step = _Speed * unity_DeltaTime.x;
|
||||||
|
float state = activation(count) * step + old_state;
|
||||||
state = clamp(state, 0, 1);
|
state = clamp(state, 0, 1);
|
||||||
|
|
||||||
// kernel visualization: lookup table (SLOW)
|
// kernel visualization: lookup table (SLOW)
|
||||||
|
@ -139,10 +125,10 @@
|
||||||
|
|
||||||
// kernel visualisation: real size
|
// kernel visualisation: real size
|
||||||
// float2 p = (i.uv - 0.5) * resolution;
|
// float2 p = (i.uv - 0.5) * resolution;
|
||||||
// float k = kernel(length(p)) * (max(abs(p.x), abs(p.y)) <= _Radius);
|
// float k = kernel(length(p)) * (max(abs(p.x), abs(p.y)) <= RADIUS);
|
||||||
|
|
||||||
// kernel visualisation: fill square
|
// kernel visualisation: fill square
|
||||||
// float k = kernel(length(i.uv - 0.5) * _Radius * 2);
|
// float k = kernel(length(i.uv - 0.5) * RADIUS * 2);
|
||||||
|
|
||||||
// float a = activation(i.uv.x);
|
// float a = activation(i.uv.x);
|
||||||
// float4 col = float4(state, k, a, 1);
|
// float4 col = float4(state, k, a, 1);
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
// generated by the rust program
|
// generated by the rust program
|
||||||
const int Radius = 20;
|
|
||||||
#define RADIUS 20
|
#define RADIUS 20
|
||||||
const half Kernel[21][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.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, },
|
||||||
|
|
|
@ -81,7 +81,7 @@ Material:
|
||||||
- _Radius: 13
|
- _Radius: 13
|
||||||
- _SmoothnessTextureChannel: 0
|
- _SmoothnessTextureChannel: 0
|
||||||
- _SpecularHighlights: 1
|
- _SpecularHighlights: 1
|
||||||
- _Speed: 0.1
|
- _Speed: 2
|
||||||
- _SrcBlend: 1
|
- _SrcBlend: 1
|
||||||
- _UVSec: 0
|
- _UVSec: 0
|
||||||
- _ZWrite: 1
|
- _ZWrite: 1
|
||||||
|
|
|
@ -23,13 +23,14 @@
|
||||||
{
|
{
|
||||||
float4 vertex : POSITION;
|
float4 vertex : POSITION;
|
||||||
float2 uv : TEXCOORD0;
|
float2 uv : TEXCOORD0;
|
||||||
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||||
};
|
};
|
||||||
|
|
||||||
struct v2f
|
struct v2f
|
||||||
{
|
{
|
||||||
float2 uv : TEXCOORD0;
|
float2 uv : TEXCOORD0;
|
||||||
|
|
||||||
float4 vertex : SV_POSITION;
|
float4 vertex : SV_POSITION;
|
||||||
|
UNITY_VERTEX_OUTPUT_STEREO
|
||||||
};
|
};
|
||||||
|
|
||||||
sampler2D _LastFrame;
|
sampler2D _LastFrame;
|
||||||
|
@ -38,9 +39,12 @@
|
||||||
v2f vert (appdata v)
|
v2f vert (appdata v)
|
||||||
{
|
{
|
||||||
v2f o;
|
v2f o;
|
||||||
|
UNITY_SETUP_INSTANCE_ID(v);
|
||||||
|
UNITY_INITIALIZE_OUTPUT(v2f, o);
|
||||||
|
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
||||||
|
|
||||||
o.vertex = UnityObjectToClipPos(v.vertex);
|
o.vertex = UnityObjectToClipPos(v.vertex);
|
||||||
o.uv = v.uv;
|
o.uv = v.uv;
|
||||||
|
|
||||||
return o;
|
return o;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,7 +90,7 @@
|
||||||
if (t > 0.9) {
|
if (t > 0.9) {
|
||||||
return float4(0, 0, 0, 1);
|
return float4(0, 0, 0, 1);
|
||||||
}
|
}
|
||||||
t = t + 0.02;
|
t += unity_DeltaTime.x * 4;
|
||||||
return float4(t, t, t, 1);
|
return float4(t, t, t, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,75 +1,81 @@
|
||||||
Shader "CrispyPin/gol"
|
Shader "CrispyPin/gol"
|
||||||
{
|
{
|
||||||
Properties
|
Properties
|
||||||
{
|
{
|
||||||
_LastFrame ("Texture", 2D) = "white" {}
|
_LastFrame ("Texture", 2D) = "white" {}
|
||||||
}
|
}
|
||||||
SubShader
|
SubShader
|
||||||
{
|
{
|
||||||
Tags { "RenderType"="Opaque" }
|
Tags { "RenderType"="Opaque" }
|
||||||
LOD 100
|
LOD 100
|
||||||
|
|
||||||
Pass
|
Pass
|
||||||
{
|
{
|
||||||
CGPROGRAM
|
CGPROGRAM
|
||||||
#pragma vertex vert
|
#pragma vertex vert
|
||||||
#pragma fragment frag
|
#pragma fragment frag
|
||||||
|
|
||||||
#include "UnityCG.cginc"
|
#include "UnityCG.cginc"
|
||||||
|
|
||||||
struct appdata
|
struct appdata
|
||||||
{
|
{
|
||||||
float4 vertex : POSITION;
|
float4 vertex : POSITION;
|
||||||
float2 uv : TEXCOORD0;
|
float2 uv : TEXCOORD0;
|
||||||
};
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||||
|
};
|
||||||
|
|
||||||
struct v2f
|
struct v2f
|
||||||
{
|
{
|
||||||
float2 uv : TEXCOORD0;
|
float2 uv : TEXCOORD0;
|
||||||
float4 vertex : SV_POSITION;
|
float4 vertex : SV_POSITION;
|
||||||
};
|
UNITY_VERTEX_OUTPUT_STEREO
|
||||||
|
};
|
||||||
|
|
||||||
sampler2D _LastFrame;
|
sampler2D _LastFrame;
|
||||||
|
|
||||||
v2f vert (appdata v)
|
v2f vert (appdata v)
|
||||||
{
|
{
|
||||||
v2f o;
|
v2f o;
|
||||||
o.vertex = UnityObjectToClipPos(v.vertex);
|
UNITY_SETUP_INSTANCE_ID(v);
|
||||||
o.uv = v.uv;
|
UNITY_INITIALIZE_OUTPUT(v2f, o);
|
||||||
return o;
|
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
||||||
}
|
|
||||||
|
|
||||||
int state(half2 uv, half x, half y){
|
o.vertex = UnityObjectToClipPos(v.vertex);
|
||||||
return tex2D(_LastFrame, uv + half2(x, y)).r > 0;
|
o.uv = v.uv;
|
||||||
}
|
return o;
|
||||||
|
}
|
||||||
|
|
||||||
fixed4 frag (v2f i) : SV_Target
|
int state(half2 uv, half x, half y){
|
||||||
{
|
return tex2D(_LastFrame, uv + half2(x, y)).r > 0;
|
||||||
const half d = 1.0/256.0;
|
}
|
||||||
|
|
||||||
int count = state(i.uv, -d, -d)+
|
fixed4 frag (v2f i) : SV_Target
|
||||||
state(i.uv, 0, -d)+
|
{
|
||||||
state(i.uv, d, -d)+
|
const half d = 1.0/256.0;
|
||||||
state(i.uv, -d, 0)+
|
|
||||||
state(i.uv, d, 0)+
|
|
||||||
state(i.uv, -d, d)+
|
|
||||||
state(i.uv, 0, d)+
|
|
||||||
state(i.uv, d, d);
|
|
||||||
half this = tex2D(_LastFrame, i.uv).r;
|
|
||||||
half state;
|
|
||||||
|
|
||||||
if (this.r > 0){
|
int count = state(i.uv, -d, -d)+
|
||||||
state = count > 1 && count < 4;
|
state(i.uv, 0, -d)+
|
||||||
// col = count > 0 && count < 6; // mazetric
|
state(i.uv, d, -d)+
|
||||||
}
|
state(i.uv, -d, 0)+
|
||||||
else {
|
state(i.uv, d, 0)+
|
||||||
state = count == 3;
|
state(i.uv, -d, d)+
|
||||||
}
|
state(i.uv, 0, d)+
|
||||||
|
state(i.uv, d, d);
|
||||||
|
half this = tex2D(_LastFrame, i.uv).r;
|
||||||
|
half state;
|
||||||
|
|
||||||
float4 col = float4(i.uv * state, 0.5 * state, 1);
|
if (this.r > 0){
|
||||||
return col;
|
state = count > 1 && count < 4;
|
||||||
}
|
// col = count > 0 && count < 6; // mazetric
|
||||||
ENDCG
|
}
|
||||||
}
|
else {
|
||||||
}
|
state = count == 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
float4 col = float4(i.uv * state, 0.5 * state, 1);
|
||||||
|
return col;
|
||||||
|
}
|
||||||
|
ENDCG
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,53 +1,58 @@
|
||||||
Shader "Custom/UnlitWithColor"
|
Shader "Custom/UnlitWithColor"
|
||||||
{
|
{
|
||||||
Properties
|
Properties
|
||||||
{
|
{
|
||||||
_Color ("Color", Color) = (1,1,1,1)
|
_Color ("Color", Color) = (1,1,1,1)
|
||||||
_MainTex ("Texture", 2D) = "white" {}
|
_MainTex ("Texture", 2D) = "white" {}
|
||||||
}
|
}
|
||||||
SubShader
|
SubShader
|
||||||
{
|
{
|
||||||
Tags { "RenderType" = "Opaque" }
|
Tags { "RenderType" = "Opaque" }
|
||||||
LOD 100
|
LOD 100
|
||||||
|
|
||||||
Pass
|
Pass
|
||||||
{
|
{
|
||||||
CGPROGRAM
|
CGPROGRAM
|
||||||
#pragma vertex vert
|
#pragma vertex vert
|
||||||
#pragma fragment frag
|
#pragma fragment frag
|
||||||
|
|
||||||
#include "UnityCG.cginc"
|
#include "UnityCG.cginc"
|
||||||
|
|
||||||
struct appdata
|
struct appdata
|
||||||
{
|
{
|
||||||
float4 vertex : POSITION;
|
float4 vertex : POSITION;
|
||||||
float2 uv : TEXCOORD0;
|
float2 uv : TEXCOORD0;
|
||||||
};
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||||
|
};
|
||||||
|
|
||||||
struct v2f
|
struct v2f
|
||||||
{
|
{
|
||||||
float2 uv : TEXCOORD0;
|
float2 uv : TEXCOORD0;
|
||||||
float4 vertex : SV_POSITION;
|
float4 vertex : SV_POSITION;
|
||||||
};
|
UNITY_VERTEX_OUTPUT_STEREO
|
||||||
|
};
|
||||||
|
|
||||||
sampler2D _MainTex;
|
sampler2D _MainTex;
|
||||||
float4 _MainTex_ST;
|
float4 _MainTex_ST;
|
||||||
fixed4 _Color;
|
fixed4 _Color;
|
||||||
|
|
||||||
v2f vert (appdata v)
|
v2f vert (appdata v)
|
||||||
{
|
{
|
||||||
v2f o;
|
v2f o;
|
||||||
o.vertex = UnityObjectToClipPos(v.vertex);
|
UNITY_SETUP_INSTANCE_ID(v);
|
||||||
o.uv = TRANSFORM_TEX(v.uv, _MainTex);
|
UNITY_INITIALIZE_OUTPUT(v2f, o);
|
||||||
return o;
|
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
||||||
}
|
|
||||||
|
|
||||||
fixed4 frag (v2f i) : SV_Target
|
o.vertex = UnityObjectToClipPos(v.vertex);
|
||||||
{
|
o.uv = TRANSFORM_TEX(v.uv, _MainTex);
|
||||||
fixed4 col = tex2D(_MainTex, i.uv);
|
return o;
|
||||||
return col * _Color;
|
}
|
||||||
}
|
|
||||||
ENDCG
|
fixed4 frag (v2f i) : SV_Target
|
||||||
}
|
{
|
||||||
}
|
return tex2D(_MainTex, i.uv) * _Color;
|
||||||
|
}
|
||||||
|
ENDCG
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,45 +1,51 @@
|
||||||
Shader "CrispyPin/uninit"
|
Shader "CrispyPin/uninit"
|
||||||
{
|
{
|
||||||
Properties
|
Properties
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
SubShader
|
SubShader
|
||||||
{
|
{
|
||||||
Tags { "RenderType"="Transparent" }
|
Tags { "RenderType"="Transparent" }
|
||||||
LOD 100
|
LOD 100
|
||||||
|
|
||||||
Pass
|
Pass
|
||||||
{
|
{
|
||||||
CGPROGRAM
|
CGPROGRAM
|
||||||
#pragma vertex vert
|
#pragma vertex vert
|
||||||
#pragma fragment frag
|
#pragma fragment frag
|
||||||
|
|
||||||
#include "UnityCG.cginc"
|
#include "UnityCG.cginc"
|
||||||
|
|
||||||
struct appdata
|
struct appdata
|
||||||
{
|
{
|
||||||
float4 vertex : POSITION;
|
float4 vertex : POSITION;
|
||||||
};
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||||
|
};
|
||||||
|
|
||||||
struct v2f
|
struct v2f
|
||||||
{
|
{
|
||||||
float4 vertex : SV_POSITION;
|
float4 vertex : SV_POSITION;
|
||||||
};
|
UNITY_VERTEX_OUTPUT_STEREO
|
||||||
|
};
|
||||||
|
|
||||||
v2f vert (appdata v)
|
v2f vert (appdata v)
|
||||||
{
|
{
|
||||||
v2f o;
|
v2f o;
|
||||||
o.vertex = UnityObjectToClipPos(v.vertex);
|
UNITY_SETUP_INSTANCE_ID(v);
|
||||||
return o;
|
UNITY_INITIALIZE_OUTPUT(v2f, o);
|
||||||
}
|
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
||||||
|
|
||||||
fixed4 frag (v2f i) : SV_Target
|
o.vertex = UnityObjectToClipPos(v.vertex);
|
||||||
{
|
return o;
|
||||||
fixed4 col;
|
}
|
||||||
col.a = 0.5f;
|
|
||||||
return col;
|
fixed4 frag (v2f i) : SV_Target
|
||||||
}
|
{
|
||||||
ENDCG
|
fixed4 col;
|
||||||
}
|
col.a = 0.5f;
|
||||||
}
|
return col;
|
||||||
|
}
|
||||||
|
ENDCG
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,6 @@ fn main() {
|
||||||
|
|
||||||
let mut total_max = 0.0;
|
let mut total_max = 0.0;
|
||||||
println!("// generated by the rust program");
|
println!("// generated by the rust program");
|
||||||
println!("const int Radius = {};", radius);
|
|
||||||
println!("#define RADIUS {}", radius);
|
println!("#define RADIUS {}", radius);
|
||||||
println!("const half Kernel[{}][{}] = {{", radius + 1, radius);
|
println!("const half Kernel[{}][{}] = {{", radius + 1, radius);
|
||||||
for y in 0..=radius {
|
for y in 0..=radius {
|
||||||
|
|
Loading…
Reference in a new issue