Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
VkCV Framework
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Vulkan2021
VkCV Framework
Commits
40f5932d
Verified
Commit
40f5932d
authored
3 years ago
by
Josch Morgenstern
Browse files
Options
Downloads
Patches
Plain Diff
[
#111
] add params in push constant to updateData shader
parent
426782d5
No related branches found
No related tags found
1 merge request
!95
Resolve "Wassersimulation mit Interaktion"
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
projects/sph/shaders/updateData.comp
+38
-18
38 additions, 18 deletions
projects/sph/shaders/updateData.comp
with
38 additions
and
18 deletions
projects/sph/shaders/updateData.comp
+
38
−
18
View file @
40f5932d
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
#extension GL_ARB_separate_shader_objects : enable
#extension GL_ARB_separate_shader_objects : enable
#extension GL_GOOGLE_include_directive : enable
#extension GL_GOOGLE_include_directive : enable
#include "particle_params.inc"
layout(local_size_x = 256) in;
layout(local_size_x = 256) in;
struct Particle
struct Particle
...
@@ -28,11 +26,20 @@ layout(std430, binding = 1) writeonly buffer buffer_outParticle
...
@@ -28,11 +26,20 @@ layout(std430, binding = 1) writeonly buffer buffer_outParticle
};
};
layout( push_constant ) uniform constants{
layout( push_constant ) uniform constants{
float deltaTime;
float h;
float mass;
float gasConstant;
float offset;
float gravity;
float viscosity;
float ABSORBTION;
float dt;
vec3 gravityDir;
float particleCount;
float particleCount;
};
};
void main() {
void main() {
uint id = gl_GlobalInvocationID.x;
uint id = gl_GlobalInvocationID.x;
if(id >= int(particleCount))
if(id >= int(particleCount))
...
@@ -42,48 +49,61 @@ void main() {
...
@@ -42,48 +49,61 @@ void main() {
vec3 accel = inParticle[id].force / inParticle[id].density;
vec3 accel = inParticle[id].force / inParticle[id].density;
vec3 vel_new = inParticle[id].velocity + (dt * accel);
vec3 vel_new = inParticle[id].velocity + (dt * accel);
vec3 out_force = inParticle[id].force;
float out_density = inParticle[id].density;
float out_pressure = inParticle[id].pressure;
if (length(vel_new) > 100.f)
{
vel_new = normalize(vel_new)*50;
out_density = 0.01f;
out_pressure = 0.01f;
out_force = gravity * vec3(-gravityDir.x,gravityDir.y,gravityDir.z);
}
vec3 pos_new = inParticle[id].position + (dt * vel_new);
vec3 pos_new = inParticle[id].position + (dt * vel_new);
// Überprüfe Randbedingungen x
// Überprüfe Randbedingungen x
if (inParticle[id].position.x < -1.0)
if (inParticle[id].position.x < -1.0)
{
{
vel_new
.x *= -
ABSORBTION;
vel_new
= reflect(vel_new.xyz, vec3(1.f,0.f,0.f)) *
ABSORBTION;
pos_new.x = -1.0;
pos_new.x = -1.0
+ 0.01f
;
}
}
else if (inParticle[id].position.x > 1.0)
else if (inParticle[id].position.x > 1.0)
{
{
vel_new
.x *= -
ABSORBTION;
vel_new
= reflect(vel_new,vec3(1.f,0.f,0.f)) *
ABSORBTION;
pos_new.x = 1.0;
pos_new.x = 1.0
- 0.01f
;
}
}
// Überprüfe Randbedingungen y
// Überprüfe Randbedingungen y
if (inParticle[id].position.y < -1.0)
if (inParticle[id].position.y < -1.0)
{
{
vel_new
.y *= -
ABSORBTION;
vel_new
= reflect(vel_new,vec3(0.f,1.f,0.f)) *
ABSORBTION;
pos_new.y = -1.0;
pos_new.y = -1.0
+ 0.01f
;
}
}
else if (inParticle[id].position.y > 1.0)
else if (inParticle[id].position.y > 1.0)
{
{
vel_new
.y *= -
ABSORBTION;
vel_new
= reflect(vel_new,vec3(0.f,1.f,0.f)) *
ABSORBTION;
pos_new.y = 1.0;
pos_new.y = 1.0
- 0.01f
;
}
}
// Überprüfe Randbedingungen z
// Überprüfe Randbedingungen z
if (inParticle[id].position.z < -1.0 )
if (inParticle[id].position.z < -1.0 )
{
{
vel_new
.z *= -
ABSORBTION;
vel_new
= reflect(vel_new,vec3(0.f,0.f,1.f)) *
ABSORBTION;
pos_new.z = -1.0;
pos_new.z = -1.0
+ 0.01f
;
}
}
else if (inParticle[id].position.z > 1.0 )
else if (inParticle[id].position.z > 1.0 )
{
{
vel_new
.z *= -
ABSORBTION;
vel_new
= reflect(vel_new,vec3(0.f,0.f,1.f)) *
ABSORBTION;
pos_new.z = 1.0;
pos_new.z = 1.0
- 0.01f
;
}
}
outParticle[id].force =
inParticle[id].
force;
outParticle[id].force =
out_
force;
outParticle[id].density =
inParticle[id].
density;
outParticle[id].density =
out_
density;
outParticle[id].pressure =
inParticle[id].
pressure;
outParticle[id].pressure =
out_
pressure;
outParticle[id].position = pos_new;
outParticle[id].position = pos_new;
outParticle[id].velocity = vel_new;
outParticle[id].velocity = vel_new;
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment