Skip to content

Commit

Permalink
restructure and force shader compilation
Browse files Browse the repository at this point in the history
  • Loading branch information
pkostic-dev committed Nov 26, 2023
1 parent 0f622bb commit 5e69113
Show file tree
Hide file tree
Showing 29 changed files with 400 additions and 313 deletions.
1 change: 0 additions & 1 deletion WebTest/docs/credits.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
magecity.png : https://opengameart.org/content/mage-city-arcanos
pisilohepunane3.png : https://opengameart.org/content/dragons
earthbound shader : https://godotshaders.com/shader/earthbound-like-battle-background-shader-w-scroll-effect-and-palette-cycling/
8 changes: 8 additions & 0 deletions WebTest/project.godot
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
; Engine configuration file.
; It's best edited using the editor UI and not directly,
; since the parameters that go here are not all obvious.
;
; Format:
; [section] ; section goes between []
; param=value ; assign values to parameters

config_version=5

[application]
Expand Down
4 changes: 4 additions & 0 deletions WebTest/resources/class/shader_material_list.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
extends Resource
class_name ShaderMaterialList

@export var shader_material_list:Array[ShaderMaterial]

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions WebTest/resources/shader_material/aura.tres
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[gd_resource type="ShaderMaterial" load_steps=2 format=3 uid="uid://dxai4ao6ii8wf"]

[ext_resource type="Shader" path="res://shaders/aura.gdshader" id="1_hrccy"]

[resource]
shader = ExtResource("1_hrccy")
shader_parameter/aura_width = 1.0
shader_parameter/aura_color = Color(0, 0.403922, 0.498039, 1)
7 changes: 7 additions & 0 deletions WebTest/resources/shader_material/blur.tres
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[gd_resource type="ShaderMaterial" load_steps=2 format=3 uid="uid://bw2yfhvbtkp0q"]

[ext_resource type="Shader" path="res://shaders/blur.gdshader" id="1_fn2h6"]

[resource]
shader = ExtResource("1_fn2h6")
shader_parameter/radius = 2.0
7 changes: 7 additions & 0 deletions WebTest/resources/shader_material/dissintegrate.tres
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[gd_resource type="ShaderMaterial" load_steps=2 format=3 uid="uid://lhbk085f0i6x"]

[ext_resource type="Shader" path="res://shaders/dissintegrate.gdshader" id="1_glt7d"]

[resource]
shader = ExtResource("1_glt7d")
shader_parameter/amount = 1.0
8 changes: 8 additions & 0 deletions WebTest/resources/shader_material/drop_shadow.tres
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[gd_resource type="ShaderMaterial" load_steps=2 format=3 uid="uid://bw5h4v21esbek"]

[ext_resource type="Shader" path="res://shaders/dropshadow.gdshader" id="1_yw8ir"]

[resource]
shader = ExtResource("1_yw8ir")
shader_parameter/radius = 2.0
shader_parameter/modulate = null
7 changes: 7 additions & 0 deletions WebTest/resources/shader_material/fisheye.tres
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[gd_resource type="ShaderMaterial" load_steps=2 format=3 uid="uid://ti3igq5o2705"]

[ext_resource type="Shader" path="res://shaders/fatty.gdshader" id="1_rxmlq"]

[resource]
shader = ExtResource("1_rxmlq")
shader_parameter/fattyness = 1.3
8 changes: 8 additions & 0 deletions WebTest/resources/shader_material/glow.tres
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[gd_resource type="ShaderMaterial" load_steps=2 format=3 uid="uid://drhlyq8y68814"]

[ext_resource type="Shader" path="res://shaders/glow.gdshader" id="1_6g01n"]

[resource]
shader = ExtResource("1_6g01n")
shader_parameter/radius = 2.0
shader_parameter/amount = 2.0
8 changes: 8 additions & 0 deletions WebTest/resources/shader_material/offset_shadow.tres
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[gd_resource type="ShaderMaterial" load_steps=2 format=3 uid="uid://b2hdibmewsoqj"]

[ext_resource type="Shader" path="res://shaders/offsetshadow.gdshader" id="1_fldde"]

[resource]
shader = ExtResource("1_fldde")
shader_parameter/offset = Vector2(4, 4)
shader_parameter/modulate = Color(0.2, 0, 0.188235, 1)
8 changes: 8 additions & 0 deletions WebTest/resources/shader_material/outline.tres
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[gd_resource type="ShaderMaterial" load_steps=2 format=3 uid="uid://vkjycfa1xrqh"]

[ext_resource type="Shader" path="res://shaders/outline.gdshader" id="1_1cr6o"]

[resource]
shader = ExtResource("1_1cr6o")
shader_parameter/outline_width = 1.0
shader_parameter/outline_color = Color(0.270588, 0.631373, 0, 1)
8 changes: 8 additions & 0 deletions WebTest/resources/shader_material/silouette.tres
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[gd_resource type="ShaderMaterial" load_steps=2 format=3 uid="uid://w5i2mafmyay2"]

[ext_resource type="Shader" path="res://shaders/silouette.gdshader" id="1_lywpw"]

