diff --git a/Assets/Materials/Background Material.mat b/Assets/Materials/Background Material.mat index 035dcfa..87f5f4b 100755 --- a/Assets/Materials/Background Material.mat +++ b/Assets/Materials/Background Material.mat @@ -66,18 +66,19 @@ Material: - _Glossiness: 0.5 - _GlossyReflections: 1 - _Metallic: 0 - - _MiddlePoint: 0.6 + - _MiddlePoint: 0.5 - _Mode: 0 - _OcclusionStrength: 1 - _Parallax: 0.02 - _Size: 100 + - _SmoothWidth: 0.0001 - _SmoothnessTextureChannel: 0 - _SpecularHighlights: 1 - _SrcBlend: 1 - _Step: 5 - _UVSec: 0 - _WaveScale: 100 - - _Width: 0.001 + - _Width: 0.0004 - _ZWrite: 1 m_Colors: - _Background: {r: 0.3, g: 0.3, b: 0.3, a: 1} diff --git a/Assets/Shaders/Gridshader.shader b/Assets/Shaders/Gridshader.shader index 6a7aa71..abd9421 100755 --- a/Assets/Shaders/Gridshader.shader +++ b/Assets/Shaders/Gridshader.shader @@ -2,7 +2,8 @@ { Properties { - _Width("Width", Range(0.0001,0.05)) = 0.001 + _Width("Width", Range(0.00001,0.05)) = 0.001 + _SmoothWidth("Smooth Width", Range(0.00001,0.05)) = 0.0002 _Size("Object Size", Range(0.01,1000)) = 100 _MiddlePoint("Middle Point", Range(0, 1)) = 0.6 _Background("Background Color", Color) = (.2, .2, .2, 1) @@ -40,6 +41,14 @@ sampler2D _MainTex; + float _Width; + float _SmoothWidth; + float _Size; + float4 _Background; + float _MiddlePoint; + float4 _Foreground; + int _Step; + v2f vert(appdata v) { v2f o; @@ -49,37 +58,36 @@ return o; } - float _Width; - float _Size; - float4 _Background; - float _MiddlePoint; - float4 _Foreground; - int _Step; + float grid(float2 uv, float w, float s) + { + return clamp(1 + - smoothstep(w - _SmoothWidth, w + _SmoothWidth, fmod(uv.x + w * .5, s)) + 1 + - smoothstep(w - _SmoothWidth, w + _SmoothWidth, fmod(uv.y + w * .5, s)), 0, 1); + } float4 frag(v2f i) : SV_Target { float d = length(ObjSpaceViewDir(i.scrPos)); float w = d * _Width; - i.uv *= _Size; - float k = log(d) / log(_Step); + float k = log(d) / log(_Step); float k0 = floor(k); float x = d / pow(_Step, k0); float s1 = pow(_Step, k0) * .1 / _Step; - float c1 = clamp(_MiddlePoint * (_Step - x) / (_Step - 1), 0, 1); + float c1 = smoothstep(0, 1, _MiddlePoint * (_Step - x) / (_Step - 1)); float s2 = s1 * _Step; - float c2 = clamp((1 - _MiddlePoint) * (_Step - x) / (_Step - 1) + _MiddlePoint, 0, 1); + float c2 = smoothstep(0, 1, (1 - _MiddlePoint) * (_Step - x) / (_Step - 1) + _MiddlePoint); float s3 = s2 * _Step; - - float2 uv = i.uv; - float grid1 = clamp(1 - step(w, fmod(uv.x + w * .5, s1)) + 1 - step(w, fmod(uv.y + w * .5, s1)), 0, 1); - float grid2 = clamp(1 - step(w, fmod(uv.x + w * .5, s2)) + 1 - step(w, fmod(uv.y + w * .5, s2)), 0, 1); - float grid3 = clamp(1 - step(w, fmod(uv.x + w * .5, s3)) + 1 - step(w, fmod(uv.y + w * .5, s3)), 0, 1); + i.uv *= _Size; + + float grid1 = grid(i.uv, w, s1); + float grid2 = grid(i.uv, w, s2); + float grid3 = grid(i.uv, w, s3); grid2 = clamp(grid2 - grid3, 0, 1); grid1 = clamp(grid1 - grid2, 0, 1); diff --git a/TODO.txt b/TODO.txt new file mode 100755 index 0000000..ee34f91 --- /dev/null +++ b/TODO.txt @@ -0,0 +1,12 @@ +TODO +-(0) mux/demux +-(0) gates into game objects +-(1) snap to grid +-(1) button gates +-(2) named anchors +-(3) overlay to drag &drop new gates +-(3) same but to destroy gates +-(3) generic rect gates +-(3) state gates +-(5) cable management +-(5) buses \ No newline at end of file