Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ mono_crash.*.json
.DS_Store
screenshots/.DS_Store
*.tmp
*.json
11 changes: 11 additions & 0 deletions ComputeShaderStudio2D.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
extends Node


# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.


# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
pass
2 changes: 1 addition & 1 deletion examples/cells/example_cells.tscn
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[gd_scene load_steps=3 format=3 uid="uid://cutxgtalwsp6q"]

[ext_resource type="Script" uid="uid://bs2f5sxok3d3i" path="res://examples/cells/cells.gd" id="1_dw4h8"]
[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"]

[node name="Cells" type="Control" node_paths=PackedStringArray("data")]
Expand Down
2 changes: 1 addition & 1 deletion examples/circles/circles.tscn
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[gd_scene load_steps=3 format=3 uid="uid://c1ux4sgouixua"]

[ext_resource type="Script" uid="uid://c8esqdv0y26yp" path="res://addons/compute_shader_studio/compute_shader_studio_2d.gd" id="1_amro2"]
[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"]
Expand Down
2 changes: 1 addition & 1 deletion examples/example_1.tscn
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[gd_scene load_steps=5 format=3 uid="uid://ddr6qtwy1pesd"]

[ext_resource type="Script" uid="uid://c8esqdv0y26yp" 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"]
Expand Down
339 changes: 339 additions & 0 deletions examples/interactive_waves/interactive_waves.tscn

Large diffs are not rendered by default.

123 changes: 123 additions & 0 deletions examples/light_source/light_source.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
// Enhanced artistic shader - Prismatic Flow
// Inspired by Danilo Guanabara with artistic extensions



//AUTHORS: NASSIM & YASSER
void main()
{
int x = int(gl_GlobalInvocationID.x);
int y = int(gl_GlobalInvocationID.y);
int idx = x + y * int(WSX);
// Normalized coordinates
vec2 fragCoord = vec2(float(x), float(y));
vec2 resolution = vec2(float(WSX), float(WSY));
float time = float(step) * 0.03;

// Mouse interaction
vec2 mouse = vec2(float(mousex), float(mousey)) / resolution;

// Calculate artistic effect
vec3 c = vec3(0.0);
float l = 0.0;
float z = time;

// Create multiple artistic layers with different parameters
for (int i = 0; i < 3; i++)
{
vec2 uv, p;

// Normalized coordinates (0 to 1)
p = fragCoord / resolution;
uv = p;

// Center coordinates (-0.5 to 0.5)
p -= 0.5;

// Fix aspect ratio
p.x *= resolution.x / resolution.y;

// Increment z for each color channel with variation
z += 0.07 + sin(time * 0.2) * 0.02;

// Calculate length for distortion
l = length(p);

// Apply artistic distortion - enhanced with variations
float distortionStrength = (sin(z) + 1.0) * (1.0 + 0.3 * sin(time * 0.3));
float wavePattern = abs(sin(l * (9.0 + sin(time * 0.2) * 3.0) - z * 2.0));

// Add mouse influence to distortion
float mouseDist = length(p - (mouse - 0.5) * vec2(resolution.x / resolution.y, 1.0));
float mouseInfluence = 0.0;
if (mouseDist < 0.5)
{
mouseInfluence = (0.5 - mouseDist) * 2.0 * sin(time * 2.0);
}

// Apply enhanced distortion
uv += p / max(0.001, l) * (distortionStrength + mouseInfluence) * wavePattern;

// Add rotational flow
float angle = atan(p.y, p.x);
uv += (5.0f*mousex/float(WSX)) * vec2(cos(angle + time), sin(angle + time)) * sin(time + l * 5.0);

// Calculate lightular-like pattern with enhanced effects
vec2 lightCoord = mod(uv, 1.0) - 0.5;

// Create multiple lightular layers
float lightPattern = 0.01 / length(lightCoord);

// Add fine details to lights
lightPattern += 0.005 / length(mod(uv * 2.0, 1.0) - 0.5) * (0.5 + 0.5 * sin(l * 20.0 + time));

// Store color with channel-specific effects
if (i == 0)
{
// Red channel - warmer pattern
c[i] = lightPattern * (0.9 + 0.3 * sin(time + l * 3.0));
}
else if (i == 1)
{
// Green channel - phase shifted
c[i] = lightPattern * (0.8 + 0.3 * sin(time * 1.1 + l * 3.5));
}
else
{
// Blue channel - different phase
c[i] = lightPattern * (0.7 + 0.4 * sin(time * 0.9 + l * 4.0));
}
}

// Enhance color blending
float intensity = max(l, 0.001) * (1.0 + 0.2 * sin(time));
vec3 rawColor = c / intensity;

// Color grading - add artistic color palette
vec3 finalColor;

// Apply color temperature shift based on position
float temp = sin(fragCoord.x / resolution.x * 3.14159 + time * 0.5) * 0.5 + 0.5;

// Create a vibrant color palette
finalColor.r = rawColor.r * (1.0 + 0.3 * temp);
finalColor.g = rawColor.g * (1.0 + 0.2 * (1.0 - temp));
finalColor.b = rawColor.b * (1.0 + 0.3 * sin(temp * 3.14159));
// Add subtle vignette effect
vec2 vignettePos = fragCoord / resolution - 0.5;
float vignette = 1.0 - dot(vignettePos, vignettePos) * 0.8;
finalColor *= vignette;

// Add subtle pulsing
finalColor *= 0.8 + (mousey/float(WSY)) * sin(time * 0.5);

// Enhance contrast
finalColor = pow(finalColor, vec3(0.9, 0.9, 0.9));

// Convert to 8-bit color
int r = int(clamp(finalColor.r * 255.0, 0.0, 255.0));
int g = int(clamp(finalColor.g * 255.0, 0.0, 255.0));
int b = int(clamp(finalColor.b * 255.0, 0.0, 255.0));
// Store the final color
data_0[idx] = 0xFF000000 | (r << 16) | (g << 8) | b;
}
26 changes: 26 additions & 0 deletions examples/light_source/light_source.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
[gd_scene load_steps=3 format=3 uid="uid://dy6y2fqmvn42e"]

[ext_resource type="Script" uid="uid://c8esqdv0y26yp" path="res://addons/compute_shader_studio/compute_shader_studio_2d.gd" id="1_bkr6h"]
[ext_resource type="Texture2D" uid="uid://demftcowdd5c6" path="res://examples/icon.svg" id="2_lvs8q"]

[node name="LightSource" type="Node2D"]

[node name="ComputeShaderStudio2D" type="Node" parent="." node_paths=PackedStringArray("data")]
script = ExtResource("1_bkr6h")
WSX = 800
WSY = 600
glsl_file = "res://examples/light_source/light_source.cpp"
data = [NodePath("../LightDisplay")]
metadata/_custom_type_script = "uid://c8esqdv0y26yp"

[node name="LightDisplay" type="Sprite2D" parent="."]
position = Vector2(571, 324)
scale = Vector2(8.92188, 5.09375)
texture = ExtResource("2_lvs8q")

[node name="InfoLabel" type="Label" parent="."]
offset_left = 14.0
offset_top = 552.0
offset_right = 415.0
offset_bottom = 601.0
text = "LIGHT SOURCE"