Merge pull request #1358 from overte-org/fix/TAA_transparencies

Fix for blurry/noisy transparencies on TAA
This commit is contained in:
ksuprynowicz 2025-03-14 19:06:01 +01:00 committed by GitHub
commit d09a927a82
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 9 additions and 10 deletions

View file

@ -72,22 +72,18 @@ void packDeferredFragmentTranslucent(vec4 prevPositionCS, vec3 normal, float alp
if (alpha <= 0.0) { if (alpha <= 0.0) {
discard; discard;
} }
// There's only one attachment here, and _albedoMetallic is actually _lighting,
// since transparencies are drawn using forward rendering, not deferred.
_albedoMetallic = vec4(albedo.rgb, alpha); _albedoMetallic = vec4(albedo.rgb, alpha);
_normalRoughness = vec4(packNormal(normal), clamp(roughness, 0.0, 1.0));
_scatteringEmissiveOcclusion = vec4(vec3(0.0), 1.0);
_velocity = vec4(packVelocity(prevPositionCS), 0.0, 0.0);
_lighting = vec4(0.0);
} }
void packDeferredFragmentTranslucentUnlit(vec4 prevPositionCS, vec3 normal, float alpha, vec3 color) { void packDeferredFragmentTranslucentUnlit(vec4 prevPositionCS, vec3 normal, float alpha, vec3 color) {
if (alpha <= 0.0) { if (alpha <= 0.0) {
discard; discard;
} }
// There's only one attachment here, and _albedoMetallic is actually _lighting,
// since transparencies are drawn using forward rendering, not deferred.
_albedoMetallic = vec4(color, alpha); _albedoMetallic = vec4(color, alpha);
_normalRoughness = vec4(packNormal(normal), 1.0);
_scatteringEmissiveOcclusion = vec4(vec3(0.0), 1.0);
_velocity = vec4(packVelocity(prevPositionCS), 0.0, 0.0);
_lighting = vec4(color, 1.0);
} }
<@endif@> <@endif@>

View file

@ -219,7 +219,7 @@ void RenderDeferredTask::build(JobModel& task, const render::Varying& input, ren
task.addJob<DrawHaze>("DrawHazeDeferred", drawHazeInputs, depth > 0); task.addJob<DrawHaze>("DrawHazeDeferred", drawHazeInputs, depth > 0);
// Render transparent objects forward in LightingBuffer // Render transparent objects forward in LightingBuffer
const auto transparentsInputs = RenderTransparentDeferred::Inputs(transparents, hazeFrame, lightFrame, lightingModel, lightClusters, shadowFrame, deferredFrameTransform).asVarying(); const auto transparentsInputs = RenderTransparentDeferred::Inputs(transparents, hazeFrame, lightFrame, lightingModel, lightClusters, shadowFrame, deferredFrameTransform, deferredFramebuffer).asVarying();
task.addJob<RenderTransparentDeferred>("DrawTransparentDeferred", transparentsInputs, shapePlumberDeferred, mainViewTransformSlot); task.addJob<RenderTransparentDeferred>("DrawTransparentDeferred", transparentsInputs, shapePlumberDeferred, mainViewTransformSlot);
// Highlight // Highlight
@ -468,6 +468,7 @@ void RenderTransparentDeferred::run(const RenderContextPointer& renderContext, c
const auto& lightClusters = inputs.get4(); const auto& lightClusters = inputs.get4();
// Not needed yet: const auto& shadowFrame = inputs.get5(); // Not needed yet: const auto& shadowFrame = inputs.get5();
const auto& deferredFrameTransform = inputs.get6(); const auto& deferredFrameTransform = inputs.get6();
auto &deferredFramebuffer = inputs.get7();
auto deferredLightingEffect = DependencyManager::get<DeferredLightingEffect>(); auto deferredLightingEffect = DependencyManager::get<DeferredLightingEffect>();
RenderArgs* args = renderContext->args; RenderArgs* args = renderContext->args;
@ -475,6 +476,8 @@ void RenderTransparentDeferred::run(const RenderContextPointer& renderContext, c
gpu::doInBatch("RenderTransparentDeferred::run", args->_context, [&](gpu::Batch& batch) { gpu::doInBatch("RenderTransparentDeferred::run", args->_context, [&](gpu::Batch& batch) {
args->_batch = &batch; args->_batch = &batch;
batch.setFramebuffer(deferredFramebuffer->getLightingFramebuffer());
// Setup camera, projection and viewport for all items // Setup camera, projection and viewport for all items
batch.setViewportTransform(args->_viewport); batch.setViewportTransform(args->_viewport);
batch.setStateScissorRect(args->_viewport); batch.setStateScissorRect(args->_viewport);

View file

@ -44,7 +44,7 @@ protected:
class RenderTransparentDeferred { class RenderTransparentDeferred {
public: public:
using Inputs = render::VaryingSet7<render::ItemBounds, HazeStage::FramePointer, LightStage::FramePointer, LightingModelPointer, LightClustersPointer, LightStage::ShadowFramePointer, DeferredFrameTransformPointer>; using Inputs = render::VaryingSet8<render::ItemBounds, HazeStage::FramePointer, LightStage::FramePointer, LightingModelPointer, LightClustersPointer, LightStage::ShadowFramePointer, DeferredFrameTransformPointer, DeferredFramebufferPointer>;
using Config = RenderTransparentDeferredConfig; using Config = RenderTransparentDeferredConfig;
using JobModel = render::Job::ModelI<RenderTransparentDeferred, Inputs, Config>; using JobModel = render::Job::ModelI<RenderTransparentDeferred, Inputs, Config>;