-
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
9d20c47
commit 51cc48d
Showing
68 changed files
with
2,877 additions
and
2,795 deletions.
There are no files selected for viewing
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
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
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
83 changes: 83 additions & 0 deletions
83
...coSysLab/Internals/EcoSysLabResources/Shaders/Compute/DynamicStrands/Operators/Pivot.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,83 @@ | ||
#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 | ||
#extension GL_EXT_control_flow_attributes : require | ||
|
||
#define DYNAMIC_STRANDS_SET 0 | ||
#include "DynamicStrands.glsl" | ||
#include "Math.glsl" | ||
|
||
const uint WORKGROUP_SIZE = COMPUTE_SUBGROUP_COUNT * SUBGROUP_SIZE; | ||
|
||
const uint ITERATIONS_PER_TASK = ((COMPUTE_WORK_GROUP_INVOCATIONS + WORKGROUP_SIZE - 1) / WORKGROUP_SIZE); | ||
|
||
uint baseID = gl_WorkGroupID.x * COMPUTE_WORK_GROUP_INVOCATIONS; | ||
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 SegmentUpdate{ | ||
float axis_offset; | ||
float axis_distance; | ||
uint segment_index; | ||
uint particle0_closer; | ||
}; | ||
|
||
layout(std430, set = 1, binding = 0) readonly buffer SEGMENT_UPDATE_BLOCK { | ||
SegmentUpdate segment_updates[]; | ||
}; | ||
|
||
layout(push_constant) uniform PUSH_CONSTANTS { | ||
vec3 pivot_position; | ||
uint command_size; | ||
vec3 axis; | ||
}; | ||
|
||
void main(){ | ||
[[unroll]] | ||
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; | ||
|
||
SegmentUpdate segment_update = segment_updates[global_index]; | ||
uint segment_index = segment_update.segment_index; | ||
Segment segment = segments[segment_index]; | ||
segment.torque = vec3(0, 0, 0); | ||
|
||
vec3 front_direction = normalize(rotate_vec3(segment.q, vec3(0, 0, -1))); | ||
vec3 up_direction = normalize(rotate_vec3(segment.q, vec3(0, 1, 0))); | ||
|
||
float current_segment_length = distance(segment.particle0.x, segment.particle1.x); | ||
vec3 segment_center_position = (segment.particle0.x + segment.particle1.x) * 0.5f; | ||
|
||
vec3 axis_position = pivot_position + segment_update.axis_offset * axis; | ||
vec3 line_projection = dot(segment_center_position - pivot_position, axis) * axis; | ||
vec3 diff = segment_center_position - pivot_position - line_projection; | ||
vec3 direction = length(diff) == 0.0f ? front_direction : normalize(diff); | ||
vec3 desired_segment_center_position = axis_position + segment_update.axis_distance * direction; | ||
|
||
//if(segment_update.particle0_closer == 0){ | ||
// direction = -direction; | ||
//} | ||
|
||
//segment.q = segment.last_q = quatLookAt(direction, up_direction); | ||
vec3 offset = direction * 0.5f * current_segment_length; | ||
|
||
//segment.particle0.x = segment.particle0.last_x = desired_segment_center_position - offset; | ||
//segment.particle0.acceleration.xyz = vec3(0, 0, 0); | ||
|
||
segment.particle1.x = segment.particle1.last_x = desired_segment_center_position - offset; | ||
segment.particle1.acceleration.xyz = vec3(0, 0, 0); | ||
|
||
segments[segment_index] = segment; | ||
} | ||
} |
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
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
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
Oops, something went wrong.