Skip to content

Commit

Permalink
Removed redundant code and shaders
Browse files Browse the repository at this point in the history
  • Loading branch information
Unbansheee committed Sep 25, 2024
1 parent b528dc8 commit d34a0ed
Show file tree
Hide file tree
Showing 25 changed files with 54 additions and 1,399 deletions.
22 changes: 11 additions & 11 deletions scenes/main.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
[ext_resource type="PackedScene" uid="uid://ddivo6ilohsb7" path="res://scenes/fps_counter.tscn" id="6_8id5a"]
[ext_resource type="Texture2D" uid="uid://bwtjo0qfnutyb" path="res://assets/simulation_data/initial_spectrumm_texture.tres" id="6_x4joo"]
[ext_resource type="Script" path="res://src/compute_steps/ComputeStep_ButterflyTexture.gd" id="7_ovy1l"]
[ext_resource type="Script" path="res://src/shaders/spectrum_compute_parameters.gd" id="7_t2u25"]
[ext_resource type="Script" path="res://src/compute_steps/parameters/SpectrumComputeParameters.gd" id="7_t2u25"]
[ext_resource type="Script" path="res://src/compute_steps/ComputeStep_FourierComponents.gd" id="8_qiald"]
[ext_resource type="Script" path="res://src/shaders/FourierComponentsParameters.gd" id="8_x671a"]
[ext_resource type="Script" path="res://src/compute_steps/parameters/FourierComponentsParameters.gd" id="8_x671a"]
[ext_resource type="Script" path="res://src/compute_steps/ComputeStep_ButterflyCompute.gd" id="11_0jn0k"]
[ext_resource type="Script" path="res://src/compute_steps/ComputeStep_InversionPermutation.gd" id="12_osvdc"]
[ext_resource type="Script" path="res://src/compute_steps/ComputeStep_CreateGradients.gd" id="13_uw1g5"]
Expand Down Expand Up @@ -211,18 +211,18 @@ light_color = Color(1, 0.788235, 0.788235, 1)
light_volumetric_fog_energy = 1.222
shadow_enabled = true

[node name="FFTOceanManager" type="Node" parent="." node_paths=PackedStringArray("GenerateSpectrum", "FourierComponents", "ButterflyComputeHoriz", "InversionPermutation", "CreateGradients", "ButterflyTexture")]
[node name="FFTOceanManager" type="Node" parent="." node_paths=PackedStringArray("GenerateSpectrum", "FourierComponents", "ButterflyFFTCompute", "InversionPermutation", "CreateGradients", "ButterflyTexture")]
script = ExtResource("3_n8jvm")
N = 512
L = 2200
A = 16
Wind = Vector2(60, 20)
GenerateSpectrum = NodePath("ComputeStep_GenerateSpectrum")
FourierComponents = NodePath("ComputeStep_FourierComponents")
ButterflyComputeHoriz = NodePath("ComputeFFT")
InversionPermutation = NodePath("ComputeStepInversionPermutation")
CreateGradients = NodePath("ComputeStepCreateGradients")
ButterflyTexture = NodePath("ComputeStepButterflyTexture")
ButterflyFFTCompute = NodePath("ComputeStep_ButterflyFFT")
InversionPermutation = NodePath("ComputeStep_InversionPermutation")
CreateGradients = NodePath("ComputeStep_CreateGradients")
ButterflyTexture = NodePath("ComputeStep_GenerateButterflyTexture")
displacement_output = SubResource("Texture2DRD_xbnnm")
spectrum_initial_output = SubResource("Texture2DRD_y2tg1")
butterfly_tex_output = SubResource("Texture2DRD_bkk2m")
Expand All @@ -238,7 +238,7 @@ params = SubResource("Resource_6hrmd")
shader_input = "res://src/shaders/generate_spectrum_compute.glsl"
group_size = Vector2i(16, 16)

[node name="ComputeStepButterflyTexture" type="Node" parent="FFTOceanManager"]
[node name="ComputeStep_GenerateButterflyTexture" type="Node" parent="FFTOceanManager"]
script = ExtResource("7_ovy1l")
N = 16
shader_input = "res://src/shaders/butterfly_texture_compute.glsl"
Expand All @@ -249,18 +249,18 @@ params = SubResource("Resource_247d2")
shader_input = "res://src/shaders/fourier_components_compute.glsl"
group_size = Vector2i(16, 16)

[node name="ComputeFFT" type="Node" parent="FFTOceanManager"]
[node name="ComputeStep_ButterflyFFT" type="Node" parent="FFTOceanManager"]
script = ExtResource("11_0jn0k")
shader_input = "res://src/shaders/butterfly_compute.glsl"
group_size = Vector2i(16, 16)

[node name="ComputeStepInversionPermutation" type="Node" parent="FFTOceanManager"]
[node name="ComputeStep_InversionPermutation" type="Node" parent="FFTOceanManager"]
script = ExtResource("12_osvdc")
N = 256
shader_input = "res://src/shaders/inversion_permutation_compute.glsl"
group_size = Vector2i(16, 16)

[node name="ComputeStepCreateGradients" type="Node" parent="FFTOceanManager"]
[node name="ComputeStep_CreateGradients" type="Node" parent="FFTOceanManager"]
script = ExtResource("13_uw1g5")
shader_input = "res://src/shaders/create_gradients.glsl"

Expand Down
48 changes: 22 additions & 26 deletions src/FFTOceanManager.gd
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ extends Node

