-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3cedf1a
commit ae2e680
Showing
12 changed files
with
703 additions
and
117 deletions.
There are no files selected for viewing
60 changes: 60 additions & 0 deletions
60
...s/EcoSysLab/Internals/EcoSysLabResources/Shaders/Compute/DynamicStrandsExternalForce.comp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#extension GL_EXT_shader_explicit_arithmetic_types_int8 : require | ||
#extension GL_KHR_shader_subgroup_basic : require | ||
#extension GL_KHR_shader_subgroup_ballot : require | ||
#extension GL_KHR_shader_subgroup_vote : require | ||
#extension GL_ARB_shading_language_include : enable | ||
|
||
#define DYNAMIC_STRANDS_SET 0 | ||
#include "DynamicStrands.glsl" | ||
|
||
#define DYNAMIC_STRANDS_PHYSICS_SET 1 | ||
#include "DynamicStrandsPhysics.glsl" | ||
|
||
const uint WORKGROUP_SIZE = EXT_TASK_SUBGROUP_COUNT * EXT_TASK_SUBGROUP_SIZE; | ||
|
||
const uint ITERATIONS_PER_TASK = ((EXT_INVOCATIONS_PER_TASK + WORKGROUP_SIZE - 1) / WORKGROUP_SIZE); | ||
|
||
uint baseID = gl_WorkGroupID.x * EXT_INVOCATIONS_PER_TASK; | ||
uint laneID = gl_LocalInvocationID.x; | ||
|
||
layout(local_size_x = WORKGROUP_SIZE, local_size_y = 1, local_size_z = 1) in; | ||
|
||
#define BARRIER() \ | ||
memoryBarrierShared(); \ | ||
barrier(); | ||
|
||
struct ExternalForce{ | ||
vec4 index_force; | ||
}; | ||
|
||
layout(std430, set = 2, binding = 0) readonly buffer EXTERNAL_FORCE_BLOCK { | ||
ExternalForce external_forces[]; | ||
}; | ||
|
||
layout(push_constant) uniform PUSH_CONSTANTS { | ||
uint command_size; | ||
float delta_time; | ||
}; | ||
|
||
void main(){ | ||
for (uint i = 0; i < ITERATIONS_PER_TASK; i++) | ||
{ | ||
uint local_index = laneID + i * WORKGROUP_SIZE; | ||
uint global_index = baseID + local_index; | ||
|
||
if(global_index >= command_size) break; | ||
|
||
//strand_segments[global_index].end_position_thickness.y = 0.0; | ||
ExternalForce external_force = external_forces[global_index]; | ||
uint strand_particle_index = floatBitsToUint(external_force.index_force.x); | ||
vec3 force = external_force.index_force.yzw; | ||
|
||
StrandSegmentParticlePhysics particle_physics = strand_segment_particle_physics_list[strand_particle_index]; | ||
float inv_mass = particle_physics.last_position_inv_mass.w; | ||
vec3 acceleration = force * inv_mass; | ||
vec4 position_thickness = strand_segment_particles[strand_particle_index].position_thickness; | ||
|
||
vec3 velocity = (position_thickness.xyz - particle_physics.last_position_inv_mass.xyz) + acceleration * delta_time * .5; | ||
position_thickness.xyz = position_thickness.xyz + velocity * delta_time; | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
.../EcoSysLab/Internals/EcoSysLabResources/Shaders/Compute/DynamicStrandsPositionUpdate.comp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#extension GL_EXT_shader_explicit_arithmetic_types_int8 : require | ||
#extension GL_KHR_shader_subgroup_basic : require | ||
#extension GL_KHR_shader_subgroup_ballot : require | ||
#extension GL_KHR_shader_subgroup_vote : require | ||
#extension GL_ARB_shading_language_include : enable | ||
|
||
#define DYNAMIC_STRANDS_SET 0 | ||
#include "DynamicStrands.glsl" | ||
|
||
#define DYNAMIC_STRANDS_PHYSICS_SET 1 | ||
#include "DynamicStrandsPhysics.glsl" | ||
|
||
const uint WORKGROUP_SIZE = EXT_TASK_SUBGROUP_COUNT * EXT_TASK_SUBGROUP_SIZE; | ||
|
||
const uint ITERATIONS_PER_TASK = ((EXT_INVOCATIONS_PER_TASK + WORKGROUP_SIZE - 1) / WORKGROUP_SIZE); | ||
|
||
uint baseID = gl_WorkGroupID.x * EXT_INVOCATIONS_PER_TASK; | ||
uint laneID = gl_LocalInvocationID.x; | ||
|
||
layout(local_size_x = WORKGROUP_SIZE, local_size_y = 1, local_size_z = 1) in; | ||
|
||
#define BARRIER() \ | ||
memoryBarrierShared(); \ | ||
barrier(); | ||
|
||
struct PositionUpdate{ | ||
vec4 index_new_position; | ||
}; | ||
|
||
layout(std430, set = 2, binding = 0) readonly buffer POSITION_UPDATE_BLOCK { | ||
PositionUpdate position_updates[]; | ||
}; | ||
|
||
layout(push_constant) uniform PUSH_CONSTANTS { | ||
uint command_size; | ||
}; | ||
|
||
void main(){ | ||
for (uint i = 0; i < ITERATIONS_PER_TASK; i++) | ||
{ | ||
uint local_index = laneID + i * WORKGROUP_SIZE; | ||
uint global_index = baseID + local_index; | ||
|
||
if(global_index >= command_size) break; | ||
|
||
PositionUpdate position_update = position_updates[global_index]; | ||
uint strand_particle_index = floatBitsToUint(position_update.index_new_position.x); | ||
vec3 new_position = position_update.index_new_position.yzw; | ||
|
||
strand_segment_particles[strand_particle_index].position_thickness.xyz = new_position; | ||
strand_segment_particle_physics_list[strand_particle_index].last_position_inv_mass.xyz = new_position; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
...lugins/EcoSysLab/Internals/EcoSysLabResources/Shaders/Includes/DynamicStrandsPhysics.glsl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
|
||
struct StrandSegmentPhysics { | ||
vec4 last_rotation; | ||
vec4 angular_velocity_radius; | ||
vec4 inv_inertia_length; | ||
}; | ||
|
||
struct StrandSegmentParticlePhysics { | ||
vec4 last_position_inv_mass; | ||
vec4 delta_position_n_updates; | ||
}; | ||
|
||
layout(std430, set = DYNAMIC_STRANDS_PHYSICS_SET, binding = 0) buffer STRAND_SEGMENTS_PHYSICS_BLOCK { | ||
StrandSegmentPhysics strand_segment_physics_list[]; | ||
}; | ||
|
||
layout(std430, set = DYNAMIC_STRANDS_PHYSICS_SET, binding = 1) buffer STRANDS_PHYSICS_BLOCK { | ||
StrandSegmentParticlePhysics strand_segment_particle_physics_list[]; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.