From 3a91299594d57521f94755be621b41a47131a9ea Mon Sep 17 00:00:00 2001 From: Clement Nassih Date: Wed, 5 Mar 2025 12:05:43 +0100 Subject: [PATCH 01/27] create project folde --- project.godot | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/project.godot b/project.godot index 725be9c..498f9b7 100644 --- a/project.godot +++ b/project.godot @@ -11,10 +11,10 @@ config_version=5 [application] config/name="compute_shader_studio" -run/main_scene="res://examples/example_1.tscn" +run/main_scene="res://examples/example_5.tscn" config/features=PackedStringArray("4.3", "Forward Plus") config/icon="res://addons/compute_shader_studio/icon.png" [editor_plugins] -enabled=PackedStringArray("res://addons/compute_shader_studio/plugin.cfg") +enabled=PackedStringArray() From b3e918a045ab5eb538d7d4f3a5659d363a1e44e4 Mon Sep 17 00:00:00 2001 From: Clement Nassih Date: Wed, 5 Mar 2025 12:30:25 +0100 Subject: [PATCH 02/27] test --- examples/project/test.cpp | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 examples/project/test.cpp diff --git a/examples/project/test.cpp b/examples/project/test.cpp new file mode 100644 index 0000000..e69de29 From db3ddaf95f2ef47c40bf896d5380d261695bd32e Mon Sep 17 00:00:00 2001 From: Clement Nassih Date: Tue, 11 Mar 2025 10:53:43 +0100 Subject: [PATCH 03/27] creation mon exemple --- examples/exampleClement/read.me | 1 + 1 file changed, 1 insertion(+) create mode 100644 examples/exampleClement/read.me diff --git a/examples/exampleClement/read.me b/examples/exampleClement/read.me new file mode 100644 index 0000000..dcb2405 --- /dev/null +++ b/examples/exampleClement/read.me @@ -0,0 +1 @@ +test branch \ No newline at end of file From 8bd548ce682515e81a3b785f66e0bd36778242f2 Mon Sep 17 00:00:00 2001 From: redalhdd Date: Tue, 11 Mar 2025 11:15:27 +0100 Subject: [PATCH 04/27] Animation oeil rouge qui tourne avec pupille qui pulse --- examples/project/test.cpp | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 examples/project/test.cpp diff --git a/examples/project/test.cpp b/examples/project/test.cpp deleted file mode 100644 index e69de29..0000000 From 345c6c60e6be70ea754b20c25fef176172bda932 Mon Sep 17 00:00:00 2001 From: redalhdd Date: Tue, 11 Mar 2025 11:31:56 +0100 Subject: [PATCH 05/27] Ajout du dossier project --- examples/project/project.cpp | 60 +++++++++++++++++++++++++++++++++++ examples/project/project.tscn | 20 ++++++++++++ node_2d.tscn | 3 ++ 3 files changed, 83 insertions(+) create mode 100644 examples/project/project.cpp create mode 100644 examples/project/project.tscn create mode 100644 node_2d.tscn diff --git a/examples/project/project.cpp b/examples/project/project.cpp new file mode 100644 index 0000000..463ab9d --- /dev/null +++ b/examples/project/project.cpp @@ -0,0 +1,60 @@ +void main() { + uint x = gl_GlobalInvocationID.x; + uint y = gl_GlobalInvocationID.y; + uint p = x + y * WSX; + + // Circle parameters + float centerX = WSX / 2.0; + float centerY = WSY / 2.0; + float radius = 70.0; + + // Angle de rotation + float angle = float(step) * 0.1; + + // Calculate distance from current pixel to circle center + float dx = float(x) - centerX; + float dy = float(y) - centerY; + float distance = sqrt(dx * dx + dy * dy); + + // Calculate angle of current pixel relative to center + float pixelAngle = atan(dy, dx); + + // Width of the line in radians + float lineWidth = 0.1; + + // Check if pixel is on the rotating line + bool onLine = abs(mod(pixelAngle - angle, 2.0 * 3.14159)) < lineWidth; + + // Inner circle parameters with pulsing effect + float baseInnerRadius = 18.0; + float pulseAmplitude = 3.0; // Change in radius (20 to 23) + float pulseFrequency = 1.5; // Réduit de 3.0 à 1.5 pour un pulsage plus lent + float innerRadius = baseInnerRadius + pulseAmplitude; //* sin(float(step) * pulseFrequency * 0.1); + + // Border circle parameters + float borderWidth = 2.0; + float borderRadius = innerRadius + 15.0; // Un peu plus grand que le cercle intérieur + + // Moving circle parameters + float movingCircleRadius = 5.0; + float movingCircleX = centerX + borderRadius * cos(angle); + float movingCircleY = centerY + borderRadius * sin(angle); + float movingCircleDistance = sqrt(pow(float(x) - movingCircleX, 2.0) + pow(float(y) - movingCircleY, 2.0)); + + // Draw circle with line and inner circle + if (distance < radius) { + if (movingCircleDistance < movingCircleRadius) { + data_0[p] = 0xFF000000; // Black moving circle + } else if (distance < innerRadius) { + data_0[p] = 0xFF000000; // Black inner circle + } else if (distance < borderRadius && distance > borderRadius - borderWidth) { + data_0[p] = 0xFF000000; // Black border + } else if (onLine) { + //data_0[p] = 0xFF000000; // Black line + } else { + data_0[p] = 0xFF0000FF; // Red circle + } + } else { + data_0[p] = 0xFFFFFFFF; // White background + } +} diff --git a/examples/project/project.tscn b/examples/project/project.tscn new file mode 100644 index 0000000..08410d5 --- /dev/null +++ b/examples/project/project.tscn @@ -0,0 +1,20 @@ +[gd_scene load_steps=3 format=3 uid="uid://b22muc60w8hia"] + +[ext_resource type="Texture2D" uid="uid://demftcowdd5c6" path="res://examples/icon.svg" id="1_se6bx"] +[ext_resource type="Script" path="res://addons/compute_shader_studio/compute_shader_studio_2d.gd" id="2_jgmy4"] + +[node name="Project" type="Node2D"] + +[node name="Node" type="Node" parent="."] + +[node name="Icon" type="Sprite2D" parent="."] +position = Vector2(559, 336) +scale = Vector2(5.04688, 4.10938) +texture = ExtResource("1_se6bx") + +[node name="ComputeShaderStudio2D2" type="Node" parent="." node_paths=PackedStringArray("data")] +script = ExtResource("2_jgmy4") +WSX = 256 +glsl_file = "res://examples/project/project.cpp" +GLSL_code = "" +data = [NodePath("../Icon")] diff --git a/node_2d.tscn b/node_2d.tscn new file mode 100644 index 0000000..76e5bf8 --- /dev/null +++ b/node_2d.tscn @@ -0,0 +1,3 @@ +[gd_scene format=3 uid="uid://dyux3ncnsf1xc"] + +[node name="Node2D" type="Node2D"] From b9bc2136a7e32b972686ea553f792f6ad25011d9 Mon Sep 17 00:00:00 2001 From: MADI-SOILIHI Date: Tue, 11 Mar 2025 11:55:59 +0100 Subject: [PATCH 06/27] RINNEGAN --- .../compute_shader_studio_2d.gd.uid | 1 + .../compute_shader_studio_plugin.gd.uid | 1 + examples/LabelStepPass.gd.uid | 1 + examples/cells/cells.gd.uid | 1 + examples/cells/example_cells.tscn | 2 +- examples/example_1.cpp | 1 + examples/example_1.tscn | 2 +- examples/example_2.tscn | 2 +- examples/example_3.tscn | 4 +- examples/example_4.tscn | 2 +- examples/example_5.cpp | 39 ++++++++++++++----- examples/example_5.tscn | 2 +- examples/example_lenia_test.tscn | 4 +- examples/example_mandelbrot.gd.uid | 1 + examples/example_mandelbrot.tscn | 4 +- examples/example_psycho_seizure.tscn | 2 +- examples/project/test.cpp | 7 ++++ project.godot | 2 +- 18 files changed, 56 insertions(+), 22 deletions(-) create mode 100644 addons/compute_shader_studio/compute_shader_studio_2d.gd.uid create mode 100644 addons/compute_shader_studio/compute_shader_studio_plugin.gd.uid create mode 100644 examples/LabelStepPass.gd.uid create mode 100644 examples/cells/cells.gd.uid create mode 100644 examples/example_mandelbrot.gd.uid diff --git a/addons/compute_shader_studio/compute_shader_studio_2d.gd.uid b/addons/compute_shader_studio/compute_shader_studio_2d.gd.uid new file mode 100644 index 0000000..083334c --- /dev/null +++ b/addons/compute_shader_studio/compute_shader_studio_2d.gd.uid @@ -0,0 +1 @@ +uid://b88ieqj4hfk8r diff --git a/addons/compute_shader_studio/compute_shader_studio_plugin.gd.uid b/addons/compute_shader_studio/compute_shader_studio_plugin.gd.uid new file mode 100644 index 0000000..b7d0e6c --- /dev/null +++ b/addons/compute_shader_studio/compute_shader_studio_plugin.gd.uid @@ -0,0 +1 @@ +uid://b16pwdohwxa05 diff --git a/examples/LabelStepPass.gd.uid b/examples/LabelStepPass.gd.uid new file mode 100644 index 0000000..430e2af --- /dev/null +++ b/examples/LabelStepPass.gd.uid @@ -0,0 +1 @@ +uid://dc0t1p5le3li2 diff --git a/examples/cells/cells.gd.uid b/examples/cells/cells.gd.uid new file mode 100644 index 0000000..96d777f --- /dev/null +++ b/examples/cells/cells.gd.uid @@ -0,0 +1 @@ +uid://b6tywcya4s4ti diff --git a/examples/cells/example_cells.tscn b/examples/cells/example_cells.tscn index 6959c31..aaca555 100644 --- a/examples/cells/example_cells.tscn +++ b/examples/cells/example_cells.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=3 format=3 uid="uid://cutxgtalwsp6q"] -[ext_resource type="Script" path="res://examples/cells/cells.gd" id="1_dw4h8"] +[ext_resource type="Script" uid="uid://b6tywcya4s4ti" path="res://examples/cells/cells.gd" id="1_dw4h8"] [ext_resource type="Texture2D" uid="uid://demftcowdd5c6" path="res://examples/icon.svg" id="2_oji6h"] [node name="Cells" type="Control" node_paths=PackedStringArray("data")] diff --git a/examples/example_1.cpp b/examples/example_1.cpp index d9cb0f8..d7cecc3 100644 --- a/examples/example_1.cpp +++ b/examples/example_1.cpp @@ -4,4 +4,5 @@ void main() { uint y = gl_GlobalInvocationID.y; uint p = x + y * WSX; data_0[p] = 0xFFFF0000 - int(x+y*1024)*(step); + } diff --git a/examples/example_1.tscn b/examples/example_1.tscn index 7d67949..c5f2216 100644 --- a/examples/example_1.tscn +++ b/examples/example_1.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=5 format=3 uid="uid://ddr6qtwy1pesd"] -[ext_resource type="Script" path="res://addons/compute_shader_studio/compute_shader_studio_2d.gd" id="1_6846p"] +[ext_resource type="Script" uid="uid://b88ieqj4hfk8r" path="res://addons/compute_shader_studio/compute_shader_studio_2d.gd" id="1_6846p"] [ext_resource type="Texture2D" uid="uid://demftcowdd5c6" path="res://examples/icon.svg" id="2_s3fct"] [sub_resource type="FastNoiseLite" id="FastNoiseLite_dmk8h"] diff --git a/examples/example_2.tscn b/examples/example_2.tscn index 766e825..3dcab04 100644 --- a/examples/example_2.tscn +++ b/examples/example_2.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=3 format=3 uid="uid://cotswmubn7uvm"] -[ext_resource type="Script" path="res://addons/compute_shader_studio/compute_shader_studio_2d.gd" id="1_2cs40"] +[ext_resource type="Script" uid="uid://b88ieqj4hfk8r" path="res://addons/compute_shader_studio/compute_shader_studio_2d.gd" id="1_2cs40"] [ext_resource type="Texture2D" uid="uid://demftcowdd5c6" path="res://examples/icon.svg" id="2_j6qu8"] [node name="Example2" type="Node2D"] diff --git a/examples/example_3.tscn b/examples/example_3.tscn index df2b8a6..585fb0e 100644 --- a/examples/example_3.tscn +++ b/examples/example_3.tscn @@ -1,7 +1,7 @@ [gd_scene load_steps=4 format=3 uid="uid://cmucgsppcoo5e"] -[ext_resource type="Script" path="res://addons/compute_shader_studio/compute_shader_studio_2d.gd" id="1_eimw3"] -[ext_resource type="Script" path="res://examples/LabelStepPass.gd" id="2_4aq4t"] +[ext_resource type="Script" uid="uid://b88ieqj4hfk8r" path="res://addons/compute_shader_studio/compute_shader_studio_2d.gd" id="1_eimw3"] +[ext_resource type="Script" uid="uid://dc0t1p5le3li2" path="res://examples/LabelStepPass.gd" id="2_4aq4t"] [ext_resource type="Texture2D" uid="uid://demftcowdd5c6" path="res://examples/icon.svg" id="2_4upxj"] [node name="CompShadStudioEx3" type="Node2D"] diff --git a/examples/example_4.tscn b/examples/example_4.tscn index c777972..fe89676 100644 --- a/examples/example_4.tscn +++ b/examples/example_4.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=3 format=3 uid="uid://b2ip5eftk3aij"] -[ext_resource type="Script" path="res://addons/compute_shader_studio/compute_shader_studio_2d.gd" id="1_ke3fj"] +[ext_resource type="Script" uid="uid://b88ieqj4hfk8r" path="res://addons/compute_shader_studio/compute_shader_studio_2d.gd" id="1_ke3fj"] [ext_resource type="Texture2D" uid="uid://2behgeplwycn" path="res://examples/grid_512x512.png" id="2_flqlh"] [node name="CompShadStudioEx4" type="Node2D"] diff --git a/examples/example_5.cpp b/examples/example_5.cpp index 5c9ebc2..7d498cd 100644 --- a/examples/example_5.cpp +++ b/examples/example_5.cpp @@ -1,11 +1,32 @@ -// Write your code HERE void main() { - uint x = gl_GlobalInvocationID.x; - uint y = gl_GlobalInvocationID.y; - uint p = x + y * WSX; - int dx = int(WSX)/2 - int(x); - int dy = int(WSY)/2 - int(y); - int r = int(64.0*sin(step/100.0)); - int d = int(dx*dx+dy*dy) ; - data_0[p] = 0xFF000000 - 600* (d + step) ; + uint x = gl_GlobalInvocationID.x; + uint y = gl_GlobalInvocationID.y; + uint p = x + y * WSX; + + int dx = int(WSX) / 2 - int(x); + int dy = int(WSY) / 2 - int(y); + + int d = dx * dx + dy * dy; + int r = int(64.0 * sin(float(step) / 100.0)); + + // Condition : après 5 secondes (ajuste la valeur selon ton framerate) + if (step > 300) { // Après 5 secondes -> Afficher les cercles + + int d = int(sqrt(float(dx * dx + dy * dy))); // Distance au centre + int spacing = 30; // Espacement des cercles (réduit) + + // Calcul des cercles noirs avec un motif en anneaux + float rings = mod(float(d), float(spacing)); + bool isBlack = rings < 6.0; // Réduction de l'épaisseur des anneaux noirs + + if (isBlack) { + data_0[p] = 0xFF000000; // Noir + } else { + data_0[p] = 0xFF800080; // Fond violet + } + + } else { + int value = clamp(600 * (d + int(step)), 0, 0xFFFFFF); + data_0[p] = 0xFF000000 | (0xFFFFFF - value); // Rendu normal + } } diff --git a/examples/example_5.tscn b/examples/example_5.tscn index 43aa420..b8179a5 100644 --- a/examples/example_5.tscn +++ b/examples/example_5.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=4 format=3 uid="uid://cets11mlsd8hb"] -[ext_resource type="Script" path="res://addons/compute_shader_studio/compute_shader_studio_2d.gd" id="1_cogap"] +[ext_resource type="Script" uid="uid://b88ieqj4hfk8r" path="res://addons/compute_shader_studio/compute_shader_studio_2d.gd" id="1_cogap"] [sub_resource type="FastNoiseLite" id="FastNoiseLite_pm7bb"] diff --git a/examples/example_lenia_test.tscn b/examples/example_lenia_test.tscn index 6c2caef..3f66d9f 100644 --- a/examples/example_lenia_test.tscn +++ b/examples/example_lenia_test.tscn @@ -1,7 +1,7 @@ [gd_scene load_steps=4 format=3 uid="uid://cljj33x767odp"] -[ext_resource type="Script" path="res://addons/compute_shader_studio/compute_shader_studio_2d.gd" id="1_wci4f"] -[ext_resource type="Script" path="res://examples/LabelStepPass.gd" id="2_ndkd3"] +[ext_resource type="Script" uid="uid://b88ieqj4hfk8r" path="res://addons/compute_shader_studio/compute_shader_studio_2d.gd" id="1_wci4f"] +[ext_resource type="Script" uid="uid://dc0t1p5le3li2" path="res://examples/LabelStepPass.gd" id="2_ndkd3"] [ext_resource type="Texture2D" uid="uid://demftcowdd5c6" path="res://examples/icon.svg" id="3_orsvs"] [node name="CompShadStudioEx3" type="Node2D"] diff --git a/examples/example_mandelbrot.gd.uid b/examples/example_mandelbrot.gd.uid new file mode 100644 index 0000000..3e93ef9 --- /dev/null +++ b/examples/example_mandelbrot.gd.uid @@ -0,0 +1 @@ +uid://n4ra8rjo3hu diff --git a/examples/example_mandelbrot.tscn b/examples/example_mandelbrot.tscn index a5e532c..0f7e9a2 100644 --- a/examples/example_mandelbrot.tscn +++ b/examples/example_mandelbrot.tscn @@ -1,7 +1,7 @@ [gd_scene load_steps=4 format=3 uid="uid://d1hhshnvrt86e"] -[ext_resource type="Script" path="res://examples/example_mandelbrot.gd" id="1_5gp20"] -[ext_resource type="Script" path="res://addons/compute_shader_studio/compute_shader_studio_2d.gd" id="1_t5cx1"] +[ext_resource type="Script" uid="uid://n4ra8rjo3hu" path="res://examples/example_mandelbrot.gd" id="1_5gp20"] +[ext_resource type="Script" uid="uid://b88ieqj4hfk8r" path="res://addons/compute_shader_studio/compute_shader_studio_2d.gd" id="1_t5cx1"] [ext_resource type="Texture2D" uid="uid://demftcowdd5c6" path="res://examples/icon.svg" id="2_dyrad"] [node name="example_mandelbrot" type="Node2D"] diff --git a/examples/example_psycho_seizure.tscn b/examples/example_psycho_seizure.tscn index f1e07d4..dfd06a1 100644 --- a/examples/example_psycho_seizure.tscn +++ b/examples/example_psycho_seizure.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=3 format=3 uid="uid://cdtqwwdxs783m"] -[ext_resource type="Script" path="res://addons/compute_shader_studio/compute_shader_studio_2d.gd" id="1_26wk6"] +[ext_resource type="Script" uid="uid://b88ieqj4hfk8r" path="res://addons/compute_shader_studio/compute_shader_studio_2d.gd" id="1_26wk6"] [ext_resource type="Texture2D" uid="uid://demftcowdd5c6" path="res://examples/icon.svg" id="2_urrfs"] [node name="exeample_psycho_seizure" type="Node2D"] diff --git a/examples/project/test.cpp b/examples/project/test.cpp index e69de29..59d6861 100644 --- a/examples/project/test.cpp +++ b/examples/project/test.cpp @@ -0,0 +1,7 @@ +void main() { + uint x = gl_GlobalInvocationID.x; + uint y = gl_GlobalInvocationID.y; + uint p = x + y * WSX; + data_0[p] = 0xFFFF0000 - int(x+y*1024)*(step); + +} \ No newline at end of file diff --git a/project.godot b/project.godot index 498f9b7..31af041 100644 --- a/project.godot +++ b/project.godot @@ -12,7 +12,7 @@ config_version=5 config/name="compute_shader_studio" run/main_scene="res://examples/example_5.tscn" -config/features=PackedStringArray("4.3", "Forward Plus") +config/features=PackedStringArray("4.4", "Forward Plus") config/icon="res://addons/compute_shader_studio/icon.png" [editor_plugins] From 1646b835cc42f2a67b66f2ebb1fd7087f7334d53 Mon Sep 17 00:00:00 2001 From: redalhdd Date: Tue, 11 Mar 2025 12:02:46 +0100 Subject: [PATCH 07/27] Presque sharingan --- examples/project/project.cpp | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/examples/project/project.cpp b/examples/project/project.cpp index 463ab9d..b5621e5 100644 --- a/examples/project/project.cpp +++ b/examples/project/project.cpp @@ -35,16 +35,29 @@ void main() { float borderWidth = 2.0; float borderRadius = innerRadius + 15.0; // Un peu plus grand que le cercle intérieur - // Moving circle parameters + // Moving circle parameters (3 circles) float movingCircleRadius = 5.0; + // Premier cercle (position originale) float movingCircleX = centerX + borderRadius * cos(angle); float movingCircleY = centerY + borderRadius * sin(angle); float movingCircleDistance = sqrt(pow(float(x) - movingCircleX, 2.0) + pow(float(y) - movingCircleY, 2.0)); + + // Deuxième cercle (décalé de 120 degrés) + float movingCircle2X = centerX + borderRadius * cos(angle + 2.0944); // 2.0944 = 2π/3 + float movingCircle2Y = centerY + borderRadius * sin(angle + 2.0944); + float movingCircle2Distance = sqrt(pow(float(x) - movingCircle2X, 2.0) + pow(float(y) - movingCircle2Y, 2.0)); + + // Troisième cercle (décalé de 240 degrés) + float movingCircle3X = centerX + borderRadius * cos(angle + 4.1888); // 4.1888 = 4π/3 + float movingCircle3Y = centerY + borderRadius * sin(angle + 4.1888); + float movingCircle3Distance = sqrt(pow(float(x) - movingCircle3X, 2.0) + pow(float(y) - movingCircle3Y, 2.0)); // Draw circle with line and inner circle if (distance < radius) { - if (movingCircleDistance < movingCircleRadius) { - data_0[p] = 0xFF000000; // Black moving circle + if (movingCircleDistance < movingCircleRadius || + movingCircle2Distance < movingCircleRadius || + movingCircle3Distance < movingCircleRadius) { + data_0[p] = 0xFF000000; // Black moving circles } else if (distance < innerRadius) { data_0[p] = 0xFF000000; // Black inner circle } else if (distance < borderRadius && distance > borderRadius - borderWidth) { From af059116ed86692e424fdd475df5ca88d8a5d823 Mon Sep 17 00:00:00 2001 From: redalhdd Date: Tue, 11 Mar 2025 12:18:00 +0100 Subject: [PATCH 08/27] Presque sharingan encore --- examples/project/project.cpp | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/examples/project/project.cpp b/examples/project/project.cpp index b5621e5..aecc943 100644 --- a/examples/project/project.cpp +++ b/examples/project/project.cpp @@ -52,11 +52,38 @@ void main() { float movingCircle3Y = centerY + borderRadius * sin(angle + 4.1888); float movingCircle3Distance = sqrt(pow(float(x) - movingCircle3X, 2.0) + pow(float(y) - movingCircle3Y, 2.0)); + // Croissant parameters pour les trois cercles + float crescentRadius = 5.0; + float crescentOffset = 2.0; + + // Croissants pour chaque cercle mobile + // Croissant 1 + float crescent1MainDist = sqrt(pow(float(x) - (movingCircleX), 2.0) + + pow(float(y) - (movingCircleY - crescentRadius), 2.0)); + float crescent1SecDist = sqrt(pow(float(x) - (movingCircleX + crescentOffset), 2.0) + + pow(float(y) - (movingCircleY - crescentRadius), 2.0)); + + // Croissant 2 + float crescent2MainDist = sqrt(pow(float(x) - (movingCircle2X), 2.0) + + pow(float(y) - (movingCircle2Y - crescentRadius), 2.0)); + float crescent2SecDist = sqrt(pow(float(x) - (movingCircle2X + crescentOffset), 2.0) + + pow(float(y) - (movingCircle2Y - crescentRadius), 2.0)); + + // Croissant 3 + float crescent3MainDist = sqrt(pow(float(x) - (movingCircle3X), 2.0) + + pow(float(y) - (movingCircle3Y - crescentRadius), 2.0)); + float crescent3SecDist = sqrt(pow(float(x) - (movingCircle3X + crescentOffset), 2.0) + + pow(float(y) - (movingCircle3Y - crescentRadius), 2.0)); + // Draw circle with line and inner circle if (distance < radius) { - if (movingCircleDistance < movingCircleRadius || - movingCircle2Distance < movingCircleRadius || - movingCircle3Distance < movingCircleRadius) { + if ((crescent1MainDist < crescentRadius && crescent1SecDist > crescentRadius - 1.0) || + (crescent2MainDist < crescentRadius && crescent2SecDist > crescentRadius - 1.0) || + (crescent3MainDist < crescentRadius && crescent3SecDist > crescentRadius - 1.0)) { + data_0[p] = 0xFF000000; // Black crescents + } else if (movingCircleDistance < movingCircleRadius || + movingCircle2Distance < movingCircleRadius || + movingCircle3Distance < movingCircleRadius) { data_0[p] = 0xFF000000; // Black moving circles } else if (distance < innerRadius) { data_0[p] = 0xFF000000; // Black inner circle From 4ea7fa4d75ca4475e40a2069c27d316ea66845b8 Mon Sep 17 00:00:00 2001 From: redalhdd Date: Wed, 12 Mar 2025 17:45:54 +0100 Subject: [PATCH 09/27] Sharingan --- examples/circles/circles.cpp | 32 +++++++ examples/circles/circles.tscn | 32 +++++++ examples/project/project.cpp | 2 +- examples/project/project.tscn | 2 +- examples/project/test.cpp | 101 ++++++++++++++++++++++ examples/project/test.tscn | 17 ++++ examples/simple circle/simple_circle.cpp | 21 +++++ examples/simple circle/simple_circle.tscn | 17 ++++ 8 files changed, 222 insertions(+), 2 deletions(-) create mode 100644 examples/circles/circles.cpp create mode 100644 examples/circles/circles.tscn create mode 100644 examples/project/test.cpp create mode 100644 examples/project/test.tscn create mode 100644 examples/simple circle/simple_circle.cpp create mode 100644 examples/simple circle/simple_circle.tscn diff --git a/examples/circles/circles.cpp b/examples/circles/circles.cpp new file mode 100644 index 0000000..4310abf --- /dev/null +++ b/examples/circles/circles.cpp @@ -0,0 +1,32 @@ + +#define RADIUS 40 + +void main() +{ + int x = int(gl_GlobalInvocationID.x); + int y = int(gl_GlobalInvocationID.y); + int p = x + y * int(WSX); + + // initial background is black & opac + if (step == 0) { + data_0[p] = 0xFF000000 + y; + } else { // draw a fading red circle + float dx = float(mousex - x); + float dy = float(mousey - y); + float dist = sqrt(dx*dx+dy*dy); + int pix = data_0[p]; + int col = pix & 0x00FFFFFF ; + float r = RADIUS + 10*sin(step/10.0f); + if( dist < r-1 ) { // interior + col = col + 0x04 ; + data_0[p] = 0xFF000000 + col ; + } + if( dist >= r-1 && dist <= r+1 ) { // perimeter + data_0[p] = 0xFF0000FF ; + } + if( dist > r + 1) { // ouside + if (col > 0) + data_0[p] = pix - 1; + } + } +} \ No newline at end of file diff --git a/examples/circles/circles.tscn b/examples/circles/circles.tscn new file mode 100644 index 0000000..1916a5c --- /dev/null +++ b/examples/circles/circles.tscn @@ -0,0 +1,32 @@ +[gd_scene load_steps=3 format=3 uid="uid://c1ux4sgouixua"] + +[ext_resource type="Script" path="res://addons/compute_shader_studio/compute_shader_studio_2d.gd" id="1_amro2"] +[ext_resource type="Texture2D" uid="uid://demftcowdd5c6" path="res://examples/icon.svg" id="2_ntl1q"] + +[node name="Circles" type="Node2D"] + +[node name="ComputeShaderStudio2D" type="Node" parent="." node_paths=PackedStringArray("data")] +script = ExtResource("1_amro2") +WSX = 512 +WSY = 256 +glsl_file = "res://examples/circles/circles.cpp" +GLSL_code = "" +data = [NodePath("../Icon")] +metadata/_custom_type_script = "uid://c8esqdv0y26yp" + +[node name="Label" type="Label" parent="."] +offset_left = 278.0 +offset_top = -1.0 +offset_right = 679.0 +offset_bottom = 101.0 +scale = Vector2(1.72, 1.72) +text = "Compute Shader Studio - Example Circles +- uses an external GLSL file +- and a Sprite2D" +horizontal_alignment = 1 +vertical_alignment = 1 + +[node name="Icon" type="Sprite2D" parent="."] +position = Vector2(605.5, 411) +scale = Vector2(5.63281, 3.17969) +texture = ExtResource("2_ntl1q") diff --git a/examples/project/project.cpp b/examples/project/project.cpp index aecc943..bc2da8c 100644 --- a/examples/project/project.cpp +++ b/examples/project/project.cpp @@ -29,7 +29,7 @@ void main() { float baseInnerRadius = 18.0; float pulseAmplitude = 3.0; // Change in radius (20 to 23) float pulseFrequency = 1.5; // Réduit de 3.0 à 1.5 pour un pulsage plus lent - float innerRadius = baseInnerRadius + pulseAmplitude; //* sin(float(step) * pulseFrequency * 0.1); + float innerRadius = baseInnerRadius + pulseAmplitude; //* sin(float(step) * pulseFrequency * 0.1); //PULSAGE // Border circle parameters float borderWidth = 2.0; diff --git a/examples/project/project.tscn b/examples/project/project.tscn index 08410d5..45bdfa2 100644 --- a/examples/project/project.tscn +++ b/examples/project/project.tscn @@ -8,7 +8,7 @@ [node name="Node" type="Node" parent="."] [node name="Icon" type="Sprite2D" parent="."] -position = Vector2(559, 336) +position = Vector2(593, 340) scale = Vector2(5.04688, 4.10938) texture = ExtResource("1_se6bx") diff --git a/examples/project/test.cpp b/examples/project/test.cpp new file mode 100644 index 0000000..d6cdc23 --- /dev/null +++ b/examples/project/test.cpp @@ -0,0 +1,101 @@ +#define RADIUS 40 +#define PUPIL_RADIUS 10 +#define IRIS_RADIUS 25 +#define DOT_RADIUS 3 +#define CRESCENT_OFFSET 2.0 // Décalage pour créer l'effet de croissant +#define PI 3.14159265359 // Ajout de la définition de PI +#define SMALL_DOT_RADIUS 2.0 // Rayon du petit point +#define SMALL_DOT_OFFSET 1.0 // Distance du point par rapport au croissant + +void main() +{ + int x = int(gl_GlobalInvocationID.x); + int y = int(gl_GlobalInvocationID.y); + int p = x + y * int(WSX); + + // initial background is black & opac + if (step == 0) { + data_0[p] = 0xFF000000; + } else { + float dx = float(mousex - x); + float dy = float(mousey - y); + float dist = sqrt(dx*dx + dy*dy); + + // Position des points tournants + float angle = float(step) * 0.05f; // Vitesse de rotation + float orbit_radius = (IRIS_RADIUS + PUPIL_RADIUS) * 0.5f; // Rayon de l'orbite + + // Premier point + float dot_x = mousex + orbit_radius * cos(angle); + float dot_y = mousey + orbit_radius * sin(angle); + float dot_dist = sqrt(pow(x - dot_x, 2) + pow(y - dot_y, 2)); + + // Deuxième point (décalé de 120°) + float dot2_x = mousex + orbit_radius * cos(angle + 2.0944); // 2π/3 + float dot2_y = mousey + orbit_radius * sin(angle + 2.0944); + float dot2_dist = sqrt(pow(x - dot2_x, 2) + pow(y - dot2_y, 2)); + + // Troisième point (décalé de 240°) + float dot3_x = mousex + orbit_radius * cos(angle + 4.1888); // 4π/3 + float dot3_y = mousey + orbit_radius * sin(angle + 4.1888); + float dot3_dist = sqrt(pow(x - dot3_x, 2) + pow(y - dot3_y, 2)); + + // Premier croissant - décalage orienté vers l'extérieur + float crescent1MainDist = sqrt(pow(x - dot_x, 2) + pow(y - dot_y, 2)); + float crescent1SecDist = sqrt(pow(x - (dot_x + CRESCENT_OFFSET * cos(angle + PI/2)), 2) + + pow(y - (dot_y + CRESCENT_OFFSET * sin(angle + PI/2)), 2)); + + // Deuxième croissant - décalage orienté vers l'extérieur + float crescent2MainDist = sqrt(pow(x - dot2_x, 2) + pow(y - dot2_y, 2)); + float crescent2SecDist = sqrt(pow(x - (dot2_x + CRESCENT_OFFSET * cos(angle + 2.0944 + + PI/2)), 2) + + pow(y - (dot2_y + CRESCENT_OFFSET * sin(angle + 2.0944 + + PI/2)), 2)); + + // Troisième croissant - décalage orienté vers l'extérieur + float crescent3MainDist = sqrt(pow(x - dot3_x, 2) + pow(y - dot3_y, 2)); + float crescent3SecDist = sqrt(pow(x - (dot3_x + CRESCENT_OFFSET * cos(angle + 4.1888 + + PI/2)), 2) + + pow(y - (dot3_y + CRESCENT_OFFSET * sin(angle + 4.1888 + + PI/2)), 2)); + + // Points superposés aux croissants + float dot1_center_x = dot_x - SMALL_DOT_OFFSET * cos(angle); + float dot1_center_y = dot_y - SMALL_DOT_OFFSET * sin(angle); + float small_dot1_dist = sqrt(pow(x - dot1_center_x, 2) + pow(y - dot1_center_y, 2)); + + float dot2_center_x = dot2_x - SMALL_DOT_OFFSET * cos(angle + 2.0944); + float dot2_center_y = dot2_y - SMALL_DOT_OFFSET * sin(angle + 2.0944); + float small_dot2_dist = sqrt(pow(x - dot2_center_x, 2) + pow(y - dot2_center_y, 2)); + + float dot3_center_x = dot3_x - SMALL_DOT_OFFSET * cos(angle + 4.1888); + float dot3_center_y = dot3_y - SMALL_DOT_OFFSET * sin(angle + 4.1888); + float small_dot3_dist = sqrt(pow(x - dot3_center_x, 2) + pow(y - dot3_center_y, 2)); + + if (dist < RADIUS) { + float z = sqrt(RADIUS*RADIUS - dist*dist); + float normal_z = z/RADIUS; + float light = normal_z; + light = clamp(light, 0.2f, 1.0f); + + if (dist < PUPIL_RADIUS) { + data_0[p] = 0xFF000000; + } else if (dist < IRIS_RADIUS) { + // Points noirs tournants dans l'iris sous forme de croissants + if ((crescent1MainDist < DOT_RADIUS && crescent1SecDist > DOT_RADIUS - 1.0) || + (crescent2MainDist < DOT_RADIUS && crescent2SecDist > DOT_RADIUS - 1.0) || + (crescent3MainDist < DOT_RADIUS && crescent3SecDist > DOT_RADIUS - 1.0) || + small_dot1_dist < SMALL_DOT_RADIUS || + small_dot2_dist < SMALL_DOT_RADIUS || + small_dot3_dist < SMALL_DOT_RADIUS) { + data_0[p] = 0xFF000000; + } else { + // Iris rouge avec ombrage + int red = int(200.0f * light); + data_0[p] = 0xFF000000 | red; + } + } else { + int value = int(255.0f * light); + data_0[p] = 0xFF000000 | (value << 16) | (value << 8) | value; + } + } else { + data_0[p] = 0xFF000000; + } + } +} diff --git a/examples/project/test.tscn b/examples/project/test.tscn new file mode 100644 index 0000000..4b79a75 --- /dev/null +++ b/examples/project/test.tscn @@ -0,0 +1,17 @@ +[gd_scene load_steps=3 format=3 uid="uid://duh7anebdiq5r"] + +[ext_resource type="Script" path="res://addons/compute_shader_studio/compute_shader_studio_2d.gd" id="1_o3uyj"] +[ext_resource type="Texture2D" uid="uid://demftcowdd5c6" path="res://examples/icon.svg" id="2_gpcd8"] + +[node name="Test" type="Node2D"] + +[node name="ComputeShaderStudio2D" type="Node" parent="." node_paths=PackedStringArray("data")] +script = ExtResource("1_o3uyj") +glsl_file = "res://examples/project/test.cpp" +data = [NodePath("../Icon")] +metadata/_custom_type_script = "uid://c8esqdv0y26yp" + +[node name="Icon" type="Sprite2D" parent="."] +position = Vector2(570, 331) +scale = Vector2(5.3125, 5.03125) +texture = ExtResource("2_gpcd8") diff --git a/examples/simple circle/simple_circle.cpp b/examples/simple circle/simple_circle.cpp new file mode 100644 index 0000000..5526980 --- /dev/null +++ b/examples/simple circle/simple_circle.cpp @@ -0,0 +1,21 @@ +void main() { + + uint x = gl_GlobalInvocationID.x; + uint y = gl_GlobalInvocationID.y; + uint p = x + y*WSX; + + if (step == 0) // init + data_0[p] = int(0xFF0000FF - y) ; // Fond + else { + float dx = float(mousex) - float(x) ; + float dy = float(mousey) - float(y) ; + float dist = sqrt( dx*dx + dy*dy ); + + if (dist < 10) { + data_0[p] = 0xFF00FF00; // Cercle vert + } else { + data_0[p] = int(0xFF0000FF - y) ; // Fond + } + + } +} \ No newline at end of file diff --git a/examples/simple circle/simple_circle.tscn b/examples/simple circle/simple_circle.tscn new file mode 100644 index 0000000..3a07914 --- /dev/null +++ b/examples/simple circle/simple_circle.tscn @@ -0,0 +1,17 @@ +[gd_scene load_steps=3 format=3 uid="uid://c63rtjh0eurgm"] + +[ext_resource type="Script" path="res://addons/compute_shader_studio/compute_shader_studio_2d.gd" id="1_rlapi"] +[ext_resource type="Texture2D" uid="uid://demftcowdd5c6" path="res://examples/icon.svg" id="2_y7slp"] + +[node name="SimpleCircle" type="Node2D"] + +[node name="ComputeShaderStudio2D" type="Node" parent="." node_paths=PackedStringArray("data")] +script = ExtResource("1_rlapi") +glsl_file = "res://examples/simple_circle/simple_circle.cpp" +data = [NodePath("../Icon")] +metadata/_custom_type_script = "uid://c8esqdv0y26yp" + +[node name="Icon" type="Sprite2D" parent="."] +position = Vector2(465.5, 268.5) +scale = Vector2(3.99219, 3.52344) +texture = ExtResource("2_y7slp") From 3d43faec274b6f3224ec939a748d58ef57de7ea1 Mon Sep 17 00:00:00 2001 From: MADI-SOILIHI Date: Thu, 13 Mar 2025 16:14:36 +0100 Subject: [PATCH 10/27] V1 --- examples/example_5.cpp | 19 +++++++++++++------ examples/example_5.tscn | 8 ++++---- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/examples/example_5.cpp b/examples/example_5.cpp index 7d498cd..b3a2bac 100644 --- a/examples/example_5.cpp +++ b/examples/example_5.cpp @@ -7,17 +7,23 @@ void main() { int dy = int(WSY) / 2 - int(y); int d = dx * dx + dy * dy; - int r = int(64.0 * sin(float(step) / 100.0)); // Condition : après 5 secondes (ajuste la valeur selon ton framerate) if (step > 300) { // Après 5 secondes -> Afficher les cercles - int d = int(sqrt(float(dx * dx + dy * dy))); // Distance au centre - int spacing = 30; // Espacement des cercles (réduit) - + float d = sqrt(float(dx * dx + dy * dy)); // Distance au centre + + // Animation des cercles (pulsation) + float amplitude = 10.0; // Amplitude de la pulsation + float vitesse = 0.08; // Vitesse de l'effet + float animatedD = d + amplitude * sin(float(step) * vitesse); + + // Espacement animé des cercles + float spacing = 30.0 + 10.0 * sin(float(step) * 0.1); + // Calcul des cercles noirs avec un motif en anneaux - float rings = mod(float(d), float(spacing)); - bool isBlack = rings < 6.0; // Réduction de l'épaisseur des anneaux noirs + float rings = mod(animatedD, spacing); + bool isBlack = rings < 6.0; // Épaisseur des anneaux noirs if (isBlack) { data_0[p] = 0xFF000000; // Noir @@ -30,3 +36,4 @@ void main() { data_0[p] = 0xFF000000 | (0xFFFFFF - value); // Rendu normal } } + diff --git a/examples/example_5.tscn b/examples/example_5.tscn index b8179a5..f05bc61 100644 --- a/examples/example_5.tscn +++ b/examples/example_5.tscn @@ -31,8 +31,8 @@ horizontal_alignment = 1 vertical_alignment = 1 [node name="TextureRect" type="TextureRect" parent="."] -offset_left = 278.0 -offset_top = 192.0 -offset_right = 975.0 -offset_bottom = 629.0 +offset_left = -10.0 +offset_top = -26.0 +offset_right = 1171.0 +offset_bottom = 667.0 texture = SubResource("NoiseTexture2D_nxi5j") From 052f6d731c69c8eb0ee85c05430bba6ac1c8ef7f Mon Sep 17 00:00:00 2001 From: redalhdd Date: Thu, 13 Mar 2025 16:46:09 +0100 Subject: [PATCH 11/27] =?UTF-8?q?Sharingan=20+=20lumi=C3=A8re?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/project/test.cpp | 21 +++++++++++++++++++-- examples/project/test.tscn | 2 +- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/examples/project/test.cpp b/examples/project/test.cpp index d6cdc23..2598a9f 100644 --- a/examples/project/test.cpp +++ b/examples/project/test.cpp @@ -6,6 +6,8 @@ #define PI 3.14159265359 // Ajout de la définition de PI #define SMALL_DOT_RADIUS 2.0 // Rayon du petit point #define SMALL_DOT_OFFSET 1.0 // Distance du point par rapport au croissant +#define IRIS_BORDER 0.5 // Épaisseur de la bordure de l'iris +#define LIGHT_INTENSITY 0.4 // Intensité de la lumière directionnelle void main() { @@ -21,6 +23,13 @@ void main() float dy = float(mousey - y); float dist = sqrt(dx*dx + dy*dy); + // Calcul de la lumière directionnelle + float lightDirX = 1.0; // Direction X de la lumière (vers la gauche) + float lightDirY = 1.0; // Direction Y de la lumière (vers le haut) + float normalX = dx/dist; + float normalY = dy/dist; + float lightAngle = (lightDirX * normalX + lightDirY * normalY) * 0.5 + 0.5; + // Position des points tournants float angle = float(step) * 0.05f; // Vitesse de rotation float orbit_radius = (IRIS_RADIUS + PUPIL_RADIUS) * 0.5f; // Rayon de l'orbite @@ -72,7 +81,8 @@ void main() float z = sqrt(RADIUS*RADIUS - dist*dist); float normal_z = z/RADIUS; float light = normal_z; - light = clamp(light, 0.2f, 1.0f); + // Combine la lumière ambiante avec la lumière directionnelle + light = clamp(light * (0.7 + lightAngle * LIGHT_INTENSITY), 0.2f, 1.0f); if (dist < PUPIL_RADIUS) { data_0[p] = 0xFF000000; @@ -85,6 +95,9 @@ void main() small_dot2_dist < SMALL_DOT_RADIUS || small_dot3_dist < SMALL_DOT_RADIUS) { data_0[p] = 0xFF000000; + } else if (dist > IRIS_RADIUS - IRIS_BORDER) { + // Bordure de l'iris en noir léger + data_0[p] = 0xFF404040; } else { // Iris rouge avec ombrage int red = int(200.0f * light); @@ -92,7 +105,11 @@ void main() } } else { int value = int(255.0f * light); - data_0[p] = 0xFF000000 | (value << 16) | (value << 8) | value; + // Ajoute une teinte légèrement jaune à la lumière + int red = value; + int green = int(value * 0.95); + int blue = int(value * 0.9); + data_0[p] = 0xFF000000 | (red << 16) | (green << 8) | blue; } } else { data_0[p] = 0xFF000000; diff --git a/examples/project/test.tscn b/examples/project/test.tscn index 4b79a75..969fd3a 100644 --- a/examples/project/test.tscn +++ b/examples/project/test.tscn @@ -12,6 +12,6 @@ data = [NodePath("../Icon")] metadata/_custom_type_script = "uid://c8esqdv0y26yp" [node name="Icon" type="Sprite2D" parent="."] -position = Vector2(570, 331) +position = Vector2(685, 320) scale = Vector2(5.3125, 5.03125) texture = ExtResource("2_gpcd8") From baa20580ce887343306f22a826e46c47059f5169 Mon Sep 17 00:00:00 2001 From: redalhdd Date: Thu, 13 Mar 2025 17:19:02 +0100 Subject: [PATCH 12/27] =?UTF-8?q?Sharingan=20pr=C3=A8s=20pour=20int=C3=A9g?= =?UTF-8?q?ration=20rinnegan?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../compute_shader_studio_2d.gd | 4 ++ examples/project/test.cpp | 55 ++++++++++++++----- examples/project/test.tscn | 6 ++ 3 files changed, 51 insertions(+), 14 deletions(-) diff --git a/addons/compute_shader_studio/compute_shader_studio_2d.gd b/addons/compute_shader_studio/compute_shader_studio_2d.gd index f947c2f..a32ae8c 100644 --- a/addons/compute_shader_studio/compute_shader_studio_2d.gd +++ b/addons/compute_shader_studio/compute_shader_studio_2d.gd @@ -333,3 +333,7 @@ func screen_to_data0(pos : Vector2): return pos; else: return Vector2(0,0) + + +func _on_check_button_button_up() -> void: + pass # Replace with function body. diff --git a/examples/project/test.cpp b/examples/project/test.cpp index 2598a9f..9775122 100644 --- a/examples/project/test.cpp +++ b/examples/project/test.cpp @@ -8,6 +8,10 @@ #define SMALL_DOT_OFFSET 1.0 // Distance du point par rapport au croissant #define IRIS_BORDER 0.5 // Épaisseur de la bordure de l'iris #define LIGHT_INTENSITY 0.4 // Intensité de la lumière directionnelle +#define BLINK_INTERVAL 200 // Intervalle de clignotement (10 secondes à 20fps) +#define BLINK_DURATION 20 // Durée du clignotement (1 seconde) +#define BLINK_SPEED 0.15 // Vitesse de propagation du noir +#define TRANSITION_WIDTH 5.0 // Largeur de la transition du noir void main() { @@ -87,21 +91,44 @@ void main() if (dist < PUPIL_RADIUS) { data_0[p] = 0xFF000000; } else if (dist < IRIS_RADIUS) { - // Points noirs tournants dans l'iris sous forme de croissants - if ((crescent1MainDist < DOT_RADIUS && crescent1SecDist > DOT_RADIUS - 1.0) || - (crescent2MainDist < DOT_RADIUS && crescent2SecDist > DOT_RADIUS - 1.0) || - (crescent3MainDist < DOT_RADIUS && crescent3SecDist > DOT_RADIUS - 1.0) || - small_dot1_dist < SMALL_DOT_RADIUS || - small_dot2_dist < SMALL_DOT_RADIUS || - small_dot3_dist < SMALL_DOT_RADIUS) { - data_0[p] = 0xFF000000; - } else if (dist > IRIS_RADIUS - IRIS_BORDER) { - // Bordure de l'iris en noir léger - data_0[p] = 0xFF404040; + // Vérification si on est dans une période de clignotement + bool is_blinking = (step % BLINK_INTERVAL) < BLINK_DURATION; + + if (is_blinking) { + // Calcul de la propagation du noir + float blink_progress = float(step % BLINK_INTERVAL) * BLINK_SPEED; + float blink_radius = blink_progress * IRIS_RADIUS; + + // Crée une transition douce + float fade = clamp((blink_radius - dist) / TRANSITION_WIDTH, 0.0, 1.0); + + if (dist < blink_radius) { + // Zone noire + data_0[p] = 0xFF000000; + } else if (dist < blink_radius + TRANSITION_WIDTH) { + // Zone de transition + int red = int((1.0 - fade) * 200.0f * light); + data_0[p] = 0xFF000000 | red; + } else { + // Zone normale + int red = int(200.0f * light); + data_0[p] = 0xFF000000 | red; + } } else { - // Iris rouge avec ombrage - int red = int(200.0f * light); - data_0[p] = 0xFF000000 | red; + // Comportement normal de l'iris + if ((crescent1MainDist < DOT_RADIUS && crescent1SecDist > DOT_RADIUS - 1.0) || + (crescent2MainDist < DOT_RADIUS && crescent2SecDist > DOT_RADIUS - 1.0) || + (crescent3MainDist < DOT_RADIUS && crescent3SecDist > DOT_RADIUS - 1.0) || + small_dot1_dist < SMALL_DOT_RADIUS || + small_dot2_dist < SMALL_DOT_RADIUS || + small_dot3_dist < SMALL_DOT_RADIUS) { + data_0[p] = 0xFF000000; + } else if (dist > IRIS_RADIUS - IRIS_BORDER) { + data_0[p] = 0xFF404040; + } else { + int red = int(200.0f * light); + data_0[p] = 0xFF000000 | red; + } } } else { int value = int(255.0f * light); diff --git a/examples/project/test.tscn b/examples/project/test.tscn index 969fd3a..3e46b05 100644 --- a/examples/project/test.tscn +++ b/examples/project/test.tscn @@ -15,3 +15,9 @@ metadata/_custom_type_script = "uid://c8esqdv0y26yp" position = Vector2(685, 320) scale = Vector2(5.3125, 5.03125) texture = ExtResource("2_gpcd8") + +[node name="Button" type="Button" parent="."] +offset_left = 17.0 +offset_top = 36.0 +offset_right = 87.0 +offset_bottom = 58.0 From 0f85a18c4215181d895a2d2fafd1d5bab886bbea Mon Sep 17 00:00:00 2001 From: Clement Nassih Date: Thu, 13 Mar 2025 17:37:30 +0100 Subject: [PATCH 13/27] quadrillage rose --- .vscode/c_cpp_properties.json | 18 ++++ .vscode/launch.json | 24 ++++++ .vscode/settings.json | 59 +++++++++++++ examples/cells/example_cells.tscn | 101 +++++------------------ examples/exampleClement/TestExample.tscn | 18 ++++ examples/exampleClement/background.cpp | 24 ++++++ examples/exampleClement/read.me | 2 +- examples/example_2.tscn | 8 +- examples/example_5.tscn | 4 +- examples/project/ShaderArt.tscn | 27 ++++++ examples/project/base.cpp | 51 ++++++++++++ project.godot | 4 +- 12 files changed, 252 insertions(+), 88 deletions(-) create mode 100644 .vscode/c_cpp_properties.json create mode 100644 .vscode/launch.json create mode 100644 .vscode/settings.json create mode 100644 examples/exampleClement/TestExample.tscn create mode 100644 examples/exampleClement/background.cpp create mode 100644 examples/project/ShaderArt.tscn create mode 100644 examples/project/base.cpp diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json new file mode 100644 index 0000000..c2098a2 --- /dev/null +++ b/.vscode/c_cpp_properties.json @@ -0,0 +1,18 @@ +{ + "configurations": [ + { + "name": "linux-gcc-x64", + "includePath": [ + "${workspaceFolder}/**" + ], + "compilerPath": "/usr/bin/gcc", + "cStandard": "${default}", + "cppStandard": "${default}", + "intelliSenseMode": "linux-gcc-x64", + "compilerArgs": [ + "" + ] + } + ], + "version": 4 +} \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..cb69edc --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,24 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "name": "C/C++ Runner: Debug Session", + "type": "cppdbg", + "request": "launch", + "args": [], + "stopAtEntry": false, + "externalConsole": false, + "cwd": "/media/clem/Transcend/master/m1/s8/AAP/godot/ComputeShaderStudio/examples/exampleClement", + "program": "/media/clem/Transcend/master/m1/s8/AAP/godot/ComputeShaderStudio/examples/exampleClement/build/Debug/outDebug", + "MIMode": "gdb", + "miDebuggerPath": "gdb", + "setupCommands": [ + { + "description": "Enable pretty-printing for gdb", + "text": "-enable-pretty-printing", + "ignoreFailures": true + } + ] + } + ] +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..3e5eb95 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,59 @@ +{ + "C_Cpp_Runner.cCompilerPath": "gcc", + "C_Cpp_Runner.cppCompilerPath": "g++", + "C_Cpp_Runner.debuggerPath": "gdb", + "C_Cpp_Runner.cStandard": "", + "C_Cpp_Runner.cppStandard": "", + "C_Cpp_Runner.msvcBatchPath": "", + "C_Cpp_Runner.useMsvc": false, + "C_Cpp_Runner.warnings": [ + "-Wall", + "-Wextra", + "-Wpedantic", + "-Wshadow", + "-Wformat=2", + "-Wcast-align", + "-Wconversion", + "-Wsign-conversion", + "-Wnull-dereference" + ], + "C_Cpp_Runner.msvcWarnings": [ + "/W4", + "/permissive-", + "/w14242", + "/w14287", + "/w14296", + "/w14311", + "/w14826", + "/w44062", + "/w44242", + "/w14905", + "/w14906", + "/w14263", + "/w44265", + "/w14928" + ], + "C_Cpp_Runner.enableWarnings": true, + "C_Cpp_Runner.warningsAsError": false, + "C_Cpp_Runner.compilerArgs": [], + "C_Cpp_Runner.linkerArgs": [], + "C_Cpp_Runner.includePaths": [], + "C_Cpp_Runner.includeSearch": [ + "*", + "**/*" + ], + "C_Cpp_Runner.excludeSearch": [ + "**/build", + "**/build/**", + "**/.*", + "**/.*/**", + "**/.vscode", + "**/.vscode/**" + ], + "C_Cpp_Runner.useAddressSanitizer": false, + "C_Cpp_Runner.useUndefinedSanitizer": false, + "C_Cpp_Runner.useLeakSanitizer": false, + "C_Cpp_Runner.showCompilationTime": false, + "C_Cpp_Runner.useLinkTimeOptimization": false, + "C_Cpp_Runner.msvcSecureNoWarnings": false +} \ No newline at end of file diff --git a/examples/cells/example_cells.tscn b/examples/cells/example_cells.tscn index 6959c31..65cbd9c 100644 --- a/examples/cells/example_cells.tscn +++ b/examples/cells/example_cells.tscn @@ -1,7 +1,14 @@ -[gd_scene load_steps=3 format=3 uid="uid://cutxgtalwsp6q"] +[gd_scene load_steps=5 format=3 uid="uid://cutxgtalwsp6q"] [ext_resource type="Script" path="res://examples/cells/cells.gd" id="1_dw4h8"] -[ext_resource type="Texture2D" uid="uid://demftcowdd5c6" path="res://examples/icon.svg" id="2_oji6h"] +[ext_resource type="Script" path="res://addons/compute_shader_studio/compute_shader_studio_2d.gd" id="2_6o5l7"] + +[sub_resource type="FastNoiseLite" id="FastNoiseLite_pm7bb"] + +[sub_resource type="NoiseTexture2D" id="NoiseTexture2D_0uqft"] +width = 256 +height = 128 +noise = SubResource("FastNoiseLite_pm7bb") [node name="Cells" type="Control" node_paths=PackedStringArray("data")] layout_mode = 3 @@ -17,83 +24,19 @@ WSY = 256 nb_passes_cyto = 20 nb_passes_memb = 14 glsl_file = "res://examples/cells/example_cells.c" -data = [NodePath("CenterAnchor/Display"), null, null, null, null, null, null, null, null, null, null, null, null] - -[node name="CenterAnchor" type="Control" parent="."] -layout_mode = 1 -anchors_preset = 8 -anchor_left = 0.5 -anchor_top = 0.5 -anchor_right = 0.5 -anchor_bottom = 0.5 -grow_horizontal = 2 -grow_vertical = 2 - -[node name="Display" type="Sprite2D" parent="CenterAnchor"] -texture_filter = 1 -scale = Vector2(4, 4) -texture = ExtResource("2_oji6h") - -[node name="DisplayNormalButton" type="Button" parent="."] -layout_mode = 0 -offset_left = 8.0 -offset_top = 8.0 -offset_right = 248.0 -offset_bottom = 56.0 -text = "Display Regular" - -[node name="DisplayCytoplasmButton" type="Button" parent="."] -layout_mode = 0 -offset_left = 8.0 -offset_top = 72.0 -offset_right = 248.0 -offset_bottom = 120.0 -text = "Display Cytoplasm Field" +data = [null, null, null, null, null, null, null, null, null, null, null, null, null] -[node name="DisplayCytoplasmButton2" type="Button" parent="."] -layout_mode = 0 -offset_left = 8.0 -offset_top = 136.0 -offset_right = 248.0 -offset_bottom = 184.0 -text = "Display Cytoplasm Field (Flat)" +[node name="ComputeShaderStudio2D2" type="Node" parent="." node_paths=PackedStringArray("data")] +script = ExtResource("2_6o5l7") +WSX = 256 +glsl_file = "res://examples/project/base.cpp" +GLSL_code = "" +data = [null] -[node name="DisplayMembranes" type="Button" parent="."] +[node name="TextureRect" type="TextureRect" parent="."] layout_mode = 0 -offset_left = 8.0 -offset_top = 200.0 -offset_right = 248.0 -offset_bottom = 248.0 -text = "Display Membranes" - -[node name="DisplayMembraneField" type="Button" parent="."] -layout_mode = 0 -offset_left = 8.0 -offset_top = 264.0 -offset_right = 248.0 -offset_bottom = 312.0 -text = "Display Membrane Field" - -[node name="RichTextLabel" type="RichTextLabel" parent="."] -layout_mode = 1 -anchors_preset = 11 -anchor_left = 1.0 -anchor_right = 1.0 -anchor_bottom = 1.0 -offset_left = -320.0 -grow_horizontal = 0 -grow_vertical = 2 -theme_override_font_sizes/normal_font_size = 20 -text = "- Step 1: Plop cytoplasm fields at center positions -- Step 2: Diffuse cytoplasm field -- Step 3: At cytoplasm edges, plop membranes -- Step 4: Diffuse membrane field -- Step 5: At centers, push in direction where membrane field is weakest -- Step 6: move centers -- Display & Repeat" - -[connection signal="pressed" from="DisplayNormalButton" to="." method="set_display_normal"] -[connection signal="pressed" from="DisplayCytoplasmButton" to="." method="set_display_cytoplasm"] -[connection signal="pressed" from="DisplayCytoplasmButton2" to="." method="set_display_cytoplasm_flat"] -[connection signal="pressed" from="DisplayMembranes" to="." method="set_display_membranes"] -[connection signal="pressed" from="DisplayMembraneField" to="." method="set_display_membrane_field"] +offset_left = 127.0 +offset_top = 5.0 +offset_right = 824.0 +offset_bottom = 442.0 +texture = SubResource("NoiseTexture2D_0uqft") diff --git a/examples/exampleClement/TestExample.tscn b/examples/exampleClement/TestExample.tscn new file mode 100644 index 0000000..7f592eb --- /dev/null +++ b/examples/exampleClement/TestExample.tscn @@ -0,0 +1,18 @@ +[gd_scene load_steps=3 format=3 uid="uid://ddfhk06k1ymy"] + +[ext_resource type="Script" path="res://addons/compute_shader_studio/compute_shader_studio_2d.gd" id="1_bowy1"] +[ext_resource type="Texture2D" uid="uid://demftcowdd5c6" path="res://examples/icon.svg" id="2_n443p"] + +[node name="background" type="Node2D"] + +[node name="ComputeShaderStudio2D" type="Node" parent="." node_paths=PackedStringArray("data")] +script = ExtResource("1_bowy1") +glsl_file = "res://examples/exampleClement/background.cpp" +GLSL_code = " +" +data = [NodePath("../Sprite2D")] + +[node name="Sprite2D" type="Sprite2D" parent="."] +position = Vector2(369, 246) +scale = Vector2(3.60063, 3.6475) +texture = ExtResource("2_n443p") diff --git a/examples/exampleClement/background.cpp b/examples/exampleClement/background.cpp new file mode 100644 index 0000000..7672891 --- /dev/null +++ b/examples/exampleClement/background.cpp @@ -0,0 +1,24 @@ +// Write your code HERE +void main() { + uint x = gl_GlobalInvocationID.x; + uint y = gl_GlobalInvocationID.y; + uint p = x + y * WSX; + + // Couleur par défaut (noir) + uvec4 color = uvec4(0xFF000000); + + // Créer un quadrillage uniquement dans la moitié inférieure de l'écran + if (y >= WSY / 2) { + // Taille des cellules du quadrillage + uint gridSize = 20; + + // Si on est sur une ligne de la grille + if (x % gridSize == 0 || y % gridSize == 0) { + // Couleur rose fluo pour un effet futuristique + color = uvec4(0xFFFF00FF); // Format ARGB: Rose fluo (FF magenta) + } + } + + // Conversion explicite en int pour résoudre l'erreur de type + data_0[p] = int(color.x); +} diff --git a/examples/exampleClement/read.me b/examples/exampleClement/read.me index dcb2405..7b3fb1d 100644 --- a/examples/exampleClement/read.me +++ b/examples/exampleClement/read.me @@ -1 +1 @@ -test branch \ No newline at end of file +objectif : fond anime akatsuki \ No newline at end of file diff --git a/examples/example_2.tscn b/examples/example_2.tscn index 766e825..7d0ee52 100644 --- a/examples/example_2.tscn +++ b/examples/example_2.tscn @@ -37,10 +37,10 @@ horizontal_alignment = 1 vertical_alignment = 1 [node name="Label2" type="Label" parent="."] -offset_left = 29.0 -offset_top = 76.0 -offset_right = 336.0 -offset_bottom = 405.0 +offset_left = -80.0 +offset_top = 41.0 +offset_right = 227.0 +offset_bottom = 370.0 scale = Vector2(1.72, 1.72) text = "// Select the node ComputeShader // to write your GLSL code diff --git a/examples/example_5.tscn b/examples/example_5.tscn index 43aa420..3567a30 100644 --- a/examples/example_5.tscn +++ b/examples/example_5.tscn @@ -2,12 +2,12 @@ [ext_resource type="Script" path="res://addons/compute_shader_studio/compute_shader_studio_2d.gd" id="1_cogap"] -[sub_resource type="FastNoiseLite" id="FastNoiseLite_pm7bb"] +[sub_resource type="FastNoiseLite" id="FastNoiseLite_ynclj"] [sub_resource type="NoiseTexture2D" id="NoiseTexture2D_nxi5j"] width = 256 height = 128 -noise = SubResource("FastNoiseLite_pm7bb") +noise = SubResource("FastNoiseLite_ynclj") [node name="CompShadStudioEx5" type="Node2D"] diff --git a/examples/project/ShaderArt.tscn b/examples/project/ShaderArt.tscn new file mode 100644 index 0000000..2f15e7c --- /dev/null +++ b/examples/project/ShaderArt.tscn @@ -0,0 +1,27 @@ +[gd_scene load_steps=4 format=3 uid="uid://p4vy0fyno8jo"] + +[ext_resource type="Script" path="res://addons/compute_shader_studio/compute_shader_studio_2d.gd" id="1_m38we"] + +[sub_resource type="FastNoiseLite" id="FastNoiseLite_laku3"] + +[sub_resource type="NoiseTexture2D" id="NoiseTexture2D_lb5ai"] +width = 256 +height = 128 +noise = SubResource("FastNoiseLite_laku3") + +[node name="ShaderArt" type="Node2D"] + +[node name="TextureRect" type="TextureRect" parent="."] +offset_left = 169.0 +offset_top = 32.0 +offset_right = 866.0 +offset_bottom = 469.0 +texture = SubResource("NoiseTexture2D_lb5ai") +metadata/_edit_use_anchors_ = true + +[node name="ComputeShaderStudio2D2" type="Node" parent="." node_paths=PackedStringArray("data")] +script = ExtResource("1_m38we") +WSX = 256 +glsl_file = "res://examples/project/base.cpp" +GLSL_code = "" +data = [null] diff --git a/examples/project/base.cpp b/examples/project/base.cpp new file mode 100644 index 0000000..d5f1d8c --- /dev/null +++ b/examples/project/base.cpp @@ -0,0 +1,51 @@ +/* This animation is the material of my first youtube tutorial about creative + coding, which is a video in which I try to introduce programmers to GLSL + and to the wonderful world of shaders, while also trying to share my recent + passion for this community. + Video URL: https://youtu.be/f4s1h2YETNY +*/ + +//https://iquilezles.org/articles/palettes/ + +uniform vec3 iResolution; // viewport resolution (in pixels) +uniform float iTime; // shader playback time (in seconds) +uniform float iTimeDelta; // render time (in seconds) +uniform float iFrameRate; // shader frame rate +uniform int iFrame; // shader playback frame +uniform float iChannelTime[4]; // channel playback time (in seconds) +uniform vec3 iChannelResolution[4]; // channel resolution (in pixels) +uniform vec4 iMouse; // mouse pixel coords. xy: current (if MLB down), zw: click +uniform samplerXX iChannel0..3; // input channel. XX = 2D/Cube + +vec3 palette( float t ) { + vec3 a = vec3(0.5, 0.5, 0.5); + vec3 b = vec3(0.5, 0.5, 0.5); + vec3 c = vec3(1.0, 1.0, 1.0); + vec3 d = vec3(0.263,0.416,0.557); + + return a + b*cos( 6.28318*(c*t+d) ); +} + +//https://www.shadertoy.com/view/mtyGWy +void mainImage( out vec4 fragColor, in vec2 fragCoord ) { + vec2 uv = (fragCoord * 2.0 - iResolution.xy) / iResolution.y; + vec2 uv0 = uv; + vec3 finalColor = vec3(0.0); + + for (float i = 0.0; i < 4.0; i++) { + uv = fract(uv * 1.5) - 0.5; + + float d = length(uv) * exp(-length(uv0)); + + vec3 col = palette(length(uv0) + i*.4 + iTime*.4); + + d = sin(d*8. + iTime)/8.; + d = abs(d); + + d = pow(0.01 / d, 1.2); + + finalColor += col * d; + } + + fragColor = vec4(finalColor, 1.0); +} \ No newline at end of file diff --git a/project.godot b/project.godot index 498f9b7..4b4d8ef 100644 --- a/project.godot +++ b/project.godot @@ -11,10 +11,10 @@ config_version=5 [application] config/name="compute_shader_studio" -run/main_scene="res://examples/example_5.tscn" +run/main_scene="res://examples/exampleClement/TestExample.tscn" config/features=PackedStringArray("4.3", "Forward Plus") config/icon="res://addons/compute_shader_studio/icon.png" [editor_plugins] -enabled=PackedStringArray() +enabled=PackedStringArray("res://addons/compute_shader_studio/plugin.cfg") From 6b0a219b5ea66d2a6b4d551189faeca202466596 Mon Sep 17 00:00:00 2001 From: Clement Nassih Date: Thu, 13 Mar 2025 17:56:59 +0100 Subject: [PATCH 14/27] quadrillage rose point de fuite --- examples/exampleClement/background.cpp | 33 +++++++++++++++++++++----- 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/examples/exampleClement/background.cpp b/examples/exampleClement/background.cpp index 7672891..de66d73 100644 --- a/examples/exampleClement/background.cpp +++ b/examples/exampleClement/background.cpp @@ -7,15 +7,36 @@ void main() { // Couleur par défaut (noir) uvec4 color = uvec4(0xFF000000); - // Créer un quadrillage uniquement dans la moitié inférieure de l'écran + // Créer un quadrillage avec effet de perspective dans la moitié inférieure if (y >= WSY / 2) { - // Taille des cellules du quadrillage - uint gridSize = 20; + // Point de fuite au centre horizontal, en haut de la zone du quadrillage + float vanishX = WSX / 2.0; + float vanishY = WSY / 2.0; - // Si on est sur une ligne de la grille - if (x % gridSize == 0 || y % gridSize == 0) { + // Calculer les coordonnées relatives au point de fuite + float dx = float(x) - vanishX; + float dy = float(y) - vanishY; + + // Calculer la distance par rapport au point de fuite + float dist = sqrt(dx*dx + dy*dy); + + // Créer les lignes horizontales (parallèles à l'axe X) + float lineSpacing = 20.0; + float distMod = mod(dist, lineSpacing); + + // Créer les lignes radiales (partant du point de fuite) + float radialSpacing = 3.14159 / 15.0; // Environ 12 degrés entre les lignes + float angle = atan(dx, dy); // En radians + float angleMod = mod(angle, radialSpacing); + + // Dessiner les lignes avec une épaisseur qui diminue avec la distance + float lineThickness = max(1.0, 3.0 - dist / 100.0); + + if (distMod < lineThickness || angleMod < 0.02 || angleMod > radialSpacing - 0.02) { // Couleur rose fluo pour un effet futuristique - color = uvec4(0xFFFF00FF); // Format ARGB: Rose fluo (FF magenta) + uint alpha = 0xFF; + uint intensity = 0xFF00FF; // Rose fluo + color = uvec4((alpha << 24) | intensity); } } From 2b4cc761308a8eaad312cc9ac5852fd1aa456f9d Mon Sep 17 00:00:00 2001 From: Clement Nassih Date: Thu, 13 Mar 2025 18:22:41 +0100 Subject: [PATCH 15/27] antialiasing + mailles fines --- examples/exampleClement/background.cpp | 55 ++++++++++++++++++++------ 1 file changed, 44 insertions(+), 11 deletions(-) diff --git a/examples/exampleClement/background.cpp b/examples/exampleClement/background.cpp index de66d73..2f1af6f 100644 --- a/examples/exampleClement/background.cpp +++ b/examples/exampleClement/background.cpp @@ -20,26 +20,59 @@ void main() { // Calculer la distance par rapport au point de fuite float dist = sqrt(dx*dx + dy*dy); - // Créer les lignes horizontales (parallèles à l'axe X) - float lineSpacing = 20.0; + // Créer les lignes horizontales (parallèles à l'axe X) - mailles plus fines + float lineSpacing = 15.0; // Espacement réduit pour des mailles plus fines float distMod = mod(dist, lineSpacing); - // Créer les lignes radiales (partant du point de fuite) - float radialSpacing = 3.14159 / 15.0; // Environ 12 degrés entre les lignes + // Créer les lignes radiales (partant du point de fuite) - plus nombreuses + float radialSpacing = 3.14159 / 36.0; // Doublement du nombre de lignes radiales float angle = atan(dx, dy); // En radians float angleMod = mod(angle, radialSpacing); - // Dessiner les lignes avec une épaisseur qui diminue avec la distance - float lineThickness = max(1.0, 3.0 - dist / 100.0); + // Anti-aliasing amélioré pour les lignes + // Largeur de ligne qui diminue avec la distance + float baseThickness = 1.0; // Ligne plus fine + float lineThickness = max(0.3, baseThickness - dist / 400.0); - if (distMod < lineThickness || angleMod < 0.02 || angleMod > radialSpacing - 0.02) { - // Couleur rose fluo pour un effet futuristique + // Calculer l'intensité pour un effet de dégradé (anti-aliasing amélioré) + float lineIntensity = 0.0; + float radialIntensity = 0.0; + + // Anti-aliasing doux pour les lignes horizontales + float fadeWidth = 1.0; // Zone de transition adaptée aux lignes plus fines + if (distMod < lineThickness) { + lineIntensity = 1.0; + } else if (distMod < lineThickness + fadeWidth) { + // Fonction de lissage cubique pour une transition plus douce + float t = (distMod - lineThickness) / fadeWidth; + lineIntensity = 1.0 - (t * t * (3.0 - 2.0 * t)); + } + + // Anti-aliasing doux pour les lignes radiales + float radialEdge = 0.03 + 0.01 * (dist / 300.0); // Zone de transition adaptée + if (angleMod < radialEdge) { + // Transition douce près du bord + float t = angleMod / radialEdge; + radialIntensity = 1.0 - (t * t * (3.0 - 2.0 * t)); + } else if (angleMod > radialSpacing - radialEdge) { + // Transition douce près du bord opposé + float t = (radialSpacing - angleMod) / radialEdge; + radialIntensity = 1.0 - (t * t * (3.0 - 2.0 * t)); + } + + // Utiliser l'intensité maximale entre les deux types de lignes + float finalIntensity = max(lineIntensity, radialIntensity); + + if (finalIntensity > 0.0) { + // Couleur rose fluo pour un effet futuristique, avec intensité variable uint alpha = 0xFF; - uint intensity = 0xFF00FF; // Rose fluo - color = uvec4((alpha << 24) | intensity); + uint r = uint(min(255.0, 230.0 * finalIntensity)); + uint b = uint(min(255.0, 255.0 * finalIntensity)); + uint g = uint(min(255.0, 50.0 * finalIntensity)); // Un peu de vert pour plus de profondeur + color = uvec4((alpha << 24) | (r << 16) | (g << 8) | b); } } // Conversion explicite en int pour résoudre l'erreur de type data_0[p] = int(color.x); -} +} \ No newline at end of file From 0763b5b3d11e3efda280f7f8bf03b5181b198c1e Mon Sep 17 00:00:00 2001 From: Clement Nassih Date: Mon, 17 Mar 2025 09:03:32 +0100 Subject: [PATCH 16/27] changement background flames minimalistes --- examples/exampleClement/background.cpp | 128 ++++++++++++------------- 1 file changed, 60 insertions(+), 68 deletions(-) diff --git a/examples/exampleClement/background.cpp b/examples/exampleClement/background.cpp index 2f1af6f..a48ea48 100644 --- a/examples/exampleClement/background.cpp +++ b/examples/exampleClement/background.cpp @@ -1,78 +1,70 @@ -// Write your code HERE +float random(vec2 st) { + return fract(sin(dot(st.xy, vec2(12.9898, 78.233))) * 43758.5453123); +} + +// inspiré par le background shadertoy suivant : https://www.shadertoy.com/view/Wf2GDt +float noise(vec2 st) { + vec2 i = floor(st); + vec2 f = fract(st); + + // Quatre coins du carré + float a = random(i); + float b = random(i + vec2(1.0, 0.0)); + float c = random(i + vec2(0.0, 1.0)); + float d = random(i + vec2(1.0, 1.0)); + + // Interpolation lisse + vec2 u = f * f * (3.0 - 2.0 * f); + + return mix(a, b, u.x) + + (c - a) * u.y * (1.0 - u.x) + + (d - b) * u.x * u.y; +} + void main() { uint x = gl_GlobalInvocationID.x; uint y = gl_GlobalInvocationID.y; uint p = x + y * WSX; - // Couleur par défaut (noir) - uvec4 color = uvec4(0xFF000000); + // Variables équivalentes à celles de ShaderToy + float iTime = step / 10.0; // Utilisation de step au lieu de iTime + vec2 fragCoord = vec2(float(x), float(y)); + vec2 iResolution = vec2(float(WSX), float(WSY)); + vec4 fragColor = vec4(0.0); + + // Conversion du code shadertoy + float t = iTime / 10.0; + + vec2 pos = 100.0 * fragCoord/(iResolution.xy); + float yPos = pos.y/100.0; + pos.y += sin(2.0*t); + pos.x += cos(5.0*t); + pos *= mat2(sin(t/2.0),-cos(t/2.0),cos(t/2.0),sin(t/2.0))/8.0; - // Créer un quadrillage avec effet de perspective dans la moitié inférieure - if (y >= WSY / 2) { - // Point de fuite au centre horizontal, en haut de la zone du quadrillage - float vanishX = WSX / 2.0; - float vanishY = WSY / 2.0; - - // Calculer les coordonnées relatives au point de fuite - float dx = float(x) - vanishX; - float dy = float(y) - vanishY; - - // Calculer la distance par rapport au point de fuite - float dist = sqrt(dx*dx + dy*dy); - - // Créer les lignes horizontales (parallèles à l'axe X) - mailles plus fines - float lineSpacing = 15.0; // Espacement réduit pour des mailles plus fines - float distMod = mod(dist, lineSpacing); - - // Créer les lignes radiales (partant du point de fuite) - plus nombreuses - float radialSpacing = 3.14159 / 36.0; // Doublement du nombre de lignes radiales - float angle = atan(dx, dy); // En radians - float angleMod = mod(angle, radialSpacing); - - // Anti-aliasing amélioré pour les lignes - // Largeur de ligne qui diminue avec la distance - float baseThickness = 1.0; // Ligne plus fine - float lineThickness = max(0.3, baseThickness - dist / 400.0); - - // Calculer l'intensité pour un effet de dégradé (anti-aliasing amélioré) - float lineIntensity = 0.0; - float radialIntensity = 0.0; - - // Anti-aliasing doux pour les lignes horizontales - float fadeWidth = 1.0; // Zone de transition adaptée aux lignes plus fines - if (distMod < lineThickness) { - lineIntensity = 1.0; - } else if (distMod < lineThickness + fadeWidth) { - // Fonction de lissage cubique pour une transition plus douce - float t = (distMod - lineThickness) / fadeWidth; - lineIntensity = 1.0 - (t * t * (3.0 - 2.0 * t)); - } - - // Anti-aliasing doux pour les lignes radiales - float radialEdge = 0.03 + 0.01 * (dist / 300.0); // Zone de transition adaptée - if (angleMod < radialEdge) { - // Transition douce près du bord - float t = angleMod / radialEdge; - radialIntensity = 1.0 - (t * t * (3.0 - 2.0 * t)); - } else if (angleMod > radialSpacing - radialEdge) { - // Transition douce près du bord opposé - float t = (radialSpacing - angleMod) / radialEdge; - radialIntensity = 1.0 - (t * t * (3.0 - 2.0 * t)); - } - - // Utiliser l'intensité maximale entre les deux types de lignes - float finalIntensity = max(lineIntensity, radialIntensity); - - if (finalIntensity > 0.0) { - // Couleur rose fluo pour un effet futuristique, avec intensité variable - uint alpha = 0xFF; - uint r = uint(min(255.0, 230.0 * finalIntensity)); - uint b = uint(min(255.0, 255.0 * finalIntensity)); - uint g = uint(min(255.0, 50.0 * finalIntensity)); // Un peu de vert pour plus de profondeur - color = uvec4((alpha << 24) | (r << 16) | (g << 8) | b); - } + // Boucle de l'effet de fractale + for (float i = 0.0; i < 8.0; i++) { + fragColor = cos(pos.xxxx*0.3)*0.5+0.5; + float n = noise(pos/5.0); + fragColor *= n; + pos.x += sin(pos.y + iTime*0.3 + i); + pos *= mat2(6.0,-8.0,8.0,6.0)/8.0; } - // Conversion explicite en int pour résoudre l'erreur de type + // Fade vertical + fragColor *= 1.0 - smoothstep(0.0, 0.91, yPos); + + // Teinte bleue + fragColor *= vec4(0.2, 0.23, 0.54, 1.0); + + // Conversion de la couleur au format requis par le buffer + uint r = uint(min(255.0, fragColor.r * 255.0)); + uint g = uint(min(255.0, fragColor.g * 255.0)); + uint b = uint(min(255.0, fragColor.b * 255.0)); + uint alpha = 0xFF; + + // Construction de la couleur finale + uvec4 color = uvec4((alpha << 24) | (r << 16) | (g << 8) | b); + + // Écriture dans le buffer data_0[p] = int(color.x); } \ No newline at end of file From f0dd73196b2b5224edb06c9962bd5d6138a279ea Mon Sep 17 00:00:00 2001 From: Clement Nassih Date: Mon, 17 Mar 2025 09:07:11 +0100 Subject: [PATCH 17/27] comment flammes --- examples/exampleClement/background.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/exampleClement/background.cpp b/examples/exampleClement/background.cpp index a48ea48..43f58f7 100644 --- a/examples/exampleClement/background.cpp +++ b/examples/exampleClement/background.cpp @@ -26,8 +26,8 @@ void main() { uint y = gl_GlobalInvocationID.y; uint p = x + y * WSX; - // Variables équivalentes à celles de ShaderToy - float iTime = step / 10.0; // Utilisation de step au lieu de iTime + //variable time basé sur la variable step de computeShaderStudio + float iTime = step / 10.0; vec2 fragCoord = vec2(float(x), float(y)); vec2 iResolution = vec2(float(WSX), float(WSY)); vec4 fragColor = vec4(0.0); @@ -53,7 +53,7 @@ void main() { // Fade vertical fragColor *= 1.0 - smoothstep(0.0, 0.91, yPos); - // Teinte bleue + // Teinte rouge fragColor *= vec4(0.2, 0.23, 0.54, 1.0); // Conversion de la couleur au format requis par le buffer From 086e9ac70dedffbbe04465b39f1aff05c3f2284e Mon Sep 17 00:00:00 2001 From: redalhdd Date: Mon, 17 Mar 2025 09:10:19 +0100 Subject: [PATCH 18/27] Sharingan + Rinnegan --- .gitattributes | 0 .gitignore | 0 LICENSE | 0 README.md | 0 .../compute_shader_studio_2d.gd | 0 .../compute_shader_studio_2d.gd.uid | 1 + .../compute_shader_studio_plugin.gd | 0 addons/compute_shader_studio/icon.png | Bin addons/compute_shader_studio/icon.png.import | 0 addons/compute_shader_studio/plugin.cfg | 0 doc/ComputeShaderStudio.pdf | Bin examples/LabelStepPass.gd | 0 examples/cells/cells.gd | 0 examples/cells/example_cells.c | 0 examples/circles/circles.cpp | 0 examples/circles/circles.tscn | 0 examples/example_1.cpp | 0 examples/example_1.glsl.import | 0 examples/example_5.cpp | 0 examples/example_mandelbrot.gd | 0 examples/example_mandelbrot.tscn | 0 examples/example_psycho_seizure.tscn | 0 examples/grid_512x512.png | Bin examples/grid_512x512.png.import | 0 examples/grid_image_licence.txt | 0 examples/icon.svg | 0 examples/icon.svg.import | 0 examples/lenia.cpp | 0 examples/project/project.cpp | 0 examples/project/project.tscn | 0 examples/project/test.cpp | 140 ++++++++++++++---- examples/project/test.tscn | 6 - examples/simple circle/simple_circle.cpp | 0 examples/simple circle/simple_circle.tscn | 0 node_2d.tscn | 2 +- screenshots/.DS_Store | Bin screenshots/.gdignore | 0 screenshots/compute_shader_studio_ex2.png | Bin .../compute_shader_studio_ext_glsl.png | Bin .../compute_shader_studio_headline.png | Bin .../compute_shader_studio_mandelbrot.png | Bin 41 files changed, 111 insertions(+), 38 deletions(-) mode change 100644 => 100755 .gitattributes mode change 100644 => 100755 .gitignore mode change 100644 => 100755 LICENSE mode change 100644 => 100755 README.md mode change 100644 => 100755 addons/compute_shader_studio/compute_shader_studio_2d.gd create mode 100755 addons/compute_shader_studio/compute_shader_studio_2d.gd.uid mode change 100644 => 100755 addons/compute_shader_studio/compute_shader_studio_plugin.gd mode change 100644 => 100755 addons/compute_shader_studio/icon.png mode change 100644 => 100755 addons/compute_shader_studio/icon.png.import mode change 100644 => 100755 addons/compute_shader_studio/plugin.cfg mode change 100644 => 100755 doc/ComputeShaderStudio.pdf mode change 100644 => 100755 examples/LabelStepPass.gd mode change 100644 => 100755 examples/cells/cells.gd mode change 100644 => 100755 examples/cells/example_cells.c mode change 100644 => 100755 examples/circles/circles.cpp mode change 100644 => 100755 examples/circles/circles.tscn mode change 100644 => 100755 examples/example_1.cpp mode change 100644 => 100755 examples/example_1.glsl.import mode change 100644 => 100755 examples/example_5.cpp mode change 100644 => 100755 examples/example_mandelbrot.gd mode change 100644 => 100755 examples/example_mandelbrot.tscn mode change 100644 => 100755 examples/example_psycho_seizure.tscn mode change 100644 => 100755 examples/grid_512x512.png mode change 100644 => 100755 examples/grid_512x512.png.import mode change 100644 => 100755 examples/grid_image_licence.txt mode change 100644 => 100755 examples/icon.svg mode change 100644 => 100755 examples/icon.svg.import mode change 100644 => 100755 examples/lenia.cpp mode change 100644 => 100755 examples/project/project.cpp mode change 100644 => 100755 examples/project/project.tscn mode change 100644 => 100755 examples/project/test.cpp mode change 100644 => 100755 examples/simple circle/simple_circle.cpp mode change 100644 => 100755 examples/simple circle/simple_circle.tscn mode change 100644 => 100755 node_2d.tscn mode change 100644 => 100755 screenshots/.DS_Store mode change 100644 => 100755 screenshots/.gdignore mode change 100644 => 100755 screenshots/compute_shader_studio_ex2.png mode change 100644 => 100755 screenshots/compute_shader_studio_ext_glsl.png mode change 100644 => 100755 screenshots/compute_shader_studio_headline.png mode change 100644 => 100755 screenshots/compute_shader_studio_mandelbrot.png diff --git a/.gitattributes b/.gitattributes old mode 100644 new mode 100755 diff --git a/.gitignore b/.gitignore old mode 100644 new mode 100755 diff --git a/LICENSE b/LICENSE old mode 100644 new mode 100755 diff --git a/README.md b/README.md old mode 100644 new mode 100755 diff --git a/addons/compute_shader_studio/compute_shader_studio_2d.gd b/addons/compute_shader_studio/compute_shader_studio_2d.gd old mode 100644 new mode 100755 diff --git a/addons/compute_shader_studio/compute_shader_studio_2d.gd.uid b/addons/compute_shader_studio/compute_shader_studio_2d.gd.uid new file mode 100755 index 0000000..26dc406 --- /dev/null +++ b/addons/compute_shader_studio/compute_shader_studio_2d.gd.uid @@ -0,0 +1 @@ +uid://db1v1hi4hf174 diff --git a/addons/compute_shader_studio/compute_shader_studio_plugin.gd b/addons/compute_shader_studio/compute_shader_studio_plugin.gd old mode 100644 new mode 100755 diff --git a/addons/compute_shader_studio/icon.png b/addons/compute_shader_studio/icon.png old mode 100644 new mode 100755 diff --git a/addons/compute_shader_studio/icon.png.import b/addons/compute_shader_studio/icon.png.import old mode 100644 new mode 100755 diff --git a/addons/compute_shader_studio/plugin.cfg b/addons/compute_shader_studio/plugin.cfg old mode 100644 new mode 100755 diff --git a/doc/ComputeShaderStudio.pdf b/doc/ComputeShaderStudio.pdf old mode 100644 new mode 100755 diff --git a/examples/LabelStepPass.gd b/examples/LabelStepPass.gd old mode 100644 new mode 100755 diff --git a/examples/cells/cells.gd b/examples/cells/cells.gd old mode 100644 new mode 100755 diff --git a/examples/cells/example_cells.c b/examples/cells/example_cells.c old mode 100644 new mode 100755 diff --git a/examples/circles/circles.cpp b/examples/circles/circles.cpp old mode 100644 new mode 100755 diff --git a/examples/circles/circles.tscn b/examples/circles/circles.tscn old mode 100644 new mode 100755 diff --git a/examples/example_1.cpp b/examples/example_1.cpp old mode 100644 new mode 100755 diff --git a/examples/example_1.glsl.import b/examples/example_1.glsl.import old mode 100644 new mode 100755 diff --git a/examples/example_5.cpp b/examples/example_5.cpp old mode 100644 new mode 100755 diff --git a/examples/example_mandelbrot.gd b/examples/example_mandelbrot.gd old mode 100644 new mode 100755 diff --git a/examples/example_mandelbrot.tscn b/examples/example_mandelbrot.tscn old mode 100644 new mode 100755 diff --git a/examples/example_psycho_seizure.tscn b/examples/example_psycho_seizure.tscn old mode 100644 new mode 100755 diff --git a/examples/grid_512x512.png b/examples/grid_512x512.png old mode 100644 new mode 100755 diff --git a/examples/grid_512x512.png.import b/examples/grid_512x512.png.import old mode 100644 new mode 100755 diff --git a/examples/grid_image_licence.txt b/examples/grid_image_licence.txt old mode 100644 new mode 100755 diff --git a/examples/icon.svg b/examples/icon.svg old mode 100644 new mode 100755 diff --git a/examples/icon.svg.import b/examples/icon.svg.import old mode 100644 new mode 100755 diff --git a/examples/lenia.cpp b/examples/lenia.cpp old mode 100644 new mode 100755 diff --git a/examples/project/project.cpp b/examples/project/project.cpp old mode 100644 new mode 100755 diff --git a/examples/project/project.tscn b/examples/project/project.tscn old mode 100644 new mode 100755 diff --git a/examples/project/test.cpp b/examples/project/test.cpp old mode 100644 new mode 100755 index 9775122..8d94c87 --- a/examples/project/test.cpp +++ b/examples/project/test.cpp @@ -12,6 +12,16 @@ #define BLINK_DURATION 20 // Durée du clignotement (1 seconde) #define BLINK_SPEED 0.15 // Vitesse de propagation du noir #define TRANSITION_WIDTH 5.0 // Largeur de la transition du noir +#define ANIMATION_INTERVAL 300 // 5 secondes à 60fps +#define PULSE_AMPLITUDE 10.0 +#define PULSE_SPEED 0.08 +#define RING_SPACING 20.0 // Espacement entre les cercles +#define RING_THICKNESS 4.0 // Épaisseur des cercles +#define SPACING_VARIATION 10.0 +#define WAVE_SPEED 0.15 // Augmentation de la vitesse de propagation (anciennement 0.05) +#define TRANSITION_DURATION 60.0 // Durée de la transition en frames +#define MAX_TRANSITION_RADIUS 60.0 // Rayon maximum du cercle de transition +#define TRANSITION_OUT_START (ANIMATION_INTERVAL - TRANSITION_DURATION) void main() { @@ -85,37 +95,106 @@ void main() float z = sqrt(RADIUS*RADIUS - dist*dist); float normal_z = z/RADIUS; float light = normal_z; - // Combine la lumière ambiante avec la lumière directionnelle light = clamp(light * (0.7 + lightAngle * LIGHT_INTENSITY), 0.2f, 1.0f); - if (dist < PUPIL_RADIUS) { - data_0[p] = 0xFF000000; - } else if (dist < IRIS_RADIUS) { - // Vérification si on est dans une période de clignotement - bool is_blinking = (step % BLINK_INTERVAL) < BLINK_DURATION; + // Alternance entre les animations + bool usePulsingAnimation = ((step / ANIMATION_INTERVAL) % 2) == 1; + + if (usePulsingAnimation) { + float d = sqrt(dx * dx + dy * dy); + float cycleStart = float(step % ANIMATION_INTERVAL); - if (is_blinking) { - // Calcul de la propagation du noir - float blink_progress = float(step % BLINK_INTERVAL) * BLINK_SPEED; - float blink_radius = blink_progress * IRIS_RADIUS; + // Gestion des transitions + if (cycleStart < TRANSITION_DURATION) { + // Transition d'entrée (comme avant) + float transitionRadius = (cycleStart / TRANSITION_DURATION) * MAX_TRANSITION_RADIUS; - // Crée une transition douce - float fade = clamp((blink_radius - dist) / TRANSITION_WIDTH, 0.0, 1.0); + if (d < transitionRadius) { + // Nouvelle animation + float animatedD = d - float(step) * WAVE_SPEED; + float rings = mod(animatedD, RING_SPACING); + + if (rings < RING_THICKNESS) { + data_0[p] = 0xFF000000; + } else { + int value = int(255.0f * light); + int red = int(180.0f * light); // Augmenté de 128 à 180 + int green = 0; + int blue = int(180.0f * light); // Augmenté de 128 à 180 + data_0[p] = 0xFF000000 | (red << 16) | (green << 8) | blue; + } + } else { + // Animation normale + if (dist < PUPIL_RADIUS) { + data_0[p] = 0xFF000000; + } + // ...reste du code de l'animation normale... + } + } else if (cycleStart > TRANSITION_OUT_START) { + // Transition de sortie + float transitionOutProgress = (cycleStart - TRANSITION_OUT_START) / TRANSITION_DURATION; + float fadeRadius = (1.0 - transitionOutProgress) * MAX_TRANSITION_RADIUS; - if (dist < blink_radius) { - // Zone noire - data_0[p] = 0xFF000000; - } else if (dist < blink_radius + TRANSITION_WIDTH) { - // Zone de transition - int red = int((1.0 - fade) * 200.0f * light); - data_0[p] = 0xFF000000 | red; + if (d < fadeRadius) { + // Zone encore visible de l'animation des cercles + float animatedD = d - float(step) * WAVE_SPEED; + float rings = mod(animatedD, RING_SPACING); + + if (rings < RING_THICKNESS) { + data_0[p] = 0xFF000000; + } else { + int value = int(255.0f * light); + int red = int(180.0f * light); // Augmenté de 128 à 180 + int green = 0; + int blue = int(180.0f * light); // Augmenté de 128 à 180 + data_0[p] = 0xFF000000 | (red << 16) | (green << 8) | blue; + } } else { - // Zone normale - int red = int(200.0f * light); - data_0[p] = 0xFF000000 | red; + // Zone qui revient à l'animation normale + if (dist < PUPIL_RADIUS) { + data_0[p] = 0xFF000000; + } else if (dist < IRIS_RADIUS) { + if ((crescent1MainDist < DOT_RADIUS && crescent1SecDist > DOT_RADIUS - 1.0) || + (crescent2MainDist < DOT_RADIUS && crescent2SecDist > DOT_RADIUS - 1.0) || + (crescent3MainDist < DOT_RADIUS && crescent3SecDist > DOT_RADIUS - 1.0) || + small_dot1_dist < SMALL_DOT_RADIUS || + small_dot2_dist < SMALL_DOT_RADIUS || + small_dot3_dist < SMALL_DOT_RADIUS) { + data_0[p] = 0xFF000000; + } else if (dist > IRIS_RADIUS - IRIS_BORDER) { + data_0[p] = 0xFF404040; + } else { + int red = int(200.0f * light); + data_0[p] = 0xFF000000 | red; + } + } else { + int value = int(255.0f * light); + int red = value; + int green = int(value * 0.95); + int blue = int(value * 0.9); + data_0[p] = 0xFF000000 | (red << 16) | (green << 8) | blue; + } } } else { - // Comportement normal de l'iris + // Animation complète des cercles (entre les deux transitions) + float animatedD = d - float(step) * WAVE_SPEED; + float rings = mod(animatedD, RING_SPACING); + + if (rings < RING_THICKNESS) { + data_0[p] = 0xFF000000; + } else { + int value = int(255.0f * light); + int red = int(180.0f * light); // Augmenté de 128 à 180 + int green = 0; + int blue = int(180.0f * light); // Augmenté de 128 à 180 + data_0[p] = 0xFF000000 | (red << 16) | (green << 8) | blue; + } + } + } else { + // Animation normale + if (dist < PUPIL_RADIUS) { + data_0[p] = 0xFF000000; + } else if (dist < IRIS_RADIUS) { if ((crescent1MainDist < DOT_RADIUS && crescent1SecDist > DOT_RADIUS - 1.0) || (crescent2MainDist < DOT_RADIUS && crescent2SecDist > DOT_RADIUS - 1.0) || (crescent3MainDist < DOT_RADIUS && crescent3SecDist > DOT_RADIUS - 1.0) || @@ -129,17 +208,16 @@ void main() int red = int(200.0f * light); data_0[p] = 0xFF000000 | red; } + } else { + int value = int(255.0f * light); + int red = value; + int green = int(value * 0.95); + int blue = int(value * 0.9); + data_0[p] = 0xFF000000 | (red << 16) | (green << 8) | blue; } - } else { - int value = int(255.0f * light); - // Ajoute une teinte légèrement jaune à la lumière - int red = value; - int green = int(value * 0.95); - int blue = int(value * 0.9); - data_0[p] = 0xFF000000 | (red << 16) | (green << 8) | blue; } } else { - data_0[p] = 0xFF000000; + data_0[p] = 0xFF404040; // Fond gris moyen au lieu de gris foncé } } } diff --git a/examples/project/test.tscn b/examples/project/test.tscn index 3e46b05..969fd3a 100644 --- a/examples/project/test.tscn +++ b/examples/project/test.tscn @@ -15,9 +15,3 @@ metadata/_custom_type_script = "uid://c8esqdv0y26yp" position = Vector2(685, 320) scale = Vector2(5.3125, 5.03125) texture = ExtResource("2_gpcd8") - -[node name="Button" type="Button" parent="."] -offset_left = 17.0 -offset_top = 36.0 -offset_right = 87.0 -offset_bottom = 58.0 diff --git a/examples/simple circle/simple_circle.cpp b/examples/simple circle/simple_circle.cpp old mode 100644 new mode 100755 diff --git a/examples/simple circle/simple_circle.tscn b/examples/simple circle/simple_circle.tscn old mode 100644 new mode 100755 diff --git a/node_2d.tscn b/node_2d.tscn old mode 100644 new mode 100755 index 76e5bf8..bf99e3c --- a/node_2d.tscn +++ b/node_2d.tscn @@ -1,3 +1,3 @@ -[gd_scene format=3 uid="uid://dyux3ncnsf1xc"] +[gd_scene load_steps=0 format=3 uid="uid://dyux3ncnsf1xc"] [node name="Node2D" type="Node2D"] diff --git a/screenshots/.DS_Store b/screenshots/.DS_Store old mode 100644 new mode 100755 diff --git a/screenshots/.gdignore b/screenshots/.gdignore old mode 100644 new mode 100755 diff --git a/screenshots/compute_shader_studio_ex2.png b/screenshots/compute_shader_studio_ex2.png old mode 100644 new mode 100755 diff --git a/screenshots/compute_shader_studio_ext_glsl.png b/screenshots/compute_shader_studio_ext_glsl.png old mode 100644 new mode 100755 diff --git a/screenshots/compute_shader_studio_headline.png b/screenshots/compute_shader_studio_headline.png old mode 100644 new mode 100755 diff --git a/screenshots/compute_shader_studio_mandelbrot.png b/screenshots/compute_shader_studio_mandelbrot.png old mode 100644 new mode 100755 From f1d5e0d6e603999b0b02dc06d78a3670bbc63dd2 Mon Sep 17 00:00:00 2001 From: Clement Nassih Date: Mon, 17 Mar 2025 09:12:29 +0100 Subject: [PATCH 19/27] edit folder name --- .gitignore | 3 +++ .vscode/launch.json | 4 ++-- .../{exampleClement => backgroundClement}/TestExample.tscn | 0 examples/{exampleClement => backgroundClement}/background.cpp | 0 examples/{exampleClement => backgroundClement}/read.me | 0 5 files changed, 5 insertions(+), 2 deletions(-) rename examples/{exampleClement => backgroundClement}/TestExample.tscn (100%) rename examples/{exampleClement => backgroundClement}/background.cpp (100%) rename examples/{exampleClement => backgroundClement}/read.me (100%) diff --git a/.gitignore b/.gitignore index d0650cc..81f0be2 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,6 @@ mono_crash.*.json .DS_Store screenshots/.DS_Store *.tmp + +# Editor-specific ignores +.vscode/ diff --git a/.vscode/launch.json b/.vscode/launch.json index cb69edc..c7bd280 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -8,8 +8,8 @@ "args": [], "stopAtEntry": false, "externalConsole": false, - "cwd": "/media/clem/Transcend/master/m1/s8/AAP/godot/ComputeShaderStudio/examples/exampleClement", - "program": "/media/clem/Transcend/master/m1/s8/AAP/godot/ComputeShaderStudio/examples/exampleClement/build/Debug/outDebug", + "cwd": "/media/clem/SSD-Clem/master/m1/s8/AAP/godot/ComputeShaderStudio/examples/backgroundClement", + "program": "/media/clem/SSD-Clem/master/m1/s8/AAP/godot/ComputeShaderStudio/examples/backgroundClement/build/Debug/outDebug", "MIMode": "gdb", "miDebuggerPath": "gdb", "setupCommands": [ diff --git a/examples/exampleClement/TestExample.tscn b/examples/backgroundClement/TestExample.tscn similarity index 100% rename from examples/exampleClement/TestExample.tscn rename to examples/backgroundClement/TestExample.tscn diff --git a/examples/exampleClement/background.cpp b/examples/backgroundClement/background.cpp similarity index 100% rename from examples/exampleClement/background.cpp rename to examples/backgroundClement/background.cpp diff --git a/examples/exampleClement/read.me b/examples/backgroundClement/read.me similarity index 100% rename from examples/exampleClement/read.me rename to examples/backgroundClement/read.me From 356a05b365da5615d77cb9f8f883d6032bd135d3 Mon Sep 17 00:00:00 2001 From: Clement Nassih Date: Mon, 17 Mar 2025 09:13:58 +0100 Subject: [PATCH 20/27] remove read.me --- README.md | 12 ------------ 1 file changed, 12 deletions(-) delete mode 100644 README.md diff --git a/README.md b/README.md deleted file mode 100644 index 28b6388..0000000 --- a/README.md +++ /dev/null @@ -1,12 +0,0 @@ -# Compute Shader Studio - A plugin for Godot to create compute shaders - -![logo](screenshots/compute_shader_studio_headline.png) - -**[Compute Shader Studio](https://virtulab.univ-brest.fr) is an addon for Godot Engine that enables you to write Compute Shaders in a minute:** - -![logo](screenshots/compute_shader_studio_ex2.png) - -**Read [the tutorial](doc/ComputeShaderStudio.pdf) or look at the [2 minutes video](https://www.youtube.com/watch?v=3bEgPawi7fQ) to make your first Compute Shader in Godot** - -**Several examples are available: test them to understand how they work and what can be done** From 1a9f3c1b678517bff29dd8f514162928876aeabb Mon Sep 17 00:00:00 2001 From: redalhdd Date: Mon, 17 Mar 2025 19:19:47 +0100 Subject: [PATCH 21/27] qq modifs --- addons/compute_shader_studio/compute_shader_studio_2d.gd | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 addons/compute_shader_studio/compute_shader_studio_2d.gd diff --git a/addons/compute_shader_studio/compute_shader_studio_2d.gd b/addons/compute_shader_studio/compute_shader_studio_2d.gd old mode 100755 new mode 100644 From e7c70d5627cd8db4490af8b371b39376eab016ca Mon Sep 17 00:00:00 2001 From: redalhdd Date: Mon, 17 Mar 2025 20:17:25 +0100 Subject: [PATCH 22/27] Sharingan + Rinnegan + Background --- examples/backgroundClement/TestExample.tscn | 2 +- examples/cells/example_cells.tscn | 5 +-- examples/example_1.tscn | 2 +- examples/example_2.tscn | 2 +- examples/example_3.tscn | 6 +-- examples/example_4.tscn | 2 +- examples/example_5.tscn | 2 +- examples/example_lenia_test.tscn | 4 +- examples/project/ShaderArt.tscn | 2 +- examples/project/project.tscn | 0 examples/project/test.cpp | 48 ++++++++++++++++++++- project.godot | 6 +-- 12 files changed, 62 insertions(+), 19 deletions(-) mode change 100755 => 100644 examples/project/project.tscn diff --git a/examples/backgroundClement/TestExample.tscn b/examples/backgroundClement/TestExample.tscn index 7f592eb..63e7330 100644 --- a/examples/backgroundClement/TestExample.tscn +++ b/examples/backgroundClement/TestExample.tscn @@ -7,7 +7,7 @@ [node name="ComputeShaderStudio2D" type="Node" parent="." node_paths=PackedStringArray("data")] script = ExtResource("1_bowy1") -glsl_file = "res://examples/exampleClement/background.cpp" +glsl_file = "res://examples/backgroundClement/background.cpp" GLSL_code = " " data = [NodePath("../Sprite2D")] diff --git a/examples/cells/example_cells.tscn b/examples/cells/example_cells.tscn index 481f64d..65cbd9c 100644 --- a/examples/cells/example_cells.tscn +++ b/examples/cells/example_cells.tscn @@ -1,7 +1,6 @@ -[gd_scene load_steps=6 format=3 uid="uid://cutxgtalwsp6q"] +[gd_scene load_steps=5 format=3 uid="uid://cutxgtalwsp6q"] [ext_resource type="Script" path="res://examples/cells/cells.gd" id="1_dw4h8"] -[ext_resource type="Texture2D" uid="uid://demftcowdd5c6" path="res://examples/icon.svg" id="2_oji6h"] [ext_resource type="Script" path="res://addons/compute_shader_studio/compute_shader_studio_2d.gd" id="2_6o5l7"] [sub_resource type="FastNoiseLite" id="FastNoiseLite_pm7bb"] @@ -40,4 +39,4 @@ offset_left = 127.0 offset_top = 5.0 offset_right = 824.0 offset_bottom = 442.0 -texture = SubResource("NoiseTexture2D_0uqft") \ No newline at end of file +texture = SubResource("NoiseTexture2D_0uqft") diff --git a/examples/example_1.tscn b/examples/example_1.tscn index c5f2216..7d67949 100644 --- a/examples/example_1.tscn +++ b/examples/example_1.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=5 format=3 uid="uid://ddr6qtwy1pesd"] -[ext_resource type="Script" uid="uid://b88ieqj4hfk8r" path="res://addons/compute_shader_studio/compute_shader_studio_2d.gd" id="1_6846p"] +[ext_resource type="Script" path="res://addons/compute_shader_studio/compute_shader_studio_2d.gd" id="1_6846p"] [ext_resource type="Texture2D" uid="uid://demftcowdd5c6" path="res://examples/icon.svg" id="2_s3fct"] [sub_resource type="FastNoiseLite" id="FastNoiseLite_dmk8h"] diff --git a/examples/example_2.tscn b/examples/example_2.tscn index ba06232..7d0ee52 100644 --- a/examples/example_2.tscn +++ b/examples/example_2.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=3 format=3 uid="uid://cotswmubn7uvm"] -[ext_resource type="Script" uid="uid://b88ieqj4hfk8r" path="res://addons/compute_shader_studio/compute_shader_studio_2d.gd" id="1_2cs40"] +[ext_resource type="Script" path="res://addons/compute_shader_studio/compute_shader_studio_2d.gd" id="1_2cs40"] [ext_resource type="Texture2D" uid="uid://demftcowdd5c6" path="res://examples/icon.svg" id="2_j6qu8"] [node name="Example2" type="Node2D"] diff --git a/examples/example_3.tscn b/examples/example_3.tscn index 585fb0e..d2ae179 100644 --- a/examples/example_3.tscn +++ b/examples/example_3.tscn @@ -1,10 +1,10 @@ [gd_scene load_steps=4 format=3 uid="uid://cmucgsppcoo5e"] -[ext_resource type="Script" uid="uid://b88ieqj4hfk8r" path="res://addons/compute_shader_studio/compute_shader_studio_2d.gd" id="1_eimw3"] -[ext_resource type="Script" uid="uid://dc0t1p5le3li2" path="res://examples/LabelStepPass.gd" id="2_4aq4t"] +[ext_resource type="Script" path="res://addons/compute_shader_studio/compute_shader_studio_2d.gd" id="1_eimw3"] +[ext_resource type="Script" path="res://examples/LabelStepPass.gd" id="2_4aq4t"] [ext_resource type="Texture2D" uid="uid://demftcowdd5c6" path="res://examples/icon.svg" id="2_4upxj"] -[node name="CompShadStudioEx3" type="Node2D"] +[node name="CompShadStudioEx4" type="Node2D"] [node name="ComputeShaderStudio2D2" type="Node" parent="." node_paths=PackedStringArray("data")] script = ExtResource("1_eimw3") diff --git a/examples/example_4.tscn b/examples/example_4.tscn index fe89676..c777972 100644 --- a/examples/example_4.tscn +++ b/examples/example_4.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=3 format=3 uid="uid://b2ip5eftk3aij"] -[ext_resource type="Script" uid="uid://b88ieqj4hfk8r" path="res://addons/compute_shader_studio/compute_shader_studio_2d.gd" id="1_ke3fj"] +[ext_resource type="Script" path="res://addons/compute_shader_studio/compute_shader_studio_2d.gd" id="1_ke3fj"] [ext_resource type="Texture2D" uid="uid://2behgeplwycn" path="res://examples/grid_512x512.png" id="2_flqlh"] [node name="CompShadStudioEx4" type="Node2D"] diff --git a/examples/example_5.tscn b/examples/example_5.tscn index 762b68d..7b8bed2 100644 --- a/examples/example_5.tscn +++ b/examples/example_5.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=4 format=3 uid="uid://cets11mlsd8hb"] -[ext_resource type="Script" uid="uid://b88ieqj4hfk8r" path="res://addons/compute_shader_studio/compute_shader_studio_2d.gd" id="1_cogap"] +[ext_resource type="Script" path="res://addons/compute_shader_studio/compute_shader_studio_2d.gd" id="1_cogap"] [sub_resource type="FastNoiseLite" id="FastNoiseLite_ynclj"] diff --git a/examples/example_lenia_test.tscn b/examples/example_lenia_test.tscn index 3f66d9f..6c2caef 100644 --- a/examples/example_lenia_test.tscn +++ b/examples/example_lenia_test.tscn @@ -1,7 +1,7 @@ [gd_scene load_steps=4 format=3 uid="uid://cljj33x767odp"] -[ext_resource type="Script" uid="uid://b88ieqj4hfk8r" path="res://addons/compute_shader_studio/compute_shader_studio_2d.gd" id="1_wci4f"] -[ext_resource type="Script" uid="uid://dc0t1p5le3li2" path="res://examples/LabelStepPass.gd" id="2_ndkd3"] +[ext_resource type="Script" path="res://addons/compute_shader_studio/compute_shader_studio_2d.gd" id="1_wci4f"] +[ext_resource type="Script" path="res://examples/LabelStepPass.gd" id="2_ndkd3"] [ext_resource type="Texture2D" uid="uid://demftcowdd5c6" path="res://examples/icon.svg" id="3_orsvs"] [node name="CompShadStudioEx3" type="Node2D"] diff --git a/examples/project/ShaderArt.tscn b/examples/project/ShaderArt.tscn index 2f15e7c..daad658 100644 --- a/examples/project/ShaderArt.tscn +++ b/examples/project/ShaderArt.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=4 format=3 uid="uid://p4vy0fyno8jo"] +[gd_scene load_steps=4 format=3 uid="uid://dmgx78vj6wpg6"] [ext_resource type="Script" path="res://addons/compute_shader_studio/compute_shader_studio_2d.gd" id="1_m38we"] diff --git a/examples/project/project.tscn b/examples/project/project.tscn old mode 100755 new mode 100644 diff --git a/examples/project/test.cpp b/examples/project/test.cpp index 44d858d..200304e 100755 --- a/examples/project/test.cpp +++ b/examples/project/test.cpp @@ -23,6 +23,22 @@ #define MAX_TRANSITION_RADIUS 60.0 // Rayon maximum du cercle de transition #define TRANSITION_OUT_START (ANIMATION_INTERVAL - TRANSITION_DURATION) +// Ajouter les fonctions de bruit en haut du fichier +float random(vec2 st) { + return fract(sin(dot(st.xy, vec2(12.9898, 78.233))) * 43758.5453123); +} + +float noise(vec2 st) { + vec2 i = floor(st); + vec2 f = fract(st); + float a = random(i); + float b = random(i + vec2(1.0, 0.0)); + float c = random(i + vec2(0.0, 1.0)); + float d = random(i + vec2(1.0, 1.0)); + vec2 u = f * f * (3.0 - 2.0 * f); + return mix(a, b, u.x) + (c - a) * u.y * (1.0 - u.x) + (d - b) * u.x * u.y; +} + void main() { int x = int(gl_GlobalInvocationID.x); @@ -91,6 +107,36 @@ void main() float dot3_center_y = dot3_y - SMALL_DOT_OFFSET * sin(angle + 4.1888); float small_dot3_dist = sqrt(pow(x - dot3_center_x, 2) + pow(y - dot3_center_y, 2)); + // Génération du fond animé + float iTime = step / 10.0; + vec2 fragCoord = vec2(float(x), float(y)); + vec2 iResolution = vec2(float(WSX), float(WSY)); + vec4 fragColor = vec4(0.0); + + float t = iTime / 10.0; + vec2 pos = 100.0 * fragCoord/(iResolution.xy); + float yPos = pos.y/100.0; + pos.y += sin(2.0*t); + pos.x += cos(5.0*t); + pos *= mat2(sin(t/2.0),-cos(t/2.0),cos(t/2.0),sin(t/2.0))/8.0; + + for (float i = 0.0; i < 8.0; i++) { + fragColor = cos(pos.xxxx*0.3)*0.5+0.5; + float n = noise(pos/5.0); + fragColor *= n; + pos.x += sin(pos.y + iTime*0.3 + i); + pos *= mat2(6.0,-8.0,8.0,6.0)/8.0; + } + + fragColor *= 1.0 - smoothstep(0.0, 0.91, yPos); + fragColor *= vec4(0.2, 0.23, 0.54, 1.0); + + // Conversion de la couleur du fond + uint r = uint(min(255.0, fragColor.r * 255.0)); + uint g = uint(min(255.0, fragColor.g * 255.0)); + uint b = uint(min(255.0, fragColor.b * 255.0)); + uint background_color = 0xFF000000 | (r << 16) | (g << 8) | b; + if (dist < RADIUS) { float z = sqrt(RADIUS*RADIUS - dist*dist); float normal_z = z/RADIUS; @@ -217,7 +263,7 @@ void main() } } } else { - data_0[p] = 0xFF404040; // Fond gris moyen au lieu de gris foncé + data_0[p] = int(background_color); // Fond animé au lieu de gris moyen } } } diff --git a/project.godot b/project.godot index a17d79e..a5e8bc4 100644 --- a/project.godot +++ b/project.godot @@ -11,10 +11,8 @@ config_version=5 [application] config/name="compute_shader_studio" - -run/main_scene="res://examples/example_5.tscn" -config/features=PackedStringArray("4.4", "Forward Plus") - +run/main_scene="res://examples/backgroundClement/TestExample.tscn" +config/features=PackedStringArray("4.3", "Forward Plus") config/icon="res://addons/compute_shader_studio/icon.png" [editor_plugins] From a0d90c484945de2fe4c49310ba0f792c46050c05 Mon Sep 17 00:00:00 2001 From: Clement Nassih Date: Mon, 17 Mar 2025 20:54:55 +0100 Subject: [PATCH 23/27] clean + readme --- .../naruto/backgroundClement/TestExample.tscn | 18 ++ .../naruto/backgroundClement/background.cpp | 70 +++++ examples/naruto/backgroundClement/read.me | 1 + examples/naruto/project/naruto.cpp | 270 ++++++++++++++++++ examples/naruto/project/test.tscn | 17 ++ examples/naruto/read.me | 13 + examples/naruto/rinnegan saad/example_5.cpp | 39 +++ examples/naruto/rinnegan saad/example_5.tscn | 38 +++ 8 files changed, 466 insertions(+) create mode 100644 examples/naruto/backgroundClement/TestExample.tscn create mode 100644 examples/naruto/backgroundClement/background.cpp create mode 100644 examples/naruto/backgroundClement/read.me create mode 100644 examples/naruto/project/naruto.cpp create mode 100644 examples/naruto/project/test.tscn create mode 100644 examples/naruto/read.me create mode 100644 examples/naruto/rinnegan saad/example_5.cpp create mode 100644 examples/naruto/rinnegan saad/example_5.tscn diff --git a/examples/naruto/backgroundClement/TestExample.tscn b/examples/naruto/backgroundClement/TestExample.tscn new file mode 100644 index 0000000..63e7330 --- /dev/null +++ b/examples/naruto/backgroundClement/TestExample.tscn @@ -0,0 +1,18 @@ +[gd_scene load_steps=3 format=3 uid="uid://ddfhk06k1ymy"] + +[ext_resource type="Script" path="res://addons/compute_shader_studio/compute_shader_studio_2d.gd" id="1_bowy1"] +[ext_resource type="Texture2D" uid="uid://demftcowdd5c6" path="res://examples/icon.svg" id="2_n443p"] + +[node name="background" type="Node2D"] + +[node name="ComputeShaderStudio2D" type="Node" parent="." node_paths=PackedStringArray("data")] +script = ExtResource("1_bowy1") +glsl_file = "res://examples/backgroundClement/background.cpp" +GLSL_code = " +" +data = [NodePath("../Sprite2D")] + +[node name="Sprite2D" type="Sprite2D" parent="."] +position = Vector2(369, 246) +scale = Vector2(3.60063, 3.6475) +texture = ExtResource("2_n443p") diff --git a/examples/naruto/backgroundClement/background.cpp b/examples/naruto/backgroundClement/background.cpp new file mode 100644 index 0000000..43f58f7 --- /dev/null +++ b/examples/naruto/backgroundClement/background.cpp @@ -0,0 +1,70 @@ +float random(vec2 st) { + return fract(sin(dot(st.xy, vec2(12.9898, 78.233))) * 43758.5453123); +} + +// inspiré par le background shadertoy suivant : https://www.shadertoy.com/view/Wf2GDt +float noise(vec2 st) { + vec2 i = floor(st); + vec2 f = fract(st); + + // Quatre coins du carré + float a = random(i); + float b = random(i + vec2(1.0, 0.0)); + float c = random(i + vec2(0.0, 1.0)); + float d = random(i + vec2(1.0, 1.0)); + + // Interpolation lisse + vec2 u = f * f * (3.0 - 2.0 * f); + + return mix(a, b, u.x) + + (c - a) * u.y * (1.0 - u.x) + + (d - b) * u.x * u.y; +} + +void main() { + uint x = gl_GlobalInvocationID.x; + uint y = gl_GlobalInvocationID.y; + uint p = x + y * WSX; + + //variable time basé sur la variable step de computeShaderStudio + float iTime = step / 10.0; + vec2 fragCoord = vec2(float(x), float(y)); + vec2 iResolution = vec2(float(WSX), float(WSY)); + vec4 fragColor = vec4(0.0); + + // Conversion du code shadertoy + float t = iTime / 10.0; + + vec2 pos = 100.0 * fragCoord/(iResolution.xy); + float yPos = pos.y/100.0; + pos.y += sin(2.0*t); + pos.x += cos(5.0*t); + pos *= mat2(sin(t/2.0),-cos(t/2.0),cos(t/2.0),sin(t/2.0))/8.0; + + // Boucle de l'effet de fractale + for (float i = 0.0; i < 8.0; i++) { + fragColor = cos(pos.xxxx*0.3)*0.5+0.5; + float n = noise(pos/5.0); + fragColor *= n; + pos.x += sin(pos.y + iTime*0.3 + i); + pos *= mat2(6.0,-8.0,8.0,6.0)/8.0; + } + + // Fade vertical + fragColor *= 1.0 - smoothstep(0.0, 0.91, yPos); + + // Teinte rouge + fragColor *= vec4(0.2, 0.23, 0.54, 1.0); + + // Conversion de la couleur au format requis par le buffer + uint r = uint(min(255.0, fragColor.r * 255.0)); + uint g = uint(min(255.0, fragColor.g * 255.0)); + uint b = uint(min(255.0, fragColor.b * 255.0)); + uint alpha = 0xFF; + + // Construction de la couleur finale + uvec4 color = uvec4((alpha << 24) | (r << 16) | (g << 8) | b); + + // Écriture dans le buffer + data_0[p] = int(color.x); +} \ No newline at end of file diff --git a/examples/naruto/backgroundClement/read.me b/examples/naruto/backgroundClement/read.me new file mode 100644 index 0000000..7b3fb1d --- /dev/null +++ b/examples/naruto/backgroundClement/read.me @@ -0,0 +1 @@ +objectif : fond anime akatsuki \ No newline at end of file diff --git a/examples/naruto/project/naruto.cpp b/examples/naruto/project/naruto.cpp new file mode 100644 index 0000000..200304e --- /dev/null +++ b/examples/naruto/project/naruto.cpp @@ -0,0 +1,270 @@ +#define RADIUS 40 +#define PUPIL_RADIUS 10 +#define IRIS_RADIUS 25 +#define DOT_RADIUS 3 +#define CRESCENT_OFFSET 2.0 // Décalage pour créer l'effet de croissant +#define PI 3.14159265359 // Ajout de la définition de PI +#define SMALL_DOT_RADIUS 2.0 // Rayon du petit point +#define SMALL_DOT_OFFSET 1.0 // Distance du point par rapport au croissant +#define IRIS_BORDER 0.5 // Épaisseur de la bordure de l'iris +#define LIGHT_INTENSITY 0.4 // Intensité de la lumière directionnelle +#define BLINK_INTERVAL 200 // Intervalle de clignotement (10 secondes à 20fps) +#define BLINK_DURATION 20 // Durée du clignotement (1 seconde) +#define BLINK_SPEED 0.15 // Vitesse de propagation du noir +#define TRANSITION_WIDTH 5.0 // Largeur de la transition du noir +#define ANIMATION_INTERVAL 300 // 5 secondes à 60fps +#define PULSE_AMPLITUDE 10.0 +#define PULSE_SPEED 0.08 +#define RING_SPACING 20.0 // Espacement entre les cercles +#define RING_THICKNESS 4.0 // Épaisseur des cercles +#define SPACING_VARIATION 10.0 +#define WAVE_SPEED 0.15 // Augmentation de la vitesse de propagation (anciennement 0.05) +#define TRANSITION_DURATION 60.0 // Durée de la transition en frames +#define MAX_TRANSITION_RADIUS 60.0 // Rayon maximum du cercle de transition +#define TRANSITION_OUT_START (ANIMATION_INTERVAL - TRANSITION_DURATION) + +// Ajouter les fonctions de bruit en haut du fichier +float random(vec2 st) { + return fract(sin(dot(st.xy, vec2(12.9898, 78.233))) * 43758.5453123); +} + +float noise(vec2 st) { + vec2 i = floor(st); + vec2 f = fract(st); + float a = random(i); + float b = random(i + vec2(1.0, 0.0)); + float c = random(i + vec2(0.0, 1.0)); + float d = random(i + vec2(1.0, 1.0)); + vec2 u = f * f * (3.0 - 2.0 * f); + return mix(a, b, u.x) + (c - a) * u.y * (1.0 - u.x) + (d - b) * u.x * u.y; +} + +void main() +{ + int x = int(gl_GlobalInvocationID.x); + int y = int(gl_GlobalInvocationID.y); + int p = x + y * int(WSX); + + // initial background is black & opac + if (step == 0) { + data_0[p] = 0xFF000000; + } else { + float dx = float(mousex - x); + float dy = float(mousey - y); + float dist = sqrt(dx*dx + dy*dy); + + // Calcul de la lumière directionnelle + float lightDirX = 1.0; // Direction X de la lumière (vers la gauche) + float lightDirY = 1.0; // Direction Y de la lumière (vers le haut) + float normalX = dx/dist; + float normalY = dy/dist; + float lightAngle = (lightDirX * normalX + lightDirY * normalY) * 0.5 + 0.5; + + // Position des points tournants + float angle = float(step) * 0.05f; // Vitesse de rotation + float orbit_radius = (IRIS_RADIUS + PUPIL_RADIUS) * 0.5f; // Rayon de l'orbite + + // Premier point + float dot_x = mousex + orbit_radius * cos(angle); + float dot_y = mousey + orbit_radius * sin(angle); + float dot_dist = sqrt(pow(x - dot_x, 2) + pow(y - dot_y, 2)); + + // Deuxième point (décalé de 120°) + float dot2_x = mousex + orbit_radius * cos(angle + 2.0944); // 2π/3 + float dot2_y = mousey + orbit_radius * sin(angle + 2.0944); + float dot2_dist = sqrt(pow(x - dot2_x, 2) + pow(y - dot2_y, 2)); + + // Troisième point (décalé de 240°) + float dot3_x = mousex + orbit_radius * cos(angle + 4.1888); // 4π/3 + float dot3_y = mousey + orbit_radius * sin(angle + 4.1888); + float dot3_dist = sqrt(pow(x - dot3_x, 2) + pow(y - dot3_y, 2)); + + // Premier croissant - décalage orienté vers l'extérieur + float crescent1MainDist = sqrt(pow(x - dot_x, 2) + pow(y - dot_y, 2)); + float crescent1SecDist = sqrt(pow(x - (dot_x + CRESCENT_OFFSET * cos(angle + PI/2)), 2) + + pow(y - (dot_y + CRESCENT_OFFSET * sin(angle + PI/2)), 2)); + + // Deuxième croissant - décalage orienté vers l'extérieur + float crescent2MainDist = sqrt(pow(x - dot2_x, 2) + pow(y - dot2_y, 2)); + float crescent2SecDist = sqrt(pow(x - (dot2_x + CRESCENT_OFFSET * cos(angle + 2.0944 + + PI/2)), 2) + + pow(y - (dot2_y + CRESCENT_OFFSET * sin(angle + 2.0944 + + PI/2)), 2)); + + // Troisième croissant - décalage orienté vers l'extérieur + float crescent3MainDist = sqrt(pow(x - dot3_x, 2) + pow(y - dot3_y, 2)); + float crescent3SecDist = sqrt(pow(x - (dot3_x + CRESCENT_OFFSET * cos(angle + 4.1888 + + PI/2)), 2) + + pow(y - (dot3_y + CRESCENT_OFFSET * sin(angle + 4.1888 + + PI/2)), 2)); + + // Points superposés aux croissants + float dot1_center_x = dot_x - SMALL_DOT_OFFSET * cos(angle); + float dot1_center_y = dot_y - SMALL_DOT_OFFSET * sin(angle); + float small_dot1_dist = sqrt(pow(x - dot1_center_x, 2) + pow(y - dot1_center_y, 2)); + + float dot2_center_x = dot2_x - SMALL_DOT_OFFSET * cos(angle + 2.0944); + float dot2_center_y = dot2_y - SMALL_DOT_OFFSET * sin(angle + 2.0944); + float small_dot2_dist = sqrt(pow(x - dot2_center_x, 2) + pow(y - dot2_center_y, 2)); + + float dot3_center_x = dot3_x - SMALL_DOT_OFFSET * cos(angle + 4.1888); + float dot3_center_y = dot3_y - SMALL_DOT_OFFSET * sin(angle + 4.1888); + float small_dot3_dist = sqrt(pow(x - dot3_center_x, 2) + pow(y - dot3_center_y, 2)); + + // Génération du fond animé + float iTime = step / 10.0; + vec2 fragCoord = vec2(float(x), float(y)); + vec2 iResolution = vec2(float(WSX), float(WSY)); + vec4 fragColor = vec4(0.0); + + float t = iTime / 10.0; + vec2 pos = 100.0 * fragCoord/(iResolution.xy); + float yPos = pos.y/100.0; + pos.y += sin(2.0*t); + pos.x += cos(5.0*t); + pos *= mat2(sin(t/2.0),-cos(t/2.0),cos(t/2.0),sin(t/2.0))/8.0; + + for (float i = 0.0; i < 8.0; i++) { + fragColor = cos(pos.xxxx*0.3)*0.5+0.5; + float n = noise(pos/5.0); + fragColor *= n; + pos.x += sin(pos.y + iTime*0.3 + i); + pos *= mat2(6.0,-8.0,8.0,6.0)/8.0; + } + + fragColor *= 1.0 - smoothstep(0.0, 0.91, yPos); + fragColor *= vec4(0.2, 0.23, 0.54, 1.0); + + // Conversion de la couleur du fond + uint r = uint(min(255.0, fragColor.r * 255.0)); + uint g = uint(min(255.0, fragColor.g * 255.0)); + uint b = uint(min(255.0, fragColor.b * 255.0)); + uint background_color = 0xFF000000 | (r << 16) | (g << 8) | b; + + if (dist < RADIUS) { + float z = sqrt(RADIUS*RADIUS - dist*dist); + float normal_z = z/RADIUS; + float light = normal_z; + light = clamp(light * (0.7 + lightAngle * LIGHT_INTENSITY), 0.2f, 1.0f); + + // Alternance entre les animations + bool usePulsingAnimation = ((step / ANIMATION_INTERVAL) % 2) == 1; + + if (usePulsingAnimation) { + float d = sqrt(dx * dx + dy * dy); + float cycleStart = float(step % ANIMATION_INTERVAL); + + // Gestion des transitions + if (cycleStart < TRANSITION_DURATION) { + // Transition d'entrée (comme avant) + float transitionRadius = (cycleStart / TRANSITION_DURATION) * MAX_TRANSITION_RADIUS; + + if (d < transitionRadius) { + // Nouvelle animation + float animatedD = d - float(step) * WAVE_SPEED; + float rings = mod(animatedD, RING_SPACING); + + if (rings < RING_THICKNESS) { + data_0[p] = 0xFF000000; + } else { + int value = int(255.0f * light); + int red = int(180.0f * light); // Augmenté de 128 à 180 + int green = 0; + int blue = int(180.0f * light); // Augmenté de 128 à 180 + data_0[p] = 0xFF000000 | (red << 16) | (green << 8) | blue; + } + } else { + // Animation normale + if (dist < PUPIL_RADIUS) { + data_0[p] = 0xFF000000; + } + // ...reste du code de l'animation normale... + } + } else if (cycleStart > TRANSITION_OUT_START) { + // Transition de sortie + float transitionOutProgress = (cycleStart - TRANSITION_OUT_START) / TRANSITION_DURATION; + float fadeRadius = (1.0 - transitionOutProgress) * MAX_TRANSITION_RADIUS; + + if (d < fadeRadius) { + // Zone encore visible de l'animation des cercles + float animatedD = d - float(step) * WAVE_SPEED; + float rings = mod(animatedD, RING_SPACING); + + if (rings < RING_THICKNESS) { + data_0[p] = 0xFF000000; + } else { + int value = int(255.0f * light); + int red = int(180.0f * light); // Augmenté de 128 à 180 + int green = 0; + int blue = int(180.0f * light); // Augmenté de 128 à 180 + data_0[p] = 0xFF000000 | (red << 16) | (green << 8) | blue; + } + } else { + // Zone qui revient à l'animation normale + if (dist < PUPIL_RADIUS) { + data_0[p] = 0xFF000000; + } else if (dist < IRIS_RADIUS) { + if ((crescent1MainDist < DOT_RADIUS && crescent1SecDist > DOT_RADIUS - 1.0) || + (crescent2MainDist < DOT_RADIUS && crescent2SecDist > DOT_RADIUS - 1.0) || + (crescent3MainDist < DOT_RADIUS && crescent3SecDist > DOT_RADIUS - 1.0) || + small_dot1_dist < SMALL_DOT_RADIUS || + small_dot2_dist < SMALL_DOT_RADIUS || + small_dot3_dist < SMALL_DOT_RADIUS) { + data_0[p] = 0xFF000000; + } else if (dist > IRIS_RADIUS - IRIS_BORDER) { + data_0[p] = 0xFF404040; + } else { + int red = int(200.0f * light); + data_0[p] = 0xFF000000 | red; + } + } else { + int value = int(255.0f * light); + int red = value; + int green = int(value * 0.95); + int blue = int(value * 0.9); + data_0[p] = 0xFF000000 | (red << 16) | (green << 8) | blue; + } + } + } else { + // Animation complète des cercles (entre les deux transitions) + float animatedD = d - float(step) * WAVE_SPEED; + float rings = mod(animatedD, RING_SPACING); + + if (rings < RING_THICKNESS) { + data_0[p] = 0xFF000000; + } else { + int value = int(255.0f * light); + int red = int(180.0f * light); // Augmenté de 128 à 180 + int green = 0; + int blue = int(180.0f * light); // Augmenté de 128 à 180 + data_0[p] = 0xFF000000 | (red << 16) | (green << 8) | blue; + } + } + } else { + // Animation normale + if (dist < PUPIL_RADIUS) { + data_0[p] = 0xFF000000; + } else if (dist < IRIS_RADIUS) { + if ((crescent1MainDist < DOT_RADIUS && crescent1SecDist > DOT_RADIUS - 1.0) || + (crescent2MainDist < DOT_RADIUS && crescent2SecDist > DOT_RADIUS - 1.0) || + (crescent3MainDist < DOT_RADIUS && crescent3SecDist > DOT_RADIUS - 1.0) || + small_dot1_dist < SMALL_DOT_RADIUS || + small_dot2_dist < SMALL_DOT_RADIUS || + small_dot3_dist < SMALL_DOT_RADIUS) { + data_0[p] = 0xFF000000; + } else if (dist > IRIS_RADIUS - IRIS_BORDER) { + data_0[p] = 0xFF404040; + } else { + int red = int(200.0f * light); + data_0[p] = 0xFF000000 | red; + } + } else { + int value = int(255.0f * light); + int red = value; + int green = int(value * 0.95); + int blue = int(value * 0.9); + data_0[p] = 0xFF000000 | (red << 16) | (green << 8) | blue; + } + } + } else { + data_0[p] = int(background_color); // Fond animé au lieu de gris moyen + } + } +} + diff --git a/examples/naruto/project/test.tscn b/examples/naruto/project/test.tscn new file mode 100644 index 0000000..6ad2f4a --- /dev/null +++ b/examples/naruto/project/test.tscn @@ -0,0 +1,17 @@ +[gd_scene load_steps=3 format=3 uid="uid://duh7anebdiq5r"] + +[ext_resource type="Script" path="res://addons/compute_shader_studio/compute_shader_studio_2d.gd" id="1_o3uyj"] +[ext_resource type="Texture2D" uid="uid://demftcowdd5c6" path="res://examples/icon.svg" id="2_gpcd8"] + +[node name="Test" type="Node2D"] + +[node name="ComputeShaderStudio2D" type="Node" parent="." node_paths=PackedStringArray("data")] +script = ExtResource("1_o3uyj") +glsl_file = "res://examples/naruto/project/naruto.cpp" +data = [NodePath("../Icon")] +metadata/_custom_type_script = "uid://c8esqdv0y26yp" + +[node name="Icon" type="Sprite2D" parent="."] +position = Vector2(685, 320) +scale = Vector2(5.3125, 5.03125) +texture = ExtResource("2_gpcd8") diff --git a/examples/naruto/read.me b/examples/naruto/read.me new file mode 100644 index 0000000..f560a5c --- /dev/null +++ b/examples/naruto/read.me @@ -0,0 +1,13 @@ +Projet godot Naruto : + +Membres du groupe : +Réda Lahdoudi +Saad Madi-Soilihi +Clément Nassih + +Pour la réalisation de notre projet nous nous sommes aidés de l'ia claude via github copilot. +Le background a été inspiré par le shadertoy suivant : https://www.shadertoy.com/view/Wf2GDt + +Dans le sous dossier backgroundClement vous pourrez retrouver le code pour le background seul. +Dans le sous dossier rinnegan saad, vous retroverez la seuxième animation violette appliquée sur l'oeil du rendu final. +Le rendu final se trouve dans le sous dossier project et le fichier naruto.cpp \ No newline at end of file diff --git a/examples/naruto/rinnegan saad/example_5.cpp b/examples/naruto/rinnegan saad/example_5.cpp new file mode 100644 index 0000000..b3a2bac --- /dev/null +++ b/examples/naruto/rinnegan saad/example_5.cpp @@ -0,0 +1,39 @@ +void main() { + uint x = gl_GlobalInvocationID.x; + uint y = gl_GlobalInvocationID.y; + uint p = x + y * WSX; + + int dx = int(WSX) / 2 - int(x); + int dy = int(WSY) / 2 - int(y); + + int d = dx * dx + dy * dy; + + // Condition : après 5 secondes (ajuste la valeur selon ton framerate) + if (step > 300) { // Après 5 secondes -> Afficher les cercles + + float d = sqrt(float(dx * dx + dy * dy)); // Distance au centre + + // Animation des cercles (pulsation) + float amplitude = 10.0; // Amplitude de la pulsation + float vitesse = 0.08; // Vitesse de l'effet + float animatedD = d + amplitude * sin(float(step) * vitesse); + + // Espacement animé des cercles + float spacing = 30.0 + 10.0 * sin(float(step) * 0.1); + + // Calcul des cercles noirs avec un motif en anneaux + float rings = mod(animatedD, spacing); + bool isBlack = rings < 6.0; // Épaisseur des anneaux noirs + + if (isBlack) { + data_0[p] = 0xFF000000; // Noir + } else { + data_0[p] = 0xFF800080; // Fond violet + } + + } else { + int value = clamp(600 * (d + int(step)), 0, 0xFFFFFF); + data_0[p] = 0xFF000000 | (0xFFFFFF - value); // Rendu normal + } +} + diff --git a/examples/naruto/rinnegan saad/example_5.tscn b/examples/naruto/rinnegan saad/example_5.tscn new file mode 100644 index 0000000..7b8bed2 --- /dev/null +++ b/examples/naruto/rinnegan saad/example_5.tscn @@ -0,0 +1,38 @@ +[gd_scene load_steps=4 format=3 uid="uid://cets11mlsd8hb"] + +[ext_resource type="Script" path="res://addons/compute_shader_studio/compute_shader_studio_2d.gd" id="1_cogap"] + +[sub_resource type="FastNoiseLite" id="FastNoiseLite_ynclj"] + +[sub_resource type="NoiseTexture2D" id="NoiseTexture2D_nxi5j"] +width = 256 +height = 128 +noise = SubResource("FastNoiseLite_ynclj") + +[node name="CompShadStudioEx5" type="Node2D"] + +[node name="ComputeShaderStudio2D2" type="Node" parent="." node_paths=PackedStringArray("data")] +script = ExtResource("1_cogap") +WSX = 256 +glsl_file = "res://examples/example_5.cpp" +GLSL_code = "" +data = [NodePath("../TextureRect")] + +[node name="Label" type="Label" parent="."] +offset_left = 278.0 +offset_top = -1.0 +offset_right = 679.0 +offset_bottom = 101.0 +scale = Vector2(1.72, 1.72) +text = "Compute Shader Studio +Example 5: using an external GLSL file +and a TextureRect" +horizontal_alignment = 1 +vertical_alignment = 1 + +[node name="TextureRect" type="TextureRect" parent="."] +offset_left = -10.0 +offset_top = -26.0 +offset_right = 1171.0 +offset_bottom = 667.0 +texture = SubResource("NoiseTexture2D_nxi5j") From 54797918c3febbfa816a82e166d9cae65674ca60 Mon Sep 17 00:00:00 2001 From: Clement Nassih Date: Mon, 17 Mar 2025 21:14:52 +0100 Subject: [PATCH 24/27] =?UTF-8?q?suppressions=20fichiers=20inutilis=C3=A9s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/backgroundClement/TestExample.tscn | 18 -- examples/backgroundClement/background.cpp | 70 ----- examples/backgroundClement/read.me | 1 - examples/project/ShaderArt.tscn | 27 -- examples/project/base.cpp | 51 ---- examples/project/project.cpp | 100 -------- examples/project/project.tscn | 20 -- examples/project/test.cpp | 270 -------------------- examples/project/test.tscn | 17 -- project.godot | 2 +- 10 files changed, 1 insertion(+), 575 deletions(-) delete mode 100644 examples/backgroundClement/TestExample.tscn delete mode 100644 examples/backgroundClement/background.cpp delete mode 100644 examples/backgroundClement/read.me delete mode 100644 examples/project/ShaderArt.tscn delete mode 100644 examples/project/base.cpp delete mode 100755 examples/project/project.cpp delete mode 100644 examples/project/project.tscn delete mode 100755 examples/project/test.cpp delete mode 100644 examples/project/test.tscn diff --git a/examples/backgroundClement/TestExample.tscn b/examples/backgroundClement/TestExample.tscn deleted file mode 100644 index 63e7330..0000000 --- a/examples/backgroundClement/TestExample.tscn +++ /dev/null @@ -1,18 +0,0 @@ -[gd_scene load_steps=3 format=3 uid="uid://ddfhk06k1ymy"] - -[ext_resource type="Script" path="res://addons/compute_shader_studio/compute_shader_studio_2d.gd" id="1_bowy1"] -[ext_resource type="Texture2D" uid="uid://demftcowdd5c6" path="res://examples/icon.svg" id="2_n443p"] - -[node name="background" type="Node2D"] - -[node name="ComputeShaderStudio2D" type="Node" parent="." node_paths=PackedStringArray("data")] -script = ExtResource("1_bowy1") -glsl_file = "res://examples/backgroundClement/background.cpp" -GLSL_code = " -" -data = [NodePath("../Sprite2D")] - -[node name="Sprite2D" type="Sprite2D" parent="."] -position = Vector2(369, 246) -scale = Vector2(3.60063, 3.6475) -texture = ExtResource("2_n443p") diff --git a/examples/backgroundClement/background.cpp b/examples/backgroundClement/background.cpp deleted file mode 100644 index 43f58f7..0000000 --- a/examples/backgroundClement/background.cpp +++ /dev/null @@ -1,70 +0,0 @@ -float random(vec2 st) { - return fract(sin(dot(st.xy, vec2(12.9898, 78.233))) * 43758.5453123); -} - -// inspiré par le background shadertoy suivant : https://www.shadertoy.com/view/Wf2GDt -float noise(vec2 st) { - vec2 i = floor(st); - vec2 f = fract(st); - - // Quatre coins du carré - float a = random(i); - float b = random(i + vec2(1.0, 0.0)); - float c = random(i + vec2(0.0, 1.0)); - float d = random(i + vec2(1.0, 1.0)); - - // Interpolation lisse - vec2 u = f * f * (3.0 - 2.0 * f); - - return mix(a, b, u.x) + - (c - a) * u.y * (1.0 - u.x) + - (d - b) * u.x * u.y; -} - -void main() { - uint x = gl_GlobalInvocationID.x; - uint y = gl_GlobalInvocationID.y; - uint p = x + y * WSX; - - //variable time basé sur la variable step de computeShaderStudio - float iTime = step / 10.0; - vec2 fragCoord = vec2(float(x), float(y)); - vec2 iResolution = vec2(float(WSX), float(WSY)); - vec4 fragColor = vec4(0.0); - - // Conversion du code shadertoy - float t = iTime / 10.0; - - vec2 pos = 100.0 * fragCoord/(iResolution.xy); - float yPos = pos.y/100.0; - pos.y += sin(2.0*t); - pos.x += cos(5.0*t); - pos *= mat2(sin(t/2.0),-cos(t/2.0),cos(t/2.0),sin(t/2.0))/8.0; - - // Boucle de l'effet de fractale - for (float i = 0.0; i < 8.0; i++) { - fragColor = cos(pos.xxxx*0.3)*0.5+0.5; - float n = noise(pos/5.0); - fragColor *= n; - pos.x += sin(pos.y + iTime*0.3 + i); - pos *= mat2(6.0,-8.0,8.0,6.0)/8.0; - } - - // Fade vertical - fragColor *= 1.0 - smoothstep(0.0, 0.91, yPos); - - // Teinte rouge - fragColor *= vec4(0.2, 0.23, 0.54, 1.0); - - // Conversion de la couleur au format requis par le buffer - uint r = uint(min(255.0, fragColor.r * 255.0)); - uint g = uint(min(255.0, fragColor.g * 255.0)); - uint b = uint(min(255.0, fragColor.b * 255.0)); - uint alpha = 0xFF; - - // Construction de la couleur finale - uvec4 color = uvec4((alpha << 24) | (r << 16) | (g << 8) | b); - - // Écriture dans le buffer - data_0[p] = int(color.x); -} \ No newline at end of file diff --git a/examples/backgroundClement/read.me b/examples/backgroundClement/read.me deleted file mode 100644 index 7b3fb1d..0000000 --- a/examples/backgroundClement/read.me +++ /dev/null @@ -1 +0,0 @@ -objectif : fond anime akatsuki \ No newline at end of file diff --git a/examples/project/ShaderArt.tscn b/examples/project/ShaderArt.tscn deleted file mode 100644 index daad658..0000000 --- a/examples/project/ShaderArt.tscn +++ /dev/null @@ -1,27 +0,0 @@ -[gd_scene load_steps=4 format=3 uid="uid://dmgx78vj6wpg6"] - -[ext_resource type="Script" path="res://addons/compute_shader_studio/compute_shader_studio_2d.gd" id="1_m38we"] - -[sub_resource type="FastNoiseLite" id="FastNoiseLite_laku3"] - -[sub_resource type="NoiseTexture2D" id="NoiseTexture2D_lb5ai"] -width = 256 -height = 128 -noise = SubResource("FastNoiseLite_laku3") - -[node name="ShaderArt" type="Node2D"] - -[node name="TextureRect" type="TextureRect" parent="."] -offset_left = 169.0 -offset_top = 32.0 -offset_right = 866.0 -offset_bottom = 469.0 -texture = SubResource("NoiseTexture2D_lb5ai") -metadata/_edit_use_anchors_ = true - -[node name="ComputeShaderStudio2D2" type="Node" parent="." node_paths=PackedStringArray("data")] -script = ExtResource("1_m38we") -WSX = 256 -glsl_file = "res://examples/project/base.cpp" -GLSL_code = "" -data = [null] diff --git a/examples/project/base.cpp b/examples/project/base.cpp deleted file mode 100644 index d5f1d8c..0000000 --- a/examples/project/base.cpp +++ /dev/null @@ -1,51 +0,0 @@ -/* This animation is the material of my first youtube tutorial about creative - coding, which is a video in which I try to introduce programmers to GLSL - and to the wonderful world of shaders, while also trying to share my recent - passion for this community. - Video URL: https://youtu.be/f4s1h2YETNY -*/ - -//https://iquilezles.org/articles/palettes/ - -uniform vec3 iResolution; // viewport resolution (in pixels) -uniform float iTime; // shader playback time (in seconds) -uniform float iTimeDelta; // render time (in seconds) -uniform float iFrameRate; // shader frame rate -uniform int iFrame; // shader playback frame -uniform float iChannelTime[4]; // channel playback time (in seconds) -uniform vec3 iChannelResolution[4]; // channel resolution (in pixels) -uniform vec4 iMouse; // mouse pixel coords. xy: current (if MLB down), zw: click -uniform samplerXX iChannel0..3; // input channel. XX = 2D/Cube - -vec3 palette( float t ) { - vec3 a = vec3(0.5, 0.5, 0.5); - vec3 b = vec3(0.5, 0.5, 0.5); - vec3 c = vec3(1.0, 1.0, 1.0); - vec3 d = vec3(0.263,0.416,0.557); - - return a + b*cos( 6.28318*(c*t+d) ); -} - -//https://www.shadertoy.com/view/mtyGWy -void mainImage( out vec4 fragColor, in vec2 fragCoord ) { - vec2 uv = (fragCoord * 2.0 - iResolution.xy) / iResolution.y; - vec2 uv0 = uv; - vec3 finalColor = vec3(0.0); - - for (float i = 0.0; i < 4.0; i++) { - uv = fract(uv * 1.5) - 0.5; - - float d = length(uv) * exp(-length(uv0)); - - vec3 col = palette(length(uv0) + i*.4 + iTime*.4); - - d = sin(d*8. + iTime)/8.; - d = abs(d); - - d = pow(0.01 / d, 1.2); - - finalColor += col * d; - } - - fragColor = vec4(finalColor, 1.0); -} \ No newline at end of file diff --git a/examples/project/project.cpp b/examples/project/project.cpp deleted file mode 100755 index bc2da8c..0000000 --- a/examples/project/project.cpp +++ /dev/null @@ -1,100 +0,0 @@ -void main() { - uint x = gl_GlobalInvocationID.x; - uint y = gl_GlobalInvocationID.y; - uint p = x + y * WSX; - - // Circle parameters - float centerX = WSX / 2.0; - float centerY = WSY / 2.0; - float radius = 70.0; - - // Angle de rotation - float angle = float(step) * 0.1; - - // Calculate distance from current pixel to circle center - float dx = float(x) - centerX; - float dy = float(y) - centerY; - float distance = sqrt(dx * dx + dy * dy); - - // Calculate angle of current pixel relative to center - float pixelAngle = atan(dy, dx); - - // Width of the line in radians - float lineWidth = 0.1; - - // Check if pixel is on the rotating line - bool onLine = abs(mod(pixelAngle - angle, 2.0 * 3.14159)) < lineWidth; - - // Inner circle parameters with pulsing effect - float baseInnerRadius = 18.0; - float pulseAmplitude = 3.0; // Change in radius (20 to 23) - float pulseFrequency = 1.5; // Réduit de 3.0 à 1.5 pour un pulsage plus lent - float innerRadius = baseInnerRadius + pulseAmplitude; //* sin(float(step) * pulseFrequency * 0.1); //PULSAGE - - // Border circle parameters - float borderWidth = 2.0; - float borderRadius = innerRadius + 15.0; // Un peu plus grand que le cercle intérieur - - // Moving circle parameters (3 circles) - float movingCircleRadius = 5.0; - // Premier cercle (position originale) - float movingCircleX = centerX + borderRadius * cos(angle); - float movingCircleY = centerY + borderRadius * sin(angle); - float movingCircleDistance = sqrt(pow(float(x) - movingCircleX, 2.0) + pow(float(y) - movingCircleY, 2.0)); - - // Deuxième cercle (décalé de 120 degrés) - float movingCircle2X = centerX + borderRadius * cos(angle + 2.0944); // 2.0944 = 2π/3 - float movingCircle2Y = centerY + borderRadius * sin(angle + 2.0944); - float movingCircle2Distance = sqrt(pow(float(x) - movingCircle2X, 2.0) + pow(float(y) - movingCircle2Y, 2.0)); - - // Troisième cercle (décalé de 240 degrés) - float movingCircle3X = centerX + borderRadius * cos(angle + 4.1888); // 4.1888 = 4π/3 - float movingCircle3Y = centerY + borderRadius * sin(angle + 4.1888); - float movingCircle3Distance = sqrt(pow(float(x) - movingCircle3X, 2.0) + pow(float(y) - movingCircle3Y, 2.0)); - - // Croissant parameters pour les trois cercles - float crescentRadius = 5.0; - float crescentOffset = 2.0; - - // Croissants pour chaque cercle mobile - // Croissant 1 - float crescent1MainDist = sqrt(pow(float(x) - (movingCircleX), 2.0) + - pow(float(y) - (movingCircleY - crescentRadius), 2.0)); - float crescent1SecDist = sqrt(pow(float(x) - (movingCircleX + crescentOffset), 2.0) + - pow(float(y) - (movingCircleY - crescentRadius), 2.0)); - - // Croissant 2 - float crescent2MainDist = sqrt(pow(float(x) - (movingCircle2X), 2.0) + - pow(float(y) - (movingCircle2Y - crescentRadius), 2.0)); - float crescent2SecDist = sqrt(pow(float(x) - (movingCircle2X + crescentOffset), 2.0) + - pow(float(y) - (movingCircle2Y - crescentRadius), 2.0)); - - // Croissant 3 - float crescent3MainDist = sqrt(pow(float(x) - (movingCircle3X), 2.0) + - pow(float(y) - (movingCircle3Y - crescentRadius), 2.0)); - float crescent3SecDist = sqrt(pow(float(x) - (movingCircle3X + crescentOffset), 2.0) + - pow(float(y) - (movingCircle3Y - crescentRadius), 2.0)); - - // Draw circle with line and inner circle - if (distance < radius) { - if ((crescent1MainDist < crescentRadius && crescent1SecDist > crescentRadius - 1.0) || - (crescent2MainDist < crescentRadius && crescent2SecDist > crescentRadius - 1.0) || - (crescent3MainDist < crescentRadius && crescent3SecDist > crescentRadius - 1.0)) { - data_0[p] = 0xFF000000; // Black crescents - } else if (movingCircleDistance < movingCircleRadius || - movingCircle2Distance < movingCircleRadius || - movingCircle3Distance < movingCircleRadius) { - data_0[p] = 0xFF000000; // Black moving circles - } else if (distance < innerRadius) { - data_0[p] = 0xFF000000; // Black inner circle - } else if (distance < borderRadius && distance > borderRadius - borderWidth) { - data_0[p] = 0xFF000000; // Black border - } else if (onLine) { - //data_0[p] = 0xFF000000; // Black line - } else { - data_0[p] = 0xFF0000FF; // Red circle - } - } else { - data_0[p] = 0xFFFFFFFF; // White background - } -} diff --git a/examples/project/project.tscn b/examples/project/project.tscn deleted file mode 100644 index 45bdfa2..0000000 --- a/examples/project/project.tscn +++ /dev/null @@ -1,20 +0,0 @@ -[gd_scene load_steps=3 format=3 uid="uid://b22muc60w8hia"] - -[ext_resource type="Texture2D" uid="uid://demftcowdd5c6" path="res://examples/icon.svg" id="1_se6bx"] -[ext_resource type="Script" path="res://addons/compute_shader_studio/compute_shader_studio_2d.gd" id="2_jgmy4"] - -[node name="Project" type="Node2D"] - -[node name="Node" type="Node" parent="."] - -[node name="Icon" type="Sprite2D" parent="."] -position = Vector2(593, 340) -scale = Vector2(5.04688, 4.10938) -texture = ExtResource("1_se6bx") - -[node name="ComputeShaderStudio2D2" type="Node" parent="." node_paths=PackedStringArray("data")] -script = ExtResource("2_jgmy4") -WSX = 256 -glsl_file = "res://examples/project/project.cpp" -GLSL_code = "" -data = [NodePath("../Icon")] diff --git a/examples/project/test.cpp b/examples/project/test.cpp deleted file mode 100755 index 200304e..0000000 --- a/examples/project/test.cpp +++ /dev/null @@ -1,270 +0,0 @@ -#define RADIUS 40 -#define PUPIL_RADIUS 10 -#define IRIS_RADIUS 25 -#define DOT_RADIUS 3 -#define CRESCENT_OFFSET 2.0 // Décalage pour créer l'effet de croissant -#define PI 3.14159265359 // Ajout de la définition de PI -#define SMALL_DOT_RADIUS 2.0 // Rayon du petit point -#define SMALL_DOT_OFFSET 1.0 // Distance du point par rapport au croissant -#define IRIS_BORDER 0.5 // Épaisseur de la bordure de l'iris -#define LIGHT_INTENSITY 0.4 // Intensité de la lumière directionnelle -#define BLINK_INTERVAL 200 // Intervalle de clignotement (10 secondes à 20fps) -#define BLINK_DURATION 20 // Durée du clignotement (1 seconde) -#define BLINK_SPEED 0.15 // Vitesse de propagation du noir -#define TRANSITION_WIDTH 5.0 // Largeur de la transition du noir -#define ANIMATION_INTERVAL 300 // 5 secondes à 60fps -#define PULSE_AMPLITUDE 10.0 -#define PULSE_SPEED 0.08 -#define RING_SPACING 20.0 // Espacement entre les cercles -#define RING_THICKNESS 4.0 // Épaisseur des cercles -#define SPACING_VARIATION 10.0 -#define WAVE_SPEED 0.15 // Augmentation de la vitesse de propagation (anciennement 0.05) -#define TRANSITION_DURATION 60.0 // Durée de la transition en frames -#define MAX_TRANSITION_RADIUS 60.0 // Rayon maximum du cercle de transition -#define TRANSITION_OUT_START (ANIMATION_INTERVAL - TRANSITION_DURATION) - -// Ajouter les fonctions de bruit en haut du fichier -float random(vec2 st) { - return fract(sin(dot(st.xy, vec2(12.9898, 78.233))) * 43758.5453123); -} - -float noise(vec2 st) { - vec2 i = floor(st); - vec2 f = fract(st); - float a = random(i); - float b = random(i + vec2(1.0, 0.0)); - float c = random(i + vec2(0.0, 1.0)); - float d = random(i + vec2(1.0, 1.0)); - vec2 u = f * f * (3.0 - 2.0 * f); - return mix(a, b, u.x) + (c - a) * u.y * (1.0 - u.x) + (d - b) * u.x * u.y; -} - -void main() -{ - int x = int(gl_GlobalInvocationID.x); - int y = int(gl_GlobalInvocationID.y); - int p = x + y * int(WSX); - - // initial background is black & opac - if (step == 0) { - data_0[p] = 0xFF000000; - } else { - float dx = float(mousex - x); - float dy = float(mousey - y); - float dist = sqrt(dx*dx + dy*dy); - - // Calcul de la lumière directionnelle - float lightDirX = 1.0; // Direction X de la lumière (vers la gauche) - float lightDirY = 1.0; // Direction Y de la lumière (vers le haut) - float normalX = dx/dist; - float normalY = dy/dist; - float lightAngle = (lightDirX * normalX + lightDirY * normalY) * 0.5 + 0.5; - - // Position des points tournants - float angle = float(step) * 0.05f; // Vitesse de rotation - float orbit_radius = (IRIS_RADIUS + PUPIL_RADIUS) * 0.5f; // Rayon de l'orbite - - // Premier point - float dot_x = mousex + orbit_radius * cos(angle); - float dot_y = mousey + orbit_radius * sin(angle); - float dot_dist = sqrt(pow(x - dot_x, 2) + pow(y - dot_y, 2)); - - // Deuxième point (décalé de 120°) - float dot2_x = mousex + orbit_radius * cos(angle + 2.0944); // 2π/3 - float dot2_y = mousey + orbit_radius * sin(angle + 2.0944); - float dot2_dist = sqrt(pow(x - dot2_x, 2) + pow(y - dot2_y, 2)); - - // Troisième point (décalé de 240°) - float dot3_x = mousex + orbit_radius * cos(angle + 4.1888); // 4π/3 - float dot3_y = mousey + orbit_radius * sin(angle + 4.1888); - float dot3_dist = sqrt(pow(x - dot3_x, 2) + pow(y - dot3_y, 2)); - - // Premier croissant - décalage orienté vers l'extérieur - float crescent1MainDist = sqrt(pow(x - dot_x, 2) + pow(y - dot_y, 2)); - float crescent1SecDist = sqrt(pow(x - (dot_x + CRESCENT_OFFSET * cos(angle + PI/2)), 2) + - pow(y - (dot_y + CRESCENT_OFFSET * sin(angle + PI/2)), 2)); - - // Deuxième croissant - décalage orienté vers l'extérieur - float crescent2MainDist = sqrt(pow(x - dot2_x, 2) + pow(y - dot2_y, 2)); - float crescent2SecDist = sqrt(pow(x - (dot2_x + CRESCENT_OFFSET * cos(angle + 2.0944 + + PI/2)), 2) + - pow(y - (dot2_y + CRESCENT_OFFSET * sin(angle + 2.0944 + + PI/2)), 2)); - - // Troisième croissant - décalage orienté vers l'extérieur - float crescent3MainDist = sqrt(pow(x - dot3_x, 2) + pow(y - dot3_y, 2)); - float crescent3SecDist = sqrt(pow(x - (dot3_x + CRESCENT_OFFSET * cos(angle + 4.1888 + + PI/2)), 2) + - pow(y - (dot3_y + CRESCENT_OFFSET * sin(angle + 4.1888 + + PI/2)), 2)); - - // Points superposés aux croissants - float dot1_center_x = dot_x - SMALL_DOT_OFFSET * cos(angle); - float dot1_center_y = dot_y - SMALL_DOT_OFFSET * sin(angle); - float small_dot1_dist = sqrt(pow(x - dot1_center_x, 2) + pow(y - dot1_center_y, 2)); - - float dot2_center_x = dot2_x - SMALL_DOT_OFFSET * cos(angle + 2.0944); - float dot2_center_y = dot2_y - SMALL_DOT_OFFSET * sin(angle + 2.0944); - float small_dot2_dist = sqrt(pow(x - dot2_center_x, 2) + pow(y - dot2_center_y, 2)); - - float dot3_center_x = dot3_x - SMALL_DOT_OFFSET * cos(angle + 4.1888); - float dot3_center_y = dot3_y - SMALL_DOT_OFFSET * sin(angle + 4.1888); - float small_dot3_dist = sqrt(pow(x - dot3_center_x, 2) + pow(y - dot3_center_y, 2)); - - // Génération du fond animé - float iTime = step / 10.0; - vec2 fragCoord = vec2(float(x), float(y)); - vec2 iResolution = vec2(float(WSX), float(WSY)); - vec4 fragColor = vec4(0.0); - - float t = iTime / 10.0; - vec2 pos = 100.0 * fragCoord/(iResolution.xy); - float yPos = pos.y/100.0; - pos.y += sin(2.0*t); - pos.x += cos(5.0*t); - pos *= mat2(sin(t/2.0),-cos(t/2.0),cos(t/2.0),sin(t/2.0))/8.0; - - for (float i = 0.0; i < 8.0; i++) { - fragColor = cos(pos.xxxx*0.3)*0.5+0.5; - float n = noise(pos/5.0); - fragColor *= n; - pos.x += sin(pos.y + iTime*0.3 + i); - pos *= mat2(6.0,-8.0,8.0,6.0)/8.0; - } - - fragColor *= 1.0 - smoothstep(0.0, 0.91, yPos); - fragColor *= vec4(0.2, 0.23, 0.54, 1.0); - - // Conversion de la couleur du fond - uint r = uint(min(255.0, fragColor.r * 255.0)); - uint g = uint(min(255.0, fragColor.g * 255.0)); - uint b = uint(min(255.0, fragColor.b * 255.0)); - uint background_color = 0xFF000000 | (r << 16) | (g << 8) | b; - - if (dist < RADIUS) { - float z = sqrt(RADIUS*RADIUS - dist*dist); - float normal_z = z/RADIUS; - float light = normal_z; - light = clamp(light * (0.7 + lightAngle * LIGHT_INTENSITY), 0.2f, 1.0f); - - // Alternance entre les animations - bool usePulsingAnimation = ((step / ANIMATION_INTERVAL) % 2) == 1; - - if (usePulsingAnimation) { - float d = sqrt(dx * dx + dy * dy); - float cycleStart = float(step % ANIMATION_INTERVAL); - - // Gestion des transitions - if (cycleStart < TRANSITION_DURATION) { - // Transition d'entrée (comme avant) - float transitionRadius = (cycleStart / TRANSITION_DURATION) * MAX_TRANSITION_RADIUS; - - if (d < transitionRadius) { - // Nouvelle animation - float animatedD = d - float(step) * WAVE_SPEED; - float rings = mod(animatedD, RING_SPACING); - - if (rings < RING_THICKNESS) { - data_0[p] = 0xFF000000; - } else { - int value = int(255.0f * light); - int red = int(180.0f * light); // Augmenté de 128 à 180 - int green = 0; - int blue = int(180.0f * light); // Augmenté de 128 à 180 - data_0[p] = 0xFF000000 | (red << 16) | (green << 8) | blue; - } - } else { - // Animation normale - if (dist < PUPIL_RADIUS) { - data_0[p] = 0xFF000000; - } - // ...reste du code de l'animation normale... - } - } else if (cycleStart > TRANSITION_OUT_START) { - // Transition de sortie - float transitionOutProgress = (cycleStart - TRANSITION_OUT_START) / TRANSITION_DURATION; - float fadeRadius = (1.0 - transitionOutProgress) * MAX_TRANSITION_RADIUS; - - if (d < fadeRadius) { - // Zone encore visible de l'animation des cercles - float animatedD = d - float(step) * WAVE_SPEED; - float rings = mod(animatedD, RING_SPACING); - - if (rings < RING_THICKNESS) { - data_0[p] = 0xFF000000; - } else { - int value = int(255.0f * light); - int red = int(180.0f * light); // Augmenté de 128 à 180 - int green = 0; - int blue = int(180.0f * light); // Augmenté de 128 à 180 - data_0[p] = 0xFF000000 | (red << 16) | (green << 8) | blue; - } - } else { - // Zone qui revient à l'animation normale - if (dist < PUPIL_RADIUS) { - data_0[p] = 0xFF000000; - } else if (dist < IRIS_RADIUS) { - if ((crescent1MainDist < DOT_RADIUS && crescent1SecDist > DOT_RADIUS - 1.0) || - (crescent2MainDist < DOT_RADIUS && crescent2SecDist > DOT_RADIUS - 1.0) || - (crescent3MainDist < DOT_RADIUS && crescent3SecDist > DOT_RADIUS - 1.0) || - small_dot1_dist < SMALL_DOT_RADIUS || - small_dot2_dist < SMALL_DOT_RADIUS || - small_dot3_dist < SMALL_DOT_RADIUS) { - data_0[p] = 0xFF000000; - } else if (dist > IRIS_RADIUS - IRIS_BORDER) { - data_0[p] = 0xFF404040; - } else { - int red = int(200.0f * light); - data_0[p] = 0xFF000000 | red; - } - } else { - int value = int(255.0f * light); - int red = value; - int green = int(value * 0.95); - int blue = int(value * 0.9); - data_0[p] = 0xFF000000 | (red << 16) | (green << 8) | blue; - } - } - } else { - // Animation complète des cercles (entre les deux transitions) - float animatedD = d - float(step) * WAVE_SPEED; - float rings = mod(animatedD, RING_SPACING); - - if (rings < RING_THICKNESS) { - data_0[p] = 0xFF000000; - } else { - int value = int(255.0f * light); - int red = int(180.0f * light); // Augmenté de 128 à 180 - int green = 0; - int blue = int(180.0f * light); // Augmenté de 128 à 180 - data_0[p] = 0xFF000000 | (red << 16) | (green << 8) | blue; - } - } - } else { - // Animation normale - if (dist < PUPIL_RADIUS) { - data_0[p] = 0xFF000000; - } else if (dist < IRIS_RADIUS) { - if ((crescent1MainDist < DOT_RADIUS && crescent1SecDist > DOT_RADIUS - 1.0) || - (crescent2MainDist < DOT_RADIUS && crescent2SecDist > DOT_RADIUS - 1.0) || - (crescent3MainDist < DOT_RADIUS && crescent3SecDist > DOT_RADIUS - 1.0) || - small_dot1_dist < SMALL_DOT_RADIUS || - small_dot2_dist < SMALL_DOT_RADIUS || - small_dot3_dist < SMALL_DOT_RADIUS) { - data_0[p] = 0xFF000000; - } else if (dist > IRIS_RADIUS - IRIS_BORDER) { - data_0[p] = 0xFF404040; - } else { - int red = int(200.0f * light); - data_0[p] = 0xFF000000 | red; - } - } else { - int value = int(255.0f * light); - int red = value; - int green = int(value * 0.95); - int blue = int(value * 0.9); - data_0[p] = 0xFF000000 | (red << 16) | (green << 8) | blue; - } - } - } else { - data_0[p] = int(background_color); // Fond animé au lieu de gris moyen - } - } -} - diff --git a/examples/project/test.tscn b/examples/project/test.tscn deleted file mode 100644 index 969fd3a..0000000 --- a/examples/project/test.tscn +++ /dev/null @@ -1,17 +0,0 @@ -[gd_scene load_steps=3 format=3 uid="uid://duh7anebdiq5r"] - -[ext_resource type="Script" path="res://addons/compute_shader_studio/compute_shader_studio_2d.gd" id="1_o3uyj"] -[ext_resource type="Texture2D" uid="uid://demftcowdd5c6" path="res://examples/icon.svg" id="2_gpcd8"] - -[node name="Test" type="Node2D"] - -[node name="ComputeShaderStudio2D" type="Node" parent="." node_paths=PackedStringArray("data")] -script = ExtResource("1_o3uyj") -glsl_file = "res://examples/project/test.cpp" -data = [NodePath("../Icon")] -metadata/_custom_type_script = "uid://c8esqdv0y26yp" - -[node name="Icon" type="Sprite2D" parent="."] -position = Vector2(685, 320) -scale = Vector2(5.3125, 5.03125) -texture = ExtResource("2_gpcd8") diff --git a/project.godot b/project.godot index a5e8bc4..9b44565 100644 --- a/project.godot +++ b/project.godot @@ -11,7 +11,7 @@ config_version=5 [application] config/name="compute_shader_studio" -run/main_scene="res://examples/backgroundClement/TestExample.tscn" +run/main_scene="res://examples/naruto/project/test.tscn" config/features=PackedStringArray("4.3", "Forward Plus") config/icon="res://addons/compute_shader_studio/icon.png" From e67de4624b89c995f2001477b77e607439e4665d Mon Sep 17 00:00:00 2001 From: Clement Nassih Date: Mon, 17 Mar 2025 21:38:21 +0100 Subject: [PATCH 25/27] ajout commentaires --- examples/naruto/project/naruto.cpp | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/examples/naruto/project/naruto.cpp b/examples/naruto/project/naruto.cpp index 200304e..d00f23a 100644 --- a/examples/naruto/project/naruto.cpp +++ b/examples/naruto/project/naruto.cpp @@ -107,31 +107,42 @@ void main() float dot3_center_y = dot3_y - SMALL_DOT_OFFSET * sin(angle + 4.1888); float small_dot3_dist = sqrt(pow(x - dot3_center_x, 2) + pow(y - dot3_center_y, 2)); - // Génération du fond animé - float iTime = step / 10.0; - vec2 fragCoord = vec2(float(x), float(y)); + // Variables nécessaires pour le background animé + float t = step / 10.0; // division par 10 pour ralentir l'animation + vec2 fragCoord = vec2(float(x), float(y));// Position du pixel vec2 iResolution = vec2(float(WSX), float(WSY)); - vec4 fragColor = vec4(0.0); + vec4 fragColor = vec4(0.0); //couleur initiale = noir transparent float t = iTime / 10.0; vec2 pos = 100.0 * fragCoord/(iResolution.xy); float yPos = pos.y/100.0; + // mouvement oscillaoire vertical et horizontal pos.y += sin(2.0*t); pos.x += cos(5.0*t); + // rotation progressive de l'effet pos *= mat2(sin(t/2.0),-cos(t/2.0),cos(t/2.0),sin(t/2.0))/8.0; + // Boucle gérant l'effet de fractale for (float i = 0.0; i < 8.0; i++) { + //motif de base répétés avec transitions douces fragColor = cos(pos.xxxx*0.3)*0.5+0.5; + //ajout de bruit de Perlin pour un effet de texture organique float n = noise(pos/5.0); + //multiplie la couleur par le bruit de Perlin fragColor *= n; + //deformation ondulatoire horizontale pos.x += sin(pos.y + iTime*0.3 + i); + //deformation ondulatoire verticale pos *= mat2(6.0,-8.0,8.0,6.0)/8.0; } - + + //fade vertical fragColor *= 1.0 - smoothstep(0.0, 0.91, yPos); + + //teinte rouge fragColor *= vec4(0.2, 0.23, 0.54, 1.0); - // Conversion de la couleur du fond + // Conversion de la couleur du fond float -> int uint r = uint(min(255.0, fragColor.r * 255.0)); uint g = uint(min(255.0, fragColor.g * 255.0)); uint b = uint(min(255.0, fragColor.b * 255.0)); From dfa52d8838decf16d4b317e7c61c00527b30cb55 Mon Sep 17 00:00:00 2001 From: Clement Nassih Date: Tue, 18 Mar 2025 09:27:31 +0100 Subject: [PATCH 26/27] =?UTF-8?q?r=C3=A9solution=20erreur=20avant=20presen?= =?UTF-8?q?tation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/naruto/project/naruto.cpp | 2 +- examples/naruto/project/{test.tscn => scene-finale.tscn} | 2 +- project.godot | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) rename examples/naruto/project/{test.tscn => scene-finale.tscn} (95%) diff --git a/examples/naruto/project/naruto.cpp b/examples/naruto/project/naruto.cpp index d00f23a..8f932d6 100644 --- a/examples/naruto/project/naruto.cpp +++ b/examples/naruto/project/naruto.cpp @@ -108,7 +108,7 @@ void main() float small_dot3_dist = sqrt(pow(x - dot3_center_x, 2) + pow(y - dot3_center_y, 2)); // Variables nécessaires pour le background animé - float t = step / 10.0; // division par 10 pour ralentir l'animation + float iTime = step / 10.0; // division par 10 pour ralentir l'animation vec2 fragCoord = vec2(float(x), float(y));// Position du pixel vec2 iResolution = vec2(float(WSX), float(WSY)); vec4 fragColor = vec4(0.0); //couleur initiale = noir transparent diff --git a/examples/naruto/project/test.tscn b/examples/naruto/project/scene-finale.tscn similarity index 95% rename from examples/naruto/project/test.tscn rename to examples/naruto/project/scene-finale.tscn index 6ad2f4a..0b448b5 100644 --- a/examples/naruto/project/test.tscn +++ b/examples/naruto/project/scene-finale.tscn @@ -3,7 +3,7 @@ [ext_resource type="Script" path="res://addons/compute_shader_studio/compute_shader_studio_2d.gd" id="1_o3uyj"] [ext_resource type="Texture2D" uid="uid://demftcowdd5c6" path="res://examples/icon.svg" id="2_gpcd8"] -[node name="Test" type="Node2D"] +[node name="finale" type="Node2D"] [node name="ComputeShaderStudio2D" type="Node" parent="." node_paths=PackedStringArray("data")] script = ExtResource("1_o3uyj") diff --git a/project.godot b/project.godot index 9b44565..0b66aa0 100644 --- a/project.godot +++ b/project.godot @@ -11,7 +11,7 @@ config_version=5 [application] config/name="compute_shader_studio" -run/main_scene="res://examples/naruto/project/test.tscn" +run/main_scene="res://examples/naruto/project/scene-finale.tscn" config/features=PackedStringArray("4.3", "Forward Plus") config/icon="res://addons/compute_shader_studio/icon.png" From e611451ab1082aafff93274d6e9e90552f8fd27d Mon Sep 17 00:00:00 2001 From: Clement Nassih Date: Tue, 18 Mar 2025 12:43:12 +0100 Subject: [PATCH 27/27] edit readme --- examples/naruto/project/scene-finale.tscn | 2 +- examples/naruto/read.me | 2 ++ project.godot | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/examples/naruto/project/scene-finale.tscn b/examples/naruto/project/scene-finale.tscn index 0b448b5..799cfb1 100644 --- a/examples/naruto/project/scene-finale.tscn +++ b/examples/naruto/project/scene-finale.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=3 format=3 uid="uid://duh7anebdiq5r"] -[ext_resource type="Script" path="res://addons/compute_shader_studio/compute_shader_studio_2d.gd" id="1_o3uyj"] +[ext_resource type="Script" uid="uid://c8esqdv0y26yp" path="res://addons/compute_shader_studio/compute_shader_studio_2d.gd" id="1_o3uyj"] [ext_resource type="Texture2D" uid="uid://demftcowdd5c6" path="res://examples/icon.svg" id="2_gpcd8"] [node name="finale" type="Node2D"] diff --git a/examples/naruto/read.me b/examples/naruto/read.me index f560a5c..ac6bf62 100644 --- a/examples/naruto/read.me +++ b/examples/naruto/read.me @@ -5,6 +5,8 @@ Réda Lahdoudi Saad Madi-Soilihi Clément Nassih +Sur git nous avons chacun travaillé dans notre propre branche avant de merge pour fusionner nos différents résultats et obtenir le résultat final que nous vous avons présenté en cours + Pour la réalisation de notre projet nous nous sommes aidés de l'ia claude via github copilot. Le background a été inspiré par le shadertoy suivant : https://www.shadertoy.com/view/Wf2GDt diff --git a/project.godot b/project.godot index 1617345..2eeea6e 100644 --- a/project.godot +++ b/project.godot @@ -11,7 +11,7 @@ config_version=5 [application] config/name="compute_shader_studio" -run/main_scene="res://examples/example_1.tscn" +run/main_scene="uid://duh7anebdiq5r" config/features=PackedStringArray("4.4", "Forward Plus") config/icon="res://addons/compute_shader_studio/icon.png"