-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Thickness & depth target for screen space fluid rendering
still work in progress. Unclear how depth target should be handled exactly (what kind of depth, how to clear, etc.)
- Loading branch information
Showing
8 changed files
with
237 additions
and
61 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#version 460 | ||
|
||
#include "../fluid_render_info.glsl" | ||
#include "../per_frame_resources.glsl" | ||
#include "../utilities.glsl" | ||
|
||
layout(set = 2, binding = 0) uniform texture2D ParticleDepth; | ||
layout(set = 2, binding = 1) uniform texture2D ParticleThickness; | ||
layout(set = 2, binding = 2, HDR_BACKBUFFER_IMAGE_FORMAT) uniform restrict image2D Backbuffer; | ||
|
||
layout(local_size_x = 32, local_size_y = 32, local_size_z = 1) in; | ||
|
||
void main() { | ||
float particleDepth = texelFetch(ParticleDepth, ivec2(gl_GlobalInvocationID.xy), 0).r; | ||
float particleThickness = texelFetch(ParticleThickness, ivec2(gl_GlobalInvocationID.xy), 0).r; | ||
vec4 previousColor = imageLoad(Backbuffer, ivec2(gl_GlobalInvocationID.xy)); | ||
|
||
vec4 outputColor = vec4(particleThickness * 0.01); | ||
imageStore(Backbuffer, ivec2(gl_GlobalInvocationID.xy), outputColor); | ||
} |
This file was deleted.
Oops, something went wrong.
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,33 @@ | ||
#version 460 | ||
|
||
#include "../per_frame_resources.glsl" | ||
#include "../utilities.glsl" | ||
|
||
layout(location = 0) in vec3 in_WorldPosition; | ||
layout(location = 1) in vec3 in_ParticleWorldPosition; | ||
layout(location = 2) in float in_Radius; | ||
layout(location = 0) out float out_Depth; | ||
layout(location = 1) out float out_Thickness; | ||
|
||
// Note that we promise to only lessen the depth value, so gpu can still do some hi-z/early depth culling | ||
layout(depth_less) out float gl_FragDepth; | ||
|
||
void main() { | ||
vec3 rayDir = normalize(in_WorldPosition - Camera.Position); | ||
float cameraDistance; | ||
// TODO: Elipsoids using APIC matrix? | ||
if (!sphereIntersect(in_ParticleWorldPosition, in_Radius, Camera.Position, rayDir, cameraDistance)) | ||
discard; | ||
|
||
vec3 sphereWorldPos = Camera.Position + cameraDistance * rayDir; | ||
vec3 normal = (sphereWorldPos - in_ParticleWorldPosition) / in_Radius; | ||
|
||
// Adjust depth buffer value. | ||
// TODO: Necessary for this step? | ||
vec2 projected_zw = (Camera.ViewProjection * vec4(sphereWorldPos, 1.0)).zw; // (trusting optimizer to pick the right thing ;-)) | ||
gl_FragDepth = projected_zw.x / projected_zw.y; | ||
|
||
// TODO: What kind of depth | ||
out_Depth = cameraDistance; | ||
out_Thickness = in_Radius; | ||
} |
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 @@ | ||
#version 450 | ||
|
||
#include "fluid_render_info.glsl" | ||
#include "per_frame_resources.glsl" | ||
#include "sphere_particles.glsl" | ||
#include "utilities.glsl" | ||
|
||
out gl_PerVertex { vec4 gl_Position; }; | ||
|
||
layout(location = 0) out vec3 out_WorldPosition; | ||
layout(location = 1) out vec3 out_ParticleWorldPosition; | ||
layout(location = 2) out float out_Radius; | ||
|
||
void main() { | ||
out_Radius = 0.25 * Rendering.FluidGridToWorldScale; | ||
out_ParticleWorldPosition = Particles[gl_InstanceIndex].Position * Rendering.FluidGridToWorldScale + Rendering.FluidWorldOrigin; | ||
out_WorldPosition = spanParticle(out_ParticleWorldPosition, out_Radius); | ||
gl_Position = Camera.ViewProjection * vec4(out_WorldPosition, 1.0); | ||
} |
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.