shader integers

This commit is contained in:
Crispy 2023-09-22 21:24:21 +02:00
parent 03e407c1eb
commit 039d6b2540
13 changed files with 17 additions and 18 deletions

View file

@ -4,7 +4,7 @@
{ {
[NoScaleOffset] [NoScaleOffset]
_LastFrame ("Render texture", 2D) = "white" {} _LastFrame ("Render texture", 2D) = "white" {}
_Rule("Rule", Int) = 110 _Rule("Rule", Integer) = 110
} }
SubShader SubShader
{ {
@ -48,7 +48,7 @@
{ {
const uint x = (p.x + dx) % WIDTH; const uint x = (p.x + dx) % WIDTH;
const uint y = (p.y + dy) % WIDTH; const uint y = (p.y + dy) % WIDTH;
return _LastFrame[uint2(x, y)].b > 0; return _LastFrame[uint2(x, y)].b > 0.1;
} }
float3 frag (v2f i) : SV_Target float3 frag (v2f i) : SV_Target
@ -60,13 +60,12 @@
return state(p, 0, 0); return state(p, 0, 0);
} }
int permutation = int permutation =
(state(p, -1, 1)<<2) | (state(p, -1, 1) << 2) |
(state(p, 0, 1)<<1) | (state(p, 0, 1) << 1) |
state(p, 1, 1); state(p, 1, 1);
float next = (_Rule >> permutation) & 1; float next = (_Rule >> permutation) & 1;
return float3(i.uv * next, next * (_SinTime.y * 0.4 + 0.6)); return float3(i.uv * next, next * (_SinTime.y * 0.4 + 0.6));
// return next;
} }
ENDCG ENDCG
} }

View file

@ -4,7 +4,7 @@
{ {
_LastFrame ("Texture", 2D) = "white" {} _LastFrame ("Texture", 2D) = "white" {}
[Toggle] [Toggle]
_Running ("Running", Int) = 0 _Running ("Running", Integer) = 0
} }
SubShader SubShader
{ {

View file

@ -3,7 +3,7 @@
Properties Properties
{ {
[Header(Raymarcher Properties)] [Header(Raymarcher Properties)]
_MaxSteps ("Max steps", Int) = 256 _MaxSteps ("Max steps", Integer) = 256
_MaxDist ("Max distance", Float) = 100 _MaxDist ("Max distance", Float) = 100
_SurfDist ("Surface distance threshold", Range(0.00001, 0.05)) = 0.001 _SurfDist ("Surface distance threshold", Range(0.00001, 0.05)) = 0.001
} }

View file

@ -3,7 +3,7 @@
Properties Properties
{ {
[Header(Raymarcher Properties)] [Header(Raymarcher Properties)]
_MaxSteps ("Max steps", Int) = 256 _MaxSteps ("Max steps", Integer) = 256
_MaxDist ("Max distance", Float) = 100 _MaxDist ("Max distance", Float) = 100
_SurfDist ("Surface distance threshold", Range(0.00001, 0.05)) = 0.001 _SurfDist ("Surface distance threshold", Range(0.00001, 0.05)) = 0.001
} }

View file

@ -6,7 +6,7 @@
_ObjectA ("Object A", Vector) = (0, 0, 0) _ObjectA ("Object A", Vector) = (0, 0, 0)
_ObjectB ("Object B", Vector) = (0, 0, 0) _ObjectB ("Object B", Vector) = (0, 0, 0)
[Header(Raymarcher Properties)] [Header(Raymarcher Properties)]
_MaxSteps ("Max steps", Int) = 256 _MaxSteps ("Max steps", Integer) = 256
_MaxDist ("Max distance", Float) = 100 _MaxDist ("Max distance", Float) = 100
_SurfDist ("Surface distance threshold", Range(0.00001, 0.05)) = 0.001 _SurfDist ("Surface distance threshold", Range(0.00001, 0.05)) = 0.001
} }

View file