[resource]
shader = ExtResource("1_lywpw")
shader_parameter/modulate = Color(1, 1, 1, 1)
shader_parameter/active = true
16 changes: 16 additions & 0 deletions WebTest/resources/shader_material_list/shader_material_list.tres
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[gd_resource type="Resource" script_class="ShaderMaterialList" load_steps=11 format=3 uid="uid://vmr45pmdlpyc"]

[ext_resource type="Script" path="res://resources/class/shader_material_list.gd" id="1_0cae1"]
[ext_resource type="Material" uid="uid://dxai4ao6ii8wf" path="res://resources/shader_material/aura.tres" id="2_yktj6"]
[ext_resource type="Material" uid="uid://bw2yfhvbtkp0q" path="res://resources/shader_material/blur.tres" id="3_qja05"]
[ext_resource type="Material" uid="uid://lhbk085f0i6x" path="res://resources/shader_material/dissintegrate.tres" id="4_uecgu"]
[ext_resource type="Material" uid="uid://bw5h4v21esbek" path="res://resources/shader_material/drop_shadow.tres" id="5_vpow5"]
[ext_resource type="Material" uid="uid://ti3igq5o2705" path="res://resources/shader_material/fisheye.tres" id="6_5iywh"]
[ext_resource type="Material" uid="uid://drhlyq8y68814" path="res://resources/shader_material/glow.tres" id="7_3wqie"]
[ext_resource type="Material" uid="uid://b2hdibmewsoqj" path="res://resources/shader_material/offset_shadow.tres" id="8_g47sg"]
[ext_resource type="Material" uid="uid://vkjycfa1xrqh" path="res://resources/shader_material/outline.tres" id="9_xxseo"]
[ext_resource type="Material" uid="uid://w5i2mafmyay2" path="res://resources/shader_material/silouette.tres" id="10_2lvyf"]

[resource]
script = ExtResource("1_0cae1")
shader_material_list = Array[ShaderMaterial]([ExtResource("2_yktj6"), ExtResource("3_qja05"), ExtResource("4_uecgu"), ExtResource("5_vpow5"), ExtResource("6_5iywh"), ExtResource("7_3wqie"), ExtResource("8_g47sg"), ExtResource("9_xxseo"), ExtResource("10_2lvyf")])
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[gd_resource type="Theme" load_steps=3 format=3 uid="uid://dhsd0ae6n47h0"]

[ext_resource type="StyleBox" uid="uid://coiwfvv45au3o" path="res://resources/line_edit_focus.tres" id="1_xs1xj"]
[ext_resource type="StyleBox" uid="uid://dn5wky06p805b" path="res://resources/line_edit_normal.tres" id="2_bp6f5"]
[ext_resource type="StyleBox" uid="uid://coiwfvv45au3o" path="res://resources/theme/style_box_flat/line_edit_focus.tres" id="1_xs1xj"]
[ext_resource type="StyleBox" uid="uid://dn5wky06p805b" path="res://resources/theme/style_box_flat/line_edit_normal.tres" id="2_bp6f5"]

[resource]
LineEdit/styles/focus = ExtResource("1_xs1xj")
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion WebTest/scenes/background/background.tscn
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[gd_scene load_steps=4 format=3 uid="uid://dln02b3s5dgp0"]

[ext_resource type="Shader" path="res://scenes/background/scroll.gdshader" id="1_h20sw"]
[ext_resource type="Shader" path="res://shaders/background.gdshader" id="1_h20sw"]
[ext_resource type="Texture2D" uid="uid://bywhq61ttu4cv" path="res://images/mechanic_rat.png" id="2_5v3lv"]

[sub_resource type="ShaderMaterial" id="ShaderMaterial_ywwle"]
Expand Down
38 changes: 0 additions & 38 deletions WebTest/scenes/background/earthbound.gdshader

This file was deleted.

2 changes: 1 addition & 1 deletion WebTest/scenes/gpu_particles/gpu_particles.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[ext_resource type="Script" path="res://scenes/gpu_particles/gpu_particles.gd" id="1_b5mit"]
[ext_resource type="Texture2D" uid="uid://w54luqyth0jx" path="res://images/fire_particle.png" id="1_u8omh"]
[ext_resource type="Shortcut" uid="uid://ck38hryheyrjn" path="res://resources/back_shortcut.tres" id="3_g2psh"]
[ext_resource type="Shortcut" uid="uid://ck38hryheyrjn" path="res://resources/shortcut/back_shortcut.tres" id="3_g2psh"]

[sub_resource type="CanvasItemMaterial" id="CanvasItemMaterial_04bat"]
blend_mode = 1
Expand Down
6 changes: 3 additions & 3 deletions WebTest/scenes/scene_2d/2d_test.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

