Neat shader and logo for titlescreen
This commit is contained in:
parent
f06526825d
commit
63b0ad545b
8 changed files with 183 additions and 3 deletions
63
Graphics/UI/Background.shader
Normal file
63
Graphics/UI/Background.shader
Normal file
|
@ -0,0 +1,63 @@
|
|||
// Based on https://www.shadertoy.com/view/XlfGRj by Pablo Roman Andrioli
|
||||
// Licensed under MIT
|
||||
|
||||
shader_type canvas_item;
|
||||
|
||||
render_mode unshaded;
|
||||
|
||||
uniform int iterations = 17;
|
||||
uniform float formuparam = 0.53;
|
||||
uniform int volsteps = 20;
|
||||
uniform float stepsize = 0.1;
|
||||
uniform float zoom = 0.80;
|
||||
uniform float tile = 0.85;
|
||||
uniform float speed = 0.001;
|
||||
uniform float brightness = 0.0015;
|
||||
uniform float darkmatter = 0.300;
|
||||
uniform float distfading = 0.730;
|
||||
uniform float saturation = 0.850;
|
||||
uniform float rotx = 0;
|
||||
uniform float roty = 0.001;
|
||||
|
||||
void fragment() {
|
||||
vec2 uv = FRAGCOORD.xy * SCREEN_PIXEL_SIZE - 0.5;
|
||||
uv.y *= SCREEN_PIXEL_SIZE.x/SCREEN_PIXEL_SIZE.y;
|
||||
|
||||
vec3 dir = vec3(uv*zoom, 1.);
|
||||
float time = TIME*speed+.25;
|
||||
|
||||
float a1=.5+TIME*rotx;
|
||||
float a2=.8+TIME*roty;
|
||||
mat2 rot1=mat2(vec2(cos(a1),sin(a1)),vec2(-sin(a1),cos(a1)));
|
||||
mat2 rot2=mat2(vec2(cos(a2),sin(a2)),vec2(-sin(a2),cos(a2)));
|
||||
dir.xz*=rot1;
|
||||
dir.xy*=rot2;
|
||||
vec3 from=vec3(1.,.5,0.5);
|
||||
from+=vec3(time*2.,time,-2.);
|
||||
from.xz*=rot1;
|
||||
from.xy*=rot2;
|
||||
|
||||
//volumetric rendering
|
||||
float s=0.1,fade=1.;
|
||||
vec3 v=vec3(0.);
|
||||
for (int r=0; r<volsteps; r++) {
|
||||
vec3 p=from+s*dir*.5;
|
||||
p = abs(vec3(tile)-mod(p,vec3(tile*2.))); // tiling fold
|
||||
float pa,a=pa=0.;
|
||||
for (int i=0; i<iterations; i++) {
|
||||
p=abs(p)/dot(p,p)-formuparam; // the magic formula
|
||||
a+=abs(length(p)-pa); // absolute sum of average change
|
||||
pa=length(p);
|
||||
}
|
||||
float dm=max(0.,darkmatter-a*a*.001); //dark matter
|
||||
a*=a*a; // add contrast
|
||||
if (r>6) fade*=1.-dm; // dark matter, don't render near
|
||||
//v+=vec3(dm,dm*.5,0.);
|
||||
v+=fade;
|
||||
v+=vec3(s,s*s,s*s*s*s)*a*brightness*fade; // coloring based on distance
|
||||
fade*=distfading; // distance fading
|
||||
s+=stepsize;
|
||||
}
|
||||
v=mix(vec3(length(v)),v,saturation); //color adjust
|
||||
COLOR = vec4(v*.01,1.);
|
||||
}
|
BIN
Graphics/UI/logo-temp.png
Normal file
BIN
Graphics/UI/logo-temp.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 20 KiB |
34
Graphics/UI/logo-temp.png.import
Normal file
34
Graphics/UI/logo-temp.png.import
Normal file
|
@ -0,0 +1,34 @@
|
|||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path="res://.import/logo-temp.png-1b1a89dd902da9895257f125fbfe6dd0.stex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://Graphics/UI/logo-temp.png"
|
||||
dest_files=[ "res://.import/logo-temp.png-1b1a89dd902da9895257f125fbfe6dd0.stex" ]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_mode=0
|
||||
compress/bptc_ldr=0
|
||||
compress/normal_map=0
|
||||
flags/repeat=0
|
||||
flags/filter=true
|
||||
flags/mipmaps=false
|
||||
flags/anisotropic=false
|
||||
flags/srgb=2
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/HDR_as_SRGB=false
|
||||
process/invert_color=false
|
||||
stream=false
|
||||
size_limit=0
|
||||
detect_3d=true
|
||||
svg/scale=1.0
|
BIN
Graphics/logo-temp.afdesign
Normal file
BIN
Graphics/logo-temp.afdesign
Normal file
Binary file not shown.
|
@ -1,4 +1,32 @@
|
|||
extends Control
|
||||
|
||||
export var scale = 2 setget set_scale
|
||||
export var upThreshold = 1.0/Engine.iterations_per_second
|
||||
export var downThreshold = 1.0/30.0
|
||||
|
||||
export var delay = 1.0
|
||||
|
||||
func _ready():
|
||||
set_scale(scale)
|
||||
$"/root/Music/BGM".play()
|
||||
|
||||
func _process(delta):
|
||||
# Give the system time to adjust
|
||||
if delay > 0:
|
||||
delay -= delta
|
||||
return
|
||||
if delta > downThreshold:
|
||||
print("GPU is taking too much (", delta, "s < ", downThreshold, "s), adjusting shader scale")
|
||||
set_scale(scale+1)
|
||||
elif delta < upThreshold and scale > 1:
|
||||
print("GPU is taking it easy (", delta, "s < ", upThreshold, "s), adjusting shader scale")
|
||||
set_scale(scale-1)
|
||||
|
||||
func set_scale(val):
|
||||
scale = val
|
||||
$Viewport.size = rect_size / scale
|
||||
$Background.update()
|
||||
|
||||
func _on_resized():
|
||||
$Viewport.size = rect_size / scale
|
||||
$Background.update()
|
||||
|
|
|
@ -1,6 +1,27 @@
|
|||
[gd_scene load_steps=2 format=2]
|
||||
[gd_scene load_steps=6 format=2]
|
||||
|
||||
[ext_resource path="res://Scenes/Menu.gd" type="Script" id=1]
|
||||
[ext_resource path="res://Graphics/UI/Background.shader" type="Shader" id=2]
|
||||
[ext_resource path="res://Graphics/UI/logo-temp.png" type="Texture" id=3]
|
||||
|
||||
[sub_resource type="ViewportTexture" id=3]
|
||||
viewport_path = NodePath("Viewport")
|
||||
|
||||
[sub_resource type="ShaderMaterial" id=4]
|
||||
shader = ExtResource( 2 )
|
||||
shader_param/iterations = 17
|
||||
shader_param/formuparam = 0.53
|
||||
shader_param/volsteps = 20
|
||||
shader_param/stepsize = 0.1
|
||||
shader_param/zoom = 0.8
|
||||
shader_param/tile = 0.85
|
||||
shader_param/speed = 0.001
|
||||
shader_param/brightness = 0.0015
|
||||
shader_param/darkmatter = 0.3
|
||||
shader_param/distfading = 0.73
|
||||
shader_param/saturation = 0.85
|
||||
shader_param/rotx = 0.0
|
||||
shader_param/roty = 0.001
|
||||
|
||||
[node name="Control" type="Control"]
|
||||
anchor_right = 1.0
|
||||
|
@ -9,3 +30,37 @@ script = ExtResource( 1 )
|
|||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Background" type="TextureRect" parent="."]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
texture = SubResource( 3 )
|
||||
stretch_mode = 7
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="logo-temp" type="TextureRect" parent="."]
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.5
|
||||
margin_left = -250.0
|
||||
margin_top = -293.953
|
||||
margin_right = 250.0
|
||||
margin_bottom = 82.0471
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
texture = ExtResource( 3 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Viewport" type="Viewport" parent="."]
|
||||
size = Vector2( 300, 300 )
|
||||
|
||||
[node name="ColorRect" type="ColorRect" parent="Viewport"]
|
||||
material = SubResource( 4 )
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
[connection signal="resized" from="." to="." method="_on_resized"]
|
||||
|
|
|
@ -7,7 +7,7 @@ custom_features=""
|
|||
export_filter="all_resources"
|
||||
include_filter=""
|
||||
exclude_filter=""
|
||||
export_path="./odyssey.exe"
|
||||
export_path="export/odyssey.exe"
|
||||
patch_list=PoolStringArray( )
|
||||
script_export_mode=1
|
||||
script_encryption_key=""
|
||||
|
|
|
@ -129,7 +129,7 @@ _global_script_class_icons={
|
|||
[application]
|
||||
|
||||
config/name="odyssey"
|
||||
run/main_scene="res://Scenes/Game.tscn"
|
||||
run/main_scene="res://Scenes/Menu.tscn"
|
||||
config/icon="res://icon.png"
|
||||
|
||||
[autoload]
|
||||
|
|
Reference in a new issue