History

using the linear depth buffer and voila

Sam Gateau committed 9 years ago

Commit bf982c31 parent 914db1d6 files · +22 −9Browse files

Unified · Split

6 files
  1. libraries/render-utils/src/AntialiasingEffect.cpp +5 −3
  2. libraries/render-utils/src/AntialiasingEffect.h +1 −1
  3. libraries/render-utils/src/RenderDeferredTask.cpp +1 −1
  4. libraries/render-utils/src/taa.slf +7 −1
  5. libraries/render-utils/src/taa.slh +3 −3
  6. libraries/render-utils/src/taa_blend.slf +5 −0
libraries/render-utils/src/AntialiasingEffect.cpp+5−3
@@ -182,9 +182,10 @@ const int AntialiasingPass_FrameTransformSlot = 1; · 181 unmodified lines
182const int AntialiasingPass_HistoryMapSlot = 0;182const int AntialiasingPass_HistoryMapSlot = 0;
183const int AntialiasingPass_SourceMapSlot = 1;183const int AntialiasingPass_SourceMapSlot = 1;
184const int AntialiasingPass_VelocityMapSlot = 2;184const int AntialiasingPass_VelocityMapSlot = 2;
185const int AntialiasingPass_NextMapSlot = 3;
186const int AntialiasingPass_DepthMapSlot = 3;185const int AntialiasingPass_DepthMapSlot = 3;
187 186
187const int AntialiasingPass_NextMapSlot = 4;
188
188 189
189Antialiasing::Antialiasing() {190Antialiasing::Antialiasing() {
190}191}
@@ -298,7 +299,8 @@ void Antialiasing::run(const render::RenderContextPointer& renderContext, const · 107 unmodified lines
298 299
299 auto& deferredFrameTransform = inputs.get0();300 auto& deferredFrameTransform = inputs.get0();
300 auto& sourceBuffer = inputs.get1();301 auto& sourceBuffer = inputs.get1();
301 auto& velocityBuffer = inputs.get2();302 auto& linearDepthBuffer = inputs.get2();
303 auto& velocityBuffer = inputs.get3();
302 304
303 int width = sourceBuffer->getWidth();305 int width = sourceBuffer->getWidth();
304 int height = sourceBuffer->getHeight();306 int height = sourceBuffer->getHeight();
@@ -334,7 +336,7 @@ void Antialiasing::run(const render::RenderContextPointer& renderContext, const · 29 unmodified lines
334 batch.setResourceTexture(AntialiasingPass_HistoryMapSlot, _antialiasingTexture[prevFrame]);336 batch.setResourceTexture(AntialiasingPass_HistoryMapSlot, _antialiasingTexture[prevFrame]);
335 batch.setResourceTexture(AntialiasingPass_SourceMapSlot, sourceBuffer->getRenderBuffer(0));337 batch.setResourceTexture(AntialiasingPass_SourceMapSlot, sourceBuffer->getRenderBuffer(0));
336 batch.setResourceTexture(AntialiasingPass_VelocityMapSlot, velocityBuffer->getVelocityTexture());338 batch.setResourceTexture(AntialiasingPass_VelocityMapSlot, velocityBuffer->getVelocityTexture());
337 batch.setResourceTexture(AntialiasingPass_DepthMapSlot, sourceBuffer->getDepthStencilBuffer());339 batch.setResourceTexture(AntialiasingPass_DepthMapSlot, linearDepthBuffer->getLinearDepthTexture());
338 340
339 batch.setUniformBuffer(AntialiasingPass_ParamsSlot, _params._buffer);341 batch.setUniformBuffer(AntialiasingPass_ParamsSlot, _params._buffer);
340 batch.setUniformBuffer(AntialiasingPass_FrameTransformSlot, deferredFrameTransform->getFrameTransformBuffer());342 batch.setUniformBuffer(AntialiasingPass_FrameTransformSlot, deferredFrameTransform->getFrameTransformBuffer());
libraries/render-utils/src/AntialiasingEffect.h+1−1
@@ -71,7 +71,7 @@ using TAAParamsBuffer = gpu::StructBuffer<TAAParams>; · 70 unmodified lines
71 71
72class Antialiasing {72class Antialiasing {
73public:73public:
74 using Inputs = render::VaryingSet3<DeferredFrameTransformPointer, gpu::FramebufferPointer, VelocityFramebufferPointer>;74 using Inputs = render::VaryingSet4 < DeferredFrameTransformPointer, gpu::FramebufferPointer, LinearDepthFramebufferPointer, VelocityFramebufferPointer > ;
75 using Config = AntialiasingConfig;75 using Config = AntialiasingConfig;
76 using JobModel = render::Job::ModelI<Antialiasing, Inputs, Config>;76 using JobModel = render::Job::ModelI<Antialiasing, Inputs, Config>;
77 77
libraries/render-utils/src/RenderDeferredTask.cpp+1−1
@@ -221,7 +221,7 @@ void RenderDeferredTask::build(JobModel& task, const render::Varying& input, ren · 220 unmodified lines
221 }221 }
222 222
223 // AA job to be revisited223 // AA job to be revisited
224 const auto antialiasingInputs = Antialiasing::Inputs(deferredFrameTransform, primaryFramebuffer, velocityBuffer).asVarying();224 const auto antialiasingInputs = Antialiasing::Inputs(deferredFrameTransform, primaryFramebuffer, linearDepthTarget, velocityBuffer).asVarying();
225 225
226 task.addJob<Antialiasing>("Antialiasing", antialiasingInputs);226 task.addJob<Antialiasing>("Antialiasing", antialiasingInputs);
227 227
libraries/render-utils/src/taa.slf+7−1
@@ -21,12 +21,18 @@ layout(location = 0) out vec4 outFragColor; · 20 unmodified lines
21void main() {21void main() {
22 22
23 vec3 fragUV = taa_findClosestFragment3x3(varTexCoord0);23 vec3 fragUV = taa_findClosestFragment3x3(varTexCoord0);
24 // vec3 fragUV = vec3(varTexCoord0, taa_fetchDepth(varTexCoord0));
24 vec2 fragVel = taa_fetchVelocityMap(fragUV.xy);25 vec2 fragVel = taa_fetchVelocityMap(fragUV.xy);
25
26 vec3 sourceColor;26 vec3 sourceColor;
27 vec3 historyColor;27 vec3 historyColor;
28 //vec3 nextColor = taa_temporalReprojection(fragUV.xy, fragVel, fragUV.z);28 //vec3 nextColor = taa_temporalReprojection(fragUV.xy, fragVel, fragUV.z);
29 vec2 prevFragUV = taa_fetchSourceAndHistory(fragUV.xy, fragVel, sourceColor, historyColor);29 vec2 prevFragUV = taa_fetchSourceAndHistory(fragUV.xy, fragVel, sourceColor, historyColor);
30 /* vec3 sourceColor = taa_fetchSourceMap(fragUV.xy).xyz;
31 vec2 prevFragUV = fragUV.xy - fragVel;
32 vec3 historyColor = sourceColor;
33 if (!(any(lessThan(prevFragUV, vec2(0.0))) || any(greaterThan(prevFragUV, vec2(1.0))))) {
34 historyColor = taa_fetchHistoryMap(prevFragUV).xyz;
35 }*/
30 36
31 vec3 nextColor = mix(historyColor, sourceColor, params.blend);37 vec3 nextColor = mix(historyColor, sourceColor, params.blend);
32 38
libraries/render-utils/src/taa.slh+3−3
@@ -88,15 +88,15 @@ vec4 taa_fetchNextMap(vec2 uv) { · 87 unmodified lines
88}88}
89 89
90vec2 taa_fetchVelocityMap(vec2 uv) {90vec2 taa_fetchVelocityMap(vec2 uv) {
91 return params.motionScale * texture(velocityMap, uv).xy;91 return texture(velocityMap, uv).xy;
92}92}
93 93
94float taa_fetchDepth(vec2 uv) {94float taa_fetchDepth(vec2 uv) {
95 return texture(depthMap, vec2(uv), 0).x;95 return -texture(depthMap, vec2(uv), 0).x;
96}96}
97 97
98 98
99#define ZCMP_GT(a, b) (a < b)99#define ZCMP_GT(a, b) (a > b)
100 100
101vec3 taa_findClosestFragment3x3(vec2 uv)101vec3 taa_findClosestFragment3x3(vec2 uv)
102{102{
libraries/render-utils/src/taa_blend.slf+5−0
@@ -21,6 +21,7 @@ void main(void) { · 20 unmodified lines
21 vec3 nextColor = texture(nextMap, varTexCoord0).xyz;21 vec3 nextColor = texture(nextMap, varTexCoord0).xyz;
22 outFragColor = vec4(nextColor, 1.0);22 outFragColor = vec4(nextColor, 1.0);
23 23
24
24 // Pixel being shaded25 // Pixel being shaded
25 vec3 sourceColor = texture(sourceMap, varTexCoord0).xyz;26 vec3 sourceColor = texture(sourceMap, varTexCoord0).xyz;
26 27
@@ -115,6 +116,10 @@ void main(void) { · 88 unmodified lines
115 return;116 return;
116 }117 }
117 118
119 vec3 fragUV = taa_findClosestFragment3x3(varTexCoord0);
120 outFragColor = vec4((fragUV.xy - varTexCoord0) * imageSize * 0.5 + vec2(0.5), 0.0, 1.0);
121
122 return;
118 outFragColor = vec4(nextColor, 1.0); 123 outFragColor = vec4(nextColor, 1.0);
119 124
120 vec3 prevColor = nextColor;125 vec3 prevColor = nextColor;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t