Skip to content

Commit

Permalink
temp: more shaders
Browse files Browse the repository at this point in the history
  • Loading branch information
akorzunin committed Sep 18, 2024
1 parent 8cc79f2 commit ade40ad
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 28 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,4 @@ mono_crash.*.json
*.import
*.blend*
.ansible_vault_password
addons/discord-rpc-gd/bin/windows/~discord_game_sdk_binding_debug.dll
33 changes: 26 additions & 7 deletions src/models/icosahedron/Icosahedron.tscn
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
[gd_scene load_steps=20 format=3 uid="uid://c28nbcejwepp8"]
[gd_scene load_steps=19 format=3 uid="uid://c28nbcejwepp8"]

[ext_resource type="ArrayMesh" uid="uid://dh3qpoqqgdct5" path="res://src/models/icosahedron/assets/icosahedron_Solid.res" id="1_kd7xu"]
[ext_resource type="Script" path="res://src/models/icosahedron/components/Icosahedron.gd" id="1_w7qn7"]
[ext_resource type="Shader" path="res://src/models/icosahedron/shaders/cut_plane_shader.gdshader" id="2_u8yhs"]
[ext_resource type="Script" path="res://src/models/icosahedron/components/CutPlane.gd" id="2_yg3qy"]
[ext_resource type="Shader" path="res://src/models/icosahedron/shaders/edge_highlight_v1.gdshader" id="5_al5e2"]
[ext_resource type="Shader" path="res://src/models/icosahedron/shaders/cutplane_effect_v2.gdshader" id="5_cipg0"]
Expand All @@ -15,7 +14,22 @@

[sub_resource type="ShaderMaterial" id="ShaderMaterial_rdyh1"]
render_priority = 0
shader = ExtResource("2_u8yhs")
shader = ExtResource("5_cipg0")
shader_parameter/cutplane = Vector4(-0.577, -0.577, 0.577, 0.794)
shader_parameter/color = Color(0, 1, 0, 1)
shader_parameter/enable = true
shader_parameter/outline_thickness = 0.0
shader_parameter/uv_offset_x = 0.0
shader_parameter/uv_offset_y = 0.0
shader_parameter/ratio = 0.1
shader_parameter/power = 3.0
shader_parameter/time_speed = 10.0
shader_parameter/max_speed = 90.0
shader_parameter/uv_rot = null
shader_parameter/center = Vector2(0.5, 0.5)
shader_parameter/strength = 1.0
shader_parameter/speed = 2.84
shader_parameter/cutlane_tex = ExtResource("8_h5ail")

[sub_resource type="PlaneMesh" id="PlaneMesh_8mu0u"]

Expand All @@ -35,9 +49,11 @@ shader_parameter/noise_pattern = ExtResource("6_ai0t7")
render_priority = 2
next_pass = SubResource("ShaderMaterial_4yeiy")
shader = ExtResource("5_ucsrc1")
shader_parameter/enable = false
shader_parameter/outline_thickness = 0.11
shader_parameter/color = Color(0, 1, 0, 1)
shader_parameter/enable = true
shader_parameter/outline_thickness = 0.05
shader_parameter/color = Color(0.358796, 0.73469, 0.907072, 1)
shader_parameter/pulse_speed = 12.0
shader_parameter/pulse_amplitude = 2.0

[sub_resource type="ShaderMaterial" id="ShaderMaterial_c0lt3"]
render_priority = 1
Expand All @@ -54,6 +70,9 @@ shader_parameter/power = 2.775
shader_parameter/time_speed = 3.61
shader_parameter/max_speed = 90.0
shader_parameter/uv_rot = Vector2(0.11, 0.375)
shader_parameter/center = null
shader_parameter/strength = null
shader_parameter/speed = null
shader_parameter/cutlane_tex = ExtResource("8_h5ail")

[sub_resource type="ShaderMaterial" id="ShaderMaterial_bjqtf"]
Expand All @@ -72,7 +91,6 @@ shader_type = -1

[node name="CutPlane" type="MeshInstance3D" parent="."]
transform = Transform3D(-0.761007, -0.570635, -0.308616, -0.107281, 0.579858, -0.807623, 0.639811, -0.581498, -0.502495, -0.843964, 0.0584427, -0.468957)
visible = false
material_override = SubResource("ShaderMaterial_rdyh1")
mesh = SubResource("PlaneMesh_8mu0u")
script = ExtResource("2_yg3qy")
Expand All @@ -86,6 +104,7 @@ script = ExtResource("7_6oydw")
shape = SubResource("BoxShape3D_nvmtx")

