Skip to content

Commit

Permalink
Add water shader (#77)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ughuuu committed Apr 20, 2024
1 parent 7418358 commit 530831c
Show file tree
Hide file tree
Showing 12 changed files with 204 additions and 174 deletions.
Binary file removed Fluid2d.gif
Binary file not shown.
6 changes: 1 addition & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ A 2d [rapier](https://github.com/dimforge/rapier) physics server for [Godot Engi

<p align="center">
<img src="rapier-vid.gif"/>
<img src="fluid_shader.gif"/>
</p>

# Features
Expand All @@ -31,11 +32,6 @@ A 2d [rapier](https://github.com/dimforge/rapier) physics server for [Godot Engi
- *DISABLED* 32 bits and 64 bits support.
- *DISABLED* Cross platform determinism.


<p align="center">
<img src="Fluid2d.gif"/>
</p>

# Limitations

- SeparationRay2D missing [issues/5](https://github.com/appsinacup/godot-rapier-2d/issues/5)
Expand Down
6 changes: 1 addition & 5 deletions bin/samples/godot-rapier2d/Fluid2DRenderer.gd
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,8 @@ func _process(_delta):
for i in points.size():
var point = points[i]
var created_at = create_times[i]
var life_remain = fluid.lifetime - (current_time - created_at) / 1000.0 + 0.5
var new_transform: Transform2D = Transform2D()
if fluid.lifetime == 0:
life_remain = 1
var new_color : Color = Color(color, life_remain)
new_transform.origin = point - position
multimesh.set_instance_transform_2d(index, new_transform)
multimesh.set_instance_color(index, new_color)
multimesh.set_instance_color(index, color)
index += 1
10 changes: 10 additions & 0 deletions bin/samples/godot-rapier2d/Radial2D.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
38 changes: 38 additions & 0 deletions bin/samples/godot-rapier2d/Radial2D.svg.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
[remap]

importer="texture"
type="CompressedTexture2D"
uid="uid://cho3shol3rky2"
path="res://.godot/imported/Radial2D.svg-49bed34ceba3cc8d0afeacd9b5c1c480.ctex"
metadata={
"has_editor_variant": true,
"vram_texture": false
}

[deps]

source_file="res://samples/godot-rapier2d/Radial2D.svg"
dest_files=["res://.godot/imported/Radial2D.svg-49bed34ceba3cc8d0afeacd9b5c1c480.ctex"]

[params]

compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
svg/scale=1.0
editor/scale_with_editor_scale=true
editor/convert_colors_with_editor_theme=false
14 changes: 7 additions & 7 deletions bin/samples/godot-rapier2d/fluid_multi_mesh.tres
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
[gd_resource type="MultiMesh" load_steps=2 format=3 uid="uid://d0bhettx43xt1"]

[sub_resource type="ArrayMesh" id="ArrayMesh_gi4ki"]
[sub_resource type="ArrayMesh" id="ArrayMesh_gnmrl"]
_surfaces = [{
"2d": true,
"aabb": AABB(-16, -16, 0, 32, 32, 0),
"attribute_data": PackedByteArray(0, 0, 128, 63, 154, 153, 129, 62, 0, 0, 128, 63, 0, 0, 112, 63, 102, 102, 118, 63, 0, 0, 112, 63, 205, 204, 76, 63, 0, 0, 128, 63, 0, 0, 0, 0, 0, 0, 128, 63, 0, 0, 0, 0, 0, 0, 168, 62, 0, 0, 0, 61, 102, 102, 166, 61, 0, 0, 0, 61, 0, 0, 0, 0, 51, 51, 59, 63, 0, 0, 0, 0),
"attribute_data": PackedByteArray(0, 0, 128, 63, 102, 102, 6, 62, 0, 0, 128, 63, 51, 51, 95, 63, 51, 51, 67, 63, 0, 0, 128, 63, 0, 0, 0, 0, 0, 0, 128, 63, 0, 0, 0, 0, 154, 153, 105, 62, 0, 0, 0, 61, 154, 153, 25, 60, 51, 51, 87, 63, 0, 0, 0, 0),
"format": 34393296913,
"index_count": 21,
"index_data": PackedByteArray(8, 0, 0, 0, 1, 0, 2, 0, 3, 0, 4, 0, 4, 0, 5, 0, 6, 0, 6, 0, 7, 0, 8, 0, 8, 0, 1, 0, 2, 0, 2, 0, 4, 0, 6, 0, 6, 0, 8, 0, 2, 0),
"index_count": 15,
"index_data": PackedByteArray(6, 0, 0, 0, 1, 0, 1, 0, 2, 0, 3, 0, 3, 0, 4, 0, 5, 0, 5, 0, 6, 0, 1, 0, 1, 0, 3, 0, 5, 0),
"primitive": 3,
"uv_scale": Vector4(0, 0, 0, 0),
"vertex_count": 9,
"vertex_data": PackedByteArray(0, 0, 128, 65, 204, 204, 252, 192, 0, 0, 128, 65, 0, 0, 96, 65, 204, 204, 108, 65, 0, 0, 96, 65, 154, 153, 25, 65, 0, 0, 128, 65, 0, 0, 128, 193, 0, 0, 128, 65, 0, 0, 128, 193, 0, 0, 176, 192, 0, 0, 112, 193, 102, 102, 86, 193, 0, 0, 112, 193, 0, 0, 128, 193, 204, 204, 236, 64, 0, 0, 128, 193)
"vertex_count": 7,
"vertex_data": PackedByteArray(0, 0, 128, 65, 205, 204, 60, 193, 0, 0, 128, 65, 102, 102, 62, 65, 102, 102, 6, 65, 0, 0, 128, 65, 0, 0, 128, 193, 0, 0, 128, 65, 0, 0, 128, 193, 51, 51, 11, 193, 0, 0, 112, 193, 51, 51, 123, 193, 102, 102, 46, 65, 0, 0, 128, 193)
}]

[resource]
use_colors = true
mesh = SubResource("ArrayMesh_gi4ki")
mesh = SubResource("ArrayMesh_gnmrl")
Loading

0 comments on commit 530831c

Please sign in to comment.