├── icon.png ├── assets └── maujoe.flowmap_shader │ ├── demo │ ├── textures │ │ ├── lava.png │ │ ├── checker.png │ │ ├── displace.png │ │ ├── flowmap.png │ │ ├── water_normal.png │ │ ├── cloud_layers_1k.hdr │ │ ├── cloud_layers_1k.hdr.import │ │ ├── lava.png.import │ │ ├── flowmap.png.import │ │ ├── checker.png.import │ │ ├── displace.png.import │ │ └── water_normal.png.import │ ├── scripts │ │ ├── example.gd │ │ └── camera_control │ │ │ ├── LICENSE.md │ │ │ ├── README.md │ │ │ ├── camera_control.gd │ │ │ └── camera_control_gui.gd │ ├── materials │ │ ├── basic_flowmap_water__vertex_color.tres │ │ ├── terrain.tres │ │ ├── basic_flowmap_water.tres │ │ ├── basic_flowmap_water__per_vertex.tres │ │ ├── simple_flowmap_lava__vertex_color.tres │ │ ├── simple_flowmap_lava__per_vertex.tres │ │ ├── simple_flowmap_lava.tres │ │ ├── basic_flowmap_water__vertex_color_displace.tres │ │ ├── basic_flowmap_water__displace.tres │ │ ├── simple_flowmap_lava__vertex_color_displace.tres │ │ └── simple_flowmap_lava__displace.tres │ └── controls.tscn │ ├── LICENSE.md │ ├── DOCUMENTATION.md │ ├── README.md │ └── shader │ ├── basic_flowmap_material.shader │ ├── basic_flowmap_material__vertex_color.shader │ ├── basic_flowmap_material__per_vertex.shader │ ├── basic_flowmap_material__vertex_color_displace.shader │ └── basic_flowmap_material__displace.shader ├── .gitignore ├── icon.png.import ├── project.godot ├── LICENSE.md ├── default_env.tres └── README.md /icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JaccomoLorenz/godot-flow-map-shader/HEAD/icon.png -------------------------------------------------------------------------------- /assets/maujoe.flowmap_shader/demo/textures/lava.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JaccomoLorenz/godot-flow-map-shader/HEAD/assets/maujoe.flowmap_shader/demo/textures/lava.png -------------------------------------------------------------------------------- /assets/maujoe.flowmap_shader/demo/textures/checker.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JaccomoLorenz/godot-flow-map-shader/HEAD/assets/maujoe.flowmap_shader/demo/textures/checker.png -------------------------------------------------------------------------------- /assets/maujoe.flowmap_shader/demo/textures/displace.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JaccomoLorenz/godot-flow-map-shader/HEAD/assets/maujoe.flowmap_shader/demo/textures/displace.png -------------------------------------------------------------------------------- /assets/maujoe.flowmap_shader/demo/textures/flowmap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JaccomoLorenz/godot-flow-map-shader/HEAD/assets/maujoe.flowmap_shader/demo/textures/flowmap.png -------------------------------------------------------------------------------- /assets/maujoe.flowmap_shader/demo/textures/water_normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JaccomoLorenz/godot-flow-map-shader/HEAD/assets/maujoe.flowmap_shader/demo/textures/water_normal.png -------------------------------------------------------------------------------- /assets/maujoe.flowmap_shader/demo/textures/cloud_layers_1k.hdr: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JaccomoLorenz/godot-flow-map-shader/HEAD/assets/maujoe.flowmap_shader/demo/textures/cloud_layers_1k.hdr -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # Godot-specific ignores 3 | .import/ 4 | export.cfg 5 | export_presets.cfg 6 | 7 | # Imported translations (automatically generated from CSV files) 8 | *.translation 9 | 10 | # Mono-specific ignores 11 | .mono/ 12 | data_*/ 13 | mono_crash.*.json 14 | 15 | # System/tool-specific ignores 16 | .directory 17 | *~ 18 | -------------------------------------------------------------------------------- /icon.png.import: -------------------------------------------------------------------------------- 1 | [remap] 2 | 3 | importer="texture" 4 | type="StreamTexture" 5 | path="res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex" 6 | 7 | [deps] 8 | 9 | source_file="res://icon.png" 10 | dest_files=[ "res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex" ] 11 | 12 | [params] 13 | 14 | compress/mode=0 15 | compress/lossy_quality=0.7 16 | compress/hdr_mode=0 17 | compress/normal_map=0 18 | flags/repeat=0 19 | flags/filter=true 20 | flags/mipmaps=false 21 | flags/anisotropic=false 22 | flags/srgb=2 23 | process/fix_alpha_border=true 24 | process/premult_alpha=false 25 | process/HDR_as_SRGB=false 26 | stream=false 27 | size_limit=0 28 | detect_3d=true 29 | svg/scale=1.0 30 | -------------------------------------------------------------------------------- /project.godot: -------------------------------------------------------------------------------- 1 | ; Engine configuration file. 2 | ; It's best edited using the editor UI and not directly, 3 | ; since the parameters that go here are not all obvious. 4 | ; 5 | ; Format: 6 | ; [section] ; section goes between [] 7 | ; param=value ; assign values to parameters 8 | 9 | config_version=3 10 | 11 | [application] 12 | 13 | config/name="Flowmap Material Shader" 14 | run/main_scene="res://assets/maujoe.flowmap_shader/demo/water_example.tscn" 15 | config/icon="res://icon.png" 16 | 17 | [display] 18 | 19 | window/size/resizable=false 20 | window/size/test_width=1920 21 | window/size/test_height=1080 22 | window/vsync/use_vsync=false 23 | 24 | [rendering] 25 | 26 | environment/default_environment="res://default_env.tres" 27 | -------------------------------------------------------------------------------- /assets/maujoe.flowmap_shader/demo/textures/cloud_layers_1k.hdr.import: -------------------------------------------------------------------------------- 1 | [remap] 2 | 3 | importer="texture" 4 | type="StreamTexture" 5 | path="res://.import/cloud_layers_1k.hdr-c70203c768f37cf8a14a489ac865c2d3.stex" 6 | 7 | [deps] 8 | 9 | source_file="res://assets/maujoe.flowmap_shader/demo/textures/cloud_layers_1k.hdr" 10 | dest_files=[ "res://.import/cloud_layers_1k.hdr-c70203c768f37cf8a14a489ac865c2d3.stex" ] 11 | 12 | [params] 13 | 14 | compress/mode=0 15 | compress/lossy_quality=0.7 16 | compress/hdr_mode=0 17 | compress/normal_map=0 18 | flags/repeat=0 19 | flags/filter=true 20 | flags/mipmaps=false 21 | flags/anisotropic=false 22 | flags/srgb=2 23 | process/fix_alpha_border=true 24 | process/premult_alpha=false 25 | process/HDR_as_SRGB=false 26 | stream=false 27 | size_limit=0 28 | detect_3d=true 29 | svg/scale=1.0 30 | -------------------------------------------------------------------------------- /assets/maujoe.flowmap_shader/demo/textures/lava.png.import: -------------------------------------------------------------------------------- 1 | [remap] 2 | 3 | importer="texture" 4 | type="StreamTexture" 5 | path.s3tc="res://.import/lava.png-c0b4af4be65676c65630fa6c7fc9a67d.s3tc.stex" 6 | path.etc2="res://.import/lava.png-c0b4af4be65676c65630fa6c7fc9a67d.etc2.stex" 7 | 8 | [deps] 9 | 10 | source_file="res://assets/maujoe.flowmap_shader/demo/textures/lava.png" 11 | dest_files=[ "res://.import/lava.png-c0b4af4be65676c65630fa6c7fc9a67d.s3tc.stex", "res://.import/lava.png-c0b4af4be65676c65630fa6c7fc9a67d.etc2.stex" ] 12 | 13 | [params] 14 | 15 | compress/mode=2 16 | compress/lossy_quality=0.7 17 | compress/hdr_mode=0 18 | compress/normal_map=1 19 | flags/repeat=true 20 | flags/filter=true 21 | flags/mipmaps=true 22 | flags/anisotropic=false 23 | flags/srgb=1 24 | process/fix_alpha_border=true 25 | process/premult_alpha=false 26 | process/HDR_as_SRGB=false 27 | stream=false 28 | size_limit=0 29 | detect_3d=false 30 | svg/scale=1.0 31 | -------------------------------------------------------------------------------- /assets/maujoe.flowmap_shader/demo/textures/flowmap.png.import: -------------------------------------------------------------------------------- 1 | [remap] 2 | 3 | importer="texture" 4 | type="StreamTexture" 5 | path.s3tc="res://.import/flowmap.png-e1349128ea463f7efdf4a25b9f8357e0.s3tc.stex" 6 | path.etc2="res://.import/flowmap.png-e1349128ea463f7efdf4a25b9f8357e0.etc2.stex" 7 | 8 | [deps] 9 | 10 | source_file="res://assets/maujoe.flowmap_shader/demo/textures/flowmap.png" 11 | dest_files=[ "res://.import/flowmap.png-e1349128ea463f7efdf4a25b9f8357e0.s3tc.stex", "res://.import/flowmap.png-e1349128ea463f7efdf4a25b9f8357e0.etc2.stex" ] 12 | 13 | [params] 14 | 15 | compress/mode=2 16 | compress/lossy_quality=0.7 17 | compress/hdr_mode=0 18 | compress/normal_map=1 19 | flags/repeat=true 20 | flags/filter=true 21 | flags/mipmaps=true 22 | flags/anisotropic=false 23 | flags/srgb=2 24 | process/fix_alpha_border=true 25 | process/premult_alpha=false 26 | process/HDR_as_SRGB=false 27 | stream=false 28 | size_limit=0 29 | detect_3d=false 30 | svg/scale=1.0 31 | -------------------------------------------------------------------------------- /assets/maujoe.flowmap_shader/demo/textures/checker.png.import: -------------------------------------------------------------------------------- 1 | [remap] 2 | 3 | importer="texture" 4 | type="StreamTexture" 5 | path.s3tc="res://.import/checker.png-9e383410096ced6337fb902f686439e7.s3tc.stex" 6 | path.etc2="res://.import/checker.png-9e383410096ced6337fb902f686439e7.etc2.stex" 7 | 8 | [deps] 9 | 10 | source_file="res://assets/maujoe.flowmap_shader/demo/textures/checker.png" 11 | dest_files=[ "res://.import/checker.png-9e383410096ced6337fb902f686439e7.s3tc.stex", "res://.import/checker.png-9e383410096ced6337fb902f686439e7.etc2.stex" ] 12 | 13 | [params] 14 | 15 | compress/mode=2 16 | compress/lossy_quality=0.7 17 | compress/hdr_mode=1 18 | compress/normal_map=0 19 | flags/repeat=true 20 | flags/filter=false 21 | flags/mipmaps=false 22 | flags/anisotropic=true 23 | flags/srgb=1 24 | process/fix_alpha_border=true 25 | process/premult_alpha=false 26 | process/HDR_as_SRGB=false 27 | stream=false 28 | size_limit=0 29 | detect_3d=false 30 | svg/scale=1.0 31 | -------------------------------------------------------------------------------- /assets/maujoe.flowmap_shader/demo/textures/displace.png.import: -------------------------------------------------------------------------------- 1 | [remap] 2 | 3 | importer="texture" 4 | type="StreamTexture" 5 | path.s3tc="res://.import/displace.png-979ef571f8a773d365b4a3661b6eac4f.s3tc.stex" 6 | path.etc2="res://.import/displace.png-979ef571f8a773d365b4a3661b6eac4f.etc2.stex" 7 | 8 | [deps] 9 | 10 | source_file="res://assets/maujoe.flowmap_shader/demo/textures/displace.png" 11 | dest_files=[ "res://.import/displace.png-979ef571f8a773d365b4a3661b6eac4f.s3tc.stex", "res://.import/displace.png-979ef571f8a773d365b4a3661b6eac4f.etc2.stex" ] 12 | 13 | [params] 14 | 15 | compress/mode=2 16 | compress/lossy_quality=0.7 17 | compress/hdr_mode=0 18 | compress/normal_map=0 19 | flags/repeat=true 20 | flags/filter=true 21 | flags/mipmaps=true 22 | flags/anisotropic=false 23 | flags/srgb=2 24 | process/fix_alpha_border=true 25 | process/premult_alpha=false 26 | process/HDR_as_SRGB=false 27 | stream=false 28 | size_limit=0 29 | detect_3d=false 30 | svg/scale=1.0 31 | -------------------------------------------------------------------------------- /assets/maujoe.flowmap_shader/demo/textures/water_normal.png.import: -------------------------------------------------------------------------------- 1 | [remap] 2 | 3 | importer="texture" 4 | type="StreamTexture" 5 | path.s3tc="res://.import/water_normal.png-33e66926122cb16b4c78cf0272b826fe.s3tc.stex" 6 | path.etc2="res://.import/water_normal.png-33e66926122cb16b4c78cf0272b826fe.etc2.stex" 7 | 8 | [deps] 9 | 10 | source_file="res://assets/maujoe.flowmap_shader/demo/textures/water_normal.png" 11 | dest_files=[ "res://.import/water_normal.png-33e66926122cb16b4c78cf0272b826fe.s3tc.stex", "res://.import/water_normal.png-33e66926122cb16b4c78cf0272b826fe.etc2.stex" ] 12 | 13 | [params] 14 | 15 | compress/mode=2 16 | compress/lossy_quality=0.7 17 | compress/hdr_mode=0 18 | compress/normal_map=1 19 | flags/repeat=true 20 | flags/filter=true 21 | flags/mipmaps=true 22 | flags/anisotropic=false 23 | flags/srgb=2 24 | process/fix_alpha_border=true 25 | process/premult_alpha=false 26 | process/HDR_as_SRGB=false 27 | stream=false 28 | size_limit=0 29 | detect_3d=false 30 | svg/scale=1.0 31 | -------------------------------------------------------------------------------- /assets/maujoe.flowmap_shader/demo/scripts/example.gd: -------------------------------------------------------------------------------- 1 | extends Control 2 | 3 | onready var materials = get_node("/root/Node/ExampleMaterials") 4 | 5 | func _ready(): 6 | $ExampleSwitcher.add_item("Select Example Scene") 7 | $ExampleSwitcher.set_item_disabled(0, true) 8 | 9 | $ExampleSwitcher.add_item("Example 1: Water") 10 | $ExampleSwitcher.add_item("Example 2: Lava") 11 | 12 | for i in range(materials.get_child_count()): 13 | var example = materials.get_child(i) 14 | $ExampleOption.add_item("Material: " + example.get_name()) 15 | 16 | if example.is_visible(): 17 | $ExampleOption.select(i) 18 | 19 | 20 | func _on_ExampleSwitcher_item_selected(ID): 21 | match (ID): 22 | (1): 23 | get_tree().change_scene("res://assets/maujoe.flowmap_shader/demo/water_example.tscn") 24 | (2): 25 | get_tree().change_scene("res://assets/maujoe.flowmap_shader/demo/lava_example.tscn") 26 | _: 27 | printerr("No Scene for this ID") 28 | 29 | 30 | func _on_ExampleOption_item_selected(ID): 31 | for example in range(materials.get_child_count()): 32 | if ID == example: 33 | materials.get_child(example).show() 34 | else: 35 | materials.get_child(example).hide() 36 | -------------------------------------------------------------------------------- /assets/maujoe.flowmap_shader/demo/materials/basic_flowmap_water__vertex_color.tres: -------------------------------------------------------------------------------- 1 | [gd_resource type="ShaderMaterial" load_steps=3 format=2] 2 | 3 | [ext_resource path="res://assets/maujoe.flowmap_shader/shader/basic_flowmap_material__vertex_color.shader" type="Shader" id=1] 4 | [ext_resource path="res://assets/maujoe.flowmap_shader/demo/textures/water_normal.png" type="Texture" id=2] 5 | 6 | [resource] 7 | 8 | render_priority = 0 9 | shader = ExtResource( 1 ) 10 | shader_param/albedo = Color( 0, 0.333333, 0.392157, 0.980392 ) 11 | shader_param/specular = 0.0 12 | shader_param/metallic = 0.0 13 | shader_param/roughness = 0.0 14 | shader_param/metallic_texture_channel = null 15 | shader_param/roughness_texture_channel = null 16 | shader_param/emission = Color( 0, 0, 0, 1 ) 17 | shader_param/emission_energy = null 18 | shader_param/refraction = null 19 | shader_param/refraction_texture_channel = null 20 | shader_param/uv_scale = Vector2( 16, 16 ) 21 | shader_param/uv_offset = null 22 | shader_param/proximity_fade_distance = 0.5 23 | shader_param/distance_fade_min = 0.0 24 | shader_param/distance_fade_max = 1.0 25 | shader_param/normal_scale = 0.2 26 | shader_param/flow_normal_influence = null 27 | shader_param/flow_map_x_channel = Plane( 1, 0, 0, 0 ) 28 | shader_param/flow_map_y_channel = Plane( 0, 1, 0, 0 ) 29 | shader_param/channel_flow_direction = Vector2( 1, -1 ) 30 | shader_param/blend_cycle = 5.0 31 | shader_param/cycle_speed = 2.0 32 | shader_param/flow_speed = -0.1 33 | shader_param/noise_texture_channel = null 34 | shader_param/flow_noise_size = null 35 | shader_param/flow_noise_influence = null 36 | shader_param/texture_normal = ExtResource( 2 ) 37 | _sections_unfolded = [ "shader_param" ] 38 | 39 | -------------------------------------------------------------------------------- /assets/maujoe.flowmap_shader/demo/materials/terrain.tres: -------------------------------------------------------------------------------- 1 | [gd_resource type="SpatialMaterial" load_steps=2 format=2] 2 | 3 | [ext_resource path="res://assets/maujoe.flowmap_shader/demo/textures/checker.png" type="Texture" id=1] 4 | 5 | [resource] 6 | 7 | render_priority = 0 8 | flags_transparent = false 9 | flags_unshaded = false 10 | flags_vertex_lighting = false 11 | flags_no_depth_test = false 12 | flags_use_point_size = false 13 | flags_world_triplanar = false 14 | flags_fixed_size = false 15 | flags_albedo_tex_force_srgb = false 16 | vertex_color_use_as_albedo = false 17 | vertex_color_is_srgb = false 18 | params_diffuse_mode = 0 19 | params_specular_mode = 0 20 | params_blend_mode = 0 21 | params_cull_mode = 0 22 | params_depth_draw_mode = 0 23 | params_line_width = 1.0 24 | params_point_size = 1.0 25 | params_billboard_mode = 0 26 | params_grow = false 27 | params_use_alpha_scissor = false 28 | albedo_color = Color( 1, 1, 1, 1 ) 29 | albedo_texture = ExtResource( 1 ) 30 | metallic = 0.5 31 | metallic_specular = 0.5 32 | metallic_texture_channel = 0 33 | roughness = 0.8 34 | roughness_texture_channel = 0 35 | emission_enabled = false 36 | normal_enabled = false 37 | rim_enabled = false 38 | clearcoat_enabled = false 39 | anisotropy_enabled = false 40 | ao_enabled = false 41 | depth_enabled = false 42 | subsurf_scatter_enabled = false 43 | transmission_enabled = false 44 | refraction_enabled = false 45 | detail_enabled = false 46 | uv1_scale = Vector3( 50, 50, 1 ) 47 | uv1_offset = Vector3( 0, 0, 0 ) 48 | uv1_triplanar = false 49 | uv1_triplanar_sharpness = 1.0 50 | uv2_scale = Vector3( 1, 1, 1 ) 51 | uv2_offset = Vector3( 0, 0, 0 ) 52 | uv2_triplanar = false 53 | uv2_triplanar_sharpness = 1.0 54 | proximity_fade_enable = false 55 | distance_fade_enable = false 56 | _sections_unfolded = [ "Roughness", "UV1" ] 57 | 58 | -------------------------------------------------------------------------------- /assets/maujoe.flowmap_shader/demo/materials/basic_flowmap_water.tres: -------------------------------------------------------------------------------- 1 | [gd_resource type="ShaderMaterial" load_steps=4 format=2] 2 | 3 | [ext_resource path="res://assets/maujoe.flowmap_shader/shader/basic_flowmap_material.shader" type="Shader" id=1] 4 | [ext_resource path="res://assets/maujoe.flowmap_shader/demo/textures/flowmap.png" type="Texture" id=2] 5 | [ext_resource path="res://assets/maujoe.flowmap_shader/demo/textures/water_normal.png" type="Texture" id=3] 6 | 7 | [resource] 8 | 9 | render_priority = 0 10 | shader = ExtResource( 1 ) 11 | shader_param/albedo = Color( 0, 0.333333, 0.392157, 0.980392 ) 12 | shader_param/specular = null 13 | shader_param/metallic = null 14 | shader_param/roughness = null 15 | shader_param/metallic_texture_channel = null 16 | shader_param/roughness_texture_channel = null 17 | shader_param/emission = null 18 | shader_param/emission_energy = null 19 | shader_param/refraction = null 20 | shader_param/refraction_texture_channel = null 21 | shader_param/uv_scale = Vector2( 16, 16 ) 22 | shader_param/uv_offset = null 23 | shader_param/proximity_fade_distance = 0.5 24 | shader_param/distance_fade_min = 0.0 25 | shader_param/distance_fade_max = 1.0 26 | shader_param/normal_scale = 0.2 27 | shader_param/flow_normal_influence = null 28 | shader_param/flow_map_x_channel = Plane( 1, 0, 0, 0 ) 29 | shader_param/flow_map_y_channel = Plane( 0, 1, 0, 0 ) 30 | shader_param/channel_flow_direction = Vector2( 1, -1 ) 31 | shader_param/blend_cycle = 5.0 32 | shader_param/cycle_speed = 2.0 33 | shader_param/flow_speed = 0.1 34 | shader_param/noise_texture_channel = null 35 | shader_param/flow_noise_size = null 36 | shader_param/flow_noise_influence = null 37 | shader_param/texture_normal = ExtResource( 3 ) 38 | shader_param/texture_flow_map = ExtResource( 2 ) 39 | _sections_unfolded = [ "shader_param" ] 40 | 41 | -------------------------------------------------------------------------------- /assets/maujoe.flowmap_shader/demo/materials/basic_flowmap_water__per_vertex.tres: -------------------------------------------------------------------------------- 1 | [gd_resource type="ShaderMaterial" load_steps=4 format=2] 2 | 3 | [ext_resource path="res://assets/maujoe.flowmap_shader/shader/basic_flowmap_material__per_vertex.shader" type="Shader" id=1] 4 | [ext_resource path="res://assets/maujoe.flowmap_shader/demo/textures/flowmap.png" type="Texture" id=2] 5 | [ext_resource path="res://assets/maujoe.flowmap_shader/demo/textures/water_normal.png" type="Texture" id=3] 6 | 7 | [resource] 8 | 9 | render_priority = 0 10 | shader = ExtResource( 1 ) 11 | shader_param/albedo = Color( 0, 0.333333, 0.392157, 0.980392 ) 12 | shader_param/specular = null 13 | shader_param/metallic = null 14 | shader_param/roughness = null 15 | shader_param/metallic_texture_channel = null 16 | shader_param/roughness_texture_channel = null 17 | shader_param/emission = null 18 | shader_param/emission_energy = null 19 | shader_param/refraction = null 20 | shader_param/refraction_texture_channel = null 21 | shader_param/uv_scale = Vector2( 16, 16 ) 22 | shader_param/uv_offset = null 23 | shader_param/proximity_fade_distance = 0.5 24 | shader_param/distance_fade_min = 0.0 25 | shader_param/distance_fade_max = 1.0 26 | shader_param/normal_scale = 0.3 27 | shader_param/flow_normal_influence = null 28 | shader_param/flow_map_x_channel = Plane( 1, 0, 0, 0 ) 29 | shader_param/flow_map_y_channel = Plane( 0, 1, 0, 0 ) 30 | shader_param/channel_flow_direction = Vector2( 1, -1 ) 31 | shader_param/blend_cycle = 5.0 32 | shader_param/cycle_speed = 2.0 33 | shader_param/flow_speed = 0.1 34 | shader_param/noise_texture_channel = null 35 | shader_param/flow_noise_size = null 36 | shader_param/flow_noise_influence = null 37 | shader_param/texture_normal = ExtResource( 3 ) 38 | shader_param/texture_flow_map = ExtResource( 2 ) 39 | _sections_unfolded = [ "shader_param" ] 40 | 41 | -------------------------------------------------------------------------------- /assets/maujoe.flowmap_shader/demo/materials/simple_flowmap_lava__vertex_color.tres: -------------------------------------------------------------------------------- 1 | [gd_resource type="ShaderMaterial" load_steps=4 format=2] 2 | 3 | [ext_resource path="res://assets/maujoe.flowmap_shader/shader/basic_flowmap_material__vertex_color.shader" type="Shader" id=1] 4 | [ext_resource path="res://assets/maujoe.flowmap_shader/demo/textures/lava.png" type="Texture" id=2] 5 | [ext_resource path="res://assets/maujoe.flowmap_shader/demo/textures/water_normal.png" type="Texture" id=3] 6 | 7 | [resource] 8 | 9 | render_priority = 0 10 | shader = ExtResource( 1 ) 11 | shader_param/albedo = Color( 0.304688, 0.304688, 0.304688, 0.966824 ) 12 | shader_param/specular = 0.0 13 | shader_param/metallic = 0.0 14 | shader_param/roughness = 1.0 15 | shader_param/metallic_texture_channel = null 16 | shader_param/roughness_texture_channel = null 17 | shader_param/emission = Color( 0, 0, 0, 1 ) 18 | shader_param/emission_energy = 1.0 19 | shader_param/refraction = null 20 | shader_param/refraction_texture_channel = null 21 | shader_param/uv_scale = Vector2( 4, 4 ) 22 | shader_param/uv_offset = null 23 | shader_param/proximity_fade_distance = 0.5 24 | shader_param/distance_fade_min = 0.0 25 | shader_param/distance_fade_max = 1.0 26 | shader_param/normal_scale = 0.3 27 | shader_param/flow_normal_influence = null 28 | shader_param/flow_map_x_channel = null 29 | shader_param/flow_map_y_channel = null 30 | shader_param/channel_flow_direction = Vector2( 1, -1 ) 31 | shader_param/blend_cycle = 10.0 32 | shader_param/cycle_speed = 1.0 33 | shader_param/flow_speed = -0.1 34 | shader_param/noise_texture_channel = null 35 | shader_param/flow_noise_size = null 36 | shader_param/flow_noise_influence = null 37 | shader_param/texture_albedo = ExtResource( 2 ) 38 | shader_param/texture_emission = ExtResource( 2 ) 39 | shader_param/texture_normal = ExtResource( 3 ) 40 | _sections_unfolded = [ "shader_param" ] 41 | 42 | -------------------------------------------------------------------------------- /assets/maujoe.flowmap_shader/demo/materials/simple_flowmap_lava__per_vertex.tres: -------------------------------------------------------------------------------- 1 | [gd_resource type="ShaderMaterial" load_steps=5 format=2] 2 | 3 | [ext_resource path="res://assets/maujoe.flowmap_shader/shader/basic_flowmap_material__per_vertex.shader" type="Shader" id=1] 4 | [ext_resource path="res://assets/maujoe.flowmap_shader/demo/textures/lava.png" type="Texture" id=2] 5 | [ext_resource path="res://assets/maujoe.flowmap_shader/demo/textures/flowmap.png" type="Texture" id=3] 6 | [ext_resource path="res://assets/maujoe.flowmap_shader/demo/textures/water_normal.png" type="Texture" id=4] 7 | 8 | [resource] 9 | 10 | render_priority = 0 11 | shader = ExtResource( 1 ) 12 | shader_param/albedo = Color( 0.363281, 0.363281, 0.363281, 0.966824 ) 13 | shader_param/specular = null 14 | shader_param/metallic = null 15 | shader_param/roughness = 1.0 16 | shader_param/roughness_texture_channel = null 17 | shader_param/emission = Color( 0, 0, 0, 1 ) 18 | shader_param/emission_energy = 1.0 19 | shader_param/refraction = null 20 | shader_param/refraction_texture_channel = null 21 | shader_param/uv_scale = Vector2( 4, 4 ) 22 | shader_param/uv_offset = null 23 | shader_param/proximity_fade_distance = 0.5 24 | shader_param/distance_fade_min = 0.0 25 | shader_param/distance_fade_max = 1.0 26 | shader_param/normal_scale = 0.3 27 | shader_param/flow_normal_influence = null 28 | shader_param/flowmap_x_channel = null 29 | shader_param/flowmap_y_channel = null 30 | shader_param/channel_flow_direction = Vector2( 1, -1 ) 31 | shader_param/blend_cycle = 10.0 32 | shader_param/cycle_speed = 1.0 33 | shader_param/flow_speed = 0.1 34 | shader_param/noise_texture_channel = null 35 | shader_param/flow_noise_size = null 36 | shader_param/flow_noise_influence = null 37 | shader_param/texture_albedo = ExtResource( 2 ) 38 | shader_param/texture_emission = ExtResource( 2 ) 39 | shader_param/texture_normal = ExtResource( 4 ) 40 | shader_param/texture_flowmap = ExtResource( 3 ) 41 | _sections_unfolded = [ "shader_param" ] 42 | 43 | -------------------------------------------------------------------------------- /assets/maujoe.flowmap_shader/demo/materials/simple_flowmap_lava.tres: -------------------------------------------------------------------------------- 1 | [gd_resource type="ShaderMaterial" load_steps=5 format=2] 2 | 3 | [ext_resource path="res://assets/maujoe.flowmap_shader/shader/basic_flowmap_material.shader" type="Shader" id=1] 4 | [ext_resource path="res://assets/maujoe.flowmap_shader/demo/textures/lava.png" type="Texture" id=2] 5 | [ext_resource path="res://assets/maujoe.flowmap_shader/demo/textures/flowmap.png" type="Texture" id=3] 6 | [ext_resource path="res://assets/maujoe.flowmap_shader/demo/textures/water_normal.png" type="Texture" id=4] 7 | 8 | [resource] 9 | 10 | render_priority = 0 11 | shader = ExtResource( 1 ) 12 | shader_param/albedo = Color( 0.433594, 0.433594, 0.433594, 0.966824 ) 13 | shader_param/specular = null 14 | shader_param/metallic = null 15 | shader_param/roughness = 1.0 16 | shader_param/metallic_texture_channel = null 17 | shader_param/roughness_texture_channel = null 18 | shader_param/emission = Color( 0, 0, 0, 1 ) 19 | shader_param/emission_energy = 1.0 20 | shader_param/refraction = null 21 | shader_param/refraction_texture_channel = null 22 | shader_param/uv_scale = Vector2( 4, 4 ) 23 | shader_param/uv_offset = null 24 | shader_param/proximity_fade_distance = 0.5 25 | shader_param/distance_fade_min = 0.0 26 | shader_param/distance_fade_max = 1.0 27 | shader_param/normal_scale = 0.3 28 | shader_param/flow_normal_influence = null 29 | shader_param/flow_map_x_channel = null 30 | shader_param/flow_map_y_channel = null 31 | shader_param/channel_flow_direction = Vector2( 1, -1 ) 32 | shader_param/blend_cycle = 10.0 33 | shader_param/cycle_speed = 1.0 34 | shader_param/flow_speed = 0.1 35 | shader_param/noise_texture_channel = null 36 | shader_param/flow_noise_size = null 37 | shader_param/flow_noise_influence = null 38 | shader_param/texture_albedo = ExtResource( 2 ) 39 | shader_param/texture_emission = ExtResource( 2 ) 40 | shader_param/texture_normal = ExtResource( 4 ) 41 | shader_param/texture_flow_map = ExtResource( 3 ) 42 | _sections_unfolded = [ "shader_param" ] 43 | 44 | -------------------------------------------------------------------------------- /assets/maujoe.flowmap_shader/demo/materials/basic_flowmap_water__vertex_color_displace.tres: -------------------------------------------------------------------------------- 1 | [gd_resource type="ShaderMaterial" load_steps=4 format=2] 2 | 3 | [ext_resource path="res://assets/maujoe.flowmap_shader/shader/basic_flowmap_material__vertex_color_displace.shader" type="Shader" id=1] 4 | [ext_resource path="res://assets/maujoe.flowmap_shader/demo/textures/displace.png" type="Texture" id=2] 5 | [ext_resource path="res://assets/maujoe.flowmap_shader/demo/textures/water_normal.png" type="Texture" id=3] 6 | 7 | [resource] 8 | 9 | render_priority = 0 10 | shader = ExtResource( 1 ) 11 | shader_param/albedo = Color( 0, 0.333333, 0.392157, 0.980392 ) 12 | shader_param/specular = 0.0 13 | shader_param/metallic = 0.0 14 | shader_param/roughness = 0.0 15 | shader_param/metallic_texture_channel = null 16 | shader_param/roughness_texture_channel = null 17 | shader_param/emission = Color( 0, 0, 0, 1 ) 18 | shader_param/emission_energy = null 19 | shader_param/refraction = null 20 | shader_param/refraction_texture_channel = null 21 | shader_param/uv_scale = Vector2( 16, 16 ) 22 | shader_param/uv_offset = null 23 | shader_param/proximity_fade_distance = 0.5 24 | shader_param/distance_fade_min = 0.0 25 | shader_param/distance_fade_max = 1.0 26 | shader_param/normal_scale = 0.2 27 | shader_param/flow_normal_influence = null 28 | shader_param/displace_texture_channel = Plane( 1, 0, 0, 0 ) 29 | shader_param/displace_scale = 1.5 30 | shader_param/flow_displace_influence = 0.0 31 | shader_param/displace_cycle_speed = 1.0 32 | shader_param/displace_speed = 0.01 33 | shader_param/displace_offset = -0.75 34 | shader_param/flow_map_x_channel = Plane( 1, 0, 0, 0 ) 35 | shader_param/flow_map_y_channel = Plane( 0, 1, 0, 0 ) 36 | shader_param/channel_flow_direction = Vector2( 1, -1 ) 37 | shader_param/blend_cycle = 5.0 38 | shader_param/cycle_speed = 2.0 39 | shader_param/flow_speed = -0.1 40 | shader_param/noise_texture_channel = null 41 | shader_param/flow_noise_size = null 42 | shader_param/flow_noise_influence = null 43 | shader_param/texture_normal = ExtResource( 3 ) 44 | shader_param/texture_displace = ExtResource( 2 ) 45 | _sections_unfolded = [ "shader_param" ] 46 | 47 | -------------------------------------------------------------------------------- /assets/maujoe.flowmap_shader/demo/materials/basic_flowmap_water__displace.tres: -------------------------------------------------------------------------------- 1 | [gd_resource type="ShaderMaterial" load_steps=5 format=2] 2 | 3 | [ext_resource path="res://assets/maujoe.flowmap_shader/shader/basic_flowmap_material__displace.shader" type="Shader" id=1] 4 | [ext_resource path="res://assets/maujoe.flowmap_shader/demo/textures/displace.png" type="Texture" id=2] 5 | [ext_resource path="res://assets/maujoe.flowmap_shader/demo/textures/flowmap.png" type="Texture" id=3] 6 | [ext_resource path="res://assets/maujoe.flowmap_shader/demo/textures/water_normal.png" type="Texture" id=4] 7 | 8 | [resource] 9 | 10 | render_priority = 0 11 | shader = ExtResource( 1 ) 12 | shader_param/albedo = Color( 0, 0.333333, 0.392157, 0.980392 ) 13 | shader_param/specular = null 14 | shader_param/metallic = null 15 | shader_param/roughness = null 16 | shader_param/metallic_texture_channel = null 17 | shader_param/roughness_texture_channel = null 18 | shader_param/emission = null 19 | shader_param/emission_energy = null 20 | shader_param/refraction = null 21 | shader_param/refraction_texture_channel = null 22 | shader_param/uv_scale = Vector2( 16, 16 ) 23 | shader_param/uv_offset = null 24 | shader_param/proximity_fade_distance = 0.5 25 | shader_param/distance_fade_min = 0.0 26 | shader_param/distance_fade_max = 1.0 27 | shader_param/normal_scale = 0.2 28 | shader_param/flow_normal_influence = 0.0 29 | shader_param/displace_texture_channel = null 30 | shader_param/displace_scale = 1.0 31 | shader_param/flow_displace_influence = 0.0 32 | shader_param/displace_cycle_speed = 0.2 33 | shader_param/displace_speed = 0.1 34 | shader_param/displace_offset = -0.5 35 | shader_param/flow_map_x_channel = null 36 | shader_param/flow_map_y_channel = null 37 | shader_param/channel_flow_direction = Vector2( 1, -1 ) 38 | shader_param/blend_cycle = 5.0 39 | shader_param/cycle_speed = 2.0 40 | shader_param/flow_speed = 0.1 41 | shader_param/noise_texture_channel = null 42 | shader_param/flow_noise_size = null 43 | shader_param/flow_noise_influence = null 44 | shader_param/texture_normal = ExtResource( 4 ) 45 | shader_param/texture_displace = ExtResource( 2 ) 46 | shader_param/texture_flow_map = ExtResource( 3 ) 47 | _sections_unfolded = [ "shader_param" ] 48 | 49 | -------------------------------------------------------------------------------- /assets/maujoe.flowmap_shader/demo/materials/simple_flowmap_lava__vertex_color_displace.tres: -------------------------------------------------------------------------------- 1 | [gd_resource type="ShaderMaterial" load_steps=5 format=2] 2 | 3 | [ext_resource path="res://assets/maujoe.flowmap_shader/shader/basic_flowmap_material__vertex_color_displace.shader" type="Shader" id=1] 4 | [ext_resource path="res://assets/maujoe.flowmap_shader/demo/textures/lava.png" type="Texture" id=2] 5 | [ext_resource path="res://assets/maujoe.flowmap_shader/demo/textures/displace.png" type="Texture" id=3] 6 | [ext_resource path="res://assets/maujoe.flowmap_shader/demo/textures/water_normal.png" type="Texture" id=4] 7 | 8 | [resource] 9 | 10 | render_priority = 0 11 | shader = ExtResource( 1 ) 12 | shader_param/albedo = Color( 0.304688, 0.304688, 0.304688, 0.966824 ) 13 | shader_param/specular = 0.0 14 | shader_param/metallic = 0.0 15 | shader_param/roughness = 1.0 16 | shader_param/metallic_texture_channel = null 17 | shader_param/roughness_texture_channel = null 18 | shader_param/emission = Color( 0, 0, 0, 1 ) 19 | shader_param/emission_energy = 1.0 20 | shader_param/refraction = null 21 | shader_param/refraction_texture_channel = null 22 | shader_param/uv_scale = Vector2( 4, 4 ) 23 | shader_param/uv_offset = null 24 | shader_param/proximity_fade_distance = 0.5 25 | shader_param/distance_fade_min = 0.0 26 | shader_param/distance_fade_max = 1.0 27 | shader_param/normal_scale = 0.3 28 | shader_param/flow_normal_influence = null 29 | shader_param/displace_texture_channel = null 30 | shader_param/displace_scale = 1.0 31 | shader_param/flow_displace_influence = null 32 | shader_param/displace_cycle_speed = 0.2 33 | shader_param/displace_speed = -0.1 34 | shader_param/displace_offset = -0.5 35 | shader_param/flow_map_x_channel = null 36 | shader_param/flow_map_y_channel = null 37 | shader_param/channel_flow_direction = Vector2( 1, -1 ) 38 | shader_param/blend_cycle = 10.0 39 | shader_param/cycle_speed = 1.0 40 | shader_param/flow_speed = -0.1 41 | shader_param/noise_texture_channel = null 42 | shader_param/flow_noise_size = null 43 | shader_param/flow_noise_influence = null 44 | shader_param/texture_albedo = ExtResource( 2 ) 45 | shader_param/texture_emission = ExtResource( 2 ) 46 | shader_param/texture_normal = ExtResource( 4 ) 47 | shader_param/texture_displace = ExtResource( 3 ) 48 | _sections_unfolded = [ "shader_param" ] 49 | 50 | -------------------------------------------------------------------------------- /assets/maujoe.flowmap_shader/demo/materials/simple_flowmap_lava__displace.tres: -------------------------------------------------------------------------------- 1 | [gd_resource type="ShaderMaterial" load_steps=6 format=2] 2 | 3 | [ext_resource path="res://assets/maujoe.flowmap_shader/shader/basic_flowmap_material__displace.shader" type="Shader" id=1] 4 | [ext_resource path="res://assets/maujoe.flowmap_shader/demo/textures/lava.png" type="Texture" id=2] 5 | [ext_resource path="res://assets/maujoe.flowmap_shader/demo/textures/displace.png" type="Texture" id=3] 6 | [ext_resource path="res://assets/maujoe.flowmap_shader/demo/textures/flowmap.png" type="Texture" id=4] 7 | [ext_resource path="res://assets/maujoe.flowmap_shader/demo/textures/water_normal.png" type="Texture" id=5] 8 | 9 | [resource] 10 | 11 | render_priority = 0 12 | shader = ExtResource( 1 ) 13 | shader_param/albedo = Color( 0.304688, 0.304688, 0.304688, 0.966824 ) 14 | shader_param/specular = 0.0 15 | shader_param/metallic = 0.0 16 | shader_param/roughness = 1.0 17 | shader_param/metallic_texture_channel = null 18 | shader_param/roughness_texture_channel = null 19 | shader_param/emission = Color( 0, 0, 0, 1 ) 20 | shader_param/emission_energy = 1.0 21 | shader_param/refraction = null 22 | shader_param/refraction_texture_channel = null 23 | shader_param/uv_scale = Vector2( 4, 4 ) 24 | shader_param/uv_offset = null 25 | shader_param/proximity_fade_distance = 0.5 26 | shader_param/distance_fade_min = 0.0 27 | shader_param/distance_fade_max = 1.0 28 | shader_param/normal_scale = 0.3 29 | shader_param/flow_normal_influence = null 30 | shader_param/displace_texture_channel = null 31 | shader_param/displace_scale = 1.0 32 | shader_param/flow_displace_influence = null 33 | shader_param/displace_cycle_speed = 0.2 34 | shader_param/displace_speed = 0.1 35 | shader_param/displace_offset = -0.5 36 | shader_param/flow_map_x_channel = null 37 | shader_param/flow_map_y_channel = null 38 | shader_param/channel_flow_direction = Vector2( 1, -1 ) 39 | shader_param/blend_cycle = 10.0 40 | shader_param/cycle_speed = 1.0 41 | shader_param/flow_speed = 0.1 42 | shader_param/noise_texture_channel = null 43 | shader_param/flow_noise_size = null 44 | shader_param/flow_noise_influence = null 45 | shader_param/texture_albedo = ExtResource( 2 ) 46 | shader_param/texture_emission = ExtResource( 2 ) 47 | shader_param/texture_normal = ExtResource( 5 ) 48 | shader_param/texture_displace = ExtResource( 3 ) 49 | shader_param/texture_flow_map = ExtResource( 4 ) 50 | _sections_unfolded = [ "shader_param" ] 51 | 52 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | 2 | The shader, the demo and all parts of this project that are not copyrighted or licensed by someone else are released under the MIT License: 3 | 4 | Copyright (c) 2018 Jaccomo Lorenz (Maujoe) 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in all 14 | copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | SOFTWARE. 23 | 24 | 25 | ------------ 26 | Other Files: 27 | 28 | Some files caintained in this project may be generated by the Godot Engine version 3.0 that is covered by its own license, an up to date version can be found on: https://github.com/godotengine/godot/blob/master/LICENSE.txt. 29 | 30 | Quote (18th February 2018): 31 | 32 | "Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. 33 | Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) 34 | 35 | Permission is hereby granted, free of charge, to any person obtaining a copy 36 | of this software and associated documentation files (the "Software"), to deal 37 | in the Software without restriction, including without limitation the rights 38 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 39 | copies of the Software, and to permit persons to whom the Software is 40 | furnished to do so, subject to the following conditions: 41 | 42 | The above copyright notice and this permission notice shall be included in all 43 | copies or substantial portions of the Software. 44 | 45 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 46 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 47 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 48 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 49 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 50 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 51 | SOFTWARE." 52 | -------------------------------------------------------------------------------- /assets/maujoe.flowmap_shader/LICENSE.md: -------------------------------------------------------------------------------- 1 | 2 | The shader, the demo and all parts of this project that are not copyrighted or licensed by someone else are released under the MIT License: 3 | 4 | Copyright (c) 2018 Jaccomo Lorenz (Maujoe) 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in all 14 | copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | SOFTWARE. 23 | 24 | 25 | ------------ 26 | Other Files: 27 | 28 | Some files caintained in this project may be generated by the Godot Engine version 3.0 that is covered by its own license, an up to date version can be found on: https://github.com/godotengine/godot/blob/master/LICENSE.txt. 29 | 30 | Quote (18th February 2018): 31 | 32 | "Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. 33 | Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) 34 | 35 | Permission is hereby granted, free of charge, to any person obtaining a copy 36 | of this software and associated documentation files (the "Software"), to deal 37 | in the Software without restriction, including without limitation the rights 38 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 39 | copies of the Software, and to permit persons to whom the Software is 40 | furnished to do so, subject to the following conditions: 41 | 42 | The above copyright notice and this permission notice shall be included in all 43 | copies or substantial portions of the Software. 44 | 45 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 46 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 47 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 48 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 49 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 50 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 51 | SOFTWARE." 52 | -------------------------------------------------------------------------------- /assets/maujoe.flowmap_shader/demo/scripts/camera_control/LICENSE.md: -------------------------------------------------------------------------------- 1 | 2 | All parts of this project that are not copyrighted or licensed by someone else are released under the MIT License: 3 | 4 | Copyright (c) 2018 Jaccomo Lorenz (Maujoe) 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in all 14 | copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | SOFTWARE. 23 | 24 | 25 | ------------ 26 | Other Files: 27 | 28 | Some files caintained in this project may be generated by the Godot Engine version 3.0 that is covered by its own license, an up to date version can be found on: https://github.com/godotengine/godot/blob/master/LICENSE.txt. 29 | 30 | Quote (18th February 2018): 31 | 32 | "Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. 33 | Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) 34 | 35 | Permission is hereby granted, free of charge, to any person obtaining a copy 36 | of this software and associated documentation files (the "Software"), to deal 37 | in the Software without restriction, including without limitation the rights 38 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 39 | copies of the Software, and to permit persons to whom the Software is 40 | furnished to do so, subject to the following conditions: 41 | 42 | The above copyright notice and this permission notice shall be included in all 43 | copies or substantial portions of the Software. 44 | 45 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 46 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 47 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 48 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 49 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 50 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 51 | SOFTWARE." 52 | -------------------------------------------------------------------------------- /assets/maujoe.flowmap_shader/DOCUMENTATION.md: -------------------------------------------------------------------------------- 1 | ## Asset Info 2 | 3 | #### Demo 4 | There are two example scenes in the demo folder that demostrate how to use flow maps for basic water and lava materials. 5 | 6 | #### Shader variations 7 | There are multiple shader variations for different requirements that are marked via file names: 8 | 9 | - "basic_flowmap_material.shader" - Default shader. 10 | - "displace" - Allows displacement via height map. (WIP doens't update normals but works ok with small displace scale). 11 | - "per_vertex" - Calculate flow per vertex instead of per per pixel. 12 | - "vertex_color" - Use the vertex color instead of a flow map. 13 | 14 | #### Performance Optimizitions / Customization: 15 | By default all textures are affected by the flowmap. The shader can be optimized/customized by deleting/replacing unnecessary shader code (with the default one). 16 | 17 | 18 | ## Shader settings 19 | 20 | Many shader settings are equivalent to godot spatial material editor and are explained in the Godot docs http://docs.godotengine.org/en/3.0. 21 | The shader specific settings can be found below. 22 | 23 | #### Flow map Settings 24 | - sampler2D texture_flow_map - The flow map texture that represents a 2D vector field to animate the uv coordinates. 25 | - vec4 flow_map_x_channel - The texture channel to animate along the x-axis. Default value is (1.0, 0.0, 0.0, 0.0) (red channel). 26 | - vec4 flow_map_y_channel - The texture channel to animate along the y-axis. Default value is (0.0, 1.0, 0.0, 0.0) (green channel). 27 | - vec2 channel_flow_direction - Set the flow directions of the x and y axes. Default value is (1, -1). 28 | - float blend_cycle - The "duration * 2" until the texture animation start over. Default value is 1.0. 29 | - float cycle_speed - The speed of the blend cycle. Default value is 1.0. 30 | - float flow_speed - The speed/direction of the flow independent from the blend cycle (can cause distortions). Default value is 1.0. 31 | - float flow_normal_influence - A factor to control how much the flow speed influences the normal scale. Default value is 0.0. 32 | 33 | 34 | - sampler2D texture_flow_noise - A noise texture to offset uv coordinates and minimize pulsing effects (Optional). 35 | - vec4 noise_texture_channel - The texture channel. 36 | - float flow_noise_size - The scale of the noise texture. Default value is vec2(1.0, 1.0). 37 | - float flow_noise_influence - The influence factor of the noise texture. Default value is 0.5. 38 | 39 | #### Displace Settings (displace version only) 40 | - sampler2D texture_displace - A height map texture used for displacement. 41 | - vec4 displace_texture_channel - The texture channel used for the displacement. 42 | - float displace_scale - The scale of the dislpacement. 43 | - float flow_displace_influence - A factor to control how much the flow speed influence the displace scale. Default value is 0.0. 44 | -------------------------------------------------------------------------------- /default_env.tres: -------------------------------------------------------------------------------- 1 | [gd_resource type="Environment" load_steps=2 format=2] 2 | 3 | [sub_resource type="ProceduralSky" id=1] 4 | 5 | radiance_size = 4 6 | sky_top_color = Color( 0.0470588, 0.454902, 0.976471, 1 ) 7 | sky_horizon_color = Color( 0.556863, 0.823529, 0.909804, 1 ) 8 | sky_curve = 0.25 9 | sky_energy = 1.0 10 | ground_bottom_color = Color( 0.101961, 0.145098, 0.188235, 1 ) 11 | ground_horizon_color = Color( 0.482353, 0.788235, 0.952941, 1 ) 12 | ground_curve = 0.01 13 | ground_energy = 1.0 14 | sun_color = Color( 1, 1, 1, 1 ) 15 | sun_latitude = 35.0 16 | sun_longitude = 0.0 17 | sun_angle_min = 1.0 18 | sun_angle_max = 100.0 19 | sun_curve = 0.05 20 | sun_energy = 16.0 21 | texture_size = 2 22 | 23 | [resource] 24 | 25 | background_mode = 2 26 | background_sky = SubResource( 1 ) 27 | background_sky_custom_fov = 0.0 28 | background_color = Color( 0, 0, 0, 1 ) 29 | background_energy = 1.0 30 | background_canvas_max_layer = 0 31 | ambient_light_color = Color( 0, 0, 0, 1 ) 32 | ambient_light_energy = 1.0 33 | ambient_light_sky_contribution = 1.0 34 | fog_enabled = false 35 | fog_color = Color( 0.5, 0.6, 0.7, 1 ) 36 | fog_sun_color = Color( 1, 0.9, 0.7, 1 ) 37 | fog_sun_amount = 0.0 38 | fog_depth_enabled = true 39 | fog_depth_begin = 10.0 40 | fog_depth_curve = 1.0 41 | fog_transmit_enabled = false 42 | fog_transmit_curve = 1.0 43 | fog_height_enabled = false 44 | fog_height_min = 0.0 45 | fog_height_max = 100.0 46 | fog_height_curve = 1.0 47 | tonemap_mode = 0 48 | tonemap_exposure = 1.0 49 | tonemap_white = 1.0 50 | auto_exposure_enabled = false 51 | auto_exposure_scale = 0.4 52 | auto_exposure_min_luma = 0.05 53 | auto_exposure_max_luma = 8.0 54 | auto_exposure_speed = 0.5 55 | ss_reflections_enabled = false 56 | ss_reflections_max_steps = 64 57 | ss_reflections_fade_in = 0.15 58 | ss_reflections_fade_out = 2.0 59 | ss_reflections_depth_tolerance = 0.2 60 | ss_reflections_roughness = true 61 | ssao_enabled = false 62 | ssao_radius = 1.0 63 | ssao_intensity = 1.0 64 | ssao_radius2 = 0.0 65 | ssao_intensity2 = 1.0 66 | ssao_bias = 0.01 67 | ssao_light_affect = 0.0 68 | ssao_color = Color( 0, 0, 0, 1 ) 69 | ssao_quality = 0 70 | ssao_blur = 3 71 | ssao_edge_sharpness = 4.0 72 | dof_blur_far_enabled = false 73 | dof_blur_far_distance = 10.0 74 | dof_blur_far_transition = 5.0 75 | dof_blur_far_amount = 0.1 76 | dof_blur_far_quality = 1 77 | dof_blur_near_enabled = false 78 | dof_blur_near_distance = 2.0 79 | dof_blur_near_transition = 1.0 80 | dof_blur_near_amount = 0.1 81 | dof_blur_near_quality = 1 82 | glow_enabled = false 83 | glow_levels/1 = false 84 | glow_levels/2 = false 85 | glow_levels/3 = true 86 | glow_levels/4 = false 87 | glow_levels/5 = true 88 | glow_levels/6 = false 89 | glow_levels/7 = false 90 | glow_intensity = 0.8 91 | glow_strength = 1.0 92 | glow_bloom = 0.0 93 | glow_blend_mode = 2 94 | glow_hdr_threshold = 1.0 95 | glow_hdr_scale = 2.0 96 | glow_bicubic_upscale = false 97 | adjustment_enabled = false 98 | adjustment_brightness = 1.0 99 | adjustment_contrast = 1.0 100 | adjustment_saturation = 1.0 101 | 102 | -------------------------------------------------------------------------------- /assets/maujoe.flowmap_shader/demo/controls.tscn: -------------------------------------------------------------------------------- 1 | [gd_scene load_steps=3 format=2] 2 | 3 | [ext_resource path="res://assets/maujoe.flowmap_shader/demo/scripts/example.gd" type="Script" id=1] 4 | [ext_resource path="res://assets/maujoe.flowmap_shader/demo/scripts/camera_control/camera_control.gd" type="Script" id=2] 5 | 6 | [node name="Controls" type="Node" index="0"] 7 | 8 | [node name="Control" type="Control" parent="." index="0"] 9 | 10 | anchor_left = 0.0 11 | anchor_top = 0.0 12 | anchor_right = 1.0 13 | anchor_bottom = 1.0 14 | rect_pivot_offset = Vector2( 0, 0 ) 15 | rect_clip_content = false 16 | mouse_filter = 0 17 | mouse_default_cursor_shape = 0 18 | size_flags_horizontal = 1 19 | size_flags_vertical = 1 20 | script = ExtResource( 1 ) 21 | 22 | [node name="ExampleSwitcher" type="OptionButton" parent="Control" index="0"] 23 | 24 | anchor_left = 0.0 25 | anchor_top = 1.0 26 | anchor_right = 0.0 27 | anchor_bottom = 1.0 28 | margin_left = 10.0 29 | margin_top = -65.0 30 | margin_right = 39.0 31 | margin_bottom = -40.0 32 | rect_pivot_offset = Vector2( 0, 0 ) 33 | rect_clip_content = false 34 | focus_mode = 2 35 | mouse_filter = 0 36 | mouse_default_cursor_shape = 0 37 | size_flags_horizontal = 1 38 | size_flags_vertical = 1 39 | toggle_mode = false 40 | action_mode = 0 41 | enabled_focus_mode = 2 42 | shortcut = null 43 | group = null 44 | flat = false 45 | align = 0 46 | items = [ ] 47 | selected = -1 48 | _sections_unfolded = [ "Anchor", "Margin" ] 49 | 50 | [node name="ExampleOption" type="OptionButton" parent="Control" index="1"] 51 | 52 | anchor_left = 0.0 53 | anchor_top = 1.0 54 | anchor_right = 0.0 55 | anchor_bottom = 1.0 56 | margin_left = 10.0 57 | margin_top = -35.0 58 | margin_right = 39.0 59 | margin_bottom = -10.0 60 | rect_pivot_offset = Vector2( 0, 0 ) 61 | rect_clip_content = false 62 | focus_mode = 2 63 | mouse_filter = 0 64 | mouse_default_cursor_shape = 0 65 | size_flags_horizontal = 1 66 | size_flags_vertical = 1 67 | toggle_mode = false 68 | action_mode = 0 69 | enabled_focus_mode = 2 70 | shortcut = null 71 | group = null 72 | flat = false 73 | align = 0 74 | items = [ ] 75 | selected = -1 76 | _sections_unfolded = [ "Anchor", "Margin" ] 77 | 78 | [node name="Camera" type="Camera" parent="." index="1"] 79 | 80 | transform = Transform( 0.457955, -0.272284, 0.846249, 0, 0.951938, 0.30629, -0.888975, -0.140267, 0.435945, 54.729, 29.649, 14.8872 ) 81 | keep_aspect = 1 82 | cull_mask = 1048575 83 | environment = null 84 | h_offset = 0.0 85 | v_offset = 0.0 86 | doppler_tracking = 0 87 | projection = 0 88 | current = true 89 | fov = 70.0 90 | size = 1.0 91 | near = 0.05 92 | far = 500.0 93 | script = ExtResource( 2 ) 94 | enabled = true 95 | mouse_mode = 2 96 | mouselook = true 97 | sensitivity = 0.5 98 | smoothness = 0.99 99 | privot = null 100 | distance = 5.0 101 | rotate_privot = false 102 | collisions = true 103 | yaw_limit = 360 104 | pitch_limit = 360 105 | movement = true 106 | acceleration = 1.0 107 | deceleration = 0.1 108 | max_speed = Vector3( 10, 10, 10 ) 109 | local = true 110 | forward_action = "ui_up" 111 | backward_action = "ui_down" 112 | left_action = "ui_left" 113 | right_action = "ui_right" 114 | up_action = "ui_page_up" 115 | down_action = "ui_page_down" 116 | use_gui = true 117 | gui_action = "ui_cancel" 118 | 119 | [connection signal="item_selected" from="Control/ExampleSwitcher" to="Control" method="_on_ExampleSwitcher_item_selected"] 120 | 121 | [connection signal="item_selected" from="Control/ExampleOption" to="Control" method="_on_ExampleOption_item_selected"] 122 | 123 | 124 | -------------------------------------------------------------------------------- /assets/maujoe.flowmap_shader/demo/scripts/camera_control/README.md: -------------------------------------------------------------------------------- 1 | # Camera Control Script 2 | 3 | An easy "plug and play" camera script for the godot engine 3.0 that provides controls like mouselook, movement and an optional ingame control gui. 4 | Useful for development and quick tests. 5 | 6 | ### Features: 7 | - mouselook 8 | - movement 9 | - ingame gui (optional) 10 | 11 | ### Preview: 12 | Demo video: https://www.youtube.com/watch?v=OSJRc-IiOio&t=9s 13 | 14 |
15 | Editor Settings 16 | 17 |
18 |
19 | Ingame Gui 20 | 21 |
22 | 23 | ## How to use 24 | 25 | There is a demo scene in the demo folder where you can test all features and play with the script settings. 26 | 27 | If you don't need the demo just ignore the demo folder and connect your camera with the "camera_control.gd" script that can be found in the script folder. 28 | 29 | ## Docummentation: 30 | 31 | ### Settings available via Editor/GDscript: 32 | 33 | - bool enable : enable/disable camera controls. Default is true. 34 | - int mouse_mode: Same as Godot's mouse settings by default the mouse is captured: 35 | - Visible = 0 (MOUSE_MODE_VISIBLE), 36 | - Hidden = 1 (MOUSE_MODE_HIDDEN), 37 | - Capture = 2 (MOUSE_MODE_CAPTURED), 38 | - Confined = 3 (MOUSE_MODE_CONFINED). 39 | 40 | 41 | - bool mouselook - Enable/disable mouselook. Default is true. 42 | - float sensitivity - Sensitivity of the mouselook. A value between 0 and 1. Default value is 0.5. 43 | - float smoothness - Smoothness of the mouselook. A value between 0,001 and 0,999. Default value is 0.5. 44 | - Spatial privot - Optional privot object for thirdperson like mouselook. Default value is None (no privot). 45 | - bool rotate_privot - Enable/disable if the will be rotated with the camera. Default is false. 46 | - float distance - The distance between the camera and the privot object. Minimum value is 0. Default value is 5.0 47 | - bool rotate_privote - Rotate privot object with the mouselook. Default is false. 48 | - bool collision - The camera avoid it to go through/behind objects. Default is true. 49 | - int yaw_limit - Limit the yaw of the mouselook in Degrees, if limit >= 360 there is no limit. Default value is 360. 50 | - int pitch_limit - Limit the Pitch of the mouselook in Degrees, if limit = 360 there is no limit. Default value is 360. 51 | 52 | 53 | - bool movement - Enable/disable camera movement (flying). Default is true. 54 | - bool local - Switch between movement on local or global axes. Default is true. 55 | - float acceleration - Set the movement speed up factor. A Value between 0 and 1. Default value is 1.0. 56 | - float deceleration - Set the movement slow down factor. A Value between 0 and 1. Default value is 0.1. 57 | - Vector3 max_speed - Set maximum movement speed for each axes separately. Default value is (1.0, 1.0, 1.0). 58 | 59 | 60 | - String forword_action - Input Action for fordward movement. Default action is "ui_up". 61 | - String backward_action - Input Action for backward movement. Default action is "ui_down". 62 | - String left_action - Input Action for Left movement. Default action is "ui_left". 63 | - String right_action: Input Action for Right movement. Default action is "ui_right". 64 | - String up_action - Input Action for upward movement. Default action is "ui_page_up". 65 | - String down_action: Input Action for downward movement. Default action is "ui_page_down". 66 | 67 | 68 | - String gui_action - Input Action to show/hide the ingame control gui. Default action is "ui_cancel". 69 | - bool use_gui - Enable/disable ingame gui. Default is true. 70 | 71 | ### Gui configuration: 72 | 73 | The ingame gui can also be configurated via constants in the camera_control_gui.gd script 74 | 75 | ![Image](screenshots/gui_settings.png) 76 | 77 | - const Vector2 GUI_POS - The default position of the gui. Default is (10, 10). 78 | - const Vector2 GUI_SIZE - The size of the gui. Default is (200, 0) 79 | - const bool DRAGGABLE - Enable/disable draggable gui. Default is true. 80 | - const bool CUSTOM_BACKGROUND - Enable/disable custom background color. Default is false. 81 | - const Color CUSTOM_COLOR - Set custom background color. 82 | - const MAX_SPEED - The maximal value of the speedslider 83 | 84 | ### To-do/possible features: 85 | - refactoring 86 | - distance shortcut key. 87 | - improve movement: speed shortcut 88 | - multiple camera support/jump between cameras 89 | - screenshot functionality(?) 90 | - more modularisation(?) 91 | - add signal notification(?) 92 | - ... 93 | 94 | 95 | ## License 96 | 97 | All parts of this project that are not copyrighted or licensed by someone else are released free under the MIT License - see the LICENSE.md file for details. 98 | Please keep license file, thanks. :) 99 | -------------------------------------------------------------------------------- /assets/maujoe.flowmap_shader/README.md: -------------------------------------------------------------------------------- 1 | # Flow map Shader 2 | 3 | A basic flow map material shader for Godot 3.x. 4 | Flow maps are a texture based way to make detailed texture animations (e.g. water, lava, fluids...) or texture distortions. 5 | 6 | Video: https://youtu.be/kkZJ9SBH_24 7 | 8 | 9 | # How it works 10 | 11 | Basically it uses 2 channels of a texture to move texture coordinates along the x and y axes. 12 | Each channel controls one axis. A channel color value of 0.5 means no flow, a value greater than 0.5 moves the coordinates along one direction of an axis and a value smaller than 0.5 moves it to the opposite direction. 13 | So with the right values textures can be moved in all directions and that for each location individually unlike simple uv scroll. River example: 14 | 15 | 16 | 17 | But there are also some limitations, so to avoid big texture scratches/artifacts in the long run there are two repeating layers which are offseted and blended together. Also to minimize the pulsing effect a noise texture can be used to add some random offset. 18 | 19 | For references and more details about flow maps see below. 20 | 21 | 22 | ## How to create flow maps 23 | Painting flow maps manually is tricky but there are some programs to create them. 24 | 25 | #### Software to create flow maps 26 | - Flowmap Painter by Teck Lee Tan: http://teckartist.com/?page_id=107 27 | - Flow Field Editor by Stanislaw Adaszewski: https://github.com/sadaszewski/flowed 28 | - Flowmap generator by Superposition Games (Paid): http://www.superpositiongames.com/ (Haven't tested it but looks powerfull) 29 | - It's also possible to create flow maps from whole simulations with the Software Houdini but I haven't done this yet. 30 | - ... 31 | 32 | 33 | ## Asset Info 34 | 35 | #### Demo 36 | There are two example scenes in the demo folder that demostrate how to use flow maps for basic water and lava materials. 37 | 38 | #### Shader variations 39 | There are multiple shader variations for different requirements that are marked via file names: 40 | 41 | - "basic_flowmap_material.shader" - Default shader. 42 | - "displace" - Allows displacement via height map. (WIP doens't update normals but works ok with small displace scale). 43 | - "per_vertex" - Calculate flow per vertex instead of per per pixel. 44 | - "vertex_color" - Use the vertex color instead of a flow map. 45 | 46 | #### Performance Optimizitions / Customization: 47 | By default all textures are affected by the flowmap. The shader can be optimized/customized by deleting/replacing unnecessary shader code (with the default one). 48 | 49 | 50 | ## Shader settings 51 | 52 | Many shader settings are equivalent to godot spatial material editor and are explained in the Godot docs http://docs.godotengine.org/en/3.0. 53 | The shader specific settings can be found below. 54 | 55 | #### Flow map Settings 56 | - sampler2D texture_flow_map - The flow map texture that represents a 2D vector field to animate the uv coordinates. 57 | - vec4 flow_map_x_channel - The texture channel to animate along the x-axis. Default value is (1.0, 0.0, 0.0, 0.0) (red channel). 58 | - vec4 flow_map_y_channel - The texture channel to animate along the y-axis. Default value is (0.0, 1.0, 0.0, 0.0) (green channel). 59 | - vec2 channel_flow_direction - Set the flow directions of the x and y axes. Default value is (1, -1). 60 | - float blend_cycle - The "duration * 2" until the texture animation start over. Default value is 1.0. 61 | - float cycle_speed - The speed of the blend cycle. Default value is 1.0. 62 | - float flow_speed - The speed/direction of the flow independent from the blend cycle (can cause distortions). Default value is 1.0. 63 | - float flow_normal_influence - A factor to control how much the flow speed influences the normal scale. Default value is 0.0. 64 | 65 | 66 | - sampler2D texture_flow_noise - A noise texture to offset uv coordinates and minimize pulsing effects (Optional). 67 | - vec4 noise_texture_channel - The texture channel. 68 | - float flow_noise_size - The scale of the noise texture. Default value is vec2(1.0, 1.0). 69 | - float flow_noise_influence - The influence factor of the noise texture. Default value is 0.5. 70 | 71 | #### Displace Settings (displace version only) 72 | - sampler2D texture_displace - A height map texture used for displacement. 73 | - vec4 displace_texture_channel - The texture channel used for the displacement. 74 | - float displace_scale - The scale of the dislpacement. 75 | - float flow_displace_influence - A factor to control how much the flow speed influence the displace scale. Default value is 0.0. 76 | 77 | 78 | ## References / More about Flow maps 79 | Valve: 80 | 81 | https://steamcdn-a.akamaihd.net/apps/valve/2010/siggraph2010_vlachos_waterflow.pdf 82 | https://developer.valvesoftware.com/wiki/Water_(shader)#Flowmaps 83 | https://steamcdn-a.akamaihd.net/apps/valve/2011/gdc_2011_grimes_nonstandard_textures.pdf 84 | 85 | Naughty Dog: 86 | 87 | https://cgzoo.files.wordpress.com/2012/04/water-technology-of-uncharted-gdc-2012.pdf 88 | 89 | Other: 90 | 91 | https://mtnphil.wordpress.com/2012/08/25/water-flow-shader/ 92 | http://graphicsrunner.blogspot.de/2010/08/water-using-flow-maps.html 93 | http://phill.inksworth.com/tut.php 94 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Flow map Shader 2 | 3 | A basic flow map material shader for Godot 3.x. 4 | Flow maps are a texture based way to make detailed texture animations (e.g. water, lava, fluids...) or texture distortions. 5 | 6 | Video: https://youtu.be/kkZJ9SBH_24 7 | 8 | 9 | ## How it works 10 | 11 | Basically it uses 2 channels of a texture to move texture coordinates along the x and y axes. 12 | Each channel controls one axis. A channel color value of 0.5 means no flow, a value greater than 0.5 moves the coordinates along one direction of an axis and a value smaller than 0.5 moves it to the opposite direction. 13 | So with the right values textures can be moved in all directions and that for each location individually unlike simple uv scroll. River example: 14 | 15 | 16 | 17 | But there are also some limitations, so to avoid big texture scratches/artifacts in the long run there are two repeating layers which are offseted and blended together. Also to minimize the pulsing effect a noise texture can be used to add some random offset. 18 | 19 | For references and more details about flow maps see below. 20 | 21 | 22 | ## How to create flow maps 23 | Painting flow maps manually is tricky but there are some programs to create them. 24 | 25 | #### Software to create flow maps 26 | - Flowmap Painter by Teck Lee Tan: http://teckartist.com/?page_id=107 27 | - Flow Field Editor by Stanislaw Adaszewski: https://github.com/sadaszewski/flowed 28 | - Flowmap generator by Superposition Games (Paid): http://www.superpositiongames.com/ (Haven't tested it but looks powerfull) 29 | - It's also possible to create flow maps from whole simulations with the Software Houdini but I haven't done this yet. 30 | - ... 31 | 32 | 33 | ## Asset Info 34 | 35 | #### Demo 36 | There are two example scenes in the demo folder that demostrate how to use flow maps for basic water and lava materials. 37 | 38 | #### Shader variations 39 | There are multiple shader variations for different requirements that are marked via file names: 40 | 41 | - "basic_flowmap_material.shader" - Default shader. 42 | - "displace" - Allows displacement via height map. (WIP doens't update normals but works ok with small displace scale). 43 | - "per_vertex" - Calculate flow per vertex instead of per per pixel. 44 | - "vertex_color" - Use the vertex color instead of a flow map. 45 | 46 | #### Performance Optimizitions / Customization: 47 | By default all textures are affected by the flowmap. The shader can be optimized/customized by deleting/replacing unnecessary shader code (with the default one). 48 | 49 | 50 | ## Shader settings 51 | 52 | Many shader settings are equivalent to godot spatial material editor and are explained in the Godot docs http://docs.godotengine.org/en/3.0. 53 | The shader specific settings can be found below. 54 | 55 | #### Flow map Settings 56 | - sampler2D texture_flow_map - The flow map texture that represents a 2D vector field to animate the uv coordinates. 57 | - vec4 flow_map_x_channel - The texture channel to animate along the x-axis. Default value is (1.0, 0.0, 0.0, 0.0) (red channel). 58 | - vec4 flow_map_y_channel - The texture channel to animate along the y-axis. Default value is (0.0, 1.0, 0.0, 0.0) (green channel). 59 | - vec2 channel_flow_direction - Set the flow directions of the x and y axes. Default value is (1, -1). 60 | - float blend_cycle - The "duration * 2" until the texture animation start over. Default value is 1.0. 61 | - float cycle_speed - The speed of the blend cycle. Default value is 1.0. 62 | - float flow_speed - The speed/direction of the flow independent from the blend cycle (can cause distortions). Default value is 1.0. 63 | - float flow_normal_influence - A factor to control how much the flow speed influences the normal scale. Default value is 0.0. 64 | 65 | 66 | - sampler2D texture_flow_noise - A noise texture to offset uv coordinates and minimize pulsing effects (Optional). 67 | - vec4 noise_texture_channel - The texture channel. 68 | - float flow_noise_size - The scale of the noise texture. Default value is vec2(1.0, 1.0). 69 | - float flow_noise_influence - The influence factor of the noise texture. Default value is 0.5. 70 | 71 | #### Displace Settings (displace version only) 72 | - sampler2D texture_displace - A height map texture used for displacement. 73 | - vec4 displace_texture_channel - The texture channel used for the displacement. 74 | - float displace_scale - The scale of the dislpacement. 75 | - float flow_displace_influence - A factor to control how much the flow speed influence the displace scale. Default value is 0.0. 76 | 77 | 78 | ## References / More about Flow maps 79 | Valve: 80 | 81 | https://steamcdn-a.akamaihd.net/apps/valve/2010/siggraph2010_vlachos_waterflow.pdf 82 | https://developer.valvesoftware.com/wiki/Water_(shader)#Flowmaps 83 | https://steamcdn-a.akamaihd.net/apps/valve/2011/gdc_2011_grimes_nonstandard_textures.pdf 84 | 85 | Naughty Dog: 86 | 87 | https://cgzoo.files.wordpress.com/2012/04/water-technology-of-uncharted-gdc-2012.pdf 88 | 89 | Other: 90 | 91 | https://mtnphil.wordpress.com/2012/08/25/water-flow-shader/ 92 | http://graphicsrunner.blogspot.de/2010/08/water-using-flow-maps.html 93 | http://phill.inksworth.com/tut.php 94 | -------------------------------------------------------------------------------- /assets/maujoe.flowmap_shader/shader/basic_flowmap_material.shader: -------------------------------------------------------------------------------- 1 | shader_type spatial; 2 | render_mode blend_mix, depth_draw_always, cull_back, diffuse_burley, specular_schlick_ggx; 3 | uniform vec4 albedo : hint_color; 4 | uniform sampler2D texture_albedo : hint_albedo; 5 | uniform float specular; 6 | uniform float metallic; 7 | uniform float roughness : hint_range(0,1); 8 | uniform sampler2D texture_metallic : hint_white; 9 | uniform vec4 metallic_texture_channel = vec4(1.0, 0.0, 0.0, 0.0); 10 | uniform sampler2D texture_roughness : hint_white; 11 | uniform vec4 roughness_texture_channel = vec4(1.0, 0.0, 0.0, 0.0); 12 | uniform sampler2D texture_emission : hint_black_albedo; 13 | uniform vec4 emission : hint_color; 14 | uniform float emission_energy; 15 | uniform sampler2D texture_refraction; 16 | uniform float refraction : hint_range(-16,16); 17 | uniform vec4 refraction_texture_channel = vec4(1.0, 0.0, 0.0, 0.0); 18 | uniform vec2 uv_scale = vec2(1.0, 1.0); 19 | uniform vec2 uv_offset; 20 | uniform float proximity_fade_distance; 21 | uniform float distance_fade_min; 22 | uniform float distance_fade_max; 23 | 24 | uniform sampler2D texture_normal : hint_normal; 25 | uniform float normal_scale : hint_range(-16,16); 26 | uniform float flow_normal_influence : hint_range(0, 1); 27 | 28 | // Flow / Water uniforms 29 | uniform sampler2D texture_flow_map : hint_normal; 30 | uniform vec4 flow_map_x_channel = vec4(1.0, 0.0, 0.0, 0.0); 31 | uniform vec4 flow_map_y_channel = vec4(0.0, 1.0, 0.0, 0.0); 32 | uniform vec2 channel_flow_direction = vec2(1.0, -1.0); 33 | uniform float blend_cycle = 1.0; 34 | uniform float cycle_speed = 1.0; 35 | uniform float flow_speed = 0.5; 36 | 37 | uniform sampler2D texture_flow_noise; 38 | uniform vec4 noise_texture_channel = vec4(1.0, 0.0, 0.0, 0.0); 39 | uniform vec2 flow_noise_size = vec2(1.0, 1.0); 40 | uniform float flow_noise_influence = 0.5; 41 | 42 | 43 | varying vec2 base_uv; 44 | 45 | void vertex() { 46 | base_uv = UV * uv_scale.xy + uv_offset.xy; 47 | } 48 | 49 | void fragment() { 50 | // UV flow calculation 51 | /****************************************************************************************************/ 52 | float half_cycle = blend_cycle * 0.5; 53 | 54 | // Use noise texture for offset to reduce pulsing effect 55 | float offset = dot(texture(texture_flow_noise, UV * flow_noise_size), noise_texture_channel) * flow_noise_influence; 56 | 57 | float phase1 = mod(offset + TIME * cycle_speed, blend_cycle); 58 | float phase2 = mod(offset + TIME * cycle_speed + half_cycle, blend_cycle); 59 | 60 | vec4 flow_tex = texture(texture_flow_map, UV); 61 | vec2 flow; 62 | flow.x = dot(flow_tex, flow_map_x_channel) * 2.0 - 1.0; 63 | flow.y = dot(flow_tex, flow_map_y_channel) * 2.0 - 1.0; 64 | flow *= normalize(channel_flow_direction); 65 | 66 | // Make flow incluence on the normalmap strenght adjustable (optional) 67 | float normal_influence = mix(1.0, dot(abs(flow), vec2(1.0, 1.0)) * 0.5, flow_normal_influence); 68 | 69 | // Blend factor to mix the two layers 70 | float blend_factor = abs(half_cycle - phase1)/half_cycle; 71 | 72 | // Offset by halfCycle to improve the animation for color (for normalmap not absolutely necessary) 73 | phase1 -= half_cycle; 74 | phase2 -= half_cycle; 75 | 76 | // Multiply with scale to make flow speed independent from the uv scaling 77 | flow *= flow_speed * uv_scale; 78 | 79 | vec2 layer1 = flow * phase1 + base_uv; 80 | vec2 layer2 = flow * phase2 + base_uv; 81 | /****************************************************************************************************/ 82 | 83 | // Albedo 84 | // Mix animated uv layers 85 | vec4 albedo_tex = mix(texture(texture_albedo, layer1), texture(texture_albedo, layer2), blend_factor); 86 | ALBEDO = albedo.rgb * albedo_tex.rgb; 87 | 88 | // Metallic / Roughness / Specular 89 | // Mix animated uv layers 90 | float metallic_tex = mix(dot(texture(texture_metallic, layer1), metallic_texture_channel), dot(texture(texture_metallic, layer2), metallic_texture_channel), blend_factor); 91 | METALLIC = metallic_tex * metallic; 92 | float roughness_tex = mix(dot(texture(texture_roughness, layer1), roughness_texture_channel), dot(texture(texture_roughness, layer2), roughness_texture_channel), blend_factor); 93 | ROUGHNESS = roughness_tex * roughness; 94 | SPECULAR = specular; 95 | 96 | // Normalmap 97 | // Mix animated uv layers 98 | NORMALMAP = mix(texture(texture_normal, layer1), texture(texture_normal, layer2), blend_factor).rgb; 99 | NORMALMAP_DEPTH = normal_scale * normal_influence; 100 | 101 | // Refraction 102 | vec3 ref_normal = normalize(mix(NORMAL,TANGENT * NORMALMAP.x + BINORMAL * NORMALMAP.y + NORMAL * NORMALMAP.z,NORMALMAP_DEPTH)); 103 | // Mix animated uv layers 104 | vec4 ref_tex = mix(texture(texture_refraction, layer1), texture(texture_refraction, layer2), blend_factor); 105 | vec2 ref_ofs = SCREEN_UV - ref_normal.xy * dot(ref_tex, refraction_texture_channel) * refraction; 106 | float ref_amount = 1.0 - albedo.a * albedo_tex.a; 107 | ALBEDO *= 1.0 - ref_amount; 108 | 109 | // Emission 110 | // Mix animated uv layers 111 | vec3 emission_tex = mix(texture(texture_emission, layer1), texture(texture_emission, layer2), blend_factor).rgb; 112 | EMISSION = (emission.rgb + emission_tex) * emission_energy; 113 | EMISSION += textureLod(SCREEN_TEXTURE, ref_ofs, ROUGHNESS * 8.0).rgb * ref_amount; 114 | 115 | // Proximity fade / Distance fade 116 | float depth_tex = textureLod(DEPTH_TEXTURE,SCREEN_UV, 0.0).r; 117 | vec4 world_pos = INV_PROJECTION_MATRIX * vec4(SCREEN_UV * 2.0 - 1.0, depth_tex * 2.0 - 1.0, 1.0); 118 | world_pos.xyz /= world_pos.w; 119 | ALPHA = 1.0; 120 | ALPHA *= clamp(1.0 - smoothstep(world_pos.z + proximity_fade_distance, world_pos.z, VERTEX.z), 0.0, 1.0); 121 | ALPHA *= clamp(smoothstep(distance_fade_min,distance_fade_max,-VERTEX.z), 0.0, 1.0); 122 | } 123 | -------------------------------------------------------------------------------- /assets/maujoe.flowmap_shader/shader/basic_flowmap_material__vertex_color.shader: -------------------------------------------------------------------------------- 1 | shader_type spatial; 2 | render_mode blend_mix, depth_draw_always, cull_back, diffuse_burley, specular_schlick_ggx; 3 | uniform vec4 albedo : hint_color; 4 | uniform sampler2D texture_albedo : hint_albedo; 5 | uniform float specular; 6 | uniform float metallic; 7 | uniform float roughness : hint_range(0,1); 8 | uniform sampler2D texture_metallic : hint_white; 9 | uniform vec4 metallic_texture_channel = vec4(1.0, 0.0, 0.0, 0.0); 10 | uniform sampler2D texture_roughness : hint_white; 11 | uniform vec4 roughness_texture_channel = vec4(1.0, 0.0, 0.0, 0.0); 12 | uniform sampler2D texture_emission : hint_black_albedo; 13 | uniform vec4 emission : hint_color; 14 | uniform float emission_energy; 15 | uniform sampler2D texture_refraction; 16 | uniform float refraction : hint_range(-16,16); 17 | uniform vec4 refraction_texture_channel = vec4(1.0, 0.0, 0.0, 0.0); 18 | uniform vec2 uv_scale = vec2(1.0, 1.0); 19 | uniform vec2 uv_offset; 20 | uniform float proximity_fade_distance; 21 | uniform float distance_fade_min; 22 | uniform float distance_fade_max; 23 | 24 | // Normalmap 25 | uniform sampler2D texture_normal : hint_normal; 26 | uniform float normal_scale : hint_range(-16,16); 27 | uniform float flow_normal_influence : hint_range(0, 1); 28 | 29 | // Flow uniforms 30 | uniform vec4 flow_map_x_channel = vec4(1.0, 0.0, 0.0, 0.0); 31 | uniform vec4 flow_map_y_channel = vec4(0.0, 1.0, 0.0, 0.0); 32 | uniform vec2 channel_flow_direction = vec2(1.0, -1.0); 33 | uniform float blend_cycle = 1.0; 34 | uniform float cycle_speed = 1.0; 35 | uniform float flow_speed = 0.5; 36 | 37 | uniform sampler2D texture_flow_noise; 38 | uniform vec4 noise_texture_channel = vec4(1.0, 0.0, 0.0, 0.0); 39 | uniform vec2 flow_noise_size = vec2(1.0, 1.0); 40 | uniform float flow_noise_influence = 0.5; 41 | 42 | 43 | varying vec2 base_uv; 44 | varying vec2 layer1; 45 | varying vec2 layer2; 46 | varying float blend_factor; 47 | varying float normal_influence; 48 | 49 | void vertex() { 50 | base_uv = UV * uv_scale.xy + uv_offset.xy; 51 | 52 | // UV flow calculation 53 | /****************************************************************************************************/ 54 | float half_cycle = blend_cycle * 0.5; 55 | 56 | // Use noise texture for offset to reduce pulsing effect 57 | float offset = dot(texture(texture_flow_noise, UV * flow_noise_size), noise_texture_channel) * flow_noise_influence; 58 | 59 | float phase1 = mod(offset + TIME * cycle_speed, blend_cycle); 60 | float phase2 = mod(offset + TIME * cycle_speed + half_cycle, blend_cycle); 61 | 62 | vec4 flow_tex = COLOR; 63 | vec2 flow; 64 | flow.x = dot(flow_tex, flow_map_x_channel) * 2.0 - 1.0; 65 | flow.y = dot(flow_tex, flow_map_y_channel) * 2.0 - 1.0; 66 | flow *= normalize(channel_flow_direction); 67 | 68 | // Make flow influence on the normalmap / displace strenght adjustable (optional) 69 | float flow_strength = dot(abs(flow), vec2(1.0, 1.0)) * 0.5; 70 | normal_influence = mix(1.0, flow_strength, flow_normal_influence); 71 | 72 | // Blend factor to mix the two layers 73 | blend_factor = abs(half_cycle - phase1)/half_cycle; 74 | 75 | // Offset by halfCycle to improve the animation for color (for normalmap not absolutely necessary) 76 | phase1 -= half_cycle; 77 | phase2 -= half_cycle; 78 | 79 | // Multiply with scale to make flow speed independent from the uv scaling 80 | flow *= flow_speed * uv_scale; 81 | 82 | layer1 = flow * phase1 + base_uv; 83 | layer2 = flow * phase2 + base_uv; 84 | /****************************************************************************************************/ 85 | 86 | } 87 | 88 | void fragment() { 89 | 90 | // Albedo 91 | // Mix animated uv layers 92 | vec4 albedo_tex = mix(texture(texture_albedo, layer1), texture(texture_albedo, layer2), blend_factor); 93 | ALBEDO = albedo.rgb * albedo_tex.rgb; 94 | 95 | // Metallic / Roughness / Specular 96 | // Mix animated uv layers 97 | float metallic_tex = mix(dot(texture(texture_metallic, layer1), metallic_texture_channel), dot(texture(texture_metallic, layer2), metallic_texture_channel), blend_factor); 98 | METALLIC = metallic_tex * metallic; 99 | float roughness_tex = mix(dot(texture(texture_roughness, layer1), roughness_texture_channel), dot(texture(texture_roughness, layer2), roughness_texture_channel), blend_factor); 100 | ROUGHNESS = roughness_tex * roughness; 101 | SPECULAR = specular; 102 | 103 | // Normalmap 104 | // Mix animated uv layers 105 | NORMALMAP = mix(texture(texture_normal, layer1), texture(texture_normal, layer2), blend_factor).rgb; 106 | NORMALMAP_DEPTH = normal_scale * normal_influence; 107 | 108 | // Refraction 109 | vec3 ref_normal = normalize(mix(NORMAL,TANGENT * NORMALMAP.x + BINORMAL * NORMALMAP.y + NORMAL * NORMALMAP.z,NORMALMAP_DEPTH)); 110 | // Mix animated uv layers 111 | vec4 ref_tex = mix(texture(texture_refraction, layer1), texture(texture_refraction, layer2), blend_factor); 112 | vec2 ref_ofs = SCREEN_UV - ref_normal.xy * dot(ref_tex, refraction_texture_channel) * refraction; 113 | float ref_amount = 1.0 - albedo.a * albedo_tex.a; 114 | ALBEDO *= 1.0 - ref_amount; 115 | 116 | // Emission 117 | // Mix animated uv layers 118 | vec3 emission_tex = mix(texture(texture_emission, layer1), texture(texture_emission, layer2), blend_factor).rgb; 119 | EMISSION = (emission.rgb+emission_tex) * emission_energy; 120 | EMISSION += textureLod(SCREEN_TEXTURE, ref_ofs, ROUGHNESS * 8.0).rgb * ref_amount; 121 | 122 | // Proximity fade / Distance fade 123 | float depth_tex = textureLod(DEPTH_TEXTURE,SCREEN_UV, 0.0).r; 124 | vec4 world_pos = INV_PROJECTION_MATRIX * vec4(SCREEN_UV * 2.0 - 1.0, depth_tex * 2.0 - 1.0, 1.0); 125 | world_pos.xyz /= world_pos.w; 126 | ALPHA = 1.0; 127 | ALPHA *= clamp(1.0 - smoothstep(world_pos.z + proximity_fade_distance, world_pos.z, VERTEX.z), 0.0, 1.0); 128 | ALPHA *= clamp(smoothstep(distance_fade_min,distance_fade_max,-VERTEX.z), 0.0, 1.0); 129 | } 130 | -------------------------------------------------------------------------------- /assets/maujoe.flowmap_shader/shader/basic_flowmap_material__per_vertex.shader: -------------------------------------------------------------------------------- 1 | shader_type spatial; 2 | render_mode blend_mix, depth_draw_always, cull_back, diffuse_burley, specular_schlick_ggx; 3 | uniform vec4 albedo : hint_color; 4 | uniform sampler2D texture_albedo : hint_albedo; 5 | uniform float specular; 6 | uniform float metallic; 7 | uniform float roughness : hint_range(0,1); 8 | uniform sampler2D texture_metallic : hint_white; 9 | uniform vec4 metallic_texture_channel = vec4(1.0, 0.0, 0.0, 0.0); 10 | uniform sampler2D texture_roughness : hint_white; 11 | uniform vec4 roughness_texture_channel = vec4(1.0, 0.0, 0.0, 0.0); 12 | uniform sampler2D texture_emission : hint_black_albedo; 13 | uniform vec4 emission : hint_color; 14 | uniform float emission_energy; 15 | uniform sampler2D texture_refraction; 16 | uniform float refraction : hint_range(-16,16); 17 | uniform vec4 refraction_texture_channel = vec4(1.0, 0.0, 0.0, 0.0); 18 | uniform vec2 uv_scale = vec2(1.0, 1.0); 19 | uniform vec2 uv_offset; 20 | uniform float proximity_fade_distance; 21 | uniform float distance_fade_min; 22 | uniform float distance_fade_max; 23 | 24 | // Normalmap 25 | uniform sampler2D texture_normal : hint_normal; 26 | uniform float normal_scale : hint_range(-16,16); 27 | uniform float flow_normal_influence : hint_range(0, 1); 28 | 29 | // Flow uniforms 30 | uniform sampler2D texture_flow_map : hint_normal; 31 | uniform vec4 flow_map_x_channel = vec4(1.0, 0.0, 0.0, 0.0); 32 | uniform vec4 flow_map_y_channel = vec4(0.0, 1.0, 0.0, 0.0); 33 | uniform vec2 channel_flow_direction = vec2(1.0, 1.0); 34 | uniform float blend_cycle = 1.0; 35 | uniform float cycle_speed = 1.0; 36 | uniform float flow_speed = 0.5; 37 | 38 | uniform sampler2D texture_flow_noise; 39 | uniform vec4 noise_texture_channel = vec4(1.0, 0.0, 0.0, 0.0); 40 | uniform vec2 flow_noise_size = vec2(1.0, -1.0); 41 | uniform float flow_noise_influence = 0.5; 42 | 43 | 44 | varying vec2 base_uv; 45 | varying vec2 layer1; 46 | varying vec2 layer2; 47 | varying float blend_factor; 48 | varying float normal_influence; 49 | 50 | void vertex() { 51 | base_uv = UV * uv_scale.xy + uv_offset.xy; 52 | 53 | // UV flow calculation 54 | /****************************************************************************************************/ 55 | float half_cycle = blend_cycle * 0.5; 56 | 57 | // Use noise texture for offset to reduce pulsing effect 58 | float offset = dot(texture(texture_flow_noise, UV * flow_noise_size), noise_texture_channel) * flow_noise_influence; 59 | 60 | float phase1 = mod(offset + TIME * cycle_speed, blend_cycle); 61 | float phase2 = mod(offset + TIME * cycle_speed + half_cycle, blend_cycle); 62 | 63 | vec4 flow_tex = texture(texture_flow_map, UV); 64 | vec2 flow; 65 | flow.x = dot(flow_tex, flow_map_x_channel) * 2.0 - 1.0; 66 | flow.y = dot(flow_tex, flow_map_y_channel) * 2.0 - 1.0; 67 | flow *= normalize(channel_flow_direction); 68 | 69 | // Make flow influence on the normalmap / displace strenght adjustable (optional) 70 | float flow_strength = dot(abs(flow), vec2(1.0, 1.0)) * 0.5; 71 | normal_influence = mix(1.0, flow_strength, flow_normal_influence); 72 | 73 | // Blend factor to mix the two layers 74 | blend_factor = abs(half_cycle - phase1)/half_cycle; 75 | 76 | // Offset by halfCycle to improve the animation for color (for normalmap not absolutely necessary) 77 | phase1 -= half_cycle; 78 | phase2 -= half_cycle; 79 | 80 | // Multiply with scale to make flow speed independent from the uv scaling 81 | flow *= flow_speed * uv_scale; 82 | 83 | layer1 = flow * phase1 + base_uv; 84 | layer2 = flow * phase2 + base_uv; 85 | /****************************************************************************************************/ 86 | 87 | } 88 | 89 | void fragment() { 90 | 91 | // Albedo 92 | // Mix animated uv layers 93 | vec4 albedo_tex = mix(texture(texture_albedo, layer1), texture(texture_albedo, layer2), blend_factor); 94 | ALBEDO = albedo.rgb * albedo_tex.rgb; 95 | 96 | // Metallic / Roughness / Specular 97 | // Mix animated uv layers 98 | float metallic_tex = mix(dot(texture(texture_metallic, layer1), metallic_texture_channel), dot(texture(texture_metallic, layer2), metallic_texture_channel), blend_factor); 99 | METALLIC = metallic_tex * metallic; 100 | float roughness_tex = mix(dot(texture(texture_roughness, layer1), roughness_texture_channel), dot(texture(texture_roughness, layer2), roughness_texture_channel), blend_factor); 101 | ROUGHNESS = roughness_tex * roughness; 102 | SPECULAR = specular; 103 | 104 | // Normalmap 105 | // Mix animated uv layers 106 | NORMALMAP = mix(texture(texture_normal, layer1), texture(texture_normal, layer2), blend_factor).rgb; 107 | NORMALMAP_DEPTH = normal_scale * normal_influence; 108 | 109 | // Refraction 110 | vec3 ref_normal = normalize(mix(NORMAL,TANGENT * NORMALMAP.x + BINORMAL * NORMALMAP.y + NORMAL * NORMALMAP.z,NORMALMAP_DEPTH)); 111 | // Mix animated uv layers 112 | vec4 ref_tex = mix(texture(texture_refraction, layer1), texture(texture_refraction, layer2), blend_factor); 113 | vec2 ref_ofs = SCREEN_UV - ref_normal.xy * dot(ref_tex, refraction_texture_channel) * refraction; 114 | float ref_amount = 1.0 - albedo.a * albedo_tex.a; 115 | ALBEDO *= 1.0 - ref_amount; 116 | 117 | // Emission 118 | // Mix animated uv layers 119 | vec3 emission_tex = mix(texture(texture_emission, layer1), texture(texture_emission, layer2), blend_factor).rgb; 120 | EMISSION = (emission.rgb+emission_tex) * emission_energy; 121 | EMISSION += textureLod(SCREEN_TEXTURE, ref_ofs, ROUGHNESS * 8.0).rgb * ref_amount; 122 | 123 | // Proximity fade / Distance fade 124 | float depth_tex = textureLod(DEPTH_TEXTURE,SCREEN_UV, 0.0).r; 125 | vec4 world_pos = INV_PROJECTION_MATRIX * vec4(SCREEN_UV * 2.0 - 1.0, depth_tex * 2.0 - 1.0, 1.0); 126 | world_pos.xyz /= world_pos.w; 127 | ALPHA = 1.0; 128 | ALPHA *= clamp(1.0 - smoothstep(world_pos.z + proximity_fade_distance, world_pos.z, VERTEX.z), 0.0, 1.0); 129 | ALPHA *= clamp(smoothstep(distance_fade_min,distance_fade_max,-VERTEX.z), 0.0, 1.0); 130 | } 131 | -------------------------------------------------------------------------------- /assets/maujoe.flowmap_shader/demo/scripts/camera_control/camera_control.gd: -------------------------------------------------------------------------------- 1 | # Licensed under the MIT License. 2 | # Copyright (c) 2018 Jaccomo Lorenz (Maujoe) 3 | 4 | extends Camera 5 | 6 | # User settings: 7 | # General settings 8 | export var enabled = true setget set_enabled 9 | export(int, "Visible", "Hidden", "Caputered, Confined") var mouse_mode = 2 10 | 11 | # Mouslook settings 12 | export var mouselook = true 13 | export (float, 0.0, 1.0) var sensitivity = 0.5 14 | export (float, 0.0, 0.999, 0.001) var smoothness = 0.5 setget set_smoothness 15 | export(NodePath) var privot setget set_privot 16 | export var distance = 5.0 setget set_distance 17 | export var rotate_privot = false 18 | export var collisions = true setget set_collisions 19 | export (int, 0, 360) var yaw_limit = 360 20 | export (int, 0, 360) var pitch_limit = 360 21 | 22 | # Movement settings 23 | export var movement = true 24 | export (float, 0.0, 1.0) var acceleration = 1.0 25 | export (float, 0.0, 0.0, 1.0) var deceleration = 0.1 26 | export var max_speed = Vector3(1.0, 1.0, 1.0) 27 | export var local = true 28 | export var forward_action = "ui_up" 29 | export var backward_action = "ui_down" 30 | export var left_action = "ui_left" 31 | export var right_action = "ui_right" 32 | export var up_action = "ui_page_up" 33 | export var down_action = "ui_page_down" 34 | 35 | # Gui settings 36 | export var use_gui = true 37 | export var gui_action = "ui_cancel" 38 | 39 | # Intern variables. 40 | var _mouse_position = Vector2(0.0, 0.0) 41 | var _yaw = 0.0 42 | var _pitch = 0.0 43 | var _total_yaw = 0.0 44 | var _total_pitch = 0.0 45 | 46 | var _direction = Vector3(0.0, 0.0, 0.0) 47 | var _speed = Vector3(0.0, 0.0, 0.0) 48 | var _gui 49 | 50 | func _ready(): 51 | _check_actions([forward_action, backward_action, left_action, right_action, gui_action, up_action, down_action]) 52 | 53 | if privot: 54 | privot = get_node(privot) 55 | else: 56 | privot = null 57 | 58 | set_enabled(enabled) 59 | 60 | if use_gui: 61 | _gui = preload("camera_control_gui.gd") 62 | _gui = _gui.new(self, gui_action) 63 | add_child(_gui) 64 | 65 | func _input(event): 66 | if mouselook: 67 | if event is InputEventMouseMotion: 68 | _mouse_position = event.relative 69 | 70 | if movement: 71 | if event.is_action_pressed(forward_action): 72 | _direction.z = -1 73 | elif event.is_action_pressed(backward_action): 74 | _direction.z = 1 75 | elif not Input.is_action_pressed(forward_action) and not Input.is_action_pressed(backward_action): 76 | _direction.z = 0 77 | 78 | if event.is_action_pressed(left_action): 79 | _direction.x = -1 80 | elif event.is_action_pressed(right_action): 81 | _direction.x = 1 82 | elif not Input.is_action_pressed(left_action) and not Input.is_action_pressed(right_action): 83 | _direction.x = 0 84 | 85 | if event.is_action_pressed(up_action): 86 | _direction.y = 1 87 | if event.is_action_pressed(down_action): 88 | _direction.y = -1 89 | elif not Input.is_action_pressed(up_action) and not Input.is_action_pressed(down_action): 90 | _direction.y = 0 91 | 92 | func _process(delta): 93 | if privot: 94 | _update_distance() 95 | if mouselook: 96 | _update_mouselook() 97 | if movement: 98 | _update_movement(delta) 99 | 100 | func _physics_process(delta): 101 | # Called when collision are enabled 102 | _update_distance() 103 | if mouselook: 104 | _update_mouselook() 105 | 106 | var space_state = get_world().get_direct_space_state() 107 | var obstacle = space_state.intersect_ray(privot.get_translation(), get_translation()) 108 | if not obstacle.empty(): 109 | set_translation(obstacle.position) 110 | 111 | func _update_movement(delta): 112 | var offset = max_speed * acceleration * _direction 113 | 114 | _speed.x = clamp(_speed.x + offset.x, -max_speed.x, max_speed.x) 115 | _speed.y = clamp(_speed.y + offset.y, -max_speed.y, max_speed.y) 116 | _speed.z = clamp(_speed.z + offset.z, -max_speed.z, max_speed.z) 117 | 118 | # Apply deceleration if no input 119 | if _direction.x == 0: 120 | _speed.x *= (1.0 - deceleration) 121 | if _direction.y == 0: 122 | _speed.y *= (1.0 - deceleration) 123 | if _direction.z == 0: 124 | _speed.z *= (1.0 - deceleration) 125 | 126 | if local: 127 | translate(_speed * delta) 128 | else: 129 | global_translate(_speed * delta) 130 | 131 | func _update_mouselook(): 132 | _mouse_position *= sensitivity 133 | _yaw = _yaw * smoothness + _mouse_position.x * (1.0 - smoothness) 134 | _pitch = _pitch * smoothness + _mouse_position.y * (1.0 - smoothness) 135 | _mouse_position = Vector2(0, 0) 136 | 137 | if yaw_limit < 360: 138 | _yaw = clamp(_yaw, -yaw_limit - _total_yaw, yaw_limit - _total_yaw) 139 | if pitch_limit < 360: 140 | _pitch = clamp(_pitch, -pitch_limit - _total_pitch, pitch_limit - _total_pitch) 141 | 142 | _total_yaw += _yaw 143 | _total_pitch += _pitch 144 | 145 | if privot: 146 | var target = privot.get_translation() 147 | var offset = get_translation().distance_to(target) 148 | 149 | set_translation(target) 150 | rotate_y(deg2rad(-_yaw)) 151 | rotate_object_local(Vector3(1,0,0), deg2rad(-_pitch)) 152 | translate(Vector3(0.0, 0.0, offset)) 153 | 154 | if rotate_privot: 155 | privot.rotate_y(deg2rad(-_yaw)) 156 | else: 157 | rotate_y(deg2rad(-_yaw)) 158 | rotate_object_local(Vector3(1,0,0), deg2rad(-_pitch)) 159 | 160 | func _update_distance(): 161 | var t = privot.get_translation() 162 | t.z -= distance 163 | set_translation(t) 164 | 165 | func _update_process_func(): 166 | # Use physics process if collision are enabled 167 | if collisions and privot: 168 | set_physics_process(true) 169 | set_process(false) 170 | else: 171 | set_physics_process(false) 172 | set_process(true) 173 | 174 | func _check_actions(actions=[]): 175 | if OS.is_debug_build(): 176 | for action in actions: 177 | if not InputMap.has_action(action): 178 | print('WARNING: No action "' + action + '"') 179 | 180 | func set_privot(value): 181 | privot = value 182 | # TODO: fix parenting. 183 | # if privot: 184 | # if get_parent(): 185 | # get_parent().remove_child(self) 186 | # privot.add_child(self) 187 | _update_process_func() 188 | 189 | func set_collisions(value): 190 | collisions = value 191 | _update_process_func() 192 | 193 | func set_enabled(value): 194 | enabled = value 195 | if enabled: 196 | Input.set_mouse_mode(mouse_mode) 197 | set_process_input(true) 198 | _update_process_func() 199 | else: 200 | set_process(false) 201 | set_process_input(false) 202 | set_physics_process(false) 203 | 204 | func set_smoothness(value): 205 | smoothness = clamp(value, 0.001, 0.999) 206 | 207 | func set_distance(value): 208 | distance = max(0, value) 209 | -------------------------------------------------------------------------------- /assets/maujoe.flowmap_shader/shader/basic_flowmap_material__vertex_color_displace.shader: -------------------------------------------------------------------------------- 1 | shader_type spatial; 2 | render_mode blend_mix, depth_draw_always, cull_back, diffuse_burley, specular_schlick_ggx; 3 | uniform vec4 albedo : hint_color; 4 | uniform sampler2D texture_albedo : hint_albedo; 5 | uniform float specular; 6 | uniform float metallic; 7 | uniform float roughness : hint_range(0,1); 8 | uniform sampler2D texture_metallic : hint_white; 9 | uniform vec4 metallic_texture_channel = vec4(1.0, 0.0, 0.0, 0.0); 10 | uniform sampler2D texture_roughness : hint_white; 11 | uniform vec4 roughness_texture_channel = vec4(1.0, 0.0, 0.0, 0.0); 12 | uniform sampler2D texture_emission : hint_black_albedo; 13 | uniform vec4 emission : hint_color; 14 | uniform float emission_energy; 15 | uniform sampler2D texture_refraction; 16 | uniform float refraction : hint_range(-16,16); 17 | uniform vec4 refraction_texture_channel = vec4(1.0, 0.0, 0.0, 0.0); 18 | uniform vec2 uv_scale = vec2(1.0, 1.0); 19 | uniform vec2 uv_offset; 20 | uniform float proximity_fade_distance; 21 | uniform float distance_fade_min; 22 | uniform float distance_fade_max; 23 | 24 | // Normalmap 25 | uniform sampler2D texture_normal : hint_normal; 26 | uniform float normal_scale : hint_range(-16,16); 27 | uniform float flow_normal_influence : hint_range(0, 1); 28 | 29 | // Displacemap 30 | uniform sampler2D texture_displace : hint_black; 31 | uniform vec4 displace_texture_channel = vec4(1.0, 0.0, 0.0, 0.0); 32 | uniform float displace_scale; 33 | uniform float flow_displace_influence : hint_range(0, 1); 34 | uniform float displace_cycle_speed = 1.0; 35 | uniform float displace_speed = 1.0; 36 | uniform float displace_offset; 37 | 38 | // Flow uniforms 39 | uniform vec4 flow_map_x_channel = vec4(1.0, 0.0, 0.0, 0.0); 40 | uniform vec4 flow_map_y_channel = vec4(0.0, 1.0, 0.0, 0.0); 41 | uniform vec2 channel_flow_direction = vec2(1.0, -1.0); 42 | uniform float blend_cycle = 1.0; 43 | uniform float cycle_speed = 1.0; 44 | uniform float flow_speed = 0.5; 45 | 46 | uniform sampler2D texture_flow_noise; 47 | uniform vec4 noise_texture_channel = vec4(1.0, 0.0, 0.0, 0.0); 48 | uniform vec2 flow_noise_size = vec2(1.0, 1.0); 49 | uniform float flow_noise_influence = 0.5; 50 | 51 | 52 | varying vec2 base_uv; 53 | varying vec2 layer1; 54 | varying vec2 layer2; 55 | varying float blend_factor; 56 | varying float normal_influence; 57 | 58 | void vertex() { 59 | base_uv = UV * uv_scale.xy + uv_offset.xy; 60 | 61 | // UV flow calculation 62 | /****************************************************************************************************/ 63 | float half_cycle = blend_cycle * 0.5; 64 | 65 | // Use noise texture for offset to reduce pulsing effect 66 | float offset = dot(texture(texture_flow_noise, UV * flow_noise_size), noise_texture_channel) * flow_noise_influence; 67 | 68 | float phase1 = mod(offset + TIME * cycle_speed, blend_cycle); 69 | float phase2 = mod(offset + TIME * cycle_speed + half_cycle, blend_cycle); 70 | 71 | vec4 flow_tex = COLOR; 72 | vec2 flow; 73 | flow.x = dot(flow_tex, flow_map_x_channel) * 2.0 - 1.0; 74 | flow.y = dot(flow_tex, flow_map_y_channel) * 2.0 - 1.0; 75 | flow *= normalize(channel_flow_direction); 76 | 77 | // Make flow influence on the normalmap / displace strenght adjustable (optional) 78 | float flow_strength = dot(abs(flow), vec2(1.0, 1.0)) * 0.5; 79 | normal_influence = mix(1.0, flow_strength, flow_normal_influence); 80 | float displace_influence = mix(1.0, flow_strength, flow_displace_influence); 81 | 82 | // Blend factor to mix the two layers 83 | blend_factor = abs(half_cycle - phase1)/half_cycle; 84 | 85 | // Offset by halfCycle to improve the animation for color (for normalmap not absolutely necessary) 86 | phase1 -= half_cycle; 87 | phase2 -= half_cycle; 88 | 89 | // Multiply with scale to make flow speed independent from the uv scaling 90 | vec2 displace_flow = flow * displace_speed * uv_scale; 91 | flow *= flow_speed * uv_scale; 92 | 93 | layer1 = flow * phase1 + base_uv; 94 | layer2 = flow * phase2 + base_uv; 95 | /****************************************************************************************************/ 96 | 97 | // Displacement (WIP - works ok for small displace scale) 98 | // Use own phases for displacement for better control 99 | float disp_phase1 = mod(offset + TIME * displace_cycle_speed, blend_cycle); 100 | float disp_phase2 = mod(offset + TIME * displace_cycle_speed + half_cycle, blend_cycle); 101 | float disp_blend_factor = abs(half_cycle - disp_phase1)/half_cycle; 102 | float voffset = dot(mix(texture(texture_displace, displace_flow * disp_phase1 + base_uv), texture(texture_displace, displace_flow * disp_phase2 + base_uv), disp_blend_factor), displace_texture_channel) * displace_scale * displace_influence + displace_offset; 103 | VERTEX.y += voffset; 104 | 105 | // Todo: recalculating normals 106 | // (Also creating heightmap value inside shader is maybe more efficient for this purpose) 107 | } 108 | 109 | void fragment() { 110 | 111 | // Albedo 112 | // Mix animated uv layers 113 | vec4 albedo_tex = mix(texture(texture_albedo, layer1), texture(texture_albedo, layer2), blend_factor); 114 | ALBEDO = albedo.rgb * albedo_tex.rgb; 115 | 116 | // Metallic / Roughness / Specular 117 | // Mix animated uv layers 118 | float metallic_tex = mix(dot(texture(texture_metallic, layer1), metallic_texture_channel), dot(texture(texture_metallic, layer2), metallic_texture_channel), blend_factor); 119 | METALLIC = metallic_tex * metallic; 120 | float roughness_tex = mix(dot(texture(texture_roughness, layer1), roughness_texture_channel), dot(texture(texture_roughness, layer2), roughness_texture_channel), blend_factor); 121 | ROUGHNESS = roughness_tex * roughness; 122 | SPECULAR = specular; 123 | 124 | // Normalmap 125 | // Mix animated uv layers 126 | NORMALMAP = mix(texture(texture_normal, layer1), texture(texture_normal, layer2), blend_factor).rgb; 127 | NORMALMAP_DEPTH = normal_scale * normal_influence; 128 | 129 | // Refraction 130 | vec3 ref_normal = normalize(mix(NORMAL,TANGENT * NORMALMAP.x + BINORMAL * NORMALMAP.y + NORMAL * NORMALMAP.z,NORMALMAP_DEPTH)); 131 | // Mix animated uv layers 132 | vec4 ref_tex = mix(texture(texture_refraction, layer1), texture(texture_refraction, layer2), blend_factor); 133 | vec2 ref_ofs = SCREEN_UV - ref_normal.xy * dot(ref_tex, refraction_texture_channel) * refraction; 134 | float ref_amount = 1.0 - albedo.a * albedo_tex.a; 135 | ALBEDO *= 1.0 - ref_amount; 136 | 137 | // Emission 138 | // Mix animated uv layers 139 | vec3 emission_tex = mix(texture(texture_emission, layer1), texture(texture_emission, layer2), blend_factor).rgb; 140 | EMISSION = (emission.rgb+emission_tex) * emission_energy; 141 | EMISSION += textureLod(SCREEN_TEXTURE, ref_ofs, ROUGHNESS * 8.0).rgb * ref_amount; 142 | 143 | // Proximity fade / Distance fade 144 | float depth_tex = textureLod(DEPTH_TEXTURE,SCREEN_UV, 0.0).r; 145 | vec4 world_pos = INV_PROJECTION_MATRIX * vec4(SCREEN_UV * 2.0 - 1.0, depth_tex * 2.0 - 1.0, 1.0); 146 | world_pos.xyz /= world_pos.w; 147 | ALPHA = 1.0; 148 | ALPHA *= clamp(1.0 - smoothstep(world_pos.z + proximity_fade_distance, world_pos.z, VERTEX.z), 0.0, 1.0); 149 | ALPHA *= clamp(smoothstep(distance_fade_min,distance_fade_max,-VERTEX.z), 0.0, 1.0); 150 | } 151 | -------------------------------------------------------------------------------- /assets/maujoe.flowmap_shader/shader/basic_flowmap_material__displace.shader: -------------------------------------------------------------------------------- 1 | shader_type spatial; 2 | render_mode blend_mix, depth_draw_always, cull_back, diffuse_burley, specular_schlick_ggx; 3 | uniform vec4 albedo : hint_color; 4 | uniform sampler2D texture_albedo : hint_albedo; 5 | uniform float specular; 6 | uniform float metallic; 7 | uniform float roughness : hint_range(0,1); 8 | uniform sampler2D texture_metallic : hint_white; 9 | uniform vec4 metallic_texture_channel = vec4(1.0, 0.0, 0.0, 0.0); 10 | uniform sampler2D texture_roughness : hint_white; 11 | uniform vec4 roughness_texture_channel = vec4(1.0, 0.0, 0.0, 0.0); 12 | uniform sampler2D texture_emission : hint_black_albedo; 13 | uniform vec4 emission : hint_color; 14 | uniform float emission_energy; 15 | uniform sampler2D texture_refraction; 16 | uniform float refraction : hint_range(-16,16); 17 | uniform vec4 refraction_texture_channel = vec4(1.0, 0.0, 0.0, 0.0); 18 | uniform vec2 uv_scale = vec2(1.0, 1.0); 19 | uniform vec2 uv_offset; 20 | uniform float proximity_fade_distance; 21 | uniform float distance_fade_min; 22 | uniform float distance_fade_max; 23 | 24 | // Normalmap 25 | uniform sampler2D texture_normal : hint_normal; 26 | uniform float normal_scale : hint_range(-16,16); 27 | uniform float flow_normal_influence : hint_range(0, 1); 28 | 29 | // Displacemap 30 | uniform sampler2D texture_displace : hint_black; 31 | uniform vec4 displace_texture_channel = vec4(1.0, 0.0, 0.0, 0.0); 32 | uniform float displace_scale; 33 | uniform float flow_displace_influence : hint_range(0, 1); 34 | uniform float displace_cycle_speed = 1.0; 35 | uniform float displace_speed = 1.0; 36 | uniform float displace_offset; 37 | 38 | // Flow uniforms 39 | uniform sampler2D texture_flow_map : hint_normal; 40 | uniform vec4 flow_map_x_channel = vec4(1.0, 0.0, 0.0, 0.0); 41 | uniform vec4 flow_map_y_channel = vec4(0.0, 1.0, 0.0, 0.0); 42 | uniform vec2 channel_flow_direction = vec2(1.0, -1.0); 43 | uniform float blend_cycle = 1.0; 44 | uniform float cycle_speed = 1.0; 45 | uniform float flow_speed = 0.5; 46 | 47 | uniform sampler2D texture_flow_noise; 48 | uniform vec4 noise_texture_channel = vec4(1.0, 0.0, 0.0, 0.0); 49 | uniform vec2 flow_noise_size = vec2(1.0, 1.0); 50 | uniform float flow_noise_influence = 0.5; 51 | 52 | 53 | varying vec2 base_uv; 54 | varying vec2 layer1; 55 | varying vec2 layer2; 56 | varying float blend_factor; 57 | varying float normal_influence; 58 | 59 | void vertex() { 60 | base_uv = UV * uv_scale.xy + uv_offset.xy; 61 | 62 | // UV flow calculation 63 | /****************************************************************************************************/ 64 | float half_cycle = blend_cycle * 0.5; 65 | 66 | // Use noise texture for offset to reduce pulsing effect 67 | float offset = dot(texture(texture_flow_noise, UV * flow_noise_size), noise_texture_channel) * flow_noise_influence; 68 | 69 | float phase1 = mod(offset + TIME * cycle_speed, blend_cycle); 70 | float phase2 = mod(offset + TIME * cycle_speed + half_cycle, blend_cycle); 71 | 72 | vec4 flow_tex = texture(texture_flow_map, UV); 73 | vec2 flow; 74 | flow.x = dot(flow_tex, flow_map_x_channel) * 2.0 - 1.0; 75 | flow.y = dot(flow_tex, flow_map_y_channel) * 2.0 - 1.0; 76 | flow *= normalize(channel_flow_direction); 77 | 78 | // Make flow influence on the normalmap / displace strenght adjustable (optional) 79 | float flow_strength = dot(abs(flow), vec2(1.0, 1.0)) * 0.5; 80 | normal_influence = mix(1.0, flow_strength, flow_normal_influence); 81 | float displace_influence = mix(1.0, flow_strength, flow_displace_influence); 82 | 83 | // Blend factor to mix the two layers 84 | blend_factor = abs(half_cycle - phase1)/half_cycle; 85 | 86 | // Offset by halfCycle to improve the animation for color (for normalmap not absolutely necessary) 87 | phase1 -= half_cycle; 88 | phase2 -= half_cycle; 89 | 90 | // Multiply with scale to make flow speed independent from the uv scaling 91 | vec2 displace_flow = flow * displace_speed * uv_scale; 92 | flow *= flow_speed * uv_scale; 93 | 94 | layer1 = flow * phase1 + base_uv; 95 | layer2 = flow * phase2 + base_uv; 96 | /****************************************************************************************************/ 97 | 98 | // Displacement (WIP - works ok for small displace scale) 99 | // Use own phases for displacement for better control 100 | float disp_phase1 = mod(offset + TIME * displace_cycle_speed, blend_cycle); 101 | float disp_phase2 = mod(offset + TIME * displace_cycle_speed + half_cycle, blend_cycle); 102 | float disp_blend_factor = abs(half_cycle - disp_phase1)/half_cycle; 103 | float voffset = dot(mix(texture(texture_displace, displace_flow * disp_phase1 + base_uv), texture(texture_displace, displace_flow * disp_phase2 + base_uv), disp_blend_factor), displace_texture_channel) * displace_scale * displace_influence + displace_offset; 104 | VERTEX.y += voffset; 105 | 106 | // Todo: recalculating normals 107 | // (Also creating heightmap value inside shader is maybe more efficient for this purpose) 108 | } 109 | 110 | void fragment() { 111 | 112 | // Albedo 113 | // Mix animated uv layers 114 | vec4 albedo_tex = mix(texture(texture_albedo, layer1), texture(texture_albedo, layer2), blend_factor); 115 | ALBEDO = albedo.rgb * albedo_tex.rgb; 116 | 117 | // Metallic / Roughness / Specular 118 | // Mix animated uv layers 119 | float metallic_tex = mix(dot(texture(texture_metallic, layer1), metallic_texture_channel), dot(texture(texture_metallic, layer2), metallic_texture_channel), blend_factor); 120 | METALLIC = metallic_tex * metallic; 121 | float roughness_tex = mix(dot(texture(texture_roughness, layer1), roughness_texture_channel), dot(texture(texture_roughness, layer2), roughness_texture_channel), blend_factor); 122 | ROUGHNESS = roughness_tex * roughness; 123 | SPECULAR = specular; 124 | 125 | // Normalmap 126 | // Mix animated uv layers 127 | NORMALMAP = mix(texture(texture_normal, layer1), texture(texture_normal, layer2), blend_factor).rgb; 128 | NORMALMAP_DEPTH = normal_scale * normal_influence; 129 | 130 | // Refraction 131 | vec3 ref_normal = normalize(mix(NORMAL,TANGENT * NORMALMAP.x + BINORMAL * NORMALMAP.y + NORMAL * NORMALMAP.z,NORMALMAP_DEPTH)); 132 | // Mix animated uv layers 133 | vec4 ref_tex = mix(texture(texture_refraction, layer1), texture(texture_refraction, layer2), blend_factor); 134 | vec2 ref_ofs = SCREEN_UV - ref_normal.xy * dot(ref_tex, refraction_texture_channel) * refraction; 135 | float ref_amount = 1.0 - albedo.a * albedo_tex.a; 136 | ALBEDO *= 1.0 - ref_amount; 137 | 138 | // Emission 139 | // Mix animated uv layers 140 | vec3 emission_tex = mix(texture(texture_emission, layer1), texture(texture_emission, layer2), blend_factor).rgb; 141 | EMISSION = (emission.rgb+emission_tex) * emission_energy; 142 | EMISSION += textureLod(SCREEN_TEXTURE, ref_ofs, ROUGHNESS * 8.0).rgb * ref_amount; 143 | 144 | // Proximity fade / Distance fade 145 | float depth_tex = textureLod(DEPTH_TEXTURE,SCREEN_UV, 0.0).r; 146 | vec4 world_pos = INV_PROJECTION_MATRIX * vec4(SCREEN_UV * 2.0 - 1.0, depth_tex * 2.0 - 1.0, 1.0); 147 | world_pos.xyz /= world_pos.w; 148 | ALPHA = 1.0; 149 | ALPHA *= clamp(1.0 - smoothstep(world_pos.z + proximity_fade_distance, world_pos.z, VERTEX.z), 0.0, 1.0); 150 | ALPHA *= clamp(smoothstep(distance_fade_min,distance_fade_max,-VERTEX.z), 0.0, 1.0); 151 | } 152 | -------------------------------------------------------------------------------- /assets/maujoe.flowmap_shader/demo/scripts/camera_control/camera_control_gui.gd: -------------------------------------------------------------------------------- 1 | # Licensed under the MIT License. 2 | # Copyright (c) 2018 Jaccomo Lorenz (Maujoe) 3 | 4 | extends Control 5 | 6 | # Constant Gui Settings 7 | #******************************************************************************* 8 | const GUI_POS = Vector2(10, 10) 9 | const GUI_SIZE = Vector2(200, 0) 10 | const DRAGGABLE = true 11 | 12 | const CUSTOM_BACKGROUND = false 13 | const BACKGROUND_COLOR = Color(0.15, 0.17, 0.23, 0.75) 14 | 15 | const MAX_SPEED = 50 16 | #******************************************************************************* 17 | 18 | var camera 19 | var shortcut 20 | var node_list 21 | var privot 22 | var panel 23 | 24 | var mouse_over = false 25 | var mouse_pressed = false 26 | 27 | func _init(camera, shortcut): 28 | self.camera = camera 29 | self.shortcut = shortcut 30 | 31 | func _ready(): 32 | if camera.enabled: 33 | set_process_input(true) 34 | 35 | # Create Gui 36 | panel = PanelContainer.new() 37 | panel.set_begin(GUI_POS) 38 | panel.set_custom_minimum_size(GUI_SIZE) 39 | 40 | if CUSTOM_BACKGROUND: 41 | var style = StyleBoxFlat.new() 42 | style.set_bg_color(BACKGROUND_COLOR) 43 | style.set_expand_margin_all(5) 44 | panel.add_stylebox_override("panel", style) 45 | 46 | var container = VBoxContainer.new() 47 | 48 | var lbl_mouse = Label.new() 49 | lbl_mouse.set_text("Mousemode") 50 | 51 | var mouse = OptionButton.new() 52 | mouse.add_item("Visible") 53 | mouse.add_item("Hidden") 54 | mouse.add_item("Captured") 55 | mouse.add_item("Confined") 56 | mouse.select(camera.mouse_mode) 57 | mouse.connect("item_selected",self,"_on_opt_mouse_item_selected") 58 | 59 | # Mouselook 60 | var mouselook = CheckButton.new() 61 | mouselook.set_text("Mouselook") 62 | mouselook.set_toggle_mode(true) 63 | mouselook.set_pressed(camera.mouselook) 64 | mouselook.connect("toggled",self,"_on_btn_mouselook_toggled") 65 | 66 | var lbl_sensitivity = Label.new() 67 | lbl_sensitivity.set_text("Sensitivity") 68 | 69 | var sensitivity = HScrollBar.new() 70 | sensitivity.set_max(1) 71 | sensitivity.set_value(camera.sensitivity) 72 | sensitivity.connect("value_changed",self,"_on_hsb_sensitivity_value_changed") 73 | 74 | var lbl_smoothless = Label.new() 75 | lbl_smoothless.set_text("Smoothness") 76 | 77 | var smoothness = HScrollBar.new() 78 | smoothness.set_max(0.999) 79 | smoothness.set_min(0.5) 80 | smoothness.set_value(camera.smoothness) 81 | smoothness.connect("value_changed",self,"_on_hsb_smoothness_value_changed") 82 | 83 | var lbl_privot = Label.new() 84 | lbl_privot.set_text("Privot") 85 | 86 | privot = OptionButton.new() 87 | privot.set_text("Privot") 88 | _update_privots(privot) 89 | privot.connect("item_selected",self,"_on_opt_privot_item_selected") 90 | privot.connect("pressed",self,"_on_opt_privot_pressed") 91 | 92 | var btn_rot_privot = CheckButton.new() 93 | btn_rot_privot.set_text("Rotate Privot") 94 | btn_rot_privot.set_toggle_mode(true) 95 | btn_rot_privot.set_pressed(camera.rotate_privot) 96 | btn_rot_privot.connect("toggled",self,"_on_btn_rot_privot_toggled") 97 | 98 | var lbl_distance = Label.new() 99 | lbl_distance.set_text("Distance") 100 | 101 | var distance = SpinBox.new() 102 | distance.set_value(camera.distance) 103 | distance.connect("value_changed",self,"_on_box_distance_value_changed") 104 | 105 | var lbl_yaw = Label.new() 106 | lbl_yaw.set_text("Yaw Limit") 107 | 108 | var yaw = SpinBox.new() 109 | yaw.set_max(360) 110 | yaw.set_value(camera.yaw_limit) 111 | yaw.connect("value_changed",self,"_on_box_yaw_value_changed") 112 | 113 | var lbl_pitch = Label.new() 114 | lbl_pitch.set_text("Pitch Limit") 115 | 116 | var pitch = SpinBox.new() 117 | pitch.set_max(360) 118 | pitch.set_value(camera.pitch_limit) 119 | pitch.connect("value_changed",self,"_on_box_pitch_value_changed") 120 | 121 | var collisions = CheckButton.new() 122 | collisions.set_text("Collisions") 123 | collisions.set_toggle_mode(true) 124 | collisions.set_pressed(camera.collisions) 125 | collisions.connect("toggled",self,"_on_btn_collisions_toggled") 126 | 127 | # Movement 128 | var lbl_movement = Label.new() 129 | lbl_movement.set_text("Movement") 130 | 131 | var movement = CheckButton.new() 132 | movement.set_pressed(camera.movement) 133 | movement.connect("toggled",self,"_on_btn_movement_toggled") 134 | 135 | var lbl_speed = Label.new() 136 | lbl_speed.set_text("Max Speed") 137 | 138 | var speed = HScrollBar.new() 139 | speed.set_max(MAX_SPEED) 140 | speed.set_value(camera.max_speed.x) 141 | speed.connect("value_changed",self,"_on_hsb_speed_value_changed") 142 | 143 | var lbl_acceleration = Label.new() 144 | lbl_acceleration.set_text("Acceleration") 145 | 146 | var acceleration = HScrollBar.new() 147 | acceleration.set_max(1.0) 148 | acceleration.set_value(camera.acceleration) 149 | acceleration.connect("value_changed", self, "_in_hsb_acceleration_value_changed") 150 | 151 | var lbl_deceleration = Label.new() 152 | lbl_deceleration.set_text("Deceleration") 153 | 154 | var deceleration = HScrollBar.new() 155 | deceleration.set_max(1.0) 156 | deceleration.set_value(camera.deceleration) 157 | deceleration.connect("value_changed", self, "_in_hsb_deceleration_value_changed") 158 | 159 | add_child(panel) 160 | panel.add_child(container) 161 | container.add_child(lbl_mouse) 162 | container.add_child(mouse) 163 | container.add_child(mouselook) 164 | container.add_child(lbl_sensitivity) 165 | container.add_child(sensitivity) 166 | container.add_child(lbl_smoothless) 167 | container.add_child(smoothness) 168 | container.add_child(lbl_privot) 169 | container.add_child(privot) 170 | container.add_child(btn_rot_privot) 171 | container.add_child(lbl_distance) 172 | container.add_child(distance) 173 | container.add_child(lbl_yaw) 174 | container.add_child(yaw) 175 | container.add_child(lbl_pitch) 176 | container.add_child(pitch) 177 | container.add_child(collisions) 178 | container.add_child(lbl_movement) 179 | container.add_child(movement) 180 | container.add_child(lbl_speed) 181 | container.add_child(speed) 182 | container.add_child(lbl_acceleration) 183 | container.add_child(acceleration) 184 | container.add_child(lbl_deceleration) 185 | container.add_child(deceleration) 186 | 187 | if DRAGGABLE: 188 | panel.connect("mouse_entered", self, "_panel_entered") 189 | panel.connect("mouse_exited", self, "_panel_exited") 190 | container.connect("mouse_entered", self, "_panel_entered") 191 | container.connect("mouse_exited", self, "_panel_exited") 192 | 193 | self.hide() 194 | else: 195 | set_process_input(false) 196 | 197 | func _input(event): 198 | if event.is_action_pressed(shortcut): 199 | if camera.enabled: 200 | camera.enabled = false 201 | Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE) 202 | self.show() 203 | else: 204 | camera.enabled = true 205 | self.hide() 206 | 207 | if DRAGGABLE: 208 | if event is InputEventMouseButton and event.button_index == BUTTON_LEFT: 209 | mouse_pressed = event.pressed 210 | 211 | elif event is InputEventMouseMotion and mouse_over and mouse_pressed: 212 | panel.set_begin(panel.get_begin() + event.relative) 213 | 214 | func _update_privots(privot): 215 | privot.clear() 216 | privot.add_item("None") 217 | node_list = _get_spatials_recusiv(get_tree().get_root(), [get_name(), camera.get_name()]) 218 | 219 | var size = node_list.size() 220 | for i in range(0, size): 221 | var node = node_list[i] 222 | privot.add_item(node.get_name()) 223 | if node == camera.privot: 224 | privot.select(i+1) 225 | 226 | if not camera.privot: 227 | privot.select(0) 228 | 229 | 230 | func _get_spatials_recusiv(node, exceptions=[]): 231 | var list = [] 232 | for child in node.get_children(): 233 | if not child.get_name() in exceptions: 234 | if child is Spatial: 235 | list.append(child) 236 | if not child.get_children().empty(): 237 | for subchild in _get_spatials_recusiv(child, exceptions): 238 | list.append(subchild) 239 | return list 240 | 241 | func _panel_entered(): 242 | mouse_over = true 243 | 244 | func _panel_exited(): 245 | mouse_over = false 246 | 247 | func _on_opt_mouse_item_selected(id): 248 | camera.mouse_mode = id 249 | 250 | func _on_btn_mouselook_toggled(pressed): 251 | camera.mouselook = pressed 252 | 253 | func _on_hsb_sensitivity_value_changed(value): 254 | camera.sensitivity = value 255 | 256 | func _on_hsb_smoothness_value_changed(value): 257 | camera.smoothness = value 258 | 259 | func _on_opt_privot_pressed(): 260 | _update_privots(privot) 261 | 262 | func _on_opt_privot_item_selected(id): 263 | if id > 0: 264 | camera.privot = node_list[id-1] 265 | else: 266 | camera.privot = null 267 | privot.select(id) 268 | 269 | func _on_btn_rot_privot_toggled(pressed): 270 | camera.rotate_privot = pressed 271 | 272 | func _on_box_distance_value_changed(value): 273 | camera.distance = value 274 | 275 | func _on_box_yaw_value_changed(value): 276 | camera.yaw_limit = value 277 | 278 | func _on_box_pitch_value_changed(value): 279 | camera.pitch_limit = value 280 | 281 | func _on_btn_collisions_toggled(pressed): 282 | camera.collisions = pressed 283 | 284 | func _on_btn_movement_toggled(pressed): 285 | camera.movement = pressed 286 | 287 | func _on_hsb_speed_value_changed(value): 288 | camera.max_speed.x = value 289 | camera.max_speed.y = value 290 | camera.max_speed.z = value 291 | 292 | func _in_hsb_acceleration_value_changed(value): 293 | camera.acceleration = value 294 | 295 | func _in_hsb_deceleration_value_changed(value): 296 | camera.deceleration = value 297 | --------------------------------------------------------------------------------