[ext_resource type="Script" path="res://scenes/scene_2d/2d_test.gd" id="1_b3tb6"]
[ext_resource type="Script" path="res://scenes/scene_2d/camera_2d.gd" id="1_tt0a0"]
[ext_resource type="TileSet" uid="uid://dt27fvaeaksuh" path="res://resources/magecity_tile_set.tres" id="2_asdvs"]
[ext_resource type="Shortcut" uid="uid://ck38hryheyrjn" path="res://resources/back_shortcut.tres" id="4_ksx2g"]
[ext_resource type="StyleBox" uid="uid://v1pgvqqrkx1m" path="res://resources/black_panel.tres" id="5_xn612"]
[ext_resource type="TileSet" uid="uid://dt27fvaeaksuh" path="res://resources/tile_set/magecity_tile_set.tres" id="2_asdvs"]
[ext_resource type="Shortcut" uid="uid://ck38hryheyrjn" path="res://resources/shortcut/back_shortcut.tres" id="4_ksx2g"]
[ext_resource type="StyleBox" uid="uid://v1pgvqqrkx1m" path="res://resources/theme/style_box_flat/black_panel.tres" id="5_xn612"]

[node name="2DTest" type="Node2D"]
script = ExtResource("1_b3tb6")
Expand Down
6 changes: 3 additions & 3 deletions WebTest/scenes/scene_3d/3d_test.tscn
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
[gd_scene load_steps=10 format=3 uid="uid://oo2e1k6k84n4"]

[ext_resource type="Script" path="res://scenes/scene_3d/3d_test.gd" id="1_bq37j"]
[ext_resource type="Shortcut" uid="uid://ck38hryheyrjn" path="res://resources/back_shortcut.tres" id="2_vuwbf"]
[ext_resource type="StyleBox" uid="uid://v1pgvqqrkx1m" path="res://resources/black_panel.tres" id="3_m13x3"]
[ext_resource type="MeshLibrary" uid="uid://f0dkbvc0mra7" path="res://resources/graveyard_mesh_library.tres" id="4_qk4yl"]
[ext_resource type="Shortcut" uid="uid://ck38hryheyrjn" path="res://resources/shortcut/back_shortcut.tres" id="2_vuwbf"]
[ext_resource type="StyleBox" uid="uid://v1pgvqqrkx1m" path="res://resources/theme/style_box_flat/black_panel.tres" id="3_m13x3"]
[ext_resource type="MeshLibrary" uid="uid://f0dkbvc0mra7" path="res://resources/mesh_library/graveyard_mesh_library.tres" id="4_qk4yl"]

[sub_resource type="ProceduralSkyMaterial" id="ProceduralSkyMaterial_a0s62"]
sky_top_color = Color(0.317647, 0.427451, 0.545098, 1)
Expand Down
4 changes: 2 additions & 2 deletions WebTest/scenes/settings/settings.tscn
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
[gd_scene load_steps=6 format=3 uid="uid://p5qrs63vk0n4"]

[ext_resource type="Script" path="res://scenes/settings/settings.gd" id="1_ia4qq"]
[ext_resource type="Theme" uid="uid://dhsd0ae6n47h0" path="res://resources/theme.tres" id="2_kfob1"]
[ext_resource type="Theme" uid="uid://dhsd0ae6n47h0" path="res://resources/theme/theme.tres" id="2_kfob1"]
[ext_resource type="PackedScene" uid="uid://dln02b3s5dgp0" path="res://scenes/background/background.tscn" id="2_owxej"]
[ext_resource type="Texture2D" uid="uid://du4nsr4krvofr" path="res://images/tick.png" id="3_tfcqm"]
[ext_resource type="Shortcut" uid="uid://ck38hryheyrjn" path="res://resources/back_shortcut.tres" id="4_3wh6k"]
[ext_resource type="Shortcut" uid="uid://ck38hryheyrjn" path="res://resources/shortcut/back_shortcut.tres" id="4_3wh6k"]

[node name="Settings" type="Control"]
layout_mode = 3
Expand Down
36 changes: 36 additions & 0 deletions WebTest/scenes/shaders/shaders.gd
Original file line number Diff line number Diff line change
@@ -1,6 +1,42 @@
extends Control

var scene_main = load("res://scenes/main/main.tscn") as PackedScene
var shaders_loaded:bool = false

@export var shader_material_list:ShaderMaterialList

@onready var shader_progress_bar = %ShaderProgressBar
@onready var shader_loading = %ShaderLoading
@onready var shaders = %Shaders
@onready var loaded_shaders = %LoadedShaders

func _ready():
if shader_material_list:
var steps = shader_material_list.shader_material_list.size()
print(steps)
var step = 100.0 / steps
print(step)
for shader_material in shader_material_list.shader_material_list:
print("Compiling shader " + shader_material.resource_name)
await load_shader(shader_material)
await get_tree().create_timer(0.01).timeout
print("Done")
shader_progress_bar.value += step
print(shader_progress_bar.value + " %")


func load_shader(shader_material:ShaderMaterial):
var color_rect = ColorRect.new()
color_rect.material = shader_material
color_rect.custom_minimum_size = Vector2(20, 20)
color_rect.size_flags_horizontal = Control.SIZE_SHRINK_CENTER
loaded_shaders.add_child(color_rect)

func _on_back_pressed():
get_tree().change_scene_to_packed(scene_main)


func _on_shader_progress_bar_value_changed(value):
if value > 99.0:
shader_loading.visible = false
shaders.visible = true

0 comments on commit 5e69113

Please sign in to comment.