@ -3,7 +3,7 @@
Properties Properties
{ {
[Header(Raymarcher Properties)] [Header(Raymarcher Properties)]
_MaxSteps ("Max steps", Int) = 128 _MaxSteps ("Max steps", Integer) = 128
_MaxDist ("Max distance", Float) = 128 _MaxDist ("Max distance", Float) = 128
_SurfDist ("Surface distance threshold", Range(0.0001, 0.05)) = 0.001 _SurfDist ("Surface distance threshold", Range(0.0001, 0.05)) = 0.001
[Header(Sky)] [Header(Sky)]

View file

@ -3,7 +3,7 @@ Shader "CrispyPin/Distortion"
Properties Properties
{ {
[Header(Raymarcher Properties)] [Header(Raymarcher Properties)]
_MaxSteps ("Max steps", Int) = 128 _MaxSteps ("Max steps", Integer) = 128
_MaxDist ("Max distance", Float) = 128 _MaxDist ("Max distance", Float) = 128
_SurfDist ("Surface distance threshold", Range(0.0001, 0.05)) = 0.001 _SurfDist ("Surface distance threshold", Range(0.0001, 0.05)) = 0.001

View file

@ -3,7 +3,7 @@ Shader "CrispyPin/Gyroid"
Properties Properties
{ {
[Header(Raymarcher Properties)] [Header(Raymarcher Properties)]
_MaxSteps ("Max steps", Int) = 128 _MaxSteps ("Max steps", Integer) = 128
_MaxDist ("Max distance", Float) = 128 _MaxDist ("Max distance", Float) = 128
_SurfDist ("Surface distance threshold", Range(0.0001, 0.05)) = 0.001 _SurfDist ("Surface distance threshold", Range(0.0001, 0.05)) = 0.001

View file

@ -3,7 +3,7 @@ Shader "CrispyPin/LibGarbageExample"
Properties Properties
{ {
[Header(Raymarcher Properties)] [Header(Raymarcher Properties)]
_MaxSteps ("Max steps", Int) = 128 _MaxSteps ("Max steps", Integer) = 128
_MaxDist ("Max distance", Float) = 128 _MaxDist ("Max distance", Float) = 128
_SurfDist ("Surface distance threshold", Range(0.0001, 0.05)) = 0.001 _SurfDist ("Surface distance threshold", Range(0.0001, 0.05)) = 0.001

View file

@ -3,7 +3,7 @@ Shader "CrispyPin/Nut"
Properties Properties
{ {
[Header(Raymarcher Properties)] [Header(Raymarcher Properties)]
_MaxSteps ("Max steps", Int) = 128 _MaxSteps ("Max steps", Integer) = 128
_MaxDist ("Max distance", Float) = 128 _MaxDist ("Max distance", Float) = 128
_SurfDist ("Surface distance threshold", Range(0.0001, 0.05)) = 0.001 _SurfDist ("Surface distance threshold", Range(0.0001, 0.05)) = 0.001
} }

View file

@ -3,7 +3,7 @@ Shader "CrispyPin/LibGarbageSpinny"
Properties Properties
{ {
[Header(Raymarcher Properties)] [Header(Raymarcher Properties)]
_MaxSteps ("Max steps", Int) = 128 _MaxSteps ("Max steps", Integer) = 128
_MaxDist ("Max distance", Float) = 128 _MaxDist ("Max distance", Float) = 128
_SurfDist ("Surface distance threshold", Range(0.0001, 0.05)) = 0.001 _SurfDist ("Surface distance threshold", Range(0.0001, 0.05)) = 0.001
} }

View file

@ -6,7 +6,7 @@
_SunPos ("Sun position", Vector) = (8, 4, 2) _SunPos ("Sun position", Vector) = (8, 4, 2)
[Header(Raymarcher Properties)] [Header(Raymarcher Properties)]
_MaxSteps ("Max steps", Int) = 256 _MaxSteps ("Max steps", Integer) = 256
_MaxDist ("Max distance", Float) = 256 _MaxDist ("Max distance", Float) = 256
_SurfDist ("Surface distance threshold", Range(0.00001, 0.05)) = 0.001 _SurfDist ("Surface distance threshold", Range(0.00001, 0.05)) = 0.001

View file

@ -6,7 +6,7 @@
_SunPos ("Sun position", Vector) = (8, 4, 2) _SunPos ("Sun position", Vector) = (8, 4, 2)
[Header(Raymarcher Properties)] [Header(Raymarcher Properties)]
_MaxSteps ("Max steps", Int) = 256 _MaxSteps ("Max steps", Integer) = 256
_MaxDist ("Max distance", Float) = 256 _MaxDist ("Max distance", Float) = 256
_SurfDist ("Surface distance threshold", Range(0.00001, 0.05)) = 0.001 _SurfDist ("Surface distance threshold", Range(0.00001, 0.05)) = 0.001