Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: increase skylighting resolution and range #722

Merged
merged 1 commit into from
Nov 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions features/Skylighting/Shaders/Skylighting/Skylighting.hlsli
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ Texture3D<sh2> SkylightingProbeArray : register(t29);

namespace Skylighting
{
const static uint3 ARRAY_DIM = uint3(128, 128, 64);
const static float3 ARRAY_SIZE = float3(10000, 10000, 10000 * 0.5);
const static uint3 ARRAY_DIM = uint3(256, 256, 128);
const static float3 ARRAY_SIZE = 4096.f * 3.f * float3(1, 1, 0.5);
const static float3 CELL_SIZE = ARRAY_SIZE / ARRAY_DIM;

float getFadeOutFactor(float3 positionMS)
Expand Down
11 changes: 4 additions & 7 deletions features/Skylighting/Shaders/Skylighting/UpdateProbesCS.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,17 @@ RWTexture3D<uint> outAccumFramesArray : register(u1);

SamplerState samplerPointClamp : register(s0);

#define ARRAY_DIM uint3(128, 128, 64)
#define ARRAY_SIZE float3(10000, 10000, 10000 * 0.5)

[numthreads(8, 8, 1)] void main(uint3 dtid
: SV_DispatchThreadID) {
const float fadeInThreshold = 255;
const static sh2 unitSH = float4(sqrt(4.0 * Math::PI), 0, 0, 0);
const SkylightingSettings settings = skylightingSettings;

uint3 cellID = (int3(dtid) - settings.ArrayOrigin.xyz) % ARRAY_DIM;
bool isValid = all(cellID >= max(0, settings.ValidMargin.xyz)) && all(cellID <= ARRAY_DIM - 1 + min(0, settings.ValidMargin.xyz)); // check if the cell is newly added
uint3 cellID = (int3(dtid) - settings.ArrayOrigin.xyz) % Skylighting::ARRAY_DIM;
bool isValid = all(cellID >= max(0, settings.ValidMargin.xyz)) && all(cellID <= Skylighting::ARRAY_DIM - 1 + min(0, settings.ValidMargin.xyz)); // check if the cell is newly added

float3 cellCentreMS = cellID + 0.5 - ARRAY_DIM / 2;
cellCentreMS = cellCentreMS / ARRAY_DIM * ARRAY_SIZE + settings.PosOffset.xyz;
float3 cellCentreMS = cellID + 0.5 - Skylighting::ARRAY_DIM / 2;
cellCentreMS = cellCentreMS / Skylighting::ARRAY_DIM * Skylighting::ARRAY_SIZE + settings.PosOffset.xyz;

float3 cellCentreOS = mul(settings.OcclusionViewProj, float4(cellCentreMS, 1)).xyz;
cellCentreOS.y = -cellCentreOS.y;
Expand Down
4 changes: 2 additions & 2 deletions src/Features/Skylighting.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ struct Skylighting : Feature

// misc parameters
bool doOcclusion = true;
uint probeArrayDims[3] = { 128, 128, 64 };
float occlusionDistance = 10000.f;
uint probeArrayDims[3] = { 256, 256, 128 };
float occlusionDistance = 4096.f * 3.f; // 3 cells

// cached variables
bool inOcclusion = false;
Expand Down
Loading