Skip to content

Commit

Permalink
More small adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
tippesi committed Jan 6, 2025
1 parent 38d5f7d commit 39c4d50
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 11 deletions.
8 changes: 4 additions & 4 deletions data/shader/ddgi/probeUpdate.csh
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,7 @@ void main() {
ivec3 historyVolumeCoord = ivec3(historyResOffset + pix, int(historyProbeCoord.y));
// Use a dynamic hysteris based on probe age to accumulate more efficiently at the beginning of a probes life
float hysteresis = clamp(probeAge / (probeAge + 1.0), 0.9, ddgiData.hysteresis);
hysteresis = ddgiData.hysteresis;
float hysteresis = clamp(probeAge / (probeAge + 1.0), 0.0, ddgiData.hysteresis);
#if defined(IRRADIANCE)
vec3 lastResult = texelFetch(irradianceVolume, historyVolumeCoord, 0).rgb;
Expand Down Expand Up @@ -307,11 +306,12 @@ void main() {
vec2 resultOut = lastResult;
if (result.w > 0.0) {
vec4 fullResult = vec4(result);
fullResult.xy /= fullResult.w;
if (probeState == PROBE_STATE_NEW || reset) {
resultOut = fullResult.xy / fullResult.w;
resultOut = mix(fullResult.xy, lastResult, hysteresis);
}
else {
resultOut = mix(fullResult.xy / fullResult.w, lastResult, hysteresis);
resultOut = mix(fullResult.xy, lastResult, hysteresis);
}
}
Expand Down
2 changes: 1 addition & 1 deletion data/shader/reflection/rtreflection.csh
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ void main() {

if (isRayValid) {
// Scale offset by depth since the depth buffer inaccuracies increase at a distance and might not match the ray traced geometry anymore
float viewOffset = max(1.0, length(viewPos));
float viewOffset = max(1.0, 2.0 * length(viewPos));
ray.origin = worldPos + ray.direction * EPSILON * viewOffset + worldNorm * EPSILON * viewOffset;

ray.hitID = -1;
Expand Down
2 changes: 1 addition & 1 deletion data/shader/reflection/temporal.csh
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,7 @@ void main() {
float variance = max(0.0, momentsResolve.g - momentsResolve.r * momentsResolve.r);
variance *= varianceBoost;

variance = roughness <= 0.1 ? variance * roughness : variance;
variance = roughness <= 0.1 ? max(variance * roughness, roughness * 1e-6) : variance;

imageStore(momentsImage, pixel, vec4(momentsResolve, historyLength + 1.0, 0.0));
imageStore(resolveImage, pixel, vec4(vec3(resolve), variance));
Expand Down
2 changes: 1 addition & 1 deletion data/shader/rtgi/rtgi.csh
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ void main() {
bool insideVolume = IsInsideVolume(worldPos);
float rayLength = length(GetCellSize(worldPos));
// Outside the volume we can scale the ray by 2x again
rayLength = insideVolume ? 2.0 * rayLength : INF;
rayLength = insideVolume ? 2.0 * rayLength : 4.0 * rayLength;
#else
float rayLength = INF;
#endif
Expand Down
2 changes: 2 additions & 0 deletions data/shader/rtgi/temporal.csh
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,8 @@ void main() {
float variance = max(0.0, momentsResolve.g - momentsResolve.r * momentsResolve.r);
variance *= varianceBoost;
variance = max(variance, 1e-5);
imageStore(momentsImage, pixel, vec4(momentsResolve, historyLength + 1.0, 0.0));
imageStore(resolveImage, pixel, vec4(resolve, variance));
Expand Down
2 changes: 1 addition & 1 deletion src/engine/graphics/Instance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ namespace Atlas {
appInfo.pApplicationName = name.c_str();
appInfo.applicationVersion = VK_MAKE_VERSION(1, 0, 0);
appInfo.pEngineName = "Atlas Engine";
appInfo.engineVersion = VK_MAKE_VERSION(0, 2, 0);
appInfo.engineVersion = VK_MAKE_VERSION(0, 2, 1);
appInfo.apiVersion = VK_API_VERSION_1_2;

LoadSupportedLayersAndExtensions();
Expand Down
17 changes: 14 additions & 3 deletions src/engine/renderer/GBufferRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,23 @@ namespace Atlas {
commandList->BindImage(geometryNormal->image, geometryNormal->sampler, 3, 2);
commandList->BindImage(materialIdx->image, materialIdx->sampler, 3, 3);

commandList->ImageMemoryBarrier(normal->image, VK_IMAGE_LAYOUT_GENERAL, VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT);
commandList->ImageMemoryBarrier(roughnessMetallicAo->image, VK_IMAGE_LAYOUT_GENERAL, VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT);
Graphics::ImageBarrier prePatchBarriers[] = {
{normal->image, VK_IMAGE_LAYOUT_GENERAL, VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT},
{roughnessMetallicAo->image, VK_IMAGE_LAYOUT_GENERAL, VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT},
{geometryNormal->image, VK_IMAGE_LAYOUT_GENERAL, VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT},
{materialIdx->image, VK_IMAGE_LAYOUT_GENERAL, VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT},
};
commandList->PipelineBarrier(prePatchBarriers, {});

commandList->Dispatch(groupCount.x, groupCount.y, 1);

commandList->ImageMemoryBarrier(normal->image, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL, VK_ACCESS_SHADER_READ_BIT);
Graphics::ImageBarrier postPatchBarriers[] = {
{normal->image, VK_IMAGE_LAYOUT_READ_ONLY_OPTIMAL, VK_ACCESS_SHADER_READ_BIT },
{roughnessMetallicAo->image, VK_IMAGE_LAYOUT_READ_ONLY_OPTIMAL, VK_ACCESS_SHADER_READ_BIT},
{geometryNormal->image, VK_IMAGE_LAYOUT_READ_ONLY_OPTIMAL, VK_ACCESS_SHADER_READ_BIT},
{materialIdx->image, VK_IMAGE_LAYOUT_READ_ONLY_OPTIMAL, VK_ACCESS_SHADER_READ_BIT},
};
commandList->PipelineBarrier(postPatchBarriers, {});

Graphics::Profiler::EndQuery();

Expand Down
2 changes: 2 additions & 0 deletions src/engine/renderer/MainRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,8 @@ namespace Atlas {

JobSystem::WaitSpin(scene->renderState.fillMainRenderPassJob);

// The reordering has cost us some rendering performance (not the case with validation layers active!?)
// Better orders are: Shadow, DDGI, Main or. DDGI, Shadow, Main or DDGI Main, Shadow
{
Graphics::Profiler::BeginQuery("Main render pass");

Expand Down

0 comments on commit 39c4d50

Please sign in to comment.