From 27727fdde50cac8a1ce72a73dd4b3e646ded5e03 Mon Sep 17 00:00:00 2001 From: Devin Pentecost Date: Sat, 4 May 2019 23:50:24 -0700 Subject: [PATCH] Adding OpenSimplexNoise Viewer demo --- .../OpenSimplexNoise_Viewer.gd | 92 +++++++++++++ .../OpenSimplexNoise_Viewer.shader | 21 +++ .../OpenSimplexNoise_Viewer.tres | 8 ++ .../OpenSimplexNoise_Viewer.tscn | 125 ++++++++++++++++++ misc/opensimplexnoise/icon.png | Bin 0 -> 5437 bytes misc/opensimplexnoise/icon.png.import | 34 +++++ misc/opensimplexnoise/project.godot | 27 ++++ 7 files changed, 307 insertions(+) create mode 100644 misc/opensimplexnoise/OpenSimplexNoise_Viewer.gd create mode 100644 misc/opensimplexnoise/OpenSimplexNoise_Viewer.shader create mode 100644 misc/opensimplexnoise/OpenSimplexNoise_Viewer.tres create mode 100644 misc/opensimplexnoise/OpenSimplexNoise_Viewer.tscn create mode 100644 misc/opensimplexnoise/icon.png create mode 100644 misc/opensimplexnoise/icon.png.import create mode 100644 misc/opensimplexnoise/project.godot diff --git a/misc/opensimplexnoise/OpenSimplexNoise_Viewer.gd b/misc/opensimplexnoise/OpenSimplexNoise_Viewer.gd new file mode 100644 index 00000000..02a34518 --- /dev/null +++ b/misc/opensimplexnoise/OpenSimplexNoise_Viewer.gd @@ -0,0 +1,92 @@ +extends Control + +var noise = OpenSimplexNoise.new() + +var noise_size = 500 +var min_noise = -1 +var max_noise = 1 + +# Called when the node enters the scene tree for the first time. +func _ready(): + + #Set up noise with basic info + $ParameterContainer/SeedSpinBox.value = noise.seed + $ParameterContainer/LacunaritySpinBox.value = noise.lacunarity + $ParameterContainer/OctavesSpinBox.value = noise.octaves + $ParameterContainer/PeriodSpinBox.value = noise.period + $ParameterContainer/PersistenceSpinBox.value = noise.persistence + + #Render the noise + _refresh_noise_images() + + +func _refresh_noise_images(): + + #Get a new image + var image = noise.get_seamless_image(500) + var image_texture = ImageTexture.new() + + #Adjust min/max for shader + var _min = ((min_noise + 1)/2) + var _max = ((max_noise + 1)/2) + var _material = $SeamlessNoiseTexture.material + _material.set_shader_param("min_value", _min) + _material.set_shader_param("max_value", _max) + + #Draw it + image_texture.create_from_image(image) + $SeamlessNoiseTexture.texture = image_texture + + +func _on_DocumentationButton_pressed(): + OS.shell_open("https://docs.godotengine.org/en/latest/classes/class_opensimplexnoise.html") + + +func _on_SeedSpinBox_value_changed(value): + + #Update the noise seed + noise.seed = value + _refresh_noise_images() + + +func _on_LacunaritySpinBox_value_changed(value): + + #Update noise + noise.lacunarity = value + _refresh_noise_images() + + +func _on_OctavesSpinBox_value_changed(value): + + #Update noise + noise.octaves = value + _refresh_noise_images() + + +func _on_PeriodSpinBox_value_changed(value): + + #Update noise + noise.period = value + _refresh_noise_images() + + +func _on_PersistenceSpinBox_value_changed(value): + + #Update noise + noise.persistence = value + _refresh_noise_images() + + +func _on_MinClipSpinBox_value_changed(value): + + #Just refresh + min_noise = value + _refresh_noise_images() + + +func _on_MaxClipSpinBox_value_changed(value): + + #Just refresh + max_noise = value + _refresh_noise_images() + diff --git a/misc/opensimplexnoise/OpenSimplexNoise_Viewer.shader b/misc/opensimplexnoise/OpenSimplexNoise_Viewer.shader new file mode 100644 index 00000000..bf141b47 --- /dev/null +++ b/misc/opensimplexnoise/OpenSimplexNoise_Viewer.shader @@ -0,0 +1,21 @@ +shader_type canvas_item; + +uniform float min_value = -1; +uniform float max_value = 1; + +void fragment() { + + //Get the color + vec4 color = texture(TEXTURE, UV); + + //Compare the value + float gray = color.x; + if (gray < min_value){ + color = vec4(0, 0, 0, 1); + }else if (gray > max_value) { + color = vec4(1, 1, 1, 1); + } + + //Write back the color + COLOR = color; +} \ No newline at end of file diff --git a/misc/opensimplexnoise/OpenSimplexNoise_Viewer.tres b/misc/opensimplexnoise/OpenSimplexNoise_Viewer.tres new file mode 100644 index 00000000..8cb3e14d --- /dev/null +++ b/misc/opensimplexnoise/OpenSimplexNoise_Viewer.tres @@ -0,0 +1,8 @@ +[gd_resource type="ShaderMaterial" load_steps=2 format=2] + +[ext_resource path="res://OpenSimplexNoise_Viewer.shader" type="Shader" id=1] + +[resource] +shader = ExtResource( 1 ) +shader_param/min_value = -1.0 +shader_param/max_value = 1.0 diff --git a/misc/opensimplexnoise/OpenSimplexNoise_Viewer.tscn b/misc/opensimplexnoise/OpenSimplexNoise_Viewer.tscn new file mode 100644 index 00000000..a77aef39 --- /dev/null +++ b/misc/opensimplexnoise/OpenSimplexNoise_Viewer.tscn @@ -0,0 +1,125 @@ +[gd_scene load_steps=3 format=2] + +[ext_resource path="res://OpenSimplexNoise_Viewer.gd" type="Script" id=1] +[ext_resource path="res://OpenSimplexNoise_Viewer.tres" type="Material" id=2] + +[node name="OpenSimplexNoise Viewer" type="Control"] +anchor_right = 1.0 +anchor_bottom = 1.0 +margin_left = 8.42108 +margin_top = -5.26315 +margin_right = 8.42114 +margin_bottom = -5.26318 +script = ExtResource( 1 ) + +[node name="DocumentationButton" type="Button" parent="."] +anchor_left = 1.0 +anchor_right = 1.0 +margin_top = 20.0 +margin_right = -20.0 +grow_horizontal = 0 +text = "API Documentation" + +[node name="SeamlessNoiseTexture" type="TextureRect" parent="."] +material = ExtResource( 2 ) +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +margin_left = 30.0 +margin_top = -20.0 +margin_right = 70.0 +margin_bottom = 20.0 +grow_horizontal = 2 +grow_vertical = 2 + +[node name="ParameterContainer" type="VBoxContainer" parent="."] +editor/display_folded = true +margin_left = 20.0 +margin_top = 20.0 +margin_right = 300.0 +margin_bottom = 40.0 + +[node name="SeedSpinBox" type="SpinBox" parent="ParameterContainer"] +margin_right = 280.0 +margin_bottom = 24.0 +min_value = -1.53049e+009 +max_value = 1.53049e+009 +rounded = true +allow_greater = true +allow_lesser = true +prefix = "Seed:" + +[node name="LacunaritySpinBox" type="SpinBox" parent="ParameterContainer"] +margin_top = 28.0 +margin_right = 280.0 +margin_bottom = 52.0 +max_value = 1e+008 +step = 0.01 +allow_greater = true +prefix = "Lacunarity:" + +[node name="PeriodSpinBox" type="SpinBox" parent="ParameterContainer"] +margin_top = 56.0 +margin_right = 280.0 +margin_bottom = 80.0 +min_value = -1e+008 +max_value = 1e+008 +step = 0.01 +allow_greater = true +prefix = "Period:" + +[node name="PersistenceSpinBox" type="SpinBox" parent="ParameterContainer"] +margin_top = 84.0 +margin_right = 280.0 +margin_bottom = 108.0 +max_value = 1e+008 +step = 0.01 +allow_greater = true +prefix = "Persistance:" + +[node name="OctavesSpinBox" type="SpinBox" parent="ParameterContainer"] +margin_top = 112.0 +margin_right = 280.0 +margin_bottom = 136.0 +min_value = 1.0 +max_value = 10.0 +value = 1.0 +allow_greater = true +prefix = "Octaves:" + +[node name="ClipContainer" type="VBoxContainer" parent="."] +anchor_top = 1.0 +anchor_bottom = 1.0 +margin_left = 20.0 +margin_top = -72.0 +margin_right = 300.0 +margin_bottom = -20.0 +grow_vertical = 0 + +[node name="MinClipSpinBox" type="SpinBox" parent="ClipContainer"] +margin_right = 280.0 +margin_bottom = 24.0 +min_value = -1.0 +max_value = 1.0 +step = 0.01 +value = -1.0 +prefix = "Min:" + +[node name="MaxClipSpinBox" type="SpinBox" parent="ClipContainer"] +margin_top = 28.0 +margin_right = 280.0 +margin_bottom = 52.0 +min_value = -1.0 +max_value = 1.0 +step = 0.01 +value = 1.0 +prefix = "Max:" +[connection signal="pressed" from="DocumentationButton" to="." method="_on_DocumentationButton_pressed"] +[connection signal="value_changed" from="ParameterContainer/SeedSpinBox" to="." method="_on_SeedSpinBox_value_changed"] +[connection signal="value_changed" from="ParameterContainer/LacunaritySpinBox" to="." method="_on_LacunaritySpinBox_value_changed"] +[connection signal="value_changed" from="ParameterContainer/PeriodSpinBox" to="." method="_on_PeriodSpinBox_value_changed"] +[connection signal="value_changed" from="ParameterContainer/PersistenceSpinBox" to="." method="_on_PersistenceSpinBox_value_changed"] +[connection signal="value_changed" from="ParameterContainer/OctavesSpinBox" to="." method="_on_OctavesSpinBox_value_changed"] +[connection signal="value_changed" from="ClipContainer/MinClipSpinBox" to="." method="_on_MinClipSpinBox_value_changed"] +[connection signal="value_changed" from="ClipContainer/MaxClipSpinBox" to="." method="_on_MaxClipSpinBox_value_changed"] diff --git a/misc/opensimplexnoise/icon.png b/misc/opensimplexnoise/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..1690979d8f7ebf8c84ab359b3cc94c250d6ef905 GIT binary patch literal 5437 zcmV-D6~gL?P)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!vFvd!vV){sAK>D02p*dSaefwW^{L9 za%BK;VQFr3E^cLXAT%y9E;jv63FrU-6s}1`K~#8N<=fSdU1b*raQ+6aCjr6*u0c9Q zTHGl%xVyu_-CYKEhhm4~?o!yeORxaR!LA4i3AZon_oizy)3e*ow9WTjlw{?cv*mr) zde*a^wf63?SSe+Zw$_7-lC>UO*tX@CTMos4okI^jw7b(zJ2l&GyKOn;lvB#>x8Gjw zyYIg8%rnoF#~**ZJo)64&GXMc-+knfM>;cS&Kzo6YhhdK!3DMR&O2}5=%bJB?6uck z%@$j1Q8wOq<09zox8J^OvdJc8mtA%#=bn3Rx%uXs%k|e^Uv9eTrfPTJeRl=rw%cwi zFTM0qdGpOTfz!;GF{2Ye4YcjGpw@bDe(ljmA03P!nyaq5s+@oR`Q?~njw#!0vrXAx zgAHonKDXLxtFp%)d(?9QR5{~}Gs=l4o>(rp;DR!J`t)iy-gslV>#n=%=e5^fTY(xL z9xhj2d1Z6L2`3D;?LEKNdT^rl@WT%eM)1u84?Iw_c*`xfROiur+O%n9qm4Ey>#x6l zS$plZ%jC(E%ch%dTDIG6yK=w*2b3d@IHE*plw*%Qwp@Mn)g|a(?zrQQa^Zy+mg9~) zu5>z`a`MS1SHN74NwHS5-g@gT6d+m;j@NFz_11w1zWegaFP9fyc%jzv>#x6FKLv8l zHP@8mk3YWbz4zV~1i`Ph)>bLjMLl2ebo_nr@c$HUQeYJe> z!3U*jn)2d{FV;Y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Ym3P?eLopP-k_E{s5H@NdiCw&)09h`KJ8-`|kknMJY`D4MWuh|xXh}|v+NOJ~i9s9|q~kh>a>FF|Vo;Wl4xnQQ z(r+NBZyG{d{C193I1dCqn*(B>`TG-@w4mQGgawVBGK$uQ5!v!7`&y+bQLwH-e>656 zIqy0wP`5IaYA#4E7Fe!TMjmQ_XdT0i?>@~A)|3e1D*KoLMC)Yv09ok=fRkE~hb8Y20YE%ugOi-&aL(egqZiJTf9&3PxJmMot7AM1P_cHbs1o-hgr@^0uX1-AH7&}Tz@Uvda%tR`vVbpPxb}K zAkP560Rrfq01#x$)0*JugnFkNsEG}L0RRvM!Ex==vw$Z-&jMIwJq{bCIYdttOi@>`wLflYOu$~4T^VH@z6Brf<5?F*1ASkNdjoE0MwQrvH z%00(m=Jl4A3II&82H*@wKvfD#LK5s53Fro6#vMFsJvc9mfQLDX@-`McW9pL9qo=7(hGkEQ2*y*J7aju2=X@mqJV9$;>f0!b-q-=C z>@WZWrjh_efYc2}Oo;NcTkFAzS_s@=JPhNU?1J&G4TcT8 zJ+xb$BADPkWoNv7eWKQSaA8{r)=*HsGiAz@?xabR8X#Z>70;<|)-y#Dtm($FP5?9C n!Zs0WJ-8@Y>%m3G%3}Wk<}CTIA_Bh400000NkvXXu0mjfwX`Y^ literal 0 HcmV?d00001 diff --git a/misc/opensimplexnoise/icon.png.import b/misc/opensimplexnoise/icon.png.import new file mode 100644 index 00000000..96cbf462 --- /dev/null +++ b/misc/opensimplexnoise/icon.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://icon.png" +dest_files=[ "res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.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=true +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 +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/misc/opensimplexnoise/project.godot b/misc/opensimplexnoise/project.godot new file mode 100644 index 00000000..d5157029 --- /dev/null +++ b/misc/opensimplexnoise/project.godot @@ -0,0 +1,27 @@ +; Engine configuration file. +; It's best edited using the editor UI and not directly, +; since the parameters that go here are not all obvious. +; +; Format: +; [section] ; section goes between [] +; param=value ; assign values to parameters + +config_version=4 + +_global_script_classes=[ ] +_global_script_class_icons={ + +} + +[application] + +config/name="OpenSimplexNoise Viewer" +run/main_scene="res://OpenSimplexNoise_Viewer.tscn" +config/icon="res://icon.png" + +[rendering] + +quality/driver/driver_name="GLES2" +vram_compression/import_etc=true +vram_compression/import_etc2=false +environment/default_environment="res://default_env.tres"