diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..e27e04c Binary files /dev/null and b/.DS_Store differ diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..2ef45bb --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2017 Yuri Roubinski aka Chaosus + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/Node.tscn b/Node.tscn index a821827..b9e8c58 100644 --- a/Node.tscn +++ b/Node.tscn @@ -41,9 +41,6 @@ margin_right = -10.0 margin_bottom = -10.0 follow_focus = true scroll_horizontal_enabled = false -__meta__ = { -"_edit_use_anchors_": false -} [node name="ChatMessagesContainer" type="VBoxContainer" parent="ChatContainer/Chat/ScrollContainer"] margin_right = 1900.0 diff --git a/README.md b/README.md new file mode 100644 index 0000000..c2f1cba --- /dev/null +++ b/README.md @@ -0,0 +1,30 @@ +# GDFractals +Fractal shaders for Godot 3.0 + +# Contains +* Julia fractal shader +* Mandelbrot fractal shader +* Sierpinski carpet shader + +# How to setup +* Create ColorRect and lay ShaderMaterial on it +* Drag&drop the required shader to ShaderMaterial slot +* Create gradient texture, if you dont want to create it yourself use fire_gradient.tres +* Set parameters on material: + +# for Julia: +* Gradient - gradient texture +* Scale = 4, 4 +* Offset = 0, 0 +* MaxIter = from 100 to 1000 +* Speed = 1 + +# for Mandelbrot: +* Gradient - gradient texture +* Scale = 1, 1 +* Offset = 0, 0 +* MaxIter = from 100 to 1000 + +# for Serpinski carpet: +* Scale = 81, 81 +* Offset = 0, 0 diff --git a/assets/.DS_Store b/assets/.DS_Store new file mode 100644 index 0000000..0533a0f Binary files /dev/null and b/assets/.DS_Store differ diff --git a/assets/cecep-s-handwriting-2-font/CecepsHandwriting-vmpKZ.ttf b/assets/cecep-s-handwriting-2-font/CecepsHandwriting-vmpKZ.ttf new file mode 100644 index 0000000..76185b1 Binary files /dev/null and b/assets/cecep-s-handwriting-2-font/CecepsHandwriting-vmpKZ.ttf differ diff --git a/assets/cecep-s-handwriting-2-font/info.txt b/assets/cecep-s-handwriting-2-font/info.txt new file mode 100644 index 0000000..de44e52 --- /dev/null +++ b/assets/cecep-s-handwriting-2-font/info.txt @@ -0,0 +1,2 @@ +license: Freeware +link: https://www.fontspace.com/cecep-s-handwriting-2-font-f72804 \ No newline at end of file diff --git a/assets/fractal-shaders/fire_gradient.tres b/assets/fractal-shaders/fire_gradient.tres new file mode 100644 index 0000000..b7d9b24 --- /dev/null +++ b/assets/fractal-shaders/fire_gradient.tres @@ -0,0 +1,7 @@ +[gd_resource type="Gradient" format=2] + +[resource] + +offsets = PoolRealArray( 0, 0.159763, 0.343195, 0.508876, 0.662722, 0.83432, 1 ) +colors = PoolColorArray( 0, 0, 0, 1, 1, 0, 0, 1, 1, 0.820312, 0, 1, 1, 1, 1, 1, 1, 0.914062, 0, 1, 1, 0, 0, 1, 0, 0, 0, 1 ) + diff --git a/assets/fractal-shaders/julia.shader b/assets/fractal-shaders/julia.shader new file mode 100644 index 0000000..e9157c0 Binary files /dev/null and b/assets/fractal-shaders/julia.shader differ diff --git a/assets/fractal-shaders/julia.shd b/assets/fractal-shaders/julia.shd new file mode 100644 index 0000000..e9157c0 Binary files /dev/null and b/assets/fractal-shaders/julia.shd differ diff --git a/assets/fractal-shaders/mandelbrot.shd b/assets/fractal-shaders/mandelbrot.shd new file mode 100644 index 0000000..76df336 Binary files /dev/null and b/assets/fractal-shaders/mandelbrot.shd differ diff --git a/assets/fractal-shaders/sierpinski_carpet.shd b/assets/fractal-shaders/sierpinski_carpet.shd new file mode 100644 index 0000000..cf1c327 Binary files /dev/null and b/assets/fractal-shaders/sierpinski_carpet.shd differ diff --git a/export/.gitignore b/export/.gitignore new file mode 100644 index 0000000..72e8ffc --- /dev/null +++ b/export/.gitignore @@ -0,0 +1 @@ +* diff --git a/export_presets.cfg b/export_presets.cfg index 7e85c2b..0a0b206 100644 --- a/export_presets.cfg +++ b/export_presets.cfg @@ -7,18 +7,61 @@ custom_features="" export_filter="all_resources" include_filter="" exclude_filter="" -export_path="/home/mennomax/Documents/godot/GIFT.x86_64" -patch_list=PoolStringArray( ) +export_path="../../../../../home/mennomax/Documents/godot/GIFT.x86_64" script_export_mode=1 script_encryption_key="" [preset.0.options] +custom_template/debug="" +custom_template/release="" +binary_format/64_bits=true +binary_format/embed_pck=false texture_format/bptc=false texture_format/s3tc=true texture_format/etc=false texture_format/etc2=false texture_format/no_bptc_fallbacks=true -binary_format/64_bits=true -custom_template/release="" + +[preset.1] + +name="Windows Desktop" +platform="Windows Desktop" +runnable=true +custom_features="" +export_filter="all_resources" +include_filter="" +exclude_filter="" +export_path="" +script_export_mode=1 +script_encryption_key="" + +[preset.1.options] + custom_template/debug="" +custom_template/release="" +binary_format/64_bits=true +binary_format/embed_pck=false +texture_format/bptc=false +texture_format/s3tc=true +texture_format/etc=false +texture_format/etc2=false +texture_format/no_bptc_fallbacks=true +codesign/enable=false +codesign/identity_type=0 +codesign/identity="" +codesign/password="" +codesign/timestamp=true +codesign/timestamp_server_url="" +codesign/digest_algorithm=1 +codesign/description="" +codesign/custom_options=PoolStringArray( ) +application/modify_resources=true +application/icon="" +application/file_version="" +application/product_version="" +application/company_name="" +application/product_name="" +application/file_description="" +application/copyright="" +application/trademarks="" diff --git a/scenes/2DOverlay.gd b/scenes/2DOverlay.gd new file mode 100644 index 0000000..d144d48 --- /dev/null +++ b/scenes/2DOverlay.gd @@ -0,0 +1,16 @@ +extends Node2D + + +# Declare member variables here. Examples: +# var a = 2 +# var b = "text" + + +# Called when the node enters the scene tree for the first time. +func _ready(): + pass # Replace with function body. + + +# Called every frame. 'delta' is the elapsed time since the previous frame. +#func _process(delta): +# pass diff --git a/scenes/2DOverlay.tscn b/scenes/2DOverlay.tscn index dab4bf6..4f5aefc 100644 --- a/scenes/2DOverlay.tscn +++ b/scenes/2DOverlay.tscn @@ -1,24 +1,284 @@ -[gd_scene load_steps=3 format=2] +[gd_scene load_steps=13 format=2] [ext_resource path="res://Node.tscn" type="PackedScene" id=1] -[ext_resource path="res://addons/gift/gift_node.gd" type="Script" id=2] +[ext_resource path="res://scenes/2DOverlay.gd" type="Script" id=2] +[ext_resource path="res://scenes/Overlay Text.tres" type="Theme" id=3] +[ext_resource path="res://sprites/Mara.png" type="Texture" id=4] +[ext_resource path="res://scenes/GlitchyTexture.tres" type="Material" id=5] + +[sub_resource type="Shader" id=8] +code = "shader_type canvas_item; + +uniform float battery : hint_range(0.0,1.0) = 1.0; +uniform float anchor : hint_range(-1.0,1.0) = -0.5; +uniform float speed_scale : hint_range(1.0, 10.0) = 1.0; +uniform float fov : hint_range(0.01, 1.0) = 0.2; +uniform vec4 background_color : hint_color = vec4(0.0, 0.1, 0.2, 1.0); +uniform vec4 grid_color : hint_color = vec4(1.0, 0.5, 1.0, 1.0); + +float grid(vec2 uv, float batt) { + vec2 size = vec2(uv.y, uv.y * uv.y * 0.2) * 0.01; + uv += vec2(0.0, TIME * speed_scale * (batt + 0.05)); + uv = abs(fract(uv) - 0.5); + vec2 lines = smoothstep(size, vec2(0.0), uv); + lines += smoothstep(size * 5.0, vec2(0.0), uv) * 0.4 * batt; + return clamp(lines.x + lines.y, 0.0, 3.0); +} + +void fragment() { + vec2 uv = UV; + vec4 col = background_color; + uv.y = 3.0 / (abs(uv.y + fov) + 0.05); + uv.x += anchor; + uv.x *= uv.y * 1.0; + float gridVal = grid(uv, battery); + col = mix(background_color, grid_color, gridVal); + COLOR = col; +}" + +[sub_resource type="ShaderMaterial" id=9] +shader = SubResource( 8 ) +shader_param/battery = 1.0 +shader_param/anchor = -0.5 +shader_param/speed_scale = 1.0 +shader_param/fov = 0.2 +shader_param/background_color = Color( 0, 0.1, 0.2, 1 ) +shader_param/grid_color = Color( 1, 0.5, 1, 1 ) + +[sub_resource type="Shader" id=10] +code = "// cloudy skies shader +// inspired from shadertoy shader made by Drift (https://www.shadertoy.com/view/4tdSWr) + +shader_type canvas_item; + +uniform float cloudscale = 1.1; +uniform float speed = 0.01; +uniform float clouddark = 0.5; +uniform float cloudlight = 0.3; +uniform float cloudcover = 0.2; +uniform float cloudalpha = 8.0; +uniform float skytint = 0.5; +uniform vec3 skycolour1 = vec3(0.2, 0.4, 0.6); +uniform vec3 skycolour2 = vec3(0.4, 0.7, 1.0); +uniform mat2 m = mat2(vec2(1.6,1.2),vec2(-1.2,1.6)); // changement + +// functions + +vec2 hash( vec2 p ) { + p = vec2(dot(p,vec2(127.1,311.7)), dot(p,vec2(269.5,183.3))); + return -1.0 + 2.0*fract(sin(p)*43758.5453123); +} + +float noise( in vec2 p ) { + float K1 = 0.366025404; // (sqrt(3)-1)/2; + float K2 = 0.211324865; // (3-sqrt(3))/6; + vec2 i = floor(p + (p.x+p.y)*K1); + vec2 a = p - i + (i.x+i.y)*K2; + vec2 o = (a.x>a.y) ? vec2(1.0,0.0) : vec2(0.0,1.0); //vec2 of = 0.5 + 0.5*vec2(sign(a.x-a.y), sign(a.y-a.x)); + vec2 b = a - o + K2; + vec2 c = a - 1.0 + 2.0*K2; + vec3 h = max(0.5-vec3(dot(a,a), dot(b,b), dot(c,c) ), 0.0 ); + vec3 n = h*h*h*h*vec3( dot(a,hash(i+0.0)), dot(b,hash(i+o)), dot(c,hash(i+1.0))); + return dot(n, vec3(70.0)); +} + +float fbm(vec2 n) { + float total = 0.0, amplitude = 0.1; + for (int i = 0; i < 7; i++) { + total += noise(n) * amplitude; + n = m * n; + amplitude *= 0.4; + } + return total; +} + +// fragment shader + +void fragment() { +vec2 res = 1.0 / SCREEN_PIXEL_SIZE; +vec2 p = FRAGCOORD.xy / res.xy; // changement + vec2 uv = p*vec2(res.x/res.y,1.0); // changement + float time = TIME * speed ; + float q = fbm(uv * cloudscale * 0.5); + + //ridged noise shape + float r = 0.0; + uv *= cloudscale; + uv += q - time; + float weight = 0.8; + for (int i=0; i<8; i++){ + r += abs(weight*noise( uv )); + uv = m*uv + time; + weight *= 0.7; + } + + //noise shape + float f = 0.0; + uv = p*vec2(res.x/res.y,1.0); // changement + uv *= cloudscale; + uv += q - time; + weight = 0.7; + for (int i=0; i<8; i++){ + f += weight*noise( uv ); + uv = m*uv + time; + weight *= 0.6; + } + + f *= r + f; + + //noise colour + float c = 0.0; + time = TIME * speed * 2.0; + uv = p*vec2(res.x/res.y,1.0); // changement + uv *= cloudscale*2.0; + uv += q - time; + weight = 0.4; + for (int i=0; i<7; i++){ + c += weight*noise( uv ); + uv = m*uv + time; + weight *= 0.6; + } + + //noise ridge colour + float c1 = 0.0; + time = TIME * speed * 3.0; + uv = p*vec2(res.x/res.y,1.0); + uv *= cloudscale*3.0; + uv += q - time; + weight = 0.4; + for (int i=0; i<7; i++){ + c1 += abs(weight*noise( uv )); + uv = m*uv + time; + weight *= 0.6; + } + + c += c1; + + vec3 skycolour = mix(skycolour2, skycolour1, p.y); + vec3 cloudcolour = vec3(1.1, 1.1, 0.9) * clamp((clouddark + cloudlight*c), 0.0, 1.0); + + f = cloudcover + cloudalpha*f*r; + + vec3 result = mix(skycolour, clamp(skytint * skycolour + cloudcolour, 0.0, 1.0), clamp(f + c, 0.0, 1.0)); + + COLOR.rgb = vec3(result); +} +" + +[sub_resource type="ShaderMaterial" id=11] +shader = SubResource( 10 ) +shader_param/cloudscale = 1.1 +shader_param/speed = 0.01 +shader_param/clouddark = 0.5 +shader_param/cloudlight = 0.3 +shader_param/cloudcover = 0.15 +shader_param/cloudalpha = 2.0 +shader_param/skytint = 1.0 +shader_param/skycolour1 = Vector3( 0.2, 0.4, 0.6 ) +shader_param/skycolour2 = Vector3( 0.4, 0.7, 1 ) +shader_param/m = Transform2D( 1.6, -1.2, 1.2, 1.6, 0, 0 ) + +[sub_resource type="AtlasTexture" id=4] +atlas = ExtResource( 4 ) +region = Rect2( 0, 0, 16, 16 ) + +[sub_resource type="AtlasTexture" id=5] +atlas = ExtResource( 4 ) +region = Rect2( 16, 0, 16, 16 ) + +[sub_resource type="SpriteFrames" id=3] +animations = [ { +"frames": [ SubResource( 4 ), SubResource( 5 ) ], +"loop": true, +"name": "down", +"speed": 1.0 +} ] [node name="Overlay" type="Node2D"] script = ExtResource( 2 ) -[node name="Bluescreen" type="ColorRect" parent="."] +[node name="Panel" type="Panel" parent="."] +material = SubResource( 9 ) margin_right = 1920.0 -margin_bottom = 1080.0 -color = Color( 0, 0, 1, 1 ) +margin_bottom = 1079.0 -[node name="Node" parent="." instance=ExtResource( 1 )] -margin_left = 1284.0 -margin_right = 1601.0 +[node name="Panel2" type="Panel" parent="."] +modulate = Color( 1, 1, 1, 0.376471 ) +material = SubResource( 11 ) +margin_right = 1920.0 +margin_bottom = 1079.0 + +[node name="Chatbox" parent="." instance=ExtResource( 1 )] +margin_left = 1278.0 +margin_right = 1599.0 margin_bottom = 259.0 rect_scale = Vector2( 2, 2 ) +[node name="Facecam" type="ColorRect" parent="."] +visible = false +margin_left = 1280.0 +margin_top = 518.0 +margin_right = 1920.0 +margin_bottom = 1079.0 +color = Color( 0, 1, 0.835294, 1 ) + [node name="Screen" type="ColorRect" parent="."] margin_right = 1280.0 margin_bottom = 720.0 rect_min_size = Vector2( 720, 0 ) -color = Color( 1, 0, 0, 1 ) +color = Color( 0, 0, 1, 1 ) + +[node name="HBoxContainer" type="HBoxContainer" parent="."] +margin_left = 18.0 +margin_top = 720.0 +margin_right = 1281.0 +margin_bottom = 1080.0 +rect_min_size = Vector2( 720, 0 ) + +[node name="VBoxContainer2" type="VBoxContainer" parent="HBoxContainer"] +visible = false +margin_bottom = 360.0 + +[node name="ColorRect" type="ColorRect" parent="HBoxContainer/VBoxContainer2"] +margin_right = 340.0 +margin_bottom = 360.0 + +[node name="VBoxContainer" type="VBoxContainer" parent="HBoxContainer"] +margin_right = 316.0 +margin_bottom = 360.0 + +[node name="Stream" type="Label" parent="HBoxContainer/VBoxContainer"] +margin_right = 316.0 +margin_bottom = 39.0 +theme = ExtResource( 3 ) +text = "twitch: princessxen" + +[node name="Twitter" type="Label" parent="HBoxContainer/VBoxContainer"] +margin_top = 43.0 +margin_right = 316.0 +margin_bottom = 82.0 +theme = ExtResource( 3 ) +text = "twitter: @theprincessxena" + +[node name="Website" type="Label" parent="HBoxContainer/VBoxContainer"] +margin_top = 86.0 +margin_right = 316.0 +margin_bottom = 125.0 +theme = ExtResource( 3 ) +text = "https://xeiaso.net" + +[node name="Patrone" type="Label" parent="HBoxContainer/VBoxContainer"] +margin_top = 129.0 +margin_right = 316.0 +margin_bottom = 168.0 +theme = ExtResource( 3 ) +text = "https://patreon.com/cadey" + +[node name="Mara" type="AnimatedSprite" parent="HBoxContainer/VBoxContainer"] +material = ExtResource( 5 ) +position = Vector2( 165, 263 ) +scale = Vector2( 10, 10 ) +frames = SubResource( 3 ) +animation = "down" +frame = 1 +playing = true diff --git a/scenes/GlitchyTexture.tres b/scenes/GlitchyTexture.tres new file mode 100644 index 0000000..464d438 --- /dev/null +++ b/scenes/GlitchyTexture.tres @@ -0,0 +1,42 @@ +[gd_resource type="ShaderMaterial" load_steps=2 format=2] + +[sub_resource type="Shader" id=8] +code = "shader_type canvas_item; + +uniform vec2 resolution = vec2(64.0, 64.0); +uniform float noise : hint_range(0.0, 1.0) = 0.2; +uniform float distort : hint_range(0.0, 1.0) = 0.06; +uniform float offset : hint_range(0.0, 1.0) = 0.0; + +vec2 random(vec2 uv){ + uv = vec2(dot(uv, vec2(127.1,311.7)), dot(uv, vec2(269.5,183.3))); + return -1.0 + 2.0 * fract(sin(uv) * 43758.5453123); +} + +float between(float lower, float upper, float value) { + return step(lower, value) * step(value, upper); +} + +void fragment() +{ + vec2 uv = UV; + // Distort + float oy = offset / 10.; + float dist = distort * clamp(offset / 2., 0.25, 0.75); + uv.x += dist * between(0.7, 0.8, fract(offset + TIME/4.)) * between(0.4, 0.41 + oy, uv.y); + uv.x -= dist * between(0.1, 0.15, fract(offset + TIME/3.)) * between(0.7, 0.71 + oy, uv.y); + uv.x += dist * between(0.15, 0.25, fract(offset + TIME/3.)) * between(0.6, 0.61 + oy, uv.y); + uv.x += dist * between(0.5, 0.55, fract(offset + TIME/7.)) * between(0.5, 0.73 - oy, uv.y); + // Add noise + vec4 pxl = texture(TEXTURE, uv); + pxl.rgb += clamp(random((ceil(UV * resolution) / resolution) + trunc(fract(TIME) * 4.)).x, 0.0, 1.0) * noise; + // Shade + COLOR = pxl; +}" + +[resource] +shader = SubResource( 8 ) +shader_param/resolution = Vector2( 64, 64 ) +shader_param/noise = 0.2 +shader_param/distort = 0.06 +shader_param/offset = 0.0 diff --git a/scenes/Overlay Text.tres b/scenes/Overlay Text.tres new file mode 100644 index 0000000..8142520 --- /dev/null +++ b/scenes/Overlay Text.tres @@ -0,0 +1,14 @@ +[gd_resource type="Theme" load_steps=3 format=2] + +[ext_resource path="res://assets/cecep-s-handwriting-2-font/CecepsHandwriting-vmpKZ.ttf" type="DynamicFontData" id=1] + +[sub_resource type="DynamicFont" id=1] +size = 32 +outline_size = 4 +outline_color = Color( 0, 0, 0, 1 ) +extra_spacing_top = 2 +extra_spacing_bottom = 2 +font_data = ExtResource( 1 ) + +[resource] +default_font = SubResource( 1 ) diff --git a/sprites/Mara.png b/sprites/Mara.png new file mode 100644 index 0000000..3d322ed Binary files /dev/null and b/sprites/Mara.png differ diff --git a/sprites/Mara.png.import b/sprites/Mara.png.import new file mode 100644 index 0000000..27ed49b --- /dev/null +++ b/sprites/Mara.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/Mara.png-cfb9930f0e893d4ce21d71224438979f.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://sprites/Mara.png" +dest_files=[ "res://.import/Mara.png-cfb9930f0e893d4ce21d71224438979f.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=false +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +process/normal_map_invert_y=false +stream=false +size_limit=0 +detect_3d=false +svg/scale=1.0