@export var GenerateSpectrum: ComputeStepGenerateSpectrum
@export var FourierComponents: ComputeStepFourierComponents
@export var ButterflyComputeHoriz: ComputeStepButterflyCompute
@export var ButterflyFFTCompute: ComputeStepButterflyCompute
@export var InversionPermutation: ComputeStepInversionPermutation
@export var CreateGradients: ComputeStepCreateGradients

Expand Down Expand Up @@ -53,22 +53,18 @@ func _ready():
FourierComponents.params.N = N
FourierComponents.setup()

#var ButterFlyTextureCS = ButterflyTexture as ButterflyGeneratorSharp
#ButterFlyTextureCS.N = N
#ButterFlyTextureCS.Setup()
#ButterFlyTextureCS.Execute()
ButterflyTexture.N = N
ButterflyTexture.setup()
ButterflyTexture.execute_compute()

ButterflyComputeHoriz.N = N
pingpong_texture = ButterflyComputeHoriz.create_sim_texture(RenderingDevice.DATA_FORMAT_R32G32B32A32_SFLOAT, N, N)
pingpong_texture_b = ButterflyComputeHoriz.create_sim_texture(RenderingDevice.DATA_FORMAT_R32G32B32A32_SFLOAT, N, N)
ButterflyFFTCompute.N = N
pingpong_texture = ButterflyFFTCompute.create_sim_texture(RenderingDevice.DATA_FORMAT_R32G32B32A32_SFLOAT, N, N)
pingpong_texture_b = ButterflyFFTCompute.create_sim_texture(RenderingDevice.DATA_FORMAT_R32G32B32A32_SFLOAT, N, N)

ButterflyComputeHoriz.pingpong0 = FourierComponents.hktdyTex
ButterflyComputeHoriz.pingpong1 = pingpong_texture
ButterflyComputeHoriz.butterflyTexture = ButterflyTexture.butterflyTex
ButterflyComputeHoriz.setup()
ButterflyFFTCompute.pingpong0 = FourierComponents.hktdyTex
ButterflyFFTCompute.pingpong1 = pingpong_texture
ButterflyFFTCompute.butterflyTexture = ButterflyTexture.butterflyTex
ButterflyFFTCompute.setup()

InversionPermutation.N = N
InversionPermutation.height = FourierComponents.hktdyTex
Expand Down Expand Up @@ -106,24 +102,24 @@ func compute():
var height: RID
var choppy: RID

if (ButterflyComputeHoriz.is_ready):
ButterflyComputeHoriz.butterflyTexture = ButterflyTexture.butterflyTex
ButterflyComputeHoriz.pingpongval = 0
ButterflyComputeHoriz.pingpong0 = FourierComponents.hktdyTex
ButterflyComputeHoriz.pingpong1 = pingpong_texture
ButterflyComputeHoriz.execute_compute()
height = ButterflyComputeHoriz.get_output_texture()
if (ButterflyFFTCompute.is_ready):
ButterflyFFTCompute.butterflyTexture = ButterflyTexture.butterflyTex
ButterflyFFTCompute.pingpongval = 0
ButterflyFFTCompute.pingpong0 = FourierComponents.hktdyTex
ButterflyFFTCompute.pingpong1 = pingpong_texture
ButterflyFFTCompute.execute_compute()
height = ButterflyFFTCompute.get_output_texture()

if (ButterflyComputeHoriz.is_ready):
ButterflyComputeHoriz.pingpongval = 0
ButterflyComputeHoriz.pingpong0 = FourierComponents.hktDTex
ButterflyComputeHoriz.pingpong1 = pingpong_texture_b
ButterflyComputeHoriz.execute_compute()
choppy = ButterflyComputeHoriz.get_output_texture()
if (ButterflyFFTCompute.is_ready):
ButterflyFFTCompute.pingpongval = 0
ButterflyFFTCompute.pingpong0 = FourierComponents.hktDTex
ButterflyFFTCompute.pingpong1 = pingpong_texture_b
ButterflyFFTCompute.execute_compute()
choppy = ButterflyFFTCompute.get_output_texture()


if (InversionPermutation.is_ready):
InversionPermutation.pingPong = ButterflyComputeHoriz.pingpongval
InversionPermutation.pingPong = ButterflyFFTCompute.pingpongval
InversionPermutation.height = height
InversionPermutation.choppy = choppy
InversionPermutation.execute_compute()
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
14 changes: 0 additions & 14 deletions src/shaders/compute_test.glsl.import

This file was deleted.

17 changes: 0 additions & 17 deletions src/shaders/compute_vis.gdshader

This file was deleted.

4 changes: 2 additions & 2 deletions src/shaders/create_gradients.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ void main() {
float INV_TILE_SIZE = pc.N / pc.L;
float TILE_SIZE_X2 = (pc.L * 2.0) / pc.N;

// Jacobian
// Jacobian?
vec2 dDx = (disp_right.xz - disp_left.xz) * INV_TILE_SIZE;
vec2 dDy = (disp_top.xz - disp_bottom.xz) * INV_TILE_SIZE;

float J = (1.0 + dDx.x) * (1.0 + dDy.y) - dDx.y * dDy.x;


// NOTE: normals are in tangent space for now
// NOTE: normals are in tangent space for now and are kinda broken
imageStore(gradients, loc, vec4(gradient, 8, J));

}
143 changes: 0 additions & 143 deletions src/shaders/fft_horizontal.glsl

This file was deleted.

14 changes: 0 additions & 14 deletions src/shaders/fft_horizontal.glsl.import

This file was deleted.

Loading

0 comments on commit d34a0ed

Please sign in to comment.