-
Notifications
You must be signed in to change notification settings - Fork 55
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
Showing
19 changed files
with
1,351 additions
and
0 deletions.
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
src/run/domain_layer/domain/shader/accumulation/accumulation.frag
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,41 @@ | ||
#version 450 | ||
#pragma shader_stage(fragment) | ||
|
||
#include "../common/utils.glsl" | ||
|
||
layout(location = 0) in vec2 uv; | ||
layout(location = 0) out vec4 outColor; | ||
|
||
layout(std140, set = 0, binding = 0) buffer PixelBuffer { vec4 pixels[]; } | ||
pixelBuffer; | ||
|
||
layout(std140, set = 0, binding = 1) buffer AccumulationPixelBuffer { | ||
vec4 pixels[]; | ||
} | ||
accumulationPixelBuffer; | ||
|
||
layout(set = 0, binding = 2) uniform ScreenDimension { vec2 resolution; } | ||
screenDimension; | ||
|
||
layout(std140, set = 0, binding = 3) uniform CommonData { | ||
uint sampleCount; | ||
uint totalSampleCount; | ||
uint pad_0; | ||
uint pad_1; | ||
} | ||
pushC; | ||
|
||
void main() { | ||
uint pixelIndex = getPixelIndex(uv, screenDimension.resolution); | ||
|
||
vec4 accumulationColor = accumulationPixelBuffer.pixels[pixelIndex] + | ||
pixelBuffer.pixels[pixelIndex]; | ||
|
||
accumulationPixelBuffer.pixels[pixelIndex] = accumulationColor; | ||
|
||
vec4 finalColor = accumulationColor / pushC.totalSampleCount; | ||
|
||
finalColor = vec4(gammaCorrection(vec3(finalColor)), finalColor.w); | ||
|
||
outColor = finalColor; | ||
} |
10 changes: 10 additions & 0 deletions
10
src/run/domain_layer/domain/shader/accumulation/accumulation.vert
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,10 @@ | ||
#version 450 | ||
#pragma shader_stage(vertex) | ||
|
||
layout(location = 0) out vec2 uv; | ||
|
||
void main() { | ||
uv = vec2((gl_VertexIndex << 1) & 2, gl_VertexIndex & 2); | ||
gl_Position = vec4(uv * 2.0 - 1.0, 0.0, 1.0); | ||
// uv = vec2(uv.x, 1.0 - uv.y); | ||
} |
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,9 @@ | ||
layout(std140, set = 1, binding = 0) uniform Camera { | ||
mat4 viewInverse; | ||
mat4 projectionInverse; | ||
float near; | ||
float far; | ||
float pad_0; | ||
float pad_1; | ||
} | ||
uCamera; |
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,40 @@ | ||
|
||
// float saturateFloat(float v) { | ||
// if (v < 0.0) { | ||
// return 0.0; | ||
// } | ||
|
||
// if (v > 1.0) { | ||
// return 1.0; | ||
// } | ||
|
||
// return v; | ||
// } | ||
|
||
// vec2 saturateVec2(vec2 v) { | ||
// return vec2(saturateFloat(v.x), saturateFloat(v.y)); | ||
// } | ||
|
||
float max(float f1, float f2, float f3) { return max(max(f1, f2), f3); } | ||
|
||
uint getPixelIndex(vec2 uv, vec2 resolution) { | ||
const ivec2 bufferCoord = ivec2(floor(uv * resolution)); | ||
|
||
return bufferCoord.y * uint(resolution.x) + bufferCoord.x; | ||
} | ||
|
||
vec2 gammaCorrection(vec2 colorInLinearSpace) { | ||
return pow(colorInLinearSpace, vec2(1.0 / 2.2)); | ||
} | ||
|
||
vec3 gammaCorrection(vec3 colorInLinearSpace) { | ||
return pow(colorInLinearSpace, vec3(1.0 / 2.2)); | ||
} | ||
|
||
vec3 convertSRGBToLinear(vec3 specificColorDefinedInShader) { | ||
return pow(specificColorDefinedInShader, vec3(2.2)); | ||
} | ||
|
||
vec3 getVFromRayDirection(vec3 rayDirection) { return -rayDirection; } | ||
|
||
vec3 getRayDirectionFromV(vec3 V) { return -V; } |
Oops, something went wrong.