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 eedd69f
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 63 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
17 changes: 4 additions & 13 deletions src/models/icosahedron/Icosahedron.tscn
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[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"]
Expand All @@ -11,7 +11,6 @@
[ext_resource type="Shader" path="res://src/models/icosahedron/shaders/outline_v1.gdshader" id="5_ucsrc1"]
[ext_resource type="Texture2D" uid="uid://bpr01fnnfusau" path="res://src/models/icosahedron/resources/edge_noise.res" id="6_ai0t7"]
[ext_resource type="Script" path="res://src/models/icosahedron/components/Collider.gd" id="7_6oydw"]
[ext_resource type="Texture2D" uid="uid://cixi1rd0a28e4" path="res://assets/build/textures/texture-test-v1.png" id="8_h5ail"]

[sub_resource type="ShaderMaterial" id="ShaderMaterial_rdyh1"]
render_priority = 0
Expand All @@ -35,9 +34,9 @@ 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)

[sub_resource type="ShaderMaterial" id="ShaderMaterial_c0lt3"]
render_priority = 1
Expand All @@ -47,14 +46,6 @@ 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.17
shader_parameter/uv_offset_y = 2.71
shader_parameter/ratio = 0.075
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/cutlane_tex = ExtResource("8_h5ail")

[sub_resource type="ShaderMaterial" id="ShaderMaterial_bjqtf"]
render_priority = 0
Expand Down
45 changes: 1 addition & 44 deletions src/models/icosahedron/shaders/cutplane_effect_v2.gdshader
Original file line number Diff line number Diff line change
Expand Up @@ -14,35 +14,6 @@ uniform float outline_thickness = 0.0; // how thick is the outline?

varying vec3 ver;

uniform sampler2D cutlane_tex;

uniform float uv_offset_x = 0.;
uniform float uv_offset_y = 0.;

uniform float ratio : hint_range(0.0, 1.0) = 0.1;

uniform float power = 3.0;

uniform float time_speed = 10.0;

uniform float max_speed = 90.0;

uniform vec2 uv_rot;

vec2 rotate(vec2 uv, vec2 pivot, float angle) {
// clang-format off
mat2 rotation = mat2(
vec2(sin(angle), -cos(angle)),
vec2(cos(angle), sin(angle)),
);
// clang-format on

uv -= pivot;
uv = uv * rotation;
uv += pivot;
return uv;
}

void vertex() {
if (enable) {
// VERTEX += NORMAL * outline_thickness; // apply the outlines thickness
Expand All @@ -51,18 +22,6 @@ 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.);
if (enable) {
float dist = cutplane_dist(cutplane, ver);
bool a = dist > 0.;
Expand All @@ -74,9 +33,7 @@ void fragment() {
// ALBEDO = a ? mix(vec3(1. - smoothstep(0.51, 0.9, r_sq) * 1.), color,
// 0.01) : vec3(0.); ALBEDO = a ? vec3(smoothstep(0.58, 0.9, r_sq)) :
// vec3(0.);
// vec2 rotated_uv = rotate(UV, vec2(0.5), TIME);
// ALBEDO = vec3(rotated_uv.g);
ALBEDO = color * (1. - vec3(aaa.a));
ALBEDO = color;
ALPHA = a ? 0.7 : 0.;

} else {
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 eedd69f

Please sign in to comment.