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
182182 const int AntialiasingPass_HistoryMapSlot = 0;
183183 const int AntialiasingPass_SourceMapSlot = 1;
184184 const int AntialiasingPass_VelocityMapSlot = 2;
185−const int AntialiasingPass_NextMapSlot = 3;
186185 const int AntialiasingPass_DepthMapSlot = 3;
187186
187+const int AntialiasingPass_NextMapSlot = 4;
188+
188189
189190 Antialiasing::Antialiasing() {
190191 }
@@ -298,7 +299,8 @@ void Antialiasing::run(const render::RenderContextPointer& renderContext, const · 107 unmodified lines
298299
299300 auto& deferredFrameTransform = inputs.get0();
300301 auto& sourceBuffer = inputs.get1();
301− auto& velocityBuffer = inputs.get2();
302+ auto& linearDepthBuffer = inputs.get2();
303+ auto& velocityBuffer = inputs.get3();
302304
303305 int width = sourceBuffer->getWidth();
304306 int height = sourceBuffer->getHeight();
@@ -334,7 +336,7 @@ void Antialiasing::run(const render::RenderContextPointer& renderContext, const · 29 unmodified lines
334336 batch.setResourceTexture(AntialiasingPass_HistoryMapSlot, _antialiasingTexture[prevFrame]);
335337 batch.setResourceTexture(AntialiasingPass_SourceMapSlot, sourceBuffer->getRenderBuffer(0));
336338 batch.setResourceTexture(AntialiasingPass_VelocityMapSlot, velocityBuffer->getVelocityTexture());
337− batch.setResourceTexture(AntialiasingPass_DepthMapSlot, sourceBuffer->getDepthStencilBuffer());
339+ batch.setResourceTexture(AntialiasingPass_DepthMapSlot, linearDepthBuffer->getLinearDepthTexture());
338340
339341 batch.setUniformBuffer(AntialiasingPass_ParamsSlot, _params._buffer);
340342 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
7171
7272 class Antialiasing {
7373 public:
74− using Inputs = render::VaryingSet3<DeferredFrameTransformPointer, gpu::FramebufferPointer, VelocityFramebufferPointer>;
74+ using Inputs = render::VaryingSet4 < DeferredFrameTransformPointer, gpu::FramebufferPointer, LinearDepthFramebufferPointer, VelocityFramebufferPointer > ;
7575 using Config = AntialiasingConfig;
7676 using JobModel = render::Job::ModelI<Antialiasing, Inputs, Config>;
7777
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
221221 }
222222
223223 // 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();
225225
226226 task.addJob<Antialiasing>("Antialiasing", antialiasingInputs);
227227
libraries/render-utils/src/taa.slf+7−1
@@ -21,12 +21,18 @@ layout(location = 0) out vec4 outFragColor; · 20 unmodified lines
2121 void main() {
2222
2323 vec3 fragUV = taa_findClosestFragment3x3(varTexCoord0);
24+ // vec3 fragUV = vec3(varTexCoord0, taa_fetchDepth(varTexCoord0));
2425 vec2 fragVel = taa_fetchVelocityMap(fragUV.xy);
25−
2626 vec3 sourceColor;
2727 vec3 historyColor;
2828 //vec3 nextColor = taa_temporalReprojection(fragUV.xy, fragVel, fragUV.z);
2929 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+ }*/
3036
3137 vec3 nextColor = mix(historyColor, sourceColor, params.blend);
3238
libraries/render-utils/src/taa.slh+3−3
@@ -88,15 +88,15 @@ vec4 taa_fetchNextMap(vec2 uv) { · 87 unmodified lines
8888 }
8989
9090 vec2 taa_fetchVelocityMap(vec2 uv) {
91− return params.motionScale * texture(velocityMap, uv).xy;
91+ return texture(velocityMap, uv).xy;
9292 }
9393
9494 float taa_fetchDepth(vec2 uv) {
95− return texture(depthMap, vec2(uv), 0).x;
95+ return -texture(depthMap, vec2(uv), 0).x;
9696 }
9797
9898
99−#define ZCMP_GT(a, b) (a < b)
99+#define ZCMP_GT(a, b) (a > b)
100100
101101 vec3 taa_findClosestFragment3x3(vec2 uv)
102102 {
libraries/render-utils/src/taa_blend.slf+5−0
@@ -21,6 +21,7 @@ void main(void) { · 20 unmodified lines
2121 vec3 nextColor = texture(nextMap, varTexCoord0).xyz;
2222 outFragColor = vec4(nextColor, 1.0);
2323
24+
2425 // Pixel being shaded
2526 vec3 sourceColor = texture(sourceMap, varTexCoord0).xyz;
2627
@@ -115,6 +116,10 @@ void main(void) { · 88 unmodified lines
115116 return;
116117 }
117118
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;
118123 outFragColor = vec4(nextColor, 1.0);
119124
120125 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