[node name="MeshIcosahedron" type="MeshInstance3D" parent="."]
visible = false
material_override = SubResource("ShaderMaterial_bjqtf")
cast_shadow = 0
mesh = ExtResource("1_kd7xu")
Expand Down
54 changes: 39 additions & 15 deletions src/models/icosahedron/shaders/cutplane_effect_v2.gdshader
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
shader_type spatial;
render_mode cull_front, depth_test_disabled;
render_mode cull_disabled, depth_test_disabled;

#include "cutplane.gdshaderinc"
#include "res://src/shaders/shader_utils.gdshaderinc"
Expand Down Expand Up @@ -33,7 +33,7 @@ vec2 rotate(vec2 uv, vec2 pivot, float angle) {
// clang-format off
mat2 rotation = mat2(
vec2(sin(angle), -cos(angle)),
vec2(cos(angle), sin(angle)),
vec2(cos(angle), sin(angle))
);
// clang-format on

Expand All @@ -43,6 +43,25 @@ vec2 rotate(vec2 uv, vec2 pivot, float angle) {
return uv;
}

uniform vec2 center;
uniform float strength : hint_range(-10, 10);
uniform float speed : hint_range(-10, 10);

vec2 vortex(vec2 uv, vec2 _center, float _strength, float _speed) {
float t = sin(TIME);
vec2 dir = uv - _center;
float dist = length(dir);
//float angle = atan(dir.y * (1. - abs(sin(TIME))), dir.x * abs(sin(TIME)));
float angle = atan(dir.y, dir.x) * 0.4;
//if (angle)
float radius = dist * _strength;
float new_angle = angle + TIME * _speed;

vec2 new_uv = _center + vec2(cos(new_angle), sin(new_angle)) * radius;

return new_uv;
}

void vertex() {
if (enable) {
// VERTEX += NORMAL * outline_thickness; // apply the outlines thickness
Expand All @@ -52,17 +71,21 @@ void vertex() {

void fragment() {
vec2 uv = UV;

uv *= 2.0;
uv -= vec2(1.0);

float len = length(uv);

vec2 modified_uv = rotate(UV, uv_rot, TIME * time_speed);
float t = sin(TIME);
modified_uv.x += uv_offset_x;
modified_uv.y += uv_offset_y;
vec4 aaa = texture(cutlane_tex, modified_uv * 5.);
vec2 new_uv = vortex(uv, center, strength, speed);

vec4 tex = texture(cutlane_tex, new_uv);

//
//uv *= 2.0;
//uv -= vec2(1.0);
//
//float len = length(uv);
//
//vec2 modified_uv = rotate(UV, uv_rot, TIME * time_speed);
//float t = sin(TIME);
//modified_uv.x += uv_offset_x;
//modified_uv.y += uv_offset_y;
//vec4 aaa = texture(cutlane_tex, modified_uv * 5.);
if (enable) {
float dist = cutplane_dist(cutplane, ver);
bool a = dist > 0.;
Expand All @@ -76,8 +99,9 @@ void fragment() {
// vec3(0.);
// vec2 rotated_uv = rotate(UV, vec2(0.5), TIME);
// ALBEDO = vec3(rotated_uv.g);
ALBEDO = color * (1. - vec3(aaa.a));
ALPHA = a ? 0.7 : 0.;
ALBEDO = color * (1. - vec3(tex.a));
//ALBEDO = vec3(tex.a);
//ALPHA = a ? 0.7 : 0.;

} else {
ALPHA = .0;
Expand Down
9 changes: 3 additions & 6 deletions src/models/icosahedron/shaders/outline_v1.gdshader
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
shader_type spatial;
render_mode cull_front, unshaded;
render_mode unshaded, cull_front;

uniform bool enable = false;

Expand All @@ -8,18 +8,15 @@ uniform sampler2D screen_texture : hint_screen_texture,
filter_nearest;

// outline costumization
uniform float outline_thickness = 0.11;
uniform vec4 color : source_color = vec4(0., 1., 0., 1.);
uniform float outline_thickness = 0.05;
uniform vec4 color : source_color = vec4(0.0);

// pulse customization
uniform float pulse_speed = 12.;
uniform float pulse_amplitude = 2.;

varying vec3 ver;

uniform sampler2D screen_texture : hint_screen_texture, repeat_disable, filter_nearest;
uniform sampler2D outline_tex;

void vertex() {
if (enable) {
float t = sin(TIME * pulse_speed) / pulse_amplitude + 1.;
Expand Down

0 comments on commit ade40ad

Please sign in to comment.