ADD : 에셋 추가 및 렌더링 설정 업데이트
This commit is contained in:
parent
fd529088f7
commit
3745b37e85
8
Assets/External/HTraceWSGI.meta
vendored
Normal file
8
Assets/External/HTraceWSGI.meta
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d612ac72bbff16f4a9258a3c05222013
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
BIN
Assets/External/HTraceWSGI/HTraceWSGI Quick-Start Manual.pdf
(Stored with Git LFS)
vendored
Normal file
BIN
Assets/External/HTraceWSGI/HTraceWSGI Quick-Start Manual.pdf
(Stored with Git LFS)
vendored
Normal file
Binary file not shown.
14
Assets/External/HTraceWSGI/HTraceWSGI Quick-Start Manual.pdf.meta
vendored
Normal file
14
Assets/External/HTraceWSGI/HTraceWSGI Quick-Start Manual.pdf.meta
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0f08f08fbf1ae3840a4a7f5f80d0a98a
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 379716
|
||||
packageName: 'HTrace: World Space Global Illumination URP | Beta'
|
||||
packageVersion: 0.9.6
|
||||
assetPath: Assets/HTraceWSGI/HTraceWSGI Quick-Start Manual.pdf
|
||||
uploadId: 925118
|
||||
22
Assets/External/HTraceWSGI/HTraceWSGI.asmdef
vendored
Normal file
22
Assets/External/HTraceWSGI/HTraceWSGI.asmdef
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
{
|
||||
"name": "HTraceWSGI",
|
||||
"rootNamespace": "",
|
||||
"references": [
|
||||
"GUID:3eae0364be2026648bf74846acb8a731",
|
||||
"GUID:15fc0a57446b3144c949da3e2b9737a9",
|
||||
"GUID:78bd2ddd6e276394a9615c203e574844",
|
||||
"GUID:457756d89b35d2941b3e7b37b4ece6f1",
|
||||
"GUID:c579267770062bf448e75eb160330b7f",
|
||||
"GUID:df380645f10b7bc4b97d4f5eb6303d95",
|
||||
"GUID:75469ad4d38634e559750d17036d5f7c"
|
||||
],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": true,
|
||||
"defineConstraints": [],
|
||||
"versionDefines": [],
|
||||
"noEngineReferences": false
|
||||
}
|
||||
10
Assets/External/HTraceWSGI/HTraceWSGI.asmdef.meta
vendored
Normal file
10
Assets/External/HTraceWSGI/HTraceWSGI.asmdef.meta
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 626dce77c9ae402892d1309f34bad18e
|
||||
timeCreated: 1674796741
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 379716
|
||||
packageName: 'HTrace: World Space Global Illumination URP | Beta'
|
||||
packageVersion: 0.9.6
|
||||
assetPath: Assets/HTraceWSGI/HTraceWSGI.asmdef
|
||||
uploadId: 925118
|
||||
8
Assets/External/HTraceWSGI/Icons.meta
vendored
Normal file
8
Assets/External/HTraceWSGI/Icons.meta
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0f64d29cd4984bd4eae7217cd0d67bef
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
BIN
Assets/External/HTraceWSGI/Icons/Icon (160 x 160).png
(Stored with Git LFS)
vendored
Normal file
BIN
Assets/External/HTraceWSGI/Icons/Icon (160 x 160).png
(Stored with Git LFS)
vendored
Normal file
Binary file not shown.
131
Assets/External/HTraceWSGI/Icons/Icon (160 x 160).png.meta
vendored
Normal file
131
Assets/External/HTraceWSGI/Icons/Icon (160 x 160).png.meta
vendored
Normal file
@ -0,0 +1,131 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0915864a167b66048872805a749c4360
|
||||
TextureImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 12
|
||||
mipmaps:
|
||||
mipMapMode: 0
|
||||
enableMipMap: 0
|
||||
sRGBTexture: 1
|
||||
linearTexture: 0
|
||||
fadeOut: 0
|
||||
borderMipMap: 0
|
||||
mipMapsPreserveCoverage: 0
|
||||
alphaTestReferenceValue: 0.5
|
||||
mipMapFadeDistanceStart: 1
|
||||
mipMapFadeDistanceEnd: 3
|
||||
bumpmap:
|
||||
convertToNormalMap: 0
|
||||
externalNormalMap: 0
|
||||
heightScale: 0.25
|
||||
normalMapFilter: 0
|
||||
flipGreenChannel: 0
|
||||
isReadable: 0
|
||||
streamingMipmaps: 0
|
||||
streamingMipmapsPriority: 0
|
||||
vTOnly: 0
|
||||
ignoreMipmapLimit: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 6
|
||||
cubemapConvolution: 0
|
||||
seamlessCubemap: 0
|
||||
textureFormat: 1
|
||||
maxTextureSize: 2048
|
||||
textureSettings:
|
||||
serializedVersion: 2
|
||||
filterMode: 1
|
||||
aniso: 1
|
||||
mipBias: 0
|
||||
wrapU: 0
|
||||
wrapV: 0
|
||||
wrapW: 0
|
||||
nPOTScale: 1
|
||||
lightmap: 0
|
||||
compressionQuality: 50
|
||||
spriteMode: 0
|
||||
spriteExtrude: 1
|
||||
spriteMeshType: 1
|
||||
alignment: 0
|
||||
spritePivot: {x: 0.5, y: 0.5}
|
||||
spritePixelsToUnits: 100
|
||||
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||
spriteGenerateFallbackPhysicsShape: 1
|
||||
alphaUsage: 1
|
||||
alphaIsTransparency: 0
|
||||
spriteTessellationDetail: -1
|
||||
textureType: 0
|
||||
textureShape: 1
|
||||
singleChannelComponent: 0
|
||||
flipbookRows: 1
|
||||
flipbookColumns: 1
|
||||
maxTextureSizeSet: 0
|
||||
compressionQualitySet: 0
|
||||
textureFormatSet: 0
|
||||
ignorePngGamma: 0
|
||||
applyGammaDecoding: 0
|
||||
swizzle: 50462976
|
||||
cookieLightType: 0
|
||||
platformSettings:
|
||||
- serializedVersion: 3
|
||||
buildTarget: DefaultTexturePlatform
|
||||
maxTextureSize: 64
|
||||
resizeAlgorithm: 1
|
||||
textureFormat: -1
|
||||
textureCompression: 0
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: Standalone
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: Server
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
spriteSheet:
|
||||
serializedVersion: 2
|
||||
sprites: []
|
||||
outline: []
|
||||
physicsShape: []
|
||||
bones: []
|
||||
spriteID:
|
||||
internalID: 0
|
||||
vertices: []
|
||||
indices:
|
||||
edges: []
|
||||
weights: []
|
||||
secondaryTextures: []
|
||||
nameFileIdTable: {}
|
||||
mipmapLimitGroupName:
|
||||
pSDRemoveMatte: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 379716
|
||||
packageName: 'HTrace: World Space Global Illumination URP | Beta'
|
||||
packageVersion: 0.9.6
|
||||
assetPath: Assets/HTraceWSGI/Icons/Icon (160 x 160).png
|
||||
uploadId: 925118
|
||||
12
Assets/External/HTraceWSGI/Resources.meta
vendored
Normal file
12
Assets/External/HTraceWSGI/Resources.meta
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
<<<<<<<< HEAD:HTrace_HDRP/Assets/Menu.meta
|
||||
guid: 9f50f6899e69be4478ddbfccc33ecedf
|
||||
========
|
||||
guid: 4ff4d07345483c542b3c5e943310c782
|
||||
>>>>>>>> Update_2.0:HTrace_HDRP/Assets/H-Trace/Resources.meta
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
3
Assets/External/HTraceWSGI/Resources/HTraceWSGI.meta
vendored
Normal file
3
Assets/External/HTraceWSGI/Resources/HTraceWSGI.meta
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 927af83b7c1ea7946af7638bb0db4959
|
||||
timeCreated: 1738083188
|
||||
3
Assets/External/HTraceWSGI/Resources/HTraceWSGI/URP.meta
vendored
Normal file
3
Assets/External/HTraceWSGI/Resources/HTraceWSGI/URP.meta
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 798f9d88589541baa1fde7e634d42d0c
|
||||
timeCreated: 1763045111
|
||||
3
Assets/External/HTraceWSGI/Resources/HTraceWSGI/URP/Computes.meta
vendored
Normal file
3
Assets/External/HTraceWSGI/Resources/HTraceWSGI/URP/Computes.meta
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 355c48594db44a63b285f9a382858eb8
|
||||
timeCreated: 1763045117
|
||||
231
Assets/External/HTraceWSGI/Resources/HTraceWSGI/URP/Computes/HLightClusterURP.compute
vendored
Normal file
231
Assets/External/HTraceWSGI/Resources/HTraceWSGI/URP/Computes/HLightClusterURP.compute
vendored
Normal file
@ -0,0 +1,231 @@
|
||||
#pragma kernel ClearBuffer
|
||||
#pragma kernel FillLightCluster
|
||||
#pragma kernel DebugLightCluster
|
||||
#pragma kernel FillLightClusterDebugBuffer
|
||||
#pragma kernel LightDataCompaction
|
||||
#pragma kernel TransferPreviousPosition
|
||||
|
||||
#define HAS_LIGHTLOOP
|
||||
|
||||
struct LightInfo
|
||||
{
|
||||
float3 Position;
|
||||
};
|
||||
|
||||
#include "../../_Shared/Headers/HMain.hlsl"
|
||||
#include "../../_Shared/Includes/LightCluster.hlsl"
|
||||
#pragma multi_compile _ _GBUFFER_NORMALS_OCT
|
||||
|
||||
RWStructuredBuffer<float4> _PrevBuffer;
|
||||
StructuredBuffer<LightInfo> _SceneLightsBuffer;
|
||||
RWStructuredBuffer<uint> _LightClusterDebugBuffer;
|
||||
RWStructuredBuffer<uint> _LightClusterIndexesBuffer;
|
||||
RWStructuredBuffer<uint> _LightClusterCounterBuffer;
|
||||
RWStructuredBuffer<uint> _LightDatasCompactedBuffer;
|
||||
|
||||
H_RW_TEXTURE(float4, _LightClusterDebug_Output);
|
||||
|
||||
[numthreads(64, 1, 1)]
|
||||
void ClearBuffer(uint Index : SV_DispatchThreadID)
|
||||
{
|
||||
_LightClusterCounterBuffer[Index] = 0;
|
||||
}
|
||||
|
||||
[numthreads(64, 1, 1)]
|
||||
void TransferPreviousPosition(uint Index : SV_DispatchThreadID)
|
||||
{
|
||||
// LightData Light = _LightDatas[Index];
|
||||
// LightLoopContext Context;
|
||||
//
|
||||
// Context.shadowContext = InitShadowContext();
|
||||
// HDShadowData ShadowData = Context.shadowContext.shadowDatas[Light.shadowIndex];
|
||||
//
|
||||
// //_PrevBuffer[Index] = ShadowData.pos;
|
||||
}
|
||||
|
||||
|
||||
// ------------------------ LIGHT DATA COMPACTION ------------------------
|
||||
[numthreads(64, 1, 1)]
|
||||
void LightDataCompaction(uint dispatchThreadID : SV_DispatchThreadID)
|
||||
{
|
||||
float3 LightPositionWS = _AdditionalLightsPosition[dispatchThreadID].xyz;
|
||||
|
||||
// Protection against HPunctualLights.cs script being set on a wrong light type
|
||||
// if (PunctualLightData.lightType != GPULIGHTTYPE_POINT && PunctualLightData.lightType != GPULIGHTTYPE_SPOT)
|
||||
// return;
|
||||
|
||||
for (uint CompactedLightIndex = 0; CompactedLightIndex < g_SceneLightsBufferSize; CompactedLightIndex++)
|
||||
{
|
||||
if (all(abs(_SceneLightsBuffer[CompactedLightIndex].Position - LightPositionWS.xyz) < 0.001f))
|
||||
{
|
||||
_LightDatasCompactedBuffer[CompactedLightIndex] = dispatchThreadID;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ------------------------ LIGHT CLUSTER FILL ------------------------
|
||||
[numthreads(4, 4, 4)]
|
||||
void FillLightCluster(uint3 dispatchThreadID : SV_DispatchThreadID)
|
||||
{
|
||||
float3 MinCellAABB = g_MinLightClusterPosition + (dispatchThreadID) * g_LightCluterCellSize;
|
||||
float3 MaxCellAABB = g_MinLightClusterPosition + (dispatchThreadID + 1) * g_LightCluterCellSize;
|
||||
|
||||
uint CellLightCount = 0;
|
||||
uint FlattenedGridIndex = GetFlattenedIndex(dispatchThreadID);
|
||||
|
||||
for (uint CompactedLightIndex = 0; CompactedLightIndex < g_SceneLightsBufferSize; CompactedLightIndex++)
|
||||
{
|
||||
if (CellLightCount >= g_MaxLightsPerCell)
|
||||
break;
|
||||
|
||||
int LightDataIndex = _LightDatasCompactedBuffer[CompactedLightIndex];
|
||||
|
||||
float3 LightPositionWS = _AdditionalLightsPosition[LightDataIndex].xyz;
|
||||
float4 LightAtten = _AdditionalLightsAttenuation[LightDataIndex];
|
||||
float LightRange = 1.0 / sqrt(LightAtten.x);
|
||||
|
||||
if (ClusterCellSphereIntersection(LightPositionWS, LightRange, MinCellAABB, MaxCellAABB))
|
||||
{
|
||||
// Spot lights: cull with cone-AABB test to avoid assigning cells outside the cone
|
||||
// LightAtten.z = invAngleRange (0 for point lights), LightAtten.w = -cosOuter * invAngleRange
|
||||
if (LightAtten.z > 0)
|
||||
{
|
||||
float3 SpotDir = _AdditionalLightsSpotDir[LightDataIndex].xyz;
|
||||
float CosHalfOuter = -LightAtten.w / LightAtten.z;
|
||||
float ConeAngle = degrees(acos(CosHalfOuter)) * 2.0;
|
||||
if (!ClusterCellConeIntersection(LightPositionWS, SpotDir, ConeAngle, LightRange, MinCellAABB, MaxCellAABB))
|
||||
continue;
|
||||
}
|
||||
|
||||
if (CellLightCount < g_MaxLightsPerCell)
|
||||
_LightClusterIndexesBuffer[FlattenedGridIndex * g_MaxLightsPerCell + CellLightCount] = LightDataIndex;
|
||||
|
||||
CellLightCount++;
|
||||
}
|
||||
}
|
||||
|
||||
_LightClusterCounterBuffer[FlattenedGridIndex] = CellLightCount;
|
||||
}
|
||||
|
||||
|
||||
// ------------------------ LIGHT CLUSTER DEBUG BUFFER FILL ------------------------
|
||||
[numthreads(4, 4, 4)]
|
||||
void FillLightClusterDebugBuffer(int3 dispatchThreadID : SV_DispatchThreadID)
|
||||
{
|
||||
uint FlattenedGridIndex = GetFlattenedIndex(dispatchThreadID);
|
||||
uint CellLightCount = _LightClusterCounterBuffer[FlattenedGridIndex];
|
||||
|
||||
// Early out in heatmap mode
|
||||
if (g_HeatmapDebug)
|
||||
{
|
||||
_LightClusterDebugBuffer[FlattenedGridIndex] = CellLightCount == g_MaxLightsPerCell;
|
||||
return;
|
||||
}
|
||||
|
||||
bool IsEdgeCell = false;
|
||||
bool IsCellFilled = CellLightCount > 0 ? true : false;
|
||||
|
||||
// Early out on empty cells
|
||||
if (!IsCellFilled)
|
||||
{
|
||||
_LightClusterDebugBuffer[FlattenedGridIndex] = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
const static int3 NeighborOffsets[6] = {int3( 1, 0, 0), int3(-1, 0, 0), int3(0, 1, 0), int3(0, -1, 0), int3(0, 0, 1), int3(0, 0, -1)};
|
||||
|
||||
UNITY_UNROLL
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
uint3 GridSampleIndex = dispatchThreadID + NeighborOffsets[i];
|
||||
uint FlattenedGridSampleIndex = GetFlattenedIndex(GridSampleIndex);
|
||||
|
||||
if (any(GridSampleIndex >= g_LightClusterDimensions))
|
||||
IsEdgeCell = true;
|
||||
|
||||
// If the lightcount is different between the neighboring cells it means we are on the edge of some light's radius
|
||||
if (_LightClusterCounterBuffer[FlattenedGridSampleIndex] != CellLightCount)
|
||||
IsEdgeCell = true;
|
||||
}
|
||||
|
||||
_LightClusterDebugBuffer[FlattenedGridIndex] = IsCellFilled & IsEdgeCell;
|
||||
}
|
||||
|
||||
#define ADDITIONAL_LIGHT_CALCULATE_SHADOWS
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/RealtimeLights.hlsl"
|
||||
// ------------------------ LIGHT CLUSTER DEBUG ------------------------
|
||||
[numthreads(8, 8, 1)]
|
||||
void DebugLightCluster(uint3 pixCoord : SV_DispatchThreadID, uint2 groupThreadId : SV_GroupThreadID, uint2 groupId : SV_GroupID)
|
||||
{
|
||||
float Depth = HBUFFER_DEPTH(pixCoord.xy);
|
||||
|
||||
float Background = clamp(H_LINEAR_EYE_DEPTH(Depth) / 100, 0.02f, 0.85f);
|
||||
|
||||
// Set background (sky) pixels to black
|
||||
if (Depth == UNITY_RAW_FAR_CLIP_VALUE)
|
||||
{
|
||||
_LightClusterDebug_Output[H_COORD(pixCoord.xy)] = float4(0.0, 0.0, 0.0, 1.0f);
|
||||
return;
|
||||
}
|
||||
|
||||
float3 PositionWS = H_COMPUTE_POSITION_WS((pixCoord.xy + 0.5) / _ScreenSize.xy, Depth, H_MATRIX_I_VP);
|
||||
//PositionWS = H_GET_ABSOLUTE_POSITION_WS(PositionWS + 0.005f);
|
||||
|
||||
// Set pixels outside cluster bounds to dark gray
|
||||
if (!IsInsideLightCluster(PositionWS))
|
||||
{
|
||||
_LightClusterDebug_Output[H_COORD(pixCoord.xy)] = Background;
|
||||
return;
|
||||
}
|
||||
|
||||
// Compute the grid position
|
||||
uint3 GridPosition = (uint3)((PositionWS - g_MinLightClusterPosition) / (g_MaxLightClusterPosition - g_MinLightClusterPosition) * float3(g_LightClusterDimensions));
|
||||
|
||||
// Fetch the light count in this cell
|
||||
uint CellLightCount = _LightClusterCounterBuffer[GetFlattenedIndex(GridPosition)];
|
||||
float3 CellLightColor = 0;
|
||||
|
||||
// Accumulate all light colors within the cell
|
||||
for (uint i = 0; i < CellLightCount; i++)
|
||||
{
|
||||
float3 PunctualLightColor = _AdditionalLightsColor[_LightClusterIndexesBuffer[GetFlattenedIndex(GridPosition * g_MaxLightsPerCell) + i]].xyz;
|
||||
float3 PunctualLightPosition = _AdditionalLightsPosition[_LightClusterIndexesBuffer[GetFlattenedIndex(GridPosition * g_MaxLightsPerCell) + i]].xyz;
|
||||
float PunctualLightRangte = _AdditionalLightsAttenuation[_LightClusterIndexesBuffer[GetFlattenedIndex(GridPosition * g_MaxLightsPerCell) + i]].xyz; PunctualLightRangte = 1 / sqrt(PunctualLightRangte);
|
||||
|
||||
float MaxLightColor = max(PunctualLightColor.r, max(PunctualLightColor.g, PunctualLightColor.b));
|
||||
float3 LightColor = (MaxLightColor > 0) ? PunctualLightColor / MaxLightColor : float3(0,0,0);
|
||||
|
||||
float3 CellSize = (g_MaxLightClusterPosition - g_MinLightClusterPosition) / g_LightClusterDimensions;
|
||||
float3 CellCenterWS = g_MinLightClusterPosition + (GridPosition + 0.5) * CellSize;
|
||||
|
||||
// Uniform faloff
|
||||
float Distance = length(H_GET_ABSOLUTE_POSITION_WS(PunctualLightPosition) - CellCenterWS);
|
||||
float Attenuation = lerp(0.1, 1, saturate(1.0 - Distance / PunctualLightRangte));
|
||||
|
||||
CellLightColor += LightColor * pow(Attenuation, 1.25);
|
||||
}
|
||||
|
||||
if (CellLightCount == 0)
|
||||
{
|
||||
_LightClusterDebug_Output[H_COORD(pixCoord.xy)] = Background;
|
||||
return;
|
||||
}
|
||||
|
||||
_LightClusterDebug_Output[H_COORD(pixCoord.xy)] = float4(CellLightColor, 1.0);
|
||||
|
||||
if (g_HeatmapDebug)
|
||||
{
|
||||
float3 CellHeat = lerp(float3(0,1,0), float3(0.9,0,0), float(CellLightCount) / g_MaxLightsPerCell);
|
||||
|
||||
if (CellLightCount == 1)
|
||||
CellHeat = float3(0,1,0);
|
||||
|
||||
if (CellLightCount == g_MaxLightsPerCell)
|
||||
CellHeat = float3(1,0,0);
|
||||
|
||||
_LightClusterDebug_Output[H_COORD(pixCoord.xy)] = float4(CellHeat, 1);
|
||||
}
|
||||
}
|
||||
10
Assets/External/HTraceWSGI/Resources/HTraceWSGI/URP/Computes/HLightClusterURP.compute.meta
vendored
Normal file
10
Assets/External/HTraceWSGI/Resources/HTraceWSGI/URP/Computes/HLightClusterURP.compute.meta
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e4679a5c749144f9b585a4920b80e54b
|
||||
timeCreated: 1763045122
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 379716
|
||||
packageName: 'HTrace: World Space Global Illumination URP | Beta'
|
||||
packageVersion: 0.9.6
|
||||
assetPath: Assets/HTraceWSGI/Resources/HTraceWSGI/URP/Computes/HLightClusterURP.compute
|
||||
uploadId: 925118
|
||||
43
Assets/External/HTraceWSGI/Resources/HTraceWSGI/URP/Computes/NewBrush.brush
vendored
Normal file
43
Assets/External/HTraceWSGI/Resources/HTraceWSGI/URP/Computes/NewBrush.brush
vendored
Normal file
@ -0,0 +1,43 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 12146, guid: 0000000000000000e000000000000000, type: 0}
|
||||
m_Name: NewBrush
|
||||
m_EditorClassIdentifier: UnityEditor.dll::UnityEditor.Brush
|
||||
m_Mask: {fileID: 0}
|
||||
m_Falloff:
|
||||
serializedVersion: 2
|
||||
m_Curve:
|
||||
- serializedVersion: 3
|
||||
time: 0
|
||||
value: 0
|
||||
inSlope: 0
|
||||
outSlope: 1
|
||||
tangentMode: 0
|
||||
weightedMode: 0
|
||||
inWeight: 0
|
||||
outWeight: 0
|
||||
- serializedVersion: 3
|
||||
time: 1
|
||||
value: 1
|
||||
inSlope: 1
|
||||
outSlope: 0
|
||||
tangentMode: 0
|
||||
weightedMode: 0
|
||||
inWeight: 0
|
||||
outWeight: 0
|
||||
m_PreInfinity: 2
|
||||
m_PostInfinity: 2
|
||||
m_RotationOrder: 4
|
||||
m_RadiusScale: 1
|
||||
m_BlackWhiteRemapMin: 0
|
||||
m_BlackWhiteRemapMax: 1
|
||||
m_InvertRemapRange: 0
|
||||
15
Assets/External/HTraceWSGI/Resources/HTraceWSGI/URP/Computes/NewBrush.brush.meta
vendored
Normal file
15
Assets/External/HTraceWSGI/Resources/HTraceWSGI/URP/Computes/NewBrush.brush.meta
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ee3eb903dbf5b0c4ebe012eb9c6e98b2
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 379716
|
||||
packageName: 'HTrace: World Space Global Illumination URP | Beta'
|
||||
packageVersion: 0.9.6
|
||||
assetPath: Assets/HTraceWSGI/Resources/HTraceWSGI/URP/Computes/NewBrush.brush
|
||||
uploadId: 925118
|
||||
3
Assets/External/HTraceWSGI/Resources/HTraceWSGI/URP/Shaders.meta
vendored
Normal file
3
Assets/External/HTraceWSGI/Resources/HTraceWSGI/URP/Shaders.meta
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: db13b70fb74348c6ad25624f5f165d2c
|
||||
timeCreated: 1764077239
|
||||
212
Assets/External/HTraceWSGI/Resources/HTraceWSGI/URP/Shaders/ColorComposeURP.shader
vendored
Normal file
212
Assets/External/HTraceWSGI/Resources/HTraceWSGI/URP/Shaders/ColorComposeURP.shader
vendored
Normal file
@ -0,0 +1,212 @@
|
||||
Shader "Hidden/HTraceWSGI/ColorComposeURP"
|
||||
{
|
||||
SubShader
|
||||
{
|
||||
HLSLINCLUDE
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/FoveatedRendering.hlsl"
|
||||
|
||||
struct Attributes
|
||||
{
|
||||
uint VertexID : SV_VertexID;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct Varyings
|
||||
{
|
||||
float4 PositionCS : POSITION;
|
||||
float2 TexCoord : TEXCOORD0;
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
Varyings SharedVertexStage(Attributes input)
|
||||
{
|
||||
Varyings output;
|
||||
UNITY_SETUP_INSTANCE_ID(input);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
|
||||
|
||||
output.PositionCS = GetFullScreenTriangleVertexPosition(input.VertexID);
|
||||
output.TexCoord = GetFullScreenTriangleTexCoord(input.VertexID);
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
ENDHLSL
|
||||
|
||||
Pass
|
||||
{
|
||||
Name "Copy Color Buffer"
|
||||
|
||||
Cull Off
|
||||
ZWrite Off
|
||||
|
||||
HLSLPROGRAM
|
||||
|
||||
#pragma vertex SharedVertexStage
|
||||
#pragma fragment FragmentStage
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DeclareDepthTexture.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/UnityInput.hlsl"
|
||||
#include "../../_Shared/Headers/HMain.hlsl"
|
||||
|
||||
float4 FragmentStage(Varyings input) : SV_Target
|
||||
{
|
||||
return float4(HBUFFER_COLOR(input.TexCoord * _ScreenSize.xy).xyz, 1);
|
||||
}
|
||||
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
Pass
|
||||
{
|
||||
Name "Override Indirect Lighting"
|
||||
|
||||
Cull Off
|
||||
ZWrite Off
|
||||
|
||||
// Doesn't seem to work for the R16G16A16B16 Color Buffer
|
||||
// Blend One One
|
||||
// BlendOp RevSub
|
||||
|
||||
HLSLPROGRAM
|
||||
|
||||
#pragma vertex SharedVertexStage
|
||||
#pragma fragment FragmentStage
|
||||
|
||||
#pragma multi_compile _ PROBE_VOLUMES_L1 PROBE_VOLUMES_L2
|
||||
#pragma multi_compile _ _GBUFFER_NORMALS_OCT
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
|
||||
#include "../../_Shared/Headers/HMain.hlsl"
|
||||
#include "../../_Shared/Headers/HSpaceTransforms.hlsl"
|
||||
#include "../../_Shared/Includes/FallbackAPV.hlsl"
|
||||
|
||||
H_TEXTURE(_ColorCopy);
|
||||
|
||||
#define kMaterialFlagSpecularSetup 8
|
||||
uint UnpackMaterialFlags(float packedMaterialFlags)
|
||||
{ return uint((packedMaterialFlags * 255.0h) + 0.5h); }
|
||||
|
||||
float4 FragmentStage(Varyings input) : SV_Target
|
||||
{
|
||||
uint2 pixCoord = input.TexCoord * _ScreenSize.xy;
|
||||
float3 ColorCopy = H_LOAD(_ColorCopy, pixCoord).xyz;
|
||||
|
||||
float DepthCenter = HBUFFER_DEPTH(pixCoord);
|
||||
float3 NormalCenterWS = HBUFFER_NORMAL_WS(pixCoord);
|
||||
float3 PositionCenterWS = H_COMPUTE_POSITION_WS(input.TexCoord, DepthCenter, H_MATRIX_I_VP);
|
||||
|
||||
float4 GBuffer0 = H_LOAD(g_HTraceGBuffer0, pixCoord);
|
||||
float4 Gbuffer1 = H_LOAD(g_HTraceGBuffer1, pixCoord);
|
||||
|
||||
float3 IndirectLighting = 0;
|
||||
float Metallic = Gbuffer1.r;
|
||||
|
||||
// This seems to make everything worse.
|
||||
// if ((UnpackMaterialFlags(GBuffer0.a) & kMaterialFlagSpecularSetup) != 0)
|
||||
// Metallic = (ReflectivitySpecular(Gbuffer1.rgb));
|
||||
|
||||
if (_EnableProbeVolumes)
|
||||
{
|
||||
if (PROBE_VOLUMES_L1 || PROBE_VOLUMES_L2)
|
||||
{ IndirectLighting = EvaluateAPV(PositionCenterWS, NormalCenterWS, H_GET_VIEW_DIRECTION_WS(PositionCenterWS), pixCoord); }
|
||||
}
|
||||
else
|
||||
{
|
||||
unity_SHAr = H_SHAr;
|
||||
unity_SHAg = H_SHAg;
|
||||
unity_SHAb = H_SHAb;
|
||||
unity_SHBr = H_SHBr;
|
||||
unity_SHBg = H_SHBg;
|
||||
unity_SHBb = H_SHBb;
|
||||
unity_SHC = H_SHC;
|
||||
IndirectLighting = EvaluateAmbientProbe(NormalCenterWS);
|
||||
}
|
||||
|
||||
IndirectLighting = IndirectLighting * GBuffer0.rgb * Gbuffer1.a * (1.0 - Metallic);
|
||||
|
||||
return float4(max(ColorCopy - IndirectLighting, 0), 1);
|
||||
}
|
||||
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
Pass
|
||||
{
|
||||
Name "Final Output"
|
||||
|
||||
Cull Off
|
||||
ZWrite Off
|
||||
Blend One One
|
||||
|
||||
HLSLPROGRAM
|
||||
|
||||
#pragma vertex SharedVertexStage
|
||||
#pragma fragment FragmentStage
|
||||
|
||||
#pragma multi_compile _ PROBE_VOLUMES_L1 PROBE_VOLUMES_L2
|
||||
#pragma multi_compile _ _GBUFFER_NORMALS_OCT
|
||||
#pragma multi_compile _ USE_RECEIVE_LAYER_MASK
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
|
||||
|
||||
#include "../../_Shared/Headers/HMain.hlsl"
|
||||
#include "../../_Shared/Headers/HSpaceTransforms.hlsl"
|
||||
#include "../../_Shared/Includes/FallbackAPV.hlsl"
|
||||
|
||||
H_TEXTURE(_HTraceBufferGI);
|
||||
|
||||
uint _MetallicIndirectFallback;
|
||||
uint _ExcludeReceivingLayerMaskSSGI;
|
||||
float _IndirectLightingIntensity;
|
||||
float4 _APVParams;
|
||||
|
||||
float4 FragmentStage(Varyings input) : SV_Target
|
||||
{
|
||||
uint2 pixCoord = input.TexCoord * _ScreenSize.xy;
|
||||
|
||||
if (HBUFFER_DEPTH(pixCoord) <= 1e-7) return 0;
|
||||
|
||||
float3 IndirectLighting = H_LOAD(_HTraceBufferGI, pixCoord).xyz;
|
||||
|
||||
// #if UNITY_VERSION >= 600000
|
||||
// // Restore indirect lighting on masked out objects
|
||||
// if (USE_RECEIVE_LAYER_MASK)
|
||||
// {
|
||||
// if (HBUFFER_RENDER_LAYER_MASK(input.TexCoord * _ScreenSize.xy) & _ExcludeReceivingLayerMaskSSGI)
|
||||
// {
|
||||
// float3 NormalCenterWS = HBUFFER_NORMAL_WS(pixCoord);
|
||||
// if (_EnableProbeVolumes)
|
||||
// {
|
||||
// float DepthCenter = HBUFFER_DEPTH(pixCoord);
|
||||
// float3 PositionCenterWS = H_COMPUTE_POSITION_WS(input.TexCoord, DepthCenter, H_MATRIX_I_VP);
|
||||
//
|
||||
// if (PROBE_VOLUMES_L1 || PROBE_VOLUMES_L2)
|
||||
// { IndirectLighting = EvaluateFallbackAPV(_APVParams, PositionCenterWS, NormalCenterWS, H_GET_VIEW_DIRECTION_WS(PositionCenterWS), pixCoord); }
|
||||
// }
|
||||
// else
|
||||
// IndirectLighting = EvaluateFallbackSky(NormalCenterWS);
|
||||
// }
|
||||
// }
|
||||
// #endif
|
||||
float4 GBuffer0 = H_LOAD(g_HTraceGBuffer0, pixCoord);
|
||||
float4 Gbuffer1 = H_LOAD(g_HTraceGBuffer1, pixCoord);
|
||||
|
||||
// This works reliably only with Render Graph, so we'll use Unity's _ScreenSpaceOcclusionTexture texture directly here
|
||||
// float SSAO = H_SAMPLE(g_HTraceSSAO, H_SAMPLER_POINT_CLAMP, input.TexCoord);
|
||||
float SSAO = _AmbientOcclusionParam.x == 0 ? 1 : H_SAMPLE(_ScreenSpaceOcclusionTexture, H_SAMPLER_POINT_CLAMP, input.TexCoord).x;
|
||||
|
||||
float Metallic = _MetallicIndirectFallback ? 0 : MetallicFromReflectivity(ReflectivitySpecular(Gbuffer1.rgb));
|
||||
float3 FinalIndirectLighting = IndirectLighting * _IndirectLightingIntensity * GBuffer0.rgb * Gbuffer1.a * (1 - Metallic) * SSAO;
|
||||
if (AnyIsNaN(FinalIndirectLighting))
|
||||
FinalIndirectLighting = 0;
|
||||
|
||||
return float4(FinalIndirectLighting, 1);
|
||||
}
|
||||
|
||||
ENDHLSL
|
||||
}
|
||||
}
|
||||
}
|
||||
10
Assets/External/HTraceWSGI/Resources/HTraceWSGI/URP/Shaders/ColorComposeURP.shader.meta
vendored
Normal file
10
Assets/External/HTraceWSGI/Resources/HTraceWSGI/URP/Shaders/ColorComposeURP.shader.meta
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1fa31432553d47d5a7b5be6bc675e199
|
||||
timeCreated: 1760460287
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 379716
|
||||
packageName: 'HTrace: World Space Global Illumination URP | Beta'
|
||||
packageVersion: 0.9.6
|
||||
assetPath: Assets/HTraceWSGI/Resources/HTraceWSGI/URP/Shaders/ColorComposeURP.shader
|
||||
uploadId: 925118
|
||||
360
Assets/External/HTraceWSGI/Resources/HTraceWSGI/URP/Shaders/LightClusterVisualizationURP.shader
vendored
Normal file
360
Assets/External/HTraceWSGI/Resources/HTraceWSGI/URP/Shaders/LightClusterVisualizationURP.shader
vendored
Normal file
@ -0,0 +1,360 @@
|
||||
Shader "Hidden/HTraceWSGI/LightClusterVisualizationURP"
|
||||
{
|
||||
SubShader
|
||||
{
|
||||
//Tags { "RenderPipeline" = "HDRenderPipeline" "Queue"="Transparent+0" "IgnoreProjector"="True" "RenderType"="Transparent" }
|
||||
|
||||
HLSLINCLUDE
|
||||
|
||||
static const float3 CubeVertices[24] =
|
||||
{
|
||||
// Bottom Face
|
||||
float3(0.0, 0.0, 0.0),
|
||||
float3(0.0, 1.0, 0.0),
|
||||
float3(1.0, 1.0, 0.0),
|
||||
float3(1.0, 0.0, 0.0),
|
||||
|
||||
// Left Face
|
||||
float3(0.0, 0.0, 0.0),
|
||||
float3(1.0, 0.0, 0.0),
|
||||
float3(1.0, 0.0, 1.0),
|
||||
float3(0.0, 0.0, 1.0),
|
||||
|
||||
// Front Face
|
||||
float3(1.0, 0.0, 0.0),
|
||||
float3(1.0, 1.0, 0.0),
|
||||
float3(1.0, 1.0, 1.0),
|
||||
float3(1.0, 0.0, 1.0),
|
||||
|
||||
// Right Face
|
||||
float3(0.0, 1.0, 0.0),
|
||||
float3(0.0, 1.0, 1.0),
|
||||
float3(1.0, 1.0, 1.0),
|
||||
float3(1.0, 1.0, 0.0),
|
||||
|
||||
// Back Face
|
||||
float3(0.0, 0.0, 0.0),
|
||||
float3(0.0, 0.0, 1.0),
|
||||
float3(0.0, 1.0, 1.0),
|
||||
float3(0.0, 1.0, 0.0),
|
||||
|
||||
// Top Face
|
||||
float3(0.0, 0.0, 1.0),
|
||||
float3(1.0, 0.0, 1.0),
|
||||
float3(1.0, 1.0, 1.0),
|
||||
float3(0.0, 1.0, 1.0)
|
||||
};
|
||||
|
||||
static const int CubeLines[48] =
|
||||
{
|
||||
// Bottom Face
|
||||
0, 1, 1, 2, 2, 3, 3, 0,
|
||||
|
||||
// Left Face
|
||||
4, 5, 5, 6, 6, 7, 7, 4,
|
||||
|
||||
// Front Face
|
||||
8, 9, 9, 10, 10, 11, 11, 8,
|
||||
|
||||
// Right Face
|
||||
12, 13, 13, 14, 14, 15, 15, 12,
|
||||
|
||||
// Back Face
|
||||
16, 17, 17, 18, 18, 19, 19, 16,
|
||||
|
||||
// Top Face
|
||||
20, 21, 21, 22, 22, 23, 23, 20
|
||||
};
|
||||
|
||||
static const int CubeTriangles[36] =
|
||||
{
|
||||
// Bottom Face
|
||||
0, 1, 2, 2, 3, 0,
|
||||
|
||||
// Left Face
|
||||
4, 5, 6, 4, 6, 7,
|
||||
|
||||
// Front Face
|
||||
8, 9, 10, 8, 10, 11,
|
||||
|
||||
// Right Face
|
||||
12, 13, 14, 12, 14, 15,
|
||||
|
||||
// Back Face
|
||||
16, 17, 18, 16, 18, 19,
|
||||
|
||||
// Top Face
|
||||
20, 21, 22, 20, 22, 23
|
||||
};
|
||||
|
||||
|
||||
ENDHLSL
|
||||
|
||||
Pass
|
||||
{
|
||||
Name "Cell Debug Color"
|
||||
|
||||
Cull Back
|
||||
ZWrite Off
|
||||
Blend One One
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma vertex CubeVertexStage
|
||||
#pragma fragment CubeFragmentStage
|
||||
|
||||
#include "../../_Shared/Headers/HMain.hlsl"
|
||||
#include "../../_Shared/Includes/LightCluster.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/RealtimeLights.hlsl"
|
||||
|
||||
StructuredBuffer<uint> _LightClusterCounterBuffer;
|
||||
StructuredBuffer<uint> _LightClusterIndexesBuffer;
|
||||
|
||||
struct AttributesDefault
|
||||
{
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct VaryingsDefault
|
||||
{
|
||||
float4 positionCS : SV_POSITION;
|
||||
float4 PositionNDC : TEXCOORD0;
|
||||
float3 CellColor : TEXCOORD1;
|
||||
uint CellCount : TEXCOORD2;
|
||||
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
VaryingsDefault CubeVertexStage(AttributesDefault Attributes, uint vertexID : SV_VertexID, uint instanceID: SV_InstanceID)
|
||||
{
|
||||
VaryingsDefault Output;
|
||||
UNITY_SETUP_INSTANCE_ID(Attributes);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
|
||||
|
||||
float3 PositionOS = CubeVertices[CubeTriangles[vertexID % 48]] * g_LightCluterCellSize;
|
||||
float3 PositionRWS = TransformObjectToWorld(PositionOS);
|
||||
|
||||
uint X = instanceID % g_LightClusterDimensions.x;
|
||||
uint Y = (instanceID / g_LightClusterDimensions.x) % g_LightClusterDimensions.y;
|
||||
uint Z = instanceID / (g_LightClusterDimensions.x * g_LightClusterDimensions.y);
|
||||
uint CellIndex = GetFlattenedIndex(uint3(X, Y, Z));
|
||||
|
||||
PositionRWS += g_MinLightClusterPosition + float3(g_LightCluterCellSize.x * X, g_LightCluterCellSize.y * Y, g_LightCluterCellSize.z * Z);
|
||||
|
||||
float3 CellLightColor = 0;
|
||||
uint CellLightCount = _LightClusterCounterBuffer[CellIndex];
|
||||
|
||||
// Accumulate all light colors within the cell
|
||||
for (uint i = 0; i < CellLightCount; i++)
|
||||
{
|
||||
uint LightIndex = _LightClusterIndexesBuffer[CellIndex * g_MaxLightsPerCell + i];
|
||||
float3 PunctualLightColor = _AdditionalLightsColor[LightIndex].xyz;
|
||||
float4 PunctualLightAtten = _AdditionalLightsAttenuation[LightIndex];
|
||||
float PunctualLightRange = 1.0 / sqrt(PunctualLightAtten.x);
|
||||
|
||||
float MaxLightColor = max(PunctualLightColor.r, max(PunctualLightColor.g, PunctualLightColor.b));
|
||||
float3 LightColor = (MaxLightColor > 0) ? PunctualLightColor / MaxLightColor : float3(0,0,0);
|
||||
|
||||
CellLightColor += LightColor * lerp(0.1, 0.025, saturate(PunctualLightRange / (g_LightCluterCellSize.x * 10)));
|
||||
}
|
||||
|
||||
if (CellLightCount > 0)
|
||||
CellLightColor /= float(CellLightCount);
|
||||
|
||||
Output.CellCount = CellLightCount;
|
||||
Output.CellColor = CellLightColor;
|
||||
Output.positionCS = TransformWorldToHClip(PositionRWS);
|
||||
Output.PositionNDC = float4(H_COMPUTE_NDC_Z(PositionRWS, UNITY_MATRIX_VP), 1);
|
||||
return Output;
|
||||
}
|
||||
|
||||
float4 CubeFragmentStage(VaryingsDefault Input) : SV_Target
|
||||
{
|
||||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(varying);
|
||||
|
||||
// Cull against scene depth
|
||||
if (Input.PositionNDC.z < HBUFFER_DEPTH(Input.positionCS.xy).x)
|
||||
return 0;
|
||||
|
||||
if (g_HeatmapDebug)
|
||||
{
|
||||
if (Input.CellCount == 0) return 0;
|
||||
if (Input.CellCount == 1) return float4(0,0.035,0,1);
|
||||
if (Input.CellCount == g_MaxLightsPerCell) return float4(1,0,0,1);
|
||||
|
||||
float3 CellHeat = lerp(float3(0,0.035,0), float3(0.15,0,0), float(Input.CellCount) / float(g_MaxLightsPerCell));
|
||||
return float4(CellHeat, 1);
|
||||
}
|
||||
|
||||
return float4(Input.CellColor.xyz, 1.0);
|
||||
}
|
||||
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
Pass
|
||||
{
|
||||
Name "Cell Debug Depth"
|
||||
|
||||
Cull Back
|
||||
ZWrite On
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma vertex CubeVertexStage
|
||||
#pragma fragment CubeFragmentStage
|
||||
|
||||
#include "../../_Shared/Headers/HMain.hlsl"
|
||||
#include "../../_Shared/Includes/LightCluster.hlsl"
|
||||
|
||||
StructuredBuffer<uint> _LightClusterDebugBuffer;
|
||||
|
||||
struct AttributesDefault
|
||||
{
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct VaryingsDefault
|
||||
{
|
||||
float4 PositionCS : SV_POSITION;
|
||||
float4 PositionNDC : TEXCOORD0;
|
||||
float CellCulling : TEXCOORD1;
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
VaryingsDefault CubeVertexStage(AttributesDefault Attributes, uint vertexID : SV_VertexID, uint instanceID: SV_InstanceID)
|
||||
{
|
||||
VaryingsDefault Output;
|
||||
UNITY_SETUP_INSTANCE_ID(Attributes);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
|
||||
|
||||
float3 PositionOS = CubeVertices[CubeTriangles[vertexID % 48]] * g_LightCluterCellSize;
|
||||
float3 PositionRWS = TransformObjectToWorld(PositionOS);
|
||||
|
||||
uint X = instanceID % g_LightClusterDimensions.x;
|
||||
uint Y = (instanceID / g_LightClusterDimensions.x) % g_LightClusterDimensions.y;
|
||||
uint Z = instanceID / (g_LightClusterDimensions.x * g_LightClusterDimensions.y);
|
||||
uint CellIndex = GetFlattenedIndex(uint3(X, Y, Z));
|
||||
|
||||
PositionRWS += g_MinLightClusterPosition + float3(g_LightCluterCellSize.x * X, g_LightCluterCellSize.y * Y, g_LightCluterCellSize.z * Z);
|
||||
|
||||
// Load edge cells filled earlier by the compute shader
|
||||
Output.CellCulling = _LightClusterDebugBuffer[CellIndex];
|
||||
Output.PositionCS = TransformWorldToHClip(PositionRWS);
|
||||
Output.PositionNDC = float4(H_COMPUTE_NDC_Z(PositionRWS, UNITY_MATRIX_VP), 1);
|
||||
return Output;
|
||||
}
|
||||
|
||||
void CubeFragmentStage(VaryingsDefault Input, out float OutDepth : SV_Depth)
|
||||
{
|
||||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(Input);
|
||||
|
||||
// Output Depth of the cells that survived culling in the vertex stage
|
||||
OutDepth = Input.PositionNDC.z * Input.CellCulling;
|
||||
}
|
||||
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
Pass
|
||||
{
|
||||
Name "Cell Debug Line"
|
||||
|
||||
Cull Back
|
||||
ZWrite Off
|
||||
Blend One One
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma vertex LineVertexStage
|
||||
#pragma fragment LineFragmentStage
|
||||
|
||||
StructuredBuffer<uint> _LightClusterCounterBuffer;
|
||||
StructuredBuffer<uint> _LightClusterIndexesBuffer;
|
||||
|
||||
#include "../../_Shared/Headers/HMain.hlsl"
|
||||
#include "../../_Shared/Includes/LightCluster.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/RealtimeLights.hlsl"
|
||||
|
||||
H_TEXTURE(_LightClusterDebugDepth);
|
||||
|
||||
struct AttributesDefault
|
||||
{
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct VaryingsDefault
|
||||
{
|
||||
float4 positionCS : SV_POSITION;
|
||||
float4 PositionNDC : TEXCOORD0;
|
||||
float3 CellColor : TEXCOORD1;
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
VaryingsDefault LineVertexStage(AttributesDefault Attributes, uint vertexID : SV_VertexID, uint instanceID: SV_InstanceID)
|
||||
{
|
||||
VaryingsDefault Output;
|
||||
UNITY_SETUP_INSTANCE_ID(Attributes);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
|
||||
|
||||
float3 PositionOS = CubeVertices[CubeLines[vertexID % 48]] * g_LightCluterCellSize;
|
||||
float3 PositionRWS = TransformObjectToWorld(PositionOS);
|
||||
|
||||
uint X = instanceID % g_LightClusterDimensions.x;
|
||||
uint Y = (instanceID / g_LightClusterDimensions.x) % g_LightClusterDimensions.y;
|
||||
uint Z = instanceID / (g_LightClusterDimensions.x * g_LightClusterDimensions.y);
|
||||
uint CellIndex = GetFlattenedIndex(uint3(X, Y, Z));
|
||||
|
||||
PositionRWS += g_MinLightClusterPosition + float3(g_LightCluterCellSize.x * X, g_LightCluterCellSize.y * Y, g_LightCluterCellSize.z * Z);
|
||||
|
||||
float3 CellLightColor = 0;
|
||||
uint CellLightCount = _LightClusterCounterBuffer[CellIndex];
|
||||
|
||||
// Accumulate all light colors within the cell
|
||||
for (uint i = 0; i < CellLightCount; i++)
|
||||
{
|
||||
uint LightIndex = _LightClusterIndexesBuffer[CellIndex * g_MaxLightsPerCell + i];
|
||||
float3 PunctualLightColor = _AdditionalLightsColor[LightIndex].xyz;
|
||||
|
||||
float MaxLightColor = max(PunctualLightColor.r, max(PunctualLightColor.g, PunctualLightColor.b));
|
||||
float3 LightColor = (MaxLightColor > 0) ? PunctualLightColor / MaxLightColor : float3(0,0,0);
|
||||
|
||||
CellLightColor += LightColor;
|
||||
}
|
||||
|
||||
if (CellLightCount > 0)
|
||||
CellLightColor /= float(CellLightCount);
|
||||
|
||||
float DistanceMultiplier = length(H_GET_CAMERA_POSITION_WS() - H_GET_ABSOLUTE_POSITION_WS(PositionRWS));
|
||||
DistanceMultiplier = lerp(0.1f, 0.025f, saturate(DistanceMultiplier / 50.0f));
|
||||
|
||||
Output.CellColor = CellLightColor * DistanceMultiplier;
|
||||
Output.positionCS = TransformWorldToHClip(PositionRWS);
|
||||
Output.PositionNDC = float4(H_COMPUTE_NDC_Z(PositionRWS, UNITY_MATRIX_VP), 1);
|
||||
return Output;
|
||||
}
|
||||
|
||||
float4 LineFragmentStage(VaryingsDefault Input) : SV_Target
|
||||
{
|
||||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(varying);
|
||||
|
||||
float SceneDepth = HBUFFER_DEPTH(Input.positionCS.xy);
|
||||
float CellDepth = H_LOAD(_LightClusterDebugDepth, Input.positionCS.xy).x;
|
||||
float3 CellSize = (g_MaxLightClusterPosition - g_MinLightClusterPosition) / float3(g_LightClusterDimensions);
|
||||
|
||||
// Cull against cell depth
|
||||
if (abs(H_LINEAR_EYE_DEPTH(CellDepth) - H_LINEAR_EYE_DEPTH(Input.PositionNDC.z)) > min(CellSize.x, 0.0025 * H_LINEAR_EYE_DEPTH(Input.PositionNDC.z)))
|
||||
return 0;
|
||||
|
||||
// Cull against scene depth
|
||||
if (Input.PositionNDC.z < SceneDepth)
|
||||
return 0;
|
||||
|
||||
if (g_HeatmapDebug)
|
||||
return float4(0.5,0,0,1);
|
||||
|
||||
return float4(Input.CellColor.xyz, 1.0);
|
||||
}
|
||||
|
||||
ENDHLSL
|
||||
}
|
||||
}
|
||||
Fallback Off
|
||||
}
|
||||
@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2991b564835a4e03b8f03b88f34d0bc6
|
||||
timeCreated: 1763045222
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 379716
|
||||
packageName: 'HTrace: World Space Global Illumination URP | Beta'
|
||||
packageVersion: 0.9.6
|
||||
assetPath: Assets/HTraceWSGI/Resources/HTraceWSGI/URP/Shaders/LightClusterVisualizationURP.shader
|
||||
uploadId: 925118
|
||||
231
Assets/External/HTraceWSGI/Resources/HTraceWSGI/URP/Shaders/MotionVectorsURP.shader
vendored
Normal file
231
Assets/External/HTraceWSGI/Resources/HTraceWSGI/URP/Shaders/MotionVectorsURP.shader
vendored
Normal file
@ -0,0 +1,231 @@
|
||||
Shader "Hidden/HTraceWSGI/MotionVectorsURP"
|
||||
{
|
||||
SubShader
|
||||
{
|
||||
Pass
|
||||
{
|
||||
Name "Camera Motion Vectors"
|
||||
|
||||
Cull Off
|
||||
ZWrite Off
|
||||
|
||||
HLSLPROGRAM
|
||||
|
||||
#pragma vertex VertexStage
|
||||
#pragma fragment FragmentStage
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DeclareDepthTexture.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/UnityInput.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/FoveatedRendering.hlsl"
|
||||
#include "../../_Shared/Headers/HMain.hlsl"
|
||||
|
||||
H_TEXTURE(_ObjectMotionVectors);
|
||||
H_TEXTURE(_ObjectMotionVectorsDepth);
|
||||
|
||||
float _BiasOffset;
|
||||
|
||||
struct Attributes
|
||||
{
|
||||
uint VertexID : SV_VertexID;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct Varyings
|
||||
{
|
||||
float4 PositionCS : SV_POSITION;
|
||||
float2 TexCoord : TEXCOORD0;
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
struct FragOutput
|
||||
{
|
||||
float2 MotionVectors : SV_Target0;
|
||||
float Mask : SV_Target1;
|
||||
};
|
||||
|
||||
Varyings VertexStage(Attributes Input)
|
||||
{
|
||||
Varyings Output;
|
||||
UNITY_SETUP_INSTANCE_ID(Input);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
|
||||
|
||||
Output.PositionCS = GetFullScreenTriangleVertexPosition(Input.VertexID);
|
||||
Output.TexCoord = GetFullScreenTriangleTexCoord(Input.VertexID);
|
||||
|
||||
return Output;
|
||||
}
|
||||
|
||||
FragOutput FragmentStage(Varyings Input)
|
||||
{
|
||||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input);
|
||||
FragOutput Output = (FragOutput)0;
|
||||
|
||||
float2 ObjectMotionVectorsColor = H_LOAD(_ObjectMotionVectors, Input.PositionCS.xy).xy;
|
||||
float ObjectMotionVectorsDepth = H_LOAD(_ObjectMotionVectorsDepth, Input.PositionCS.xy).x;
|
||||
float CameraDepth = LoadSceneDepth(Input.PositionCS.xy);
|
||||
|
||||
#if !UNITY_REVERSED_Z
|
||||
CameraDepth = lerp(UNITY_NEAR_CLIP_VALUE, 1, LoadSceneDepth(Input.PositionCS.xy).x);
|
||||
#endif
|
||||
|
||||
if (ObjectMotionVectorsDepth >= CameraDepth + _BiasOffset)
|
||||
{
|
||||
Output.MotionVectors = ObjectMotionVectorsColor;
|
||||
Output.Mask = 1;
|
||||
return Output;
|
||||
}
|
||||
|
||||
// Reconstruct world position
|
||||
float3 PositionWS = ComputeWorldSpacePosition(Input.PositionCS.xy * _ScreenSize.zw, CameraDepth, UNITY_MATRIX_I_VP);
|
||||
|
||||
// Multiply with current and previous non-jittered view projection
|
||||
float4 PositionCS = mul(H_MATRIX_VP, float4(PositionWS.xyz, 1.0));
|
||||
float4 PreviousPositionCS = mul(H_MATRIX_PREV_VP, float4(PositionWS.xyz, 1.0));
|
||||
|
||||
// Non-uniform raster needs to keep the posNDC values in float to avoid additional conversions
|
||||
// since uv remap functions use floats
|
||||
float2 PositionNDC = PositionCS.xy * rcp(PositionCS.w);
|
||||
float2 PreviousPositionNDC = PreviousPositionCS.xy * rcp(PreviousPositionCS.w);
|
||||
|
||||
// Calculate forward velocity
|
||||
float2 Velocity = (PositionNDC - PreviousPositionNDC);
|
||||
|
||||
// TODO: test that velocity.y is correct
|
||||
#if UNITY_UV_STARTS_AT_TOP
|
||||
Velocity.y = -Velocity.y;
|
||||
#endif
|
||||
|
||||
// Convert velocity from NDC space (-1..1) to screen UV 0..1 space
|
||||
// Note: It doesn't mean we don't have negative values, we store negative or positive offset in the UV space.
|
||||
// Note: ((posNDC * 0.5 + 0.5) - (prevPosNDC * 0.5 + 0.5)) = (velocity * 0.5)
|
||||
Velocity.xy *= 0.5;
|
||||
|
||||
Output.MotionVectors = Velocity;
|
||||
Output.Mask = 0;
|
||||
|
||||
return Output;
|
||||
}
|
||||
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
|
||||
Pass
|
||||
{
|
||||
Name "Object Motion Vectors"
|
||||
|
||||
Tags { "LightMode" = "MotionVectors" }
|
||||
|
||||
HLSLPROGRAM
|
||||
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma multi_compile_instancing
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/UnityInput.hlsl"
|
||||
#include "../../_Shared/Headers/HMain.hlsl"
|
||||
|
||||
#ifndef HAVE_VFX_MODIFICATION
|
||||
#pragma multi_compile _ DOTS_INSTANCING_ON
|
||||
#if UNITY_PLATFORM_ANDROID || UNITY_PLATFORM_WEBGL || UNITY_PLATFORM_UWP
|
||||
#pragma target 3.5 DOTS_INSTANCING_ON
|
||||
#else
|
||||
#pragma target 4.5 DOTS_INSTANCING_ON
|
||||
#endif
|
||||
#endif
|
||||
|
||||
struct Attributes
|
||||
{
|
||||
float4 Position : POSITION;
|
||||
float3 PositionOld : TEXCOORD4;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct Varyings
|
||||
{
|
||||
float4 PositionCS : SV_POSITION;
|
||||
float4 PositionCSNoJitter : TEXCOORD0;
|
||||
float4 PreviousPositionCSNoJitter : TEXCOORD1;
|
||||
float MotionMask : TEXCOORD2;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
Varyings vert(Attributes Input)
|
||||
{
|
||||
UNITY_SETUP_INSTANCE_ID(Input);
|
||||
Varyings Output = (Varyings)0;
|
||||
UNITY_TRANSFER_INSTANCE_ID(Input, Output);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(Output);
|
||||
|
||||
VertexPositionInputs VertexInput = GetVertexPositionInputs(Input.Position.xyz);
|
||||
|
||||
// Jittered. Match the frame.
|
||||
Output.PositionCS = VertexInput.positionCS;
|
||||
|
||||
// This is required to avoid artifacts ("gaps" in the _MotionVectorTexture) on some platforms
|
||||
#if defined(UNITY_REVERSED_Z)
|
||||
Output.PositionCS.z -= unity_MotionVectorsParams.z * Output.PositionCS.w;
|
||||
#else
|
||||
Output.PositionCS.z += unity_MotionVectorsParams.z * Output.PositionCS.w;
|
||||
#endif
|
||||
|
||||
const float4 PreviousPosition = (unity_MotionVectorsParams.x == 1) ? float4(Input.PositionOld, 1) : Input.Position;
|
||||
const float4 PositionWS = mul(UNITY_MATRIX_M, Input.Position);
|
||||
const float4 PreviousPositionWS = mul(UNITY_PREV_MATRIX_M, PreviousPosition);
|
||||
|
||||
Output.PositionCSNoJitter = mul(H_MATRIX_VP, PositionWS);
|
||||
Output.PreviousPositionCSNoJitter = mul(H_MATRIX_PREV_VP, PreviousPositionWS);
|
||||
Output.MotionMask = length(PositionWS - PreviousPositionWS) > 0.0001 ? 1 : 0;
|
||||
|
||||
return Output;
|
||||
}
|
||||
|
||||
struct FragOutput
|
||||
{
|
||||
float2 MotionVectors : SV_Target0;
|
||||
float Mask : SV_Target1;
|
||||
};
|
||||
|
||||
FragOutput frag(Varyings Input)
|
||||
{
|
||||
UNITY_SETUP_INSTANCE_ID(Input);
|
||||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(Input);
|
||||
FragOutput Output = (FragOutput)0;
|
||||
|
||||
// Note: unity_MotionVectorsParams.y is 0 is forceNoMotion is enabled
|
||||
bool ForceNoMotion = unity_MotionVectorsParams.y == 0.0;
|
||||
if (ForceNoMotion)
|
||||
{
|
||||
Output.MotionVectors = 0;
|
||||
Output.Mask = 0;
|
||||
return Output;
|
||||
}
|
||||
|
||||
// Calculate positions
|
||||
float4 PositionCS = Input.PositionCSNoJitter;
|
||||
float4 PreviousPositionCS = Input.PreviousPositionCSNoJitter;
|
||||
|
||||
float2 PositionNDC = PositionCS.xy * rcp(PositionCS.w);
|
||||
float2 PreviousPositionNDC = PreviousPositionCS.xy * rcp(PreviousPositionCS.w);
|
||||
|
||||
float2 Velocity = (PositionNDC.xy - PreviousPositionNDC.xy);
|
||||
#if UNITY_UV_STARTS_AT_TOP
|
||||
Velocity.y = -Velocity.y;
|
||||
#endif
|
||||
|
||||
// Convert velocity from NDC space (-1..1) to UV 0..1 space
|
||||
// Note: It doesn't mean we don't have negative values, we store negative or positive offset in UV space.
|
||||
// Note: ((posNDC * 0.5 + 0.5) - (prevPosNDC * 0.5 + 0.5)) = (velocity * 0.5)
|
||||
Velocity.xy *= 0.5;
|
||||
|
||||
Output.MotionVectors = Velocity;
|
||||
Output.Mask = Input.MotionMask;
|
||||
return Output;
|
||||
}
|
||||
ENDHLSL
|
||||
}
|
||||
}
|
||||
}
|
||||
16
Assets/External/HTraceWSGI/Resources/HTraceWSGI/URP/Shaders/MotionVectorsURP.shader.meta
vendored
Normal file
16
Assets/External/HTraceWSGI/Resources/HTraceWSGI/URP/Shaders/MotionVectorsURP.shader.meta
vendored
Normal file
@ -0,0 +1,16 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6f7f91bedc42bda418c5a03b4b7e3f2a
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 379716
|
||||
packageName: 'HTrace: World Space Global Illumination URP | Beta'
|
||||
packageVersion: 0.9.6
|
||||
assetPath: Assets/HTraceWSGI/Resources/HTraceWSGI/URP/Shaders/MotionVectorsURP.shader
|
||||
uploadId: 925118
|
||||
64
Assets/External/HTraceWSGI/Resources/HTraceWSGI/URP/Shaders/ShadowmapURP.shader
vendored
Normal file
64
Assets/External/HTraceWSGI/Resources/HTraceWSGI/URP/Shaders/ShadowmapURP.shader
vendored
Normal file
@ -0,0 +1,64 @@
|
||||
Shader "Hidden/HTraceWSGI/ShadowmapURP"
|
||||
{
|
||||
SubShader
|
||||
{
|
||||
HLSLINCLUDE
|
||||
|
||||
#pragma target 4.5
|
||||
#pragma multi_compile_instancing
|
||||
#pragma multi_compile _ DOTS_INSTANCING_ON
|
||||
|
||||
ENDHLSL
|
||||
|
||||
Pass
|
||||
{
|
||||
Name "SHADOWMAP_COPY"
|
||||
|
||||
Blend Off
|
||||
ZTest LEqual
|
||||
Cull Back
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma vertex FullScreenVert
|
||||
#pragma fragment FullScreenFrag
|
||||
|
||||
#include "../../_Shared/Headers/HMain.hlsl"
|
||||
|
||||
|
||||
H_TEXTURE_DX(float, _DirectionalShadowmapStatic);
|
||||
|
||||
struct FullScreenAttributes
|
||||
{
|
||||
uint vertexID : SV_VertexID;
|
||||
};
|
||||
|
||||
struct FullScreenVaryings
|
||||
{
|
||||
float4 positionCS : SV_POSITION;
|
||||
};
|
||||
|
||||
struct Attributes
|
||||
{
|
||||
uint vertexID : SV_VertexID;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
FullScreenVaryings FullScreenVert(Attributes input)
|
||||
{
|
||||
FullScreenVaryings output;
|
||||
output.positionCS = GetFullScreenTriangleVertexPosition(input.vertexID, UNITY_RAW_FAR_CLIP_VALUE);
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
|
||||
float FullScreenFrag(FullScreenVaryings varyings, out float Depth_Output : SV_Depth) : SV_Target
|
||||
{
|
||||
Depth_Output = H_LOAD(_DirectionalShadowmapStatic, varyings.positionCS.xy).x;
|
||||
return 0;
|
||||
}
|
||||
|
||||
ENDHLSL
|
||||
}
|
||||
}
|
||||
}
|
||||
10
Assets/External/HTraceWSGI/Resources/HTraceWSGI/URP/Shaders/ShadowmapURP.shader.meta
vendored
Normal file
10
Assets/External/HTraceWSGI/Resources/HTraceWSGI/URP/Shaders/ShadowmapURP.shader.meta
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c3a0cd0caf5f43149c1e3177309b8223
|
||||
timeCreated: 1764077361
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 379716
|
||||
packageName: 'HTrace: World Space Global Illumination URP | Beta'
|
||||
packageVersion: 0.9.6
|
||||
assetPath: Assets/HTraceWSGI/Resources/HTraceWSGI/URP/Shaders/ShadowmapURP.shader
|
||||
uploadId: 925118
|
||||
83
Assets/External/HTraceWSGI/Resources/HTraceWSGI/URP/Shaders/VoxelVisualizationURP.shader
vendored
Normal file
83
Assets/External/HTraceWSGI/Resources/HTraceWSGI/URP/Shaders/VoxelVisualizationURP.shader
vendored
Normal file
@ -0,0 +1,83 @@
|
||||
Shader "Hidden/HTraceWSGI/VoxelVisualizationURP"
|
||||
{
|
||||
SubShader
|
||||
{
|
||||
HLSLINCLUDE
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/FoveatedRendering.hlsl"
|
||||
|
||||
float4x4 _DebugCameraFrustum;
|
||||
float4 _DebugCameraFrustumArray[8];
|
||||
|
||||
struct Attributes
|
||||
{
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
uint VertexID : SV_VertexID;
|
||||
};
|
||||
|
||||
|
||||
struct FullScreenVaryings
|
||||
{
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
float4 positionCS : SV_POSITION;
|
||||
float3 ray : TEXCOORD0;
|
||||
};
|
||||
|
||||
|
||||
ENDHLSL
|
||||
|
||||
Pass
|
||||
{
|
||||
Name "Copy Color Buffer"
|
||||
|
||||
ZWrite Off
|
||||
ZTest Always
|
||||
Blend SrcAlpha OneMinusSrcAlpha
|
||||
Cull Off
|
||||
|
||||
HLSLPROGRAM
|
||||
|
||||
#pragma vertex FullScreenVert
|
||||
#pragma fragment FragmentStage
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DeclareDepthTexture.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/UnityInput.hlsl"
|
||||
#include "../../_Shared/Headers/HMain.hlsl"
|
||||
|
||||
FullScreenVaryings FullScreenVert(Attributes input)
|
||||
{
|
||||
FullScreenVaryings output;
|
||||
UNITY_SETUP_INSTANCE_ID(input);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
|
||||
|
||||
float4 PositionCS = GetFullScreenTriangleVertexPosition(input.VertexID, UNITY_RAW_FAR_CLIP_VALUE);
|
||||
output.positionCS = PositionCS;
|
||||
|
||||
PositionCS = PositionCS * 0.5 + 0.5;
|
||||
int index = (PositionCS.x / 2.0f) + PositionCS.y;
|
||||
|
||||
|
||||
output.ray = (_DebugCameraFrustum[index].xyz);
|
||||
// output.ray = ( _DebugCameraFrustumArray[0 * 4 + vertexID].xyz);
|
||||
return output;
|
||||
}
|
||||
|
||||
|
||||
float4 FragmentStage(FullScreenVaryings input) : SV_Target
|
||||
{
|
||||
float3 Test = HBUFFER_DEPTH(input.positionCS.xy);
|
||||
// return float4(Test, 1);
|
||||
|
||||
// UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(FullScreenVaryings);
|
||||
return float4(input.ray, 1);
|
||||
}
|
||||
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
16
Assets/External/HTraceWSGI/Resources/HTraceWSGI/URP/Shaders/VoxelVisualizationURP.shader.meta
vendored
Normal file
16
Assets/External/HTraceWSGI/Resources/HTraceWSGI/URP/Shaders/VoxelVisualizationURP.shader.meta
vendored
Normal file
@ -0,0 +1,16 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e492117e834a6544a875878581bb0c4a
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 379716
|
||||
packageName: 'HTrace: World Space Global Illumination URP | Beta'
|
||||
packageVersion: 0.9.6
|
||||
assetPath: Assets/HTraceWSGI/Resources/HTraceWSGI/URP/Shaders/VoxelVisualizationURP.shader
|
||||
uploadId: 925118
|
||||
33
Assets/External/HTraceWSGI/Resources/HTraceWSGI/URP/Shaders/VoxelizationURP.shader
vendored
Normal file
33
Assets/External/HTraceWSGI/Resources/HTraceWSGI/URP/Shaders/VoxelizationURP.shader
vendored
Normal file
@ -0,0 +1,33 @@
|
||||
Shader "Hidden/HTraceWSGI/VoxelizationURP"
|
||||
{
|
||||
SubShader
|
||||
{
|
||||
Pass
|
||||
{
|
||||
Name "HTrace Voxelization"
|
||||
Cull Off
|
||||
ZClip Off
|
||||
ZWrite Off
|
||||
Conservative False
|
||||
|
||||
HLSLPROGRAM
|
||||
|
||||
#pragma require geometry
|
||||
#pragma require randomwrite
|
||||
|
||||
#pragma multi_compile_instancing
|
||||
#pragma multi_compile _ DOTS_INSTANCING_ON
|
||||
#pragma multi_compile CONSTANT_VOXELIZATION PARTIAL_VOXELIZATION DYNAMIC_VOXELIZATION
|
||||
|
||||
#include "../../_Shared/Includes/VoxelizationStagesURP.hlsl"
|
||||
|
||||
#pragma vertex VoxelizationVert
|
||||
#pragma geometry VoxelizationGeom
|
||||
#pragma fragment VoxelizationFrag
|
||||
|
||||
ENDHLSL
|
||||
}
|
||||
}
|
||||
|
||||
Fallback Off
|
||||
}
|
||||
16
Assets/External/HTraceWSGI/Resources/HTraceWSGI/URP/Shaders/VoxelizationURP.shader.meta
vendored
Normal file
16
Assets/External/HTraceWSGI/Resources/HTraceWSGI/URP/Shaders/VoxelizationURP.shader.meta
vendored
Normal file
@ -0,0 +1,16 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e862d8907c85cbc4ea109bfe71614ea9
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 379716
|
||||
packageName: 'HTrace: World Space Global Illumination URP | Beta'
|
||||
packageVersion: 0.9.6
|
||||
assetPath: Assets/HTraceWSGI/Resources/HTraceWSGI/URP/Shaders/VoxelizationURP.shader
|
||||
uploadId: 925118
|
||||
BIN
Assets/External/HTraceWSGI/Resources/HTraceWSGI/Volume Profile HTrace WSGI URP.asset
(Stored with Git LFS)
vendored
Normal file
BIN
Assets/External/HTraceWSGI/Resources/HTraceWSGI/Volume Profile HTrace WSGI URP.asset
(Stored with Git LFS)
vendored
Normal file
Binary file not shown.
15
Assets/External/HTraceWSGI/Resources/HTraceWSGI/Volume Profile HTrace WSGI URP.asset.meta
vendored
Normal file
15
Assets/External/HTraceWSGI/Resources/HTraceWSGI/Volume Profile HTrace WSGI URP.asset.meta
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 354b90c2ceb7df149b2fc1d4fe328838
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 379716
|
||||
packageName: 'HTrace: World Space Global Illumination URP | Beta'
|
||||
packageVersion: 0.9.6
|
||||
assetPath: Assets/HTraceWSGI/Resources/HTraceWSGI/Volume Profile HTrace WSGI URP.asset
|
||||
uploadId: 925118
|
||||
3
Assets/External/HTraceWSGI/Resources/HTraceWSGI/_Shared.meta
vendored
Normal file
3
Assets/External/HTraceWSGI/Resources/HTraceWSGI/_Shared.meta
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 55fee9bbd30d4af79c883c6b5baeb500
|
||||
timeCreated: 1764080232
|
||||
3
Assets/External/HTraceWSGI/Resources/HTraceWSGI/_Shared/BlueNoise.meta
vendored
Normal file
3
Assets/External/HTraceWSGI/Resources/HTraceWSGI/_Shared/BlueNoise.meta
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bd0a5f0cd24c19145af4c7d02400ef5d
|
||||
timeCreated: 1747995745
|
||||
BIN
Assets/External/HTraceWSGI/Resources/HTraceWSGI/_Shared/BlueNoise/OwenScrambledNoise256.png
(Stored with Git LFS)
vendored
Normal file
BIN
Assets/External/HTraceWSGI/Resources/HTraceWSGI/_Shared/BlueNoise/OwenScrambledNoise256.png
(Stored with Git LFS)
vendored
Normal file
Binary file not shown.
134
Assets/External/HTraceWSGI/Resources/HTraceWSGI/_Shared/BlueNoise/OwenScrambledNoise256.png.meta
vendored
Normal file
134
Assets/External/HTraceWSGI/Resources/HTraceWSGI/_Shared/BlueNoise/OwenScrambledNoise256.png.meta
vendored
Normal file
@ -0,0 +1,134 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bcd52ea3c2ac332418c61d8e65a2c252
|
||||
TextureImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 13
|
||||
mipmaps:
|
||||
mipMapMode: 0
|
||||
enableMipMap: 0
|
||||
sRGBTexture: 0
|
||||
linearTexture: 0
|
||||
fadeOut: 0
|
||||
borderMipMap: 0
|
||||
mipMapsPreserveCoverage: 0
|
||||
alphaTestReferenceValue: 0.5
|
||||
mipMapFadeDistanceStart: 1
|
||||
mipMapFadeDistanceEnd: 3
|
||||
bumpmap:
|
||||
convertToNormalMap: 0
|
||||
externalNormalMap: 0
|
||||
heightScale: 0.25
|
||||
normalMapFilter: 0
|
||||
flipGreenChannel: 0
|
||||
isReadable: 0
|
||||
streamingMipmaps: 0
|
||||
streamingMipmapsPriority: 0
|
||||
vTOnly: 0
|
||||
ignoreMipmapLimit: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 6
|
||||
cubemapConvolution: 0
|
||||
seamlessCubemap: 0
|
||||
textureFormat: 1
|
||||
maxTextureSize: 2048
|
||||
textureSettings:
|
||||
serializedVersion: 2
|
||||
filterMode: 1
|
||||
aniso: 1
|
||||
mipBias: 0
|
||||
wrapU: 0
|
||||
wrapV: 0
|
||||
wrapW: 0
|
||||
nPOTScale: 1
|
||||
lightmap: 0
|
||||
compressionQuality: 50
|
||||
spriteMode: 0
|
||||
spriteExtrude: 1
|
||||
spriteMeshType: 1
|
||||
alignment: 0
|
||||
spritePivot: {x: 0.5, y: 0.5}
|
||||
spritePixelsToUnits: 100
|
||||
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||
spriteGenerateFallbackPhysicsShape: 1
|
||||
alphaUsage: 0
|
||||
alphaIsTransparency: 0
|
||||
spriteTessellationDetail: -1
|
||||
textureType: 0
|
||||
textureShape: 1
|
||||
singleChannelComponent: 0
|
||||
flipbookRows: 1
|
||||
flipbookColumns: 1
|
||||
maxTextureSizeSet: 0
|
||||
compressionQualitySet: 0
|
||||
textureFormatSet: 0
|
||||
ignorePngGamma: 0
|
||||
applyGammaDecoding: 0
|
||||
swizzle: 50462976
|
||||
cookieLightType: 0
|
||||
platformSettings:
|
||||
- serializedVersion: 3
|
||||
buildTarget: DefaultTexturePlatform
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: 3
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: Standalone
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: Server
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
spriteSheet:
|
||||
serializedVersion: 2
|
||||
sprites: []
|
||||
outline: []
|
||||
physicsShape: []
|
||||
bones: []
|
||||
spriteID:
|
||||
internalID: 0
|
||||
vertices: []
|
||||
indices:
|
||||
edges: []
|
||||
weights: []
|
||||
secondaryTextures: []
|
||||
nameFileIdTable: {}
|
||||
mipmapLimitGroupName:
|
||||
pSDRemoveMatte: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 379716
|
||||
packageName: 'HTrace: World Space Global Illumination URP | Beta'
|
||||
packageVersion: 0.9.6
|
||||
assetPath: Assets/HTraceWSGI/Resources/HTraceWSGI/_Shared/BlueNoise/OwenScrambledNoise256.png
|
||||
uploadId: 925118
|
||||
BIN
Assets/External/HTraceWSGI/Resources/HTraceWSGI/_Shared/BlueNoise/OwenScrambledNoise4.png
(Stored with Git LFS)
vendored
Normal file
BIN
Assets/External/HTraceWSGI/Resources/HTraceWSGI/_Shared/BlueNoise/OwenScrambledNoise4.png
(Stored with Git LFS)
vendored
Normal file
Binary file not shown.
134
Assets/External/HTraceWSGI/Resources/HTraceWSGI/_Shared/BlueNoise/OwenScrambledNoise4.png.meta
vendored
Normal file
134
Assets/External/HTraceWSGI/Resources/HTraceWSGI/_Shared/BlueNoise/OwenScrambledNoise4.png.meta
vendored
Normal file
@ -0,0 +1,134 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7105725bc431f7b4a9c36b57724d6c18
|
||||
TextureImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 13
|
||||
mipmaps:
|
||||
mipMapMode: 0
|
||||
enableMipMap: 0
|
||||
sRGBTexture: 0
|
||||
linearTexture: 0
|
||||
fadeOut: 0
|
||||
borderMipMap: 0
|
||||
mipMapsPreserveCoverage: 0
|
||||
alphaTestReferenceValue: 0.5
|
||||
mipMapFadeDistanceStart: 1
|
||||
mipMapFadeDistanceEnd: 3
|
||||
bumpmap:
|
||||
convertToNormalMap: 0
|
||||
externalNormalMap: 0
|
||||
heightScale: 0.25
|
||||
normalMapFilter: 0
|
||||
flipGreenChannel: 0
|
||||
isReadable: 0
|
||||
streamingMipmaps: 0
|
||||
streamingMipmapsPriority: 0
|
||||
vTOnly: 0
|
||||
ignoreMipmapLimit: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 6
|
||||
cubemapConvolution: 0
|
||||
seamlessCubemap: 0
|
||||
textureFormat: 1
|
||||
maxTextureSize: 2048
|
||||
textureSettings:
|
||||
serializedVersion: 2
|
||||
filterMode: 1
|
||||
aniso: 1
|
||||
mipBias: 0
|
||||
wrapU: 0
|
||||
wrapV: 0
|
||||
wrapW: 0
|
||||
nPOTScale: 1
|
||||
lightmap: 0
|
||||
compressionQuality: 50
|
||||
spriteMode: 0
|
||||
spriteExtrude: 1
|
||||
spriteMeshType: 1
|
||||
alignment: 0
|
||||
spritePivot: {x: 0.5, y: 0.5}
|
||||
spritePixelsToUnits: 100
|
||||
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||
spriteGenerateFallbackPhysicsShape: 1
|
||||
alphaUsage: 0
|
||||
alphaIsTransparency: 0
|
||||
spriteTessellationDetail: -1
|
||||
textureType: 0
|
||||
textureShape: 1
|
||||
singleChannelComponent: 0
|
||||
flipbookRows: 1
|
||||
flipbookColumns: 1
|
||||
maxTextureSizeSet: 0
|
||||
compressionQualitySet: 0
|
||||
textureFormatSet: 0
|
||||
ignorePngGamma: 0
|
||||
applyGammaDecoding: 0
|
||||
swizzle: 50462976
|
||||
cookieLightType: 0
|
||||
platformSettings:
|
||||
- serializedVersion: 3
|
||||
buildTarget: DefaultTexturePlatform
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: 3
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: Standalone
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: Server
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
spriteSheet:
|
||||
serializedVersion: 2
|
||||
sprites: []
|
||||
outline: []
|
||||
physicsShape: []
|
||||
bones: []
|
||||
spriteID:
|
||||
internalID: 0
|
||||
vertices: []
|
||||
indices:
|
||||
edges: []
|
||||
weights: []
|
||||
secondaryTextures: []
|
||||
nameFileIdTable: {}
|
||||
mipmapLimitGroupName:
|
||||
pSDRemoveMatte: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 379716
|
||||
packageName: 'HTrace: World Space Global Illumination URP | Beta'
|
||||
packageVersion: 0.9.6
|
||||
assetPath: Assets/HTraceWSGI/Resources/HTraceWSGI/_Shared/BlueNoise/OwenScrambledNoise4.png
|
||||
uploadId: 925118
|
||||
BIN
Assets/External/HTraceWSGI/Resources/HTraceWSGI/_Shared/BlueNoise/RankingTile1SPP.png
(Stored with Git LFS)
vendored
Normal file
BIN
Assets/External/HTraceWSGI/Resources/HTraceWSGI/_Shared/BlueNoise/RankingTile1SPP.png
(Stored with Git LFS)
vendored
Normal file
Binary file not shown.
134
Assets/External/HTraceWSGI/Resources/HTraceWSGI/_Shared/BlueNoise/RankingTile1SPP.png.meta
vendored
Normal file
134
Assets/External/HTraceWSGI/Resources/HTraceWSGI/_Shared/BlueNoise/RankingTile1SPP.png.meta
vendored
Normal file
@ -0,0 +1,134 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4cdfcda66efc7c74c9e67bdd53e48fba
|
||||
TextureImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 13
|
||||
mipmaps:
|
||||
mipMapMode: 0
|
||||
enableMipMap: 0
|
||||
sRGBTexture: 0
|
||||
linearTexture: 0
|
||||
fadeOut: 0
|
||||
borderMipMap: 0
|
||||
mipMapsPreserveCoverage: 0
|
||||
alphaTestReferenceValue: 0.5
|
||||
mipMapFadeDistanceStart: 1
|
||||
mipMapFadeDistanceEnd: 3
|
||||
bumpmap:
|
||||
convertToNormalMap: 0
|
||||
externalNormalMap: 0
|
||||
heightScale: 0.25
|
||||
normalMapFilter: 0
|
||||
flipGreenChannel: 0
|
||||
isReadable: 0
|
||||
streamingMipmaps: 0
|
||||
streamingMipmapsPriority: 0
|
||||
vTOnly: 0
|
||||
ignoreMipmapLimit: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 6
|
||||
cubemapConvolution: 0
|
||||
seamlessCubemap: 0
|
||||
textureFormat: 1
|
||||
maxTextureSize: 2048
|
||||
textureSettings:
|
||||
serializedVersion: 2
|
||||
filterMode: 1
|
||||
aniso: 1
|
||||
mipBias: 0
|
||||
wrapU: 0
|
||||
wrapV: 0
|
||||
wrapW: 0
|
||||
nPOTScale: 1
|
||||
lightmap: 0
|
||||
compressionQuality: 50
|
||||
spriteMode: 0
|
||||
spriteExtrude: 1
|
||||
spriteMeshType: 1
|
||||
alignment: 0
|
||||
spritePivot: {x: 0.5, y: 0.5}
|
||||
spritePixelsToUnits: 100
|
||||
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||
spriteGenerateFallbackPhysicsShape: 1
|
||||
alphaUsage: 0
|
||||
alphaIsTransparency: 0
|
||||
spriteTessellationDetail: -1
|
||||
textureType: 0
|
||||
textureShape: 1
|
||||
singleChannelComponent: 0
|
||||
flipbookRows: 1
|
||||
flipbookColumns: 1
|
||||
maxTextureSizeSet: 0
|
||||
compressionQualitySet: 0
|
||||
textureFormatSet: 0
|
||||
ignorePngGamma: 0
|
||||
applyGammaDecoding: 0
|
||||
swizzle: 50462976
|
||||
cookieLightType: 0
|
||||
platformSettings:
|
||||
- serializedVersion: 3
|
||||
buildTarget: DefaultTexturePlatform
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: 3
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: Standalone
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: Server
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
spriteSheet:
|
||||
serializedVersion: 2
|
||||
sprites: []
|
||||
outline: []
|
||||
physicsShape: []
|
||||
bones: []
|
||||
spriteID:
|
||||
internalID: 0
|
||||
vertices: []
|
||||
indices:
|
||||
edges: []
|
||||
weights: []
|
||||
secondaryTextures: []
|
||||
nameFileIdTable: {}
|
||||
mipmapLimitGroupName:
|
||||
pSDRemoveMatte: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 379716
|
||||
packageName: 'HTrace: World Space Global Illumination URP | Beta'
|
||||
packageVersion: 0.9.6
|
||||
assetPath: Assets/HTraceWSGI/Resources/HTraceWSGI/_Shared/BlueNoise/RankingTile1SPP.png
|
||||
uploadId: 925118
|
||||
BIN
Assets/External/HTraceWSGI/Resources/HTraceWSGI/_Shared/BlueNoise/RankingTile256SPP.png
(Stored with Git LFS)
vendored
Normal file
BIN
Assets/External/HTraceWSGI/Resources/HTraceWSGI/_Shared/BlueNoise/RankingTile256SPP.png
(Stored with Git LFS)
vendored
Normal file
Binary file not shown.
134
Assets/External/HTraceWSGI/Resources/HTraceWSGI/_Shared/BlueNoise/RankingTile256SPP.png.meta
vendored
Normal file
134
Assets/External/HTraceWSGI/Resources/HTraceWSGI/_Shared/BlueNoise/RankingTile256SPP.png.meta
vendored
Normal file
@ -0,0 +1,134 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 876f3102cad6769479a91bdb085e43af
|
||||
TextureImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 13
|
||||
mipmaps:
|
||||
mipMapMode: 0
|
||||
enableMipMap: 0
|
||||
sRGBTexture: 0
|
||||
linearTexture: 0
|
||||
fadeOut: 0
|
||||
borderMipMap: 0
|
||||
mipMapsPreserveCoverage: 0
|
||||
alphaTestReferenceValue: 0.5
|
||||
mipMapFadeDistanceStart: 1
|
||||
mipMapFadeDistanceEnd: 3
|
||||
bumpmap:
|
||||
convertToNormalMap: 0
|
||||
externalNormalMap: 0
|
||||
heightScale: 0.25
|
||||
normalMapFilter: 0
|
||||
flipGreenChannel: 0
|
||||
isReadable: 0
|
||||
streamingMipmaps: 0
|
||||
streamingMipmapsPriority: 0
|
||||
vTOnly: 0
|
||||
ignoreMipmapLimit: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 6
|
||||
cubemapConvolution: 0
|
||||
seamlessCubemap: 0
|
||||
textureFormat: 1
|
||||
maxTextureSize: 2048
|
||||
textureSettings:
|
||||
serializedVersion: 2
|
||||
filterMode: 1
|
||||
aniso: 1
|
||||
mipBias: 0
|
||||
wrapU: 0
|
||||
wrapV: 0
|
||||
wrapW: 0
|
||||
nPOTScale: 1
|
||||
lightmap: 0
|
||||
compressionQuality: 50
|
||||
spriteMode: 0
|
||||
spriteExtrude: 1
|
||||
spriteMeshType: 1
|
||||
alignment: 0
|
||||
spritePivot: {x: 0.5, y: 0.5}
|
||||
spritePixelsToUnits: 100
|
||||
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||
spriteGenerateFallbackPhysicsShape: 1
|
||||
alphaUsage: 0
|
||||
alphaIsTransparency: 0
|
||||
spriteTessellationDetail: -1
|
||||
textureType: 0
|
||||
textureShape: 1
|
||||
singleChannelComponent: 0
|
||||
flipbookRows: 1
|
||||
flipbookColumns: 1
|
||||
maxTextureSizeSet: 0
|
||||
compressionQualitySet: 0
|
||||
textureFormatSet: 0
|
||||
ignorePngGamma: 0
|
||||
applyGammaDecoding: 0
|
||||
swizzle: 50462976
|
||||
cookieLightType: 0
|
||||
platformSettings:
|
||||
- serializedVersion: 3
|
||||
buildTarget: DefaultTexturePlatform
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: 3
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: Standalone
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: Server
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
spriteSheet:
|
||||
serializedVersion: 2
|
||||
sprites: []
|
||||
outline: []
|
||||
physicsShape: []
|
||||
bones: []
|
||||
spriteID:
|
||||
internalID: 0
|
||||
vertices: []
|
||||
indices:
|
||||
edges: []
|
||||
weights: []
|
||||
secondaryTextures: []
|
||||
nameFileIdTable: {}
|
||||
mipmapLimitGroupName:
|
||||
pSDRemoveMatte: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 379716
|
||||
packageName: 'HTrace: World Space Global Illumination URP | Beta'
|
||||
packageVersion: 0.9.6
|
||||
assetPath: Assets/HTraceWSGI/Resources/HTraceWSGI/_Shared/BlueNoise/RankingTile256SPP.png
|
||||
uploadId: 925118
|
||||
BIN
Assets/External/HTraceWSGI/Resources/HTraceWSGI/_Shared/BlueNoise/RankingTile8SPP.png
(Stored with Git LFS)
vendored
Normal file
BIN
Assets/External/HTraceWSGI/Resources/HTraceWSGI/_Shared/BlueNoise/RankingTile8SPP.png
(Stored with Git LFS)
vendored
Normal file
Binary file not shown.
134
Assets/External/HTraceWSGI/Resources/HTraceWSGI/_Shared/BlueNoise/RankingTile8SPP.png.meta
vendored
Normal file
134
Assets/External/HTraceWSGI/Resources/HTraceWSGI/_Shared/BlueNoise/RankingTile8SPP.png.meta
vendored
Normal file
@ -0,0 +1,134 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 08374171679a7e040b21ce3a82786e6d
|
||||
TextureImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 13
|
||||
mipmaps:
|
||||
mipMapMode: 0
|
||||
enableMipMap: 0
|
||||
sRGBTexture: 0
|
||||
linearTexture: 0
|
||||
fadeOut: 0
|
||||
borderMipMap: 0
|
||||
mipMapsPreserveCoverage: 0
|
||||
alphaTestReferenceValue: 0.5
|
||||
mipMapFadeDistanceStart: 1
|
||||
mipMapFadeDistanceEnd: 3
|
||||
bumpmap:
|
||||
convertToNormalMap: 0
|
||||
externalNormalMap: 0
|
||||
heightScale: 0.25
|
||||
normalMapFilter: 0
|
||||
flipGreenChannel: 0
|
||||
isReadable: 0
|
||||
streamingMipmaps: 0
|
||||
streamingMipmapsPriority: 0
|
||||
vTOnly: 0
|
||||
ignoreMipmapLimit: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 6
|
||||
cubemapConvolution: 0
|
||||
seamlessCubemap: 0
|
||||
textureFormat: 1
|
||||
maxTextureSize: 2048
|
||||
textureSettings:
|
||||
serializedVersion: 2
|
||||
filterMode: 1
|
||||
aniso: 1
|
||||
mipBias: 0
|
||||
wrapU: 0
|
||||
wrapV: 0
|
||||
wrapW: 0
|
||||
nPOTScale: 1
|
||||
lightmap: 0
|
||||
compressionQuality: 50
|
||||
spriteMode: 0
|
||||
spriteExtrude: 1
|
||||
spriteMeshType: 1
|
||||
alignment: 0
|
||||
spritePivot: {x: 0.5, y: 0.5}
|
||||
spritePixelsToUnits: 100
|
||||
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||
spriteGenerateFallbackPhysicsShape: 1
|
||||
alphaUsage: 0
|
||||
alphaIsTransparency: 0
|
||||
spriteTessellationDetail: -1
|
||||
textureType: 0
|
||||
textureShape: 1
|
||||
singleChannelComponent: 0
|
||||
flipbookRows: 1
|
||||
flipbookColumns: 1
|
||||
maxTextureSizeSet: 0
|
||||
compressionQualitySet: 0
|
||||
textureFormatSet: 0
|
||||
ignorePngGamma: 0
|
||||
applyGammaDecoding: 0
|
||||
swizzle: 50462976
|
||||
cookieLightType: 0
|
||||
platformSettings:
|
||||
- serializedVersion: 3
|
||||
buildTarget: DefaultTexturePlatform
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: 3
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: Standalone
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: Server
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
spriteSheet:
|
||||
serializedVersion: 2
|
||||
sprites: []
|
||||
outline: []
|
||||
physicsShape: []
|
||||
bones: []
|
||||
spriteID:
|
||||
internalID: 0
|
||||
vertices: []
|
||||
indices:
|
||||
edges: []
|
||||
weights: []
|
||||
secondaryTextures: []
|
||||
nameFileIdTable: {}
|
||||
mipmapLimitGroupName:
|
||||
pSDRemoveMatte: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 379716
|
||||
packageName: 'HTrace: World Space Global Illumination URP | Beta'
|
||||
packageVersion: 0.9.6
|
||||
assetPath: Assets/HTraceWSGI/Resources/HTraceWSGI/_Shared/BlueNoise/RankingTile8SPP.png
|
||||
uploadId: 925118
|
||||
BIN
Assets/External/HTraceWSGI/Resources/HTraceWSGI/_Shared/BlueNoise/ScrambleNoise.png
(Stored with Git LFS)
vendored
Normal file
BIN
Assets/External/HTraceWSGI/Resources/HTraceWSGI/_Shared/BlueNoise/ScrambleNoise.png
(Stored with Git LFS)
vendored
Normal file
Binary file not shown.
134
Assets/External/HTraceWSGI/Resources/HTraceWSGI/_Shared/BlueNoise/ScrambleNoise.png.meta
vendored
Normal file
134
Assets/External/HTraceWSGI/Resources/HTraceWSGI/_Shared/BlueNoise/ScrambleNoise.png.meta
vendored
Normal file
@ -0,0 +1,134 @@
|
||||
fileFormatVersion: 2
|
||||
guid: adf16ddb85aed6846b00cb6ea5f69ee0
|
||||
TextureImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 13
|
||||
mipmaps:
|
||||
mipMapMode: 0
|
||||
enableMipMap: 0
|
||||
sRGBTexture: 0
|
||||
linearTexture: 0
|
||||
fadeOut: 0
|
||||
borderMipMap: 0
|
||||
mipMapsPreserveCoverage: 0
|
||||
alphaTestReferenceValue: 0.5
|
||||
mipMapFadeDistanceStart: 1
|
||||
mipMapFadeDistanceEnd: 3
|
||||
bumpmap:
|
||||
convertToNormalMap: 0
|
||||
externalNormalMap: 0
|
||||
heightScale: 0.25
|
||||
normalMapFilter: 0
|
||||
flipGreenChannel: 0
|
||||
isReadable: 0
|
||||
streamingMipmaps: 0
|
||||
streamingMipmapsPriority: 0
|
||||
vTOnly: 0
|
||||
ignoreMipmapLimit: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 6
|
||||
cubemapConvolution: 0
|
||||
seamlessCubemap: 0
|
||||
textureFormat: 1
|
||||
maxTextureSize: 2048
|
||||
textureSettings:
|
||||
serializedVersion: 2
|
||||
filterMode: 1
|
||||
aniso: 1
|
||||
mipBias: 0
|
||||
wrapU: 0
|
||||
wrapV: 0
|
||||
wrapW: 0
|
||||
nPOTScale: 1
|
||||
lightmap: 0
|
||||
compressionQuality: 50
|
||||
spriteMode: 0
|
||||
spriteExtrude: 1
|
||||
spriteMeshType: 1
|
||||
alignment: 0
|
||||
spritePivot: {x: 0.5, y: 0.5}
|
||||
spritePixelsToUnits: 100
|
||||
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||
spriteGenerateFallbackPhysicsShape: 1
|
||||
alphaUsage: 0
|
||||
alphaIsTransparency: 0
|
||||
spriteTessellationDetail: -1
|
||||
textureType: 0
|
||||
textureShape: 1
|
||||
singleChannelComponent: 0
|
||||
flipbookRows: 1
|
||||
flipbookColumns: 1
|
||||
maxTextureSizeSet: 0
|
||||
compressionQualitySet: 0
|
||||
textureFormatSet: 0
|
||||
ignorePngGamma: 0
|
||||
applyGammaDecoding: 0
|
||||
swizzle: 50462976
|
||||
cookieLightType: 0
|
||||
platformSettings:
|
||||
- serializedVersion: 3
|
||||
buildTarget: DefaultTexturePlatform
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: 3
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: Standalone
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: Server
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
spriteSheet:
|
||||
serializedVersion: 2
|
||||
sprites: []
|
||||
outline: []
|
||||
physicsShape: []
|
||||
bones: []
|
||||
spriteID:
|
||||
internalID: 0
|
||||
vertices: []
|
||||
indices:
|
||||
edges: []
|
||||
weights: []
|
||||
secondaryTextures: []
|
||||
nameFileIdTable: {}
|
||||
mipmapLimitGroupName:
|
||||
pSDRemoveMatte: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 379716
|
||||
packageName: 'HTrace: World Space Global Illumination URP | Beta'
|
||||
packageVersion: 0.9.6
|
||||
assetPath: Assets/HTraceWSGI/Resources/HTraceWSGI/_Shared/BlueNoise/ScrambleNoise.png
|
||||
uploadId: 925118
|
||||
BIN
Assets/External/HTraceWSGI/Resources/HTraceWSGI/_Shared/BlueNoise/ScramblingTile1SPP.png
(Stored with Git LFS)
vendored
Normal file
BIN
Assets/External/HTraceWSGI/Resources/HTraceWSGI/_Shared/BlueNoise/ScramblingTile1SPP.png
(Stored with Git LFS)
vendored
Normal file
Binary file not shown.
134
Assets/External/HTraceWSGI/Resources/HTraceWSGI/_Shared/BlueNoise/ScramblingTile1SPP.png.meta
vendored
Normal file
134
Assets/External/HTraceWSGI/Resources/HTraceWSGI/_Shared/BlueNoise/ScramblingTile1SPP.png.meta
vendored
Normal file
@ -0,0 +1,134 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ae95ac3876de5774caa3de35d227b631
|
||||
TextureImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 13
|
||||
mipmaps:
|
||||
mipMapMode: 0
|
||||
enableMipMap: 0
|
||||
sRGBTexture: 0
|
||||
linearTexture: 0
|
||||
fadeOut: 0
|
||||
borderMipMap: 0
|
||||
mipMapsPreserveCoverage: 0
|
||||
alphaTestReferenceValue: 0.5
|
||||
mipMapFadeDistanceStart: 1
|
||||
mipMapFadeDistanceEnd: 3
|
||||
bumpmap:
|
||||
convertToNormalMap: 0
|
||||
externalNormalMap: 0
|
||||
heightScale: 0.25
|
||||
normalMapFilter: 0
|
||||
flipGreenChannel: 0
|
||||
isReadable: 0
|
||||
streamingMipmaps: 0
|
||||
streamingMipmapsPriority: 0
|
||||
vTOnly: 0
|
||||
ignoreMipmapLimit: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 6
|
||||
cubemapConvolution: 0
|
||||
seamlessCubemap: 0
|
||||
textureFormat: 1
|
||||
maxTextureSize: 2048
|
||||
textureSettings:
|
||||
serializedVersion: 2
|
||||
filterMode: 1
|
||||
aniso: 1
|
||||
mipBias: 0
|
||||
wrapU: 0
|
||||
wrapV: 0
|
||||
wrapW: 0
|
||||
nPOTScale: 1
|
||||
lightmap: 0
|
||||
compressionQuality: 50
|
||||
spriteMode: 0
|
||||
spriteExtrude: 1
|
||||
spriteMeshType: 1
|
||||
alignment: 0
|
||||
spritePivot: {x: 0.5, y: 0.5}
|
||||
spritePixelsToUnits: 100
|
||||
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||
spriteGenerateFallbackPhysicsShape: 1
|
||||
alphaUsage: 0
|
||||
alphaIsTransparency: 0
|
||||
spriteTessellationDetail: -1
|
||||
textureType: 0
|
||||
textureShape: 1
|
||||
singleChannelComponent: 0
|
||||
flipbookRows: 1
|
||||
flipbookColumns: 1
|
||||
maxTextureSizeSet: 0
|
||||
compressionQualitySet: 0
|
||||
textureFormatSet: 0
|
||||
ignorePngGamma: 0
|
||||
applyGammaDecoding: 0
|
||||
swizzle: 50462976
|
||||
cookieLightType: 0
|
||||
platformSettings:
|
||||
- serializedVersion: 3
|
||||
buildTarget: DefaultTexturePlatform
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: 3
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: Standalone
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: Server
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
spriteSheet:
|
||||
serializedVersion: 2
|
||||
sprites: []
|
||||
outline: []
|
||||
physicsShape: []
|
||||
bones: []
|
||||
spriteID:
|
||||
internalID: 0
|
||||
vertices: []
|
||||
indices:
|
||||
edges: []
|
||||
weights: []
|
||||
secondaryTextures: []
|
||||
nameFileIdTable: {}
|
||||
mipmapLimitGroupName:
|
||||
pSDRemoveMatte: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 379716
|
||||
packageName: 'HTrace: World Space Global Illumination URP | Beta'
|
||||
packageVersion: 0.9.6
|
||||
assetPath: Assets/HTraceWSGI/Resources/HTraceWSGI/_Shared/BlueNoise/ScramblingTile1SPP.png
|
||||
uploadId: 925118
|
||||
BIN
Assets/External/HTraceWSGI/Resources/HTraceWSGI/_Shared/BlueNoise/ScramblingTile256SPP.png
(Stored with Git LFS)
vendored
Normal file
BIN
Assets/External/HTraceWSGI/Resources/HTraceWSGI/_Shared/BlueNoise/ScramblingTile256SPP.png
(Stored with Git LFS)
vendored
Normal file
Binary file not shown.
134
Assets/External/HTraceWSGI/Resources/HTraceWSGI/_Shared/BlueNoise/ScramblingTile256SPP.png.meta
vendored
Normal file
134
Assets/External/HTraceWSGI/Resources/HTraceWSGI/_Shared/BlueNoise/ScramblingTile256SPP.png.meta
vendored
Normal file
@ -0,0 +1,134 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0e53c38031c2bff45a2428c44c181436
|
||||
TextureImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 13
|
||||
mipmaps:
|
||||
mipMapMode: 0
|
||||
enableMipMap: 0
|
||||
sRGBTexture: 0
|
||||
linearTexture: 0
|
||||
fadeOut: 0
|
||||
borderMipMap: 0
|
||||
mipMapsPreserveCoverage: 0
|
||||
alphaTestReferenceValue: 0.5
|
||||
mipMapFadeDistanceStart: 1
|
||||
mipMapFadeDistanceEnd: 3
|
||||
bumpmap:
|
||||
convertToNormalMap: 0
|
||||
externalNormalMap: 0
|
||||
heightScale: 0.25
|
||||
normalMapFilter: 0
|
||||
flipGreenChannel: 0
|
||||
isReadable: 0
|
||||
streamingMipmaps: 0
|
||||
streamingMipmapsPriority: 0
|
||||
vTOnly: 0
|
||||
ignoreMipmapLimit: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 6
|
||||
cubemapConvolution: 0
|
||||
seamlessCubemap: 0
|
||||
textureFormat: 1
|
||||
maxTextureSize: 2048
|
||||
textureSettings:
|
||||
serializedVersion: 2
|
||||
filterMode: 1
|
||||
aniso: 1
|
||||
mipBias: 0
|
||||
wrapU: 0
|
||||
wrapV: 0
|
||||
wrapW: 0
|
||||
nPOTScale: 1
|
||||
lightmap: 0
|
||||
compressionQuality: 50
|
||||
spriteMode: 0
|
||||
spriteExtrude: 1
|
||||
spriteMeshType: 1
|
||||
alignment: 0
|
||||
spritePivot: {x: 0.5, y: 0.5}
|
||||
spritePixelsToUnits: 100
|
||||
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||
spriteGenerateFallbackPhysicsShape: 1
|
||||
alphaUsage: 0
|
||||
alphaIsTransparency: 0
|
||||
spriteTessellationDetail: -1
|
||||
textureType: 0
|
||||
textureShape: 1
|
||||
singleChannelComponent: 0
|
||||
flipbookRows: 1
|
||||
flipbookColumns: 1
|
||||
maxTextureSizeSet: 0
|
||||
compressionQualitySet: 0
|
||||
textureFormatSet: 0
|
||||
ignorePngGamma: 0
|
||||
applyGammaDecoding: 0
|
||||
swizzle: 50462976
|
||||
cookieLightType: 0
|
||||
platformSettings:
|
||||
- serializedVersion: 3
|
||||
buildTarget: DefaultTexturePlatform
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: 3
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: Standalone
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: Server
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
spriteSheet:
|
||||
serializedVersion: 2
|
||||
sprites: []
|
||||
outline: []
|
||||
physicsShape: []
|
||||
bones: []
|
||||
spriteID:
|
||||
internalID: 0
|
||||
vertices: []
|
||||
indices:
|
||||
edges: []
|
||||
weights: []
|
||||
secondaryTextures: []
|
||||
nameFileIdTable: {}
|
||||
mipmapLimitGroupName:
|
||||
pSDRemoveMatte: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 379716
|
||||
packageName: 'HTrace: World Space Global Illumination URP | Beta'
|
||||
packageVersion: 0.9.6
|
||||
assetPath: Assets/HTraceWSGI/Resources/HTraceWSGI/_Shared/BlueNoise/ScramblingTile256SPP.png
|
||||
uploadId: 925118
|
||||
BIN
Assets/External/HTraceWSGI/Resources/HTraceWSGI/_Shared/BlueNoise/ScramblingTile8SPP.png
(Stored with Git LFS)
vendored
Normal file
BIN
Assets/External/HTraceWSGI/Resources/HTraceWSGI/_Shared/BlueNoise/ScramblingTile8SPP.png
(Stored with Git LFS)
vendored
Normal file
Binary file not shown.
134
Assets/External/HTraceWSGI/Resources/HTraceWSGI/_Shared/BlueNoise/ScramblingTile8SPP.png.meta
vendored
Normal file
134
Assets/External/HTraceWSGI/Resources/HTraceWSGI/_Shared/BlueNoise/ScramblingTile8SPP.png.meta
vendored
Normal file
@ -0,0 +1,134 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f9c63c94bb48b6a49a8c685d8d474482
|
||||
TextureImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 13
|
||||
mipmaps:
|
||||
mipMapMode: 0
|
||||
enableMipMap: 0
|
||||
sRGBTexture: 0
|
||||
linearTexture: 0
|
||||
fadeOut: 0
|
||||
borderMipMap: 0
|
||||
mipMapsPreserveCoverage: 0
|
||||
alphaTestReferenceValue: 0.5
|
||||
mipMapFadeDistanceStart: 1
|
||||
mipMapFadeDistanceEnd: 3
|
||||
bumpmap:
|
||||
convertToNormalMap: 0
|
||||
externalNormalMap: 0
|
||||
heightScale: 0.25
|
||||
normalMapFilter: 0
|
||||
flipGreenChannel: 0
|
||||
isReadable: 0
|
||||
streamingMipmaps: 0
|
||||
streamingMipmapsPriority: 0
|
||||
vTOnly: 0
|
||||
ignoreMipmapLimit: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 6
|
||||
cubemapConvolution: 0
|
||||
seamlessCubemap: 0
|
||||
textureFormat: 1
|
||||
maxTextureSize: 2048
|
||||
textureSettings:
|
||||
serializedVersion: 2
|
||||
filterMode: 1
|
||||
aniso: 1
|
||||
mipBias: 0
|
||||
wrapU: 0
|
||||
wrapV: 0
|
||||
wrapW: 0
|
||||
nPOTScale: 1
|
||||
lightmap: 0
|
||||
compressionQuality: 50
|
||||
spriteMode: 0
|
||||
spriteExtrude: 1
|
||||
spriteMeshType: 1
|
||||
alignment: 0
|
||||
spritePivot: {x: 0.5, y: 0.5}
|
||||
spritePixelsToUnits: 100
|
||||
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||
spriteGenerateFallbackPhysicsShape: 1
|
||||
alphaUsage: 0
|
||||
alphaIsTransparency: 0
|
||||
spriteTessellationDetail: -1
|
||||
textureType: 0
|
||||
textureShape: 1
|
||||
singleChannelComponent: 0
|
||||
flipbookRows: 1
|
||||
flipbookColumns: 1
|
||||
maxTextureSizeSet: 0
|
||||
compressionQualitySet: 0
|
||||
textureFormatSet: 0
|
||||
ignorePngGamma: 0
|
||||
applyGammaDecoding: 0
|
||||
swizzle: 50462976
|
||||
cookieLightType: 0
|
||||
platformSettings:
|
||||
- serializedVersion: 3
|
||||
buildTarget: DefaultTexturePlatform
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: 3
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: Standalone
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: Server
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
spriteSheet:
|
||||
serializedVersion: 2
|
||||
sprites: []
|
||||
outline: []
|
||||
physicsShape: []
|
||||
bones: []
|
||||
spriteID:
|
||||
internalID: 0
|
||||
vertices: []
|
||||
indices:
|
||||
edges: []
|
||||
weights: []
|
||||
secondaryTextures: []
|
||||
nameFileIdTable: {}
|
||||
mipmapLimitGroupName:
|
||||
pSDRemoveMatte: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 379716
|
||||
packageName: 'HTrace: World Space Global Illumination URP | Beta'
|
||||
packageVersion: 0.9.6
|
||||
assetPath: Assets/HTraceWSGI/Resources/HTraceWSGI/_Shared/BlueNoise/ScramblingTile8SPP.png
|
||||
uploadId: 925118
|
||||
3
Assets/External/HTraceWSGI/Resources/HTraceWSGI/_Shared/Computes.meta
vendored
Normal file
3
Assets/External/HTraceWSGI/Resources/HTraceWSGI/_Shared/Computes.meta
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 31a45e77d5c4e984398280d1697ed939
|
||||
timeCreated: 1719664117
|
||||
24
Assets/External/HTraceWSGI/Resources/HTraceWSGI/_Shared/Computes/CopyBuffersBIRP.compute
vendored
Normal file
24
Assets/External/HTraceWSGI/Resources/HTraceWSGI/_Shared/Computes/CopyBuffersBIRP.compute
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
#pragma kernel CopyColor
|
||||
#pragma kernel CopyEmissives
|
||||
|
||||
#include "../Headers/HMain.hlsl"
|
||||
|
||||
H_TEXTURE(_ColorInput);
|
||||
H_TEXTURE(_EmissivesInput);
|
||||
|
||||
H_RW_TEXTURE(float3, _ColorOutput);
|
||||
H_RW_TEXTURE(float3, _EmissivesOutput);
|
||||
|
||||
// ------------------------ COPY COLOR (BIRP ONLY) ------------------------
|
||||
[numthreads(8, 8, 1)]
|
||||
void CopyColor(uint3 pixCoord : SV_DispatchThreadID)
|
||||
{
|
||||
_ColorOutput[H_COORD(pixCoord.xy)] = H_LOAD(_ColorInput, pixCoord.xy);
|
||||
}
|
||||
|
||||
// ------------------------ COPY EMISSIVES (BIRP ONLY) ------------------------
|
||||
[numthreads(8, 8, 1)]
|
||||
void CopyEmissives(uint3 pixCoord : SV_DispatchThreadID)
|
||||
{
|
||||
_EmissivesOutput[H_COORD(pixCoord.xy)] = H_LOAD(_EmissivesInput, pixCoord.xy);
|
||||
}
|
||||
10
Assets/External/HTraceWSGI/Resources/HTraceWSGI/_Shared/Computes/CopyBuffersBIRP.compute.meta
vendored
Normal file
10
Assets/External/HTraceWSGI/Resources/HTraceWSGI/_Shared/Computes/CopyBuffersBIRP.compute.meta
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1615930f75214d8286118bfcd908eca6
|
||||
timeCreated: 1759140972
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 379716
|
||||
packageName: 'HTrace: World Space Global Illumination URP | Beta'
|
||||
packageVersion: 0.9.6
|
||||
assetPath: Assets/HTraceWSGI/Resources/HTraceWSGI/_Shared/Computes/CopyBuffersBIRP.compute
|
||||
uploadId: 925118
|
||||
48
Assets/External/HTraceWSGI/Resources/HTraceWSGI/_Shared/Computes/HCopy.compute
vendored
Normal file
48
Assets/External/HTraceWSGI/Resources/HTraceWSGI/_Shared/Computes/HCopy.compute
vendored
Normal file
@ -0,0 +1,48 @@
|
||||
#pragma kernel CopyProbeAtlases
|
||||
#pragma kernel CopyProbeBuffers
|
||||
#pragma kernel CopyFullResBuffers
|
||||
|
||||
|
||||
#include "../Headers/HMain.hlsl"
|
||||
|
||||
#pragma multi_compile _ _GBUFFER_NORMALS_OCT
|
||||
|
||||
H_TEXTURE(g_GeometryNormal);
|
||||
H_TEXTURE(_ShadowGuidanceMask);
|
||||
H_TEXTURE(_ShadowGuidanceMask_Samplecount);
|
||||
H_TEXTURE(_ShadowGuidanceMask_Accumulated);
|
||||
|
||||
H_RW_TEXTURE(uint2, _NormalDepth_HistoryOutput);
|
||||
H_RW_TEXTURE(float, _ShadowGuidanceMask_HistoryOutput);
|
||||
H_RW_TEXTURE(float, _ShadowGuidanceMask_SamplecountHistoryOutput);
|
||||
H_RW_TEXTURE(float, _ShadowGuidanceMask_CheckerboardHistoryOutput);
|
||||
|
||||
|
||||
// ------------------------ PROBE ATLAS COPY ------------------------
|
||||
[numthreads(8, 8, 1)]
|
||||
void CopyProbeAtlases(uint3 pixCoord : SV_DispatchThreadID, uint2 groupThreadID : SV_GroupThreadID, uint groupIndex : SV_GroupIndex, uint groupID : SV_GroupID)
|
||||
{
|
||||
|
||||
_ShadowGuidanceMask_CheckerboardHistoryOutput[H_COORD(pixCoord.xy)] = H_LOAD(_ShadowGuidanceMask, pixCoord.xy).x;
|
||||
_ShadowGuidanceMask_HistoryOutput[H_COORD(pixCoord.xy)] = H_LOAD(_ShadowGuidanceMask_Accumulated, pixCoord.xy).x;
|
||||
}
|
||||
|
||||
|
||||
// ------------------------ PROBE BUFFER COPY ------------------------
|
||||
[numthreads(8, 8, 1)]
|
||||
void CopyProbeBuffers(uint3 pixCoord : SV_DispatchThreadID, uint2 groupThreadID : SV_GroupThreadID, uint groupIndex : SV_GroupIndex, uint groupID : SV_GroupID)
|
||||
{
|
||||
|
||||
_ShadowGuidanceMask_SamplecountHistoryOutput[H_COORD(pixCoord.xy)] = H_LOAD(_ShadowGuidanceMask_Samplecount, pixCoord.xy).x;
|
||||
}
|
||||
|
||||
|
||||
// ------------------------ FULL RES BUFFER COPY ------------------------
|
||||
[numthreads(8, 8, 1)]
|
||||
void CopyFullResBuffers(uint3 pixCoord : SV_DispatchThreadID, uint2 groupThreadID : SV_GroupThreadID, uint groupIndex : SV_GroupIndex, uint groupID : SV_GroupID)
|
||||
{
|
||||
|
||||
float DepthForHistory = HBUFFER_DEPTH(pixCoord.xy);
|
||||
float3 NormalForHistory = H_LOAD(g_GeometryNormal, pixCoord.xy).xyz;
|
||||
// _NormalDepth_HistoryOutput[H_COORD(pixCoord.xy)] = PackNormalDepth(NormalForHistory, DepthForHistory);
|
||||
}
|
||||
14
Assets/External/HTraceWSGI/Resources/HTraceWSGI/_Shared/Computes/HCopy.compute.meta
vendored
Normal file
14
Assets/External/HTraceWSGI/Resources/HTraceWSGI/_Shared/Computes/HCopy.compute.meta
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ddf1b1e824de7ca4a87d4a6fc22d0f32
|
||||
ComputeShaderImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 379716
|
||||
packageName: 'HTrace: World Space Global Illumination URP | Beta'
|
||||
packageVersion: 0.9.6
|
||||
assetPath: Assets/HTraceWSGI/Resources/HTraceWSGI/_Shared/Computes/HCopy.compute
|
||||
uploadId: 925118
|
||||
118
Assets/External/HTraceWSGI/Resources/HTraceWSGI/_Shared/Computes/HDebug.compute
vendored
Normal file
118
Assets/External/HTraceWSGI/Resources/HTraceWSGI/_Shared/Computes/HDebug.compute
vendored
Normal file
@ -0,0 +1,118 @@
|
||||
#pragma kernel Debug
|
||||
|
||||
|
||||
#include "../Headers/HMain.hlsl"
|
||||
#pragma multi_compile _ _GBUFFER_NORMALS_OCT
|
||||
|
||||
// Input bufferes
|
||||
H_TEXTURE(_HTraceBufferGI);
|
||||
H_TEXTURE(g_GeometryNormal);
|
||||
H_TEXTURE(_HTraceBufferVoxelVisualization);
|
||||
//H_TEXTURE(g_HTraceShadowmap);
|
||||
H_TEXTURE(g_LightClusterDebug);
|
||||
|
||||
|
||||
|
||||
//UNITY_DECLARE_SHADOWMAP (g_HTraceShadowmap);
|
||||
SamplerComparisonState sampler_g_HTraceShadowmap;
|
||||
Texture2D<float> g_HTraceShadowmap;
|
||||
float4x4 g_DirLightMatrix;
|
||||
// sampler_ShadowMapTexture;
|
||||
//H_TEXTURE(_ShadowmapAtlas);
|
||||
|
||||
float4 g_HTraceShadowmap_TexelSize;
|
||||
#define SHADOWMAPSAMPLER_AND_TEXELSIZE_DEFINED
|
||||
|
||||
// Output buffers
|
||||
H_RW_TEXTURE(float4, _Debug_Output);
|
||||
|
||||
int _DebugSwitch;
|
||||
int _BuffersSwitch;
|
||||
|
||||
void DebugFinal(uint3 pixCoord)
|
||||
{
|
||||
if (_DebugSwitch == 1) // MainBuffers
|
||||
{
|
||||
if (_BuffersSwitch == 0) // Multi
|
||||
{
|
||||
uint2 quadSize = _ScreenSize / 2;
|
||||
uint2 quadIndex = pixCoord.xy / quadSize; // (0,0), (1,0), (0,1), (1,1)
|
||||
uint2 localCoord = pixCoord.xy % quadSize;
|
||||
uint2 sampleCoord = localCoord * 2;
|
||||
|
||||
float4 outputColor = float4(0, 0, 0, 1);
|
||||
|
||||
if (HBUFFER_DEPTH(sampleCoord.xy) <= UNITY_RAW_FAR_CLIP_VALUE)
|
||||
{
|
||||
_Debug_Output[H_COORD(pixCoord.xy)] = outputColor;
|
||||
return;
|
||||
}
|
||||
|
||||
if (quadIndex.x == 0 && quadIndex.y == 0) // Bot Left
|
||||
{
|
||||
outputColor = float4(HBUFFER_NORMAL_WS(sampleCoord).xyz, 1);
|
||||
}
|
||||
else if (quadIndex.x == 1 && quadIndex.y == 0) // Bot right
|
||||
{
|
||||
float2 motionVector = HBUFFER_MOTION_VECTOR(sampleCoord).xy;
|
||||
float motionMask = HBUFFER_MOTION_MASK(sampleCoord).x;
|
||||
outputColor = float4(motionVector * 5, motionMask * 0.05, 1);
|
||||
}
|
||||
else if (quadIndex.x == 0 && quadIndex.y == 1) // Top left
|
||||
{
|
||||
outputColor = float4(H_LINEAR_EYE_DEPTH(HBUFFER_DEPTH(sampleCoord).x).xxx / 20.0f, 1);
|
||||
}
|
||||
else if (quadIndex.x == 1 && quadIndex.y == 1) // Top right
|
||||
{
|
||||
outputColor = float4(HBUFFER_DIFFUSE(sampleCoord).xyz, 1);
|
||||
}
|
||||
|
||||
_Debug_Output[H_COORD(pixCoord.xy)] = outputColor;
|
||||
}
|
||||
if (_BuffersSwitch == 1) // Depth
|
||||
{
|
||||
_Debug_Output[H_COORD(pixCoord.xy)] = float4(HBUFFER_DEPTH(pixCoord.xy).xxx, 1);
|
||||
}
|
||||
if (_BuffersSwitch == 2) // Diffuse
|
||||
{
|
||||
_Debug_Output[H_COORD(pixCoord.xy)] = float4(HBUFFER_DIFFUSE(pixCoord.xy).xyz, 1);
|
||||
}
|
||||
if (_BuffersSwitch == 3) // Normal
|
||||
{
|
||||
_Debug_Output[H_COORD(pixCoord.xy)] = float4(HBUFFER_NORMAL_WS(pixCoord.xy).xyz, 1);
|
||||
}
|
||||
if (_BuffersSwitch == 4) // Motion Mask
|
||||
{
|
||||
_Debug_Output[H_COORD(pixCoord.xy)] = float4(HBUFFER_MOTION_MASK(pixCoord.xy).xxx, 1);
|
||||
}
|
||||
if (_BuffersSwitch == 5) // MV
|
||||
{
|
||||
_Debug_Output[H_COORD(pixCoord.xy)] = float4(HBUFFER_MOTION_VECTOR(pixCoord.xy).xy, 0, 1);
|
||||
}
|
||||
}
|
||||
|
||||
if (_DebugSwitch == 2) // GlobalIllumination
|
||||
_Debug_Output[H_COORD(pixCoord.xy)] = H_LOAD(_HTraceBufferGI, pixCoord.xy);
|
||||
|
||||
if (_DebugSwitch == 3) // GeometryNormals
|
||||
_Debug_Output[H_COORD(pixCoord.xy)] = H_LOAD(g_GeometryNormal, pixCoord.xy);
|
||||
|
||||
if (_DebugSwitch == 4) // Shadowmap
|
||||
_Debug_Output[H_COORD(pixCoord.xy)] = H_LOAD(g_HTraceShadowmap, pixCoord.xy * (2048 / _ScreenSize.y)).x;
|
||||
|
||||
if (_DebugSwitch == 5) // VoxelizedColor
|
||||
_Debug_Output[H_COORD(pixCoord.xy)] = H_LOAD(_HTraceBufferGI, pixCoord.xy);
|
||||
|
||||
if (_DebugSwitch == 6) // VoxelizedLighting
|
||||
_Debug_Output[H_COORD(pixCoord.xy)] = H_LOAD(_HTraceBufferGI, pixCoord.xy);
|
||||
|
||||
if (_DebugSwitch == 7 || _DebugSwitch == 8) // LightCluster
|
||||
_Debug_Output[H_COORD(pixCoord.xy)] = H_LOAD(g_LightClusterDebug, pixCoord.xy);
|
||||
}
|
||||
|
||||
[numthreads(8, 8, 1)]
|
||||
void Debug(uint3 pixCoord : SV_DispatchThreadID)
|
||||
{
|
||||
|
||||
DebugFinal(pixCoord);
|
||||
}
|
||||
14
Assets/External/HTraceWSGI/Resources/HTraceWSGI/_Shared/Computes/HDebug.compute.meta
vendored
Normal file
14
Assets/External/HTraceWSGI/Resources/HTraceWSGI/_Shared/Computes/HDebug.compute.meta
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6e81537dfc967764694c7747f08cf20e
|
||||
ComputeShaderImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 379716
|
||||
packageName: 'HTrace: World Space Global Illumination URP | Beta'
|
||||
packageVersion: 0.9.6
|
||||
assetPath: Assets/HTraceWSGI/Resources/HTraceWSGI/_Shared/Computes/HDebug.compute
|
||||
uploadId: 925118
|
||||
19
Assets/External/HTraceWSGI/Resources/HTraceWSGI/_Shared/Computes/HDebugPassthrough.compute
vendored
Normal file
19
Assets/External/HTraceWSGI/Resources/HTraceWSGI/_Shared/Computes/HDebugPassthrough.compute
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
#include "../Headers/HMain.hlsl"
|
||||
|
||||
#pragma kernel DebugPassthrough
|
||||
|
||||
#pragma multi_compile _ _GBUFFER_NORMALS_OCT
|
||||
|
||||
H_TEXTURE(_InputA);
|
||||
H_TEXTURE(_InputB);
|
||||
H_TEXTURE(_ReprojectionCoords);
|
||||
|
||||
H_RW_TEXTURE(float3, _Output);
|
||||
|
||||
[numthreads(8, 8, 1)]
|
||||
void DebugPassthrough(uint3 pixCoord : SV_DispatchThreadID, uint2 groupThreadID : SV_GroupThreadID, uint2 groupId : SV_GroupID)
|
||||
{
|
||||
|
||||
_Output[H_COORD(pixCoord.xy)] = H_LOAD(_InputA, pixCoord.xy).xyz ;
|
||||
|
||||
}
|
||||
14
Assets/External/HTraceWSGI/Resources/HTraceWSGI/_Shared/Computes/HDebugPassthrough.compute.meta
vendored
Normal file
14
Assets/External/HTraceWSGI/Resources/HTraceWSGI/_Shared/Computes/HDebugPassthrough.compute.meta
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 94a5f9a2dfc71004ebb53009d1179d9c
|
||||
ComputeShaderImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 379716
|
||||
packageName: 'HTrace: World Space Global Illumination URP | Beta'
|
||||
packageVersion: 0.9.6
|
||||
assetPath: Assets/HTraceWSGI/Resources/HTraceWSGI/_Shared/Computes/HDebugPassthrough.compute
|
||||
uploadId: 925118
|
||||
176
Assets/External/HTraceWSGI/Resources/HTraceWSGI/_Shared/Computes/HDepthPyramid.compute
vendored
Normal file
176
Assets/External/HTraceWSGI/Resources/HTraceWSGI/_Shared/Computes/HDepthPyramid.compute
vendored
Normal file
@ -0,0 +1,176 @@
|
||||
#pragma kernel GenerateDepthPyramid_1
|
||||
#pragma kernel GenerateDepthPyramid_2
|
||||
|
||||
#include "../Headers/HMain.hlsl"
|
||||
|
||||
#pragma multi_compile _ _GBUFFER_NORMALS_OCT
|
||||
|
||||
H_TEXTURE(_DepthIntermediate);
|
||||
|
||||
H_RW_TEXTURE(float, _DepthPyramid_OutputMIP0);
|
||||
H_RW_TEXTURE(float, _DepthPyramid_OutputMIP1);
|
||||
H_RW_TEXTURE(float, _DepthPyramid_OutputMIP2);
|
||||
H_RW_TEXTURE(float, _DepthPyramid_OutputMIP3);
|
||||
H_RW_TEXTURE(float, _DepthPyramid_OutputMIP4);
|
||||
H_RW_TEXTURE(float, _DepthPyramid_OutputMIP5);
|
||||
H_RW_TEXTURE(float, _DepthPyramid_OutputMIP6);
|
||||
H_RW_TEXTURE(float, _DepthPyramid_OutputMIP7);
|
||||
H_RW_TEXTURE(float, _DepthPyramid_OutputMIP8);
|
||||
H_RW_TEXTURE(float, _DepthIntermediate_Output);
|
||||
|
||||
groupshared float MipDepthLDS[8][8];
|
||||
|
||||
// ------------------------ MIP LEVEL 0-4 GENERATIONS ------------------------
|
||||
[numthreads(8, 8, 1)]
|
||||
void GenerateDepthPyramid_1(uint3 pixCoord : SV_DispatchThreadID, uint2 groupThreadID : SV_GroupThreadID)
|
||||
{
|
||||
|
||||
|
||||
const uint2 baseCoord = pixCoord.xy;
|
||||
pixCoord.xy = baseCoord * 2;
|
||||
|
||||
float Depth_00 = any(pixCoord.xy + uint2(0,0) >= uint2(_ScreenSize.xy)) ? 0 : HBUFFER_DEPTH(pixCoord.xy + uint2(0,0));
|
||||
float Depth_10 = any(pixCoord.xy + uint2(1,0) >= uint2(_ScreenSize.xy)) ? 0 : HBUFFER_DEPTH(pixCoord.xy + uint2(1,0));
|
||||
float Depth_01 = any(pixCoord.xy + uint2(0,1) >= uint2(_ScreenSize.xy)) ? 0 : HBUFFER_DEPTH(pixCoord.xy + uint2(0,1));
|
||||
float Depth_11 = any(pixCoord.xy + uint2(1,1) >= uint2(_ScreenSize.xy)) ? 0 : HBUFFER_DEPTH(pixCoord.xy + uint2(1,1));
|
||||
|
||||
Depth_00 = Depth_00 >= 0.9999f ? 0 : Depth_00;
|
||||
Depth_10 = Depth_10 >= 0.9999f ? 0 : Depth_10;
|
||||
Depth_01 = Depth_01 >= 0.9999f ? 0 : Depth_01;
|
||||
Depth_11 = Depth_11 >= 0.9999f ? 0 : Depth_11;
|
||||
|
||||
// Write to MIP0
|
||||
_DepthPyramid_OutputMIP0[H_COORD(pixCoord.xy + uint2(0, 0))] = Depth_00;
|
||||
_DepthPyramid_OutputMIP0[H_COORD(pixCoord.xy + uint2(1, 0))] = Depth_10;
|
||||
_DepthPyramid_OutputMIP0[H_COORD(pixCoord.xy + uint2(0, 1))] = Depth_01;
|
||||
_DepthPyramid_OutputMIP0[H_COORD(pixCoord.xy + uint2(1, 1))] = Depth_11;
|
||||
|
||||
float DepthMIP1 = max(max(Depth_00, Depth_10), max(Depth_01, Depth_11));
|
||||
|
||||
// Write to MIP1
|
||||
_DepthPyramid_OutputMIP1[H_COORD(baseCoord)] = DepthMIP1;
|
||||
|
||||
MipDepthLDS[groupThreadID.x][groupThreadID.y] = DepthMIP1;
|
||||
GroupMemoryBarrierWithGroupSync();
|
||||
|
||||
// Write to MIP2
|
||||
[branch]
|
||||
if (all((groupThreadID.xy % int2(2, 2)) == 0))
|
||||
{
|
||||
float DepthLDS_00 = MipDepthLDS[groupThreadID.x + 0][groupThreadID.y + 0];
|
||||
float DepthLDS_10 = MipDepthLDS[groupThreadID.x + 1][groupThreadID.y + 0];
|
||||
float DepthLDS_01 = MipDepthLDS[groupThreadID.x + 0][groupThreadID.y + 1];
|
||||
float DepthLDS_11 = MipDepthLDS[groupThreadID.x + 1][groupThreadID.y + 1];
|
||||
|
||||
float DepthMIP2 = max(max(DepthLDS_00, DepthLDS_10), max(DepthLDS_01, DepthLDS_11));
|
||||
|
||||
_DepthPyramid_OutputMIP2[H_COORD(baseCoord / 2)] = DepthMIP2;
|
||||
MipDepthLDS[groupThreadID.x][groupThreadID.y] = DepthMIP2;
|
||||
}
|
||||
|
||||
GroupMemoryBarrierWithGroupSync();
|
||||
|
||||
// Write to MIP3
|
||||
[branch]
|
||||
if (all((groupThreadID.xy % int2(4, 4)) == 0))
|
||||
{
|
||||
float DepthLDS_00 = MipDepthLDS[groupThreadID.x + 0][groupThreadID.y + 0];
|
||||
float DepthLDS_10 = MipDepthLDS[groupThreadID.x + 2][groupThreadID.y + 0];
|
||||
float DepthLDS_01 = MipDepthLDS[groupThreadID.x + 0][groupThreadID.y + 2];
|
||||
float DepthLDS_11 = MipDepthLDS[groupThreadID.x + 2][groupThreadID.y + 2];
|
||||
|
||||
float DepthMIP3 = max(max(DepthLDS_00, DepthLDS_10), max(DepthLDS_01, DepthLDS_11));
|
||||
|
||||
_DepthPyramid_OutputMIP3[H_COORD(baseCoord / 4)] = DepthMIP3;
|
||||
MipDepthLDS[groupThreadID.x][groupThreadID.y] = DepthMIP3;
|
||||
}
|
||||
|
||||
GroupMemoryBarrierWithGroupSync();
|
||||
|
||||
// Write to MIP4
|
||||
[branch]
|
||||
if (all((groupThreadID.xy % int2(8, 8)) == 0))
|
||||
{
|
||||
float DepthLDS_00 = MipDepthLDS[groupThreadID.x + 0][groupThreadID.y + 0];
|
||||
float DepthLDS_10 = MipDepthLDS[groupThreadID.x + 4][groupThreadID.y + 0];
|
||||
float DepthLDS_01 = MipDepthLDS[groupThreadID.x + 0][groupThreadID.y + 4];
|
||||
float DepthLDS_11 = MipDepthLDS[groupThreadID.x + 4][groupThreadID.y + 4];
|
||||
|
||||
float DepthMIP4 = max(max(DepthLDS_00, DepthLDS_10), max(DepthLDS_01, DepthLDS_11));
|
||||
|
||||
_DepthPyramid_OutputMIP4[H_COORD(baseCoord / 8)] = DepthMIP4;
|
||||
_DepthIntermediate_Output[H_COORD(baseCoord / 8)] = DepthMIP4;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ------------------------ MIP LEVEL 5-7 GENERATIONS ------------------------
|
||||
[numthreads(8, 8, 1)]
|
||||
void GenerateDepthPyramid_2(uint3 pixCoord : SV_DispatchThreadID, uint2 groupThreadID : SV_GroupThreadID)
|
||||
{
|
||||
|
||||
|
||||
const uint2 baseCoord = pixCoord.xy;
|
||||
pixCoord.xy = baseCoord * 2;
|
||||
|
||||
float Depth_00 = H_LOAD_LOD(_DepthIntermediate, pixCoord.xy + uint2(0,0), 0).x;
|
||||
float Depth_10 = H_LOAD_LOD(_DepthIntermediate, pixCoord.xy + uint2(1,0), 0).x;
|
||||
float Depth_01 = H_LOAD_LOD(_DepthIntermediate, pixCoord.xy + uint2(0,1), 0).x;
|
||||
float Depth_11 = H_LOAD_LOD(_DepthIntermediate, pixCoord.xy + uint2(1,1), 0).x;
|
||||
|
||||
float DepthMIP5 = max(max(Depth_00, Depth_10), max(Depth_01, Depth_11));
|
||||
|
||||
// Write to MIP5
|
||||
_DepthPyramid_OutputMIP5[H_COORD(baseCoord)] = DepthMIP5;
|
||||
|
||||
MipDepthLDS[groupThreadID.x][groupThreadID.y] = DepthMIP5;
|
||||
GroupMemoryBarrierWithGroupSync();
|
||||
|
||||
// Write to MIP6
|
||||
[branch]
|
||||
if (all((groupThreadID.xy % int2(2, 2)) == 0))
|
||||
{
|
||||
float DepthLDS_00 = MipDepthLDS[groupThreadID.x + 0][groupThreadID.y + 0];
|
||||
float DepthLDS_10 = MipDepthLDS[groupThreadID.x + 1][groupThreadID.y + 0];
|
||||
float DepthLDS_01 = MipDepthLDS[groupThreadID.x + 0][groupThreadID.y + 1];
|
||||
float DepthLDS_11 = MipDepthLDS[groupThreadID.x + 1][groupThreadID.y + 1];
|
||||
|
||||
float DepthMIP6 = max(max(DepthLDS_00, DepthLDS_10), max(DepthLDS_01, DepthLDS_11));
|
||||
|
||||
_DepthPyramid_OutputMIP6[H_COORD(baseCoord / 2)] = DepthMIP6;
|
||||
MipDepthLDS[groupThreadID.x][groupThreadID.y] = DepthMIP6;
|
||||
}
|
||||
|
||||
GroupMemoryBarrierWithGroupSync();
|
||||
|
||||
// Write to MIP7
|
||||
[branch]
|
||||
if (all((groupThreadID.xy % int2(4, 4)) == 0))
|
||||
{
|
||||
float DepthLDS_00 = MipDepthLDS[groupThreadID.x + 0][groupThreadID.y + 0];
|
||||
float DepthLDS_10 = MipDepthLDS[groupThreadID.x + 2][groupThreadID.y + 0];
|
||||
float DepthLDS_01 = MipDepthLDS[groupThreadID.x + 0][groupThreadID.y + 2];
|
||||
float DepthLDS_11 = MipDepthLDS[groupThreadID.x + 2][groupThreadID.y + 2];
|
||||
|
||||
float DepthMIP7 = max(max(DepthLDS_00, DepthLDS_10), max(DepthLDS_01, DepthLDS_11));
|
||||
|
||||
_DepthPyramid_OutputMIP7[H_COORD(baseCoord / 4)] = DepthMIP7;
|
||||
MipDepthLDS[groupThreadID.x][groupThreadID.y] = DepthMIP7;
|
||||
}
|
||||
|
||||
// GroupMemoryBarrierWithGroupSync();
|
||||
//
|
||||
// // Write to MIP8
|
||||
// [branch]
|
||||
// if (all((groupThreadID.xy % int2(8, 8)) == 0))
|
||||
// {
|
||||
// float DepthLDS_00 = MipDepthLDS[groupThreadID.x + 0][groupThreadID.y + 0];
|
||||
// float DepthLDS_10 = MipDepthLDS[groupThreadID.x + 4][groupThreadID.y + 0];
|
||||
// float DepthLDS_01 = MipDepthLDS[groupThreadID.x + 0][groupThreadID.y + 4];
|
||||
// float DepthLDS_11 = MipDepthLDS[groupThreadID.x + 4][groupThreadID.y + 4];
|
||||
//
|
||||
// float DepthMIP8 = max(max(DepthLDS_00, DepthLDS_10), max(DepthLDS_01, DepthLDS_11));
|
||||
//
|
||||
// _DepthPyramid_OutputMIP8[H_COORD(baseCoord / 8)] = DepthMIP8;
|
||||
// }
|
||||
}
|
||||
14
Assets/External/HTraceWSGI/Resources/HTraceWSGI/_Shared/Computes/HDepthPyramid.compute.meta
vendored
Normal file
14
Assets/External/HTraceWSGI/Resources/HTraceWSGI/_Shared/Computes/HDepthPyramid.compute.meta
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ea1b07ce290d9b74090fc5ecf236697e
|
||||
ComputeShaderImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 379716
|
||||
packageName: 'HTrace: World Space Global Illumination URP | Beta'
|
||||
packageVersion: 0.9.6
|
||||
assetPath: Assets/HTraceWSGI/Resources/HTraceWSGI/_Shared/Computes/HDepthPyramid.compute
|
||||
uploadId: 925118
|
||||
266
Assets/External/HTraceWSGI/Resources/HTraceWSGI/_Shared/Computes/HInterpolation.compute
vendored
Normal file
266
Assets/External/HTraceWSGI/Resources/HTraceWSGI/_Shared/Computes/HInterpolation.compute
vendored
Normal file
@ -0,0 +1,266 @@
|
||||
#pragma kernel GatherSH
|
||||
#pragma kernel Interpolation
|
||||
|
||||
#pragma multi_compile _ USE_DIRECTIONAL_OCCLUSION
|
||||
|
||||
#include "../Includes/Config.hlsl"
|
||||
#include "../Includes/Reservoir.hlsl"
|
||||
#include "../Includes/SpatialFilteringFunctions.hlsl"
|
||||
#include "../Includes/SphericalHarmonics.hlsl"
|
||||
|
||||
#pragma multi_compile _ _GBUFFER_NORMALS_OCT
|
||||
|
||||
H_TEXTURE(_ShadowGuidanceMask);
|
||||
|
||||
H_TEXTURE(_ProbeSSAO);
|
||||
H_TEXTURE(_PackedSH_A);
|
||||
H_TEXTURE(_PackedSH_B);
|
||||
H_TEXTURE(_BentNormalsAO);
|
||||
H_TEXTURE(_ProbeNormalDepth);
|
||||
H_TEXTURE(g_GeometryNormal);
|
||||
|
||||
H_TEXTURE(_Temp);
|
||||
|
||||
H_RW_TEXTURE(uint, _Radiance_Output);
|
||||
H_RW_TEXTURE(uint4, _PackedSH_A_Output);
|
||||
H_RW_TEXTURE(uint4, _PackedSH_B_Output);
|
||||
|
||||
float _AO_Intensity;
|
||||
|
||||
// ------------------------ SH GATHER -----------------------
|
||||
[numthreads(8, 8, 1)]
|
||||
void GatherSH(uint3 pixCoord : SV_DispatchThreadID)
|
||||
{
|
||||
|
||||
|
||||
// Initialize SH storage
|
||||
SH_L2_Color CoefficientsSH;
|
||||
InitializeSH(CoefficientsSH);
|
||||
|
||||
uint2 Unused;
|
||||
float3 Normal = UnpackNormalDepth(asuint(H_LOAD(_ProbeNormalDepth, pixCoord.xy)).xy, Unused).xyz;
|
||||
|
||||
// Accumulate all cells to SH
|
||||
for (int x = 0; x < _OctahedralSize; x++)
|
||||
{
|
||||
for (int y = 0; y < _OctahedralSize; y++)
|
||||
{
|
||||
int2 TapCoord = pixCoord.xy * _OctahedralSize + uint2(x,y);
|
||||
|
||||
// Load packed radiance data reservoir
|
||||
uint2 RadianceDataPacked = asuint(H_LOAD(_ReservoirAtlasRadianceData, TapCoord).xy);
|
||||
|
||||
// Unpack radiance and W
|
||||
float3 ReservoirRadiance = UnpackTonemappedColor24bit(RadianceDataPacked.x);
|
||||
float ReservoirW = f16tof32(RadianceDataPacked.y >> 16);
|
||||
|
||||
// Calculate octahedral ray direction
|
||||
float3 RayDirection = OrientedOctahedronToDirection((float2(x, y) + 0.5f) / float(_OctahedralSize), Normal);
|
||||
|
||||
// Use reservoir ray direction instead (optional)
|
||||
if (USE_RESERVOIR_RAY_DIRECTION)
|
||||
{
|
||||
uint2 RayDataPacked = asuint(H_LOAD(_ReservoirAtlasRayData, TapCoord).xy);
|
||||
RayDirection = UnpackDirection24bit(RayDataPacked.x);
|
||||
}
|
||||
|
||||
// Add radiance to SH
|
||||
AddSampleSH(CoefficientsSH, RayDirection, ReservoirRadiance * ReservoirW * 2.0f);
|
||||
}
|
||||
}
|
||||
|
||||
// Normalize SH coefficients
|
||||
CoefficientsSH.R.V0 /= float(_OctahedralSize * _OctahedralSize);
|
||||
CoefficientsSH.R.V1 /= float(_OctahedralSize * _OctahedralSize);
|
||||
CoefficientsSH.R.V2 /= float(_OctahedralSize * _OctahedralSize);
|
||||
CoefficientsSH.G.V0 /= float(_OctahedralSize * _OctahedralSize);
|
||||
CoefficientsSH.G.V1 /= float(_OctahedralSize * _OctahedralSize);
|
||||
CoefficientsSH.G.V2 /= float(_OctahedralSize * _OctahedralSize);
|
||||
CoefficientsSH.B.V0 /= float(_OctahedralSize * _OctahedralSize);
|
||||
CoefficientsSH.B.V1 /= float(_OctahedralSize * _OctahedralSize);
|
||||
CoefficientsSH.B.V2 /= float(_OctahedralSize * _OctahedralSize);
|
||||
|
||||
// Pack SH coefficients
|
||||
uint4 PackedSH_A, PackedSH_B;
|
||||
PackInterpolationSH(PackedSH_A, PackedSH_B, CoefficientsSH);
|
||||
|
||||
_PackedSH_A_Output[H_COORD(pixCoord.xy)] = PackedSH_A;
|
||||
_PackedSH_B_Output[H_COORD(pixCoord.xy)] = PackedSH_B;
|
||||
}
|
||||
|
||||
|
||||
// ------------------------ INTERPOLATION KERNEL ------------------------
|
||||
[numthreads(8,8,1)]
|
||||
void Interpolation(uint3 pixCoord : SV_DispatchThreadID, uint2 groupThreadID : SV_GroupThreadID, uint2 groupId : SV_GroupID)
|
||||
{
|
||||
|
||||
|
||||
// Load center full-res depth
|
||||
float DepthCenter = HBUFFER_DEPTH(pixCoord.xy);
|
||||
|
||||
// Early-out on the skybox
|
||||
if (DepthCenter <= 1e-7)
|
||||
{
|
||||
_Radiance_Output[H_COORD(pixCoord.xy)] = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
float2 pixCoordNDC = (pixCoord.xy + 0.5f) * _ScreenSize.zw;
|
||||
int2 InterpolationCoord = pixCoord.xy;
|
||||
|
||||
// Load and prepare other center full-res data
|
||||
float DepthLinearCenter = H_LINEAR_EYE_DEPTH(DepthCenter);
|
||||
float3 GeometryNormalCenter = H_LOAD(g_GeometryNormal, pixCoord.xy).xyz;
|
||||
float3 WorldPosCenter = H_COMPUTE_POSITION_WS(pixCoordNDC, DepthCenter, H_MATRIX_I_VP);
|
||||
float4 NormalPlane = float4(GeometryNormalCenter, dot(WorldPosCenter, GeometryNormalCenter));
|
||||
|
||||
// Get interpolation jitter to hide grid-like artifacts
|
||||
float2 Jitter;
|
||||
Jitter.x = GetBNDSequenceSample(pixCoord.xy, uint(_FrameCount) % 16, 7);
|
||||
Jitter.y = GetBNDSequenceSample(pixCoord.xy, uint(_FrameCount) % 16, 8);
|
||||
float2 InterpolationJitter = Jitter.xy * float(_ProbeSize);
|
||||
// float2 InterpolationJitter = (Jitter.xy * 2 - 1 ) * float(_ProbeSize / 2);
|
||||
|
||||
// Jitter interpolation coords and calculate jittered position at these coords
|
||||
float2 JitteredCoord = pixCoord.xy + InterpolationJitter;
|
||||
float3 JitteredWorldPos = H_COMPUTE_POSITION_WS((JitteredCoord + 0.5f) * _ScreenSize.zw, HBUFFER_DEPTH(JitteredCoord), H_MATRIX_I_VP);
|
||||
|
||||
// Use the jittered position only if it's on the same plane with our initial positon
|
||||
if (ProbePlaneWeighting(NormalPlane, JitteredWorldPos, H_LINEAR_EYE_DEPTH(DepthCenter), 10000.0f) > 0.01)
|
||||
{
|
||||
InterpolationCoord = JitteredCoord;
|
||||
}
|
||||
|
||||
float4 BentNormalsSSAO = 0;
|
||||
float CosThetaSSAO = 0;
|
||||
float CenterSSAO = 0;
|
||||
|
||||
// Use bent normals and ssao to evaluate directional occlusion and assist interpolation
|
||||
if (USE_DIRECTIONAL_OCCLUSION)
|
||||
{
|
||||
BentNormalsSSAO = H_LOAD(_BentNormalsAO, pixCoord.xy);
|
||||
CosThetaSSAO = lerp(1.0f - BentNormalsSSAO.w, 1 - acos(sqrt(saturate(1.0f - BentNormalsSSAO.w))), 0.5);
|
||||
CenterSSAO = BentNormalsSSAO.w;
|
||||
}
|
||||
|
||||
// Prepare 5x5 spatial offsets for interpolation search
|
||||
int2 SampleOffsets[25] = {int2( 0, 0), int2( 0, 1), int2( 1, 0), int2( 1, 1), int2(-1, 0), int2(-1, 1), int2(-1, -1), int2( 0, -1), int2( 1, -1),
|
||||
int2(-2, 0), int2( 0, -2), int2( 2, 0), int2( 0, 2), int2(-1, 2), int2(-2, 1), int2( 1, -2), int2( 2, -1),
|
||||
int2(-2, -1), int2(-1, -2), int2( 2, 1), int2( 1, 2), int2(-2, 2), int2( 2, 2), int2( 2, -2), int2(-2, 2)};
|
||||
|
||||
// Initialize interpolation sample weights with zero
|
||||
float SampleWeights[INTERPOLATION_SAMPLES];
|
||||
|
||||
for (int s = 0; s < INTERPOLATION_SAMPLES; s++)
|
||||
{
|
||||
SampleWeights[s] = 0;
|
||||
}
|
||||
|
||||
// Do the interpolation search
|
||||
for (int i = 0; i < INTERPOLATION_SAMPLES; i++)
|
||||
{
|
||||
// Calculate sample coord
|
||||
int2 TapCoord = floor(uint2(InterpolationCoord) / _ProbeSize) + SampleOffsets[i];
|
||||
|
||||
// Load sample low-res normal, depth & SSAO
|
||||
uint2 ProbeOffset;
|
||||
float4 NormalDepthSample = UnpackNormalDepth(asuint(H_LOAD(_ProbeNormalDepth, TapCoord)).xy, ProbeOffset);
|
||||
|
||||
// Calculate low-res world position
|
||||
float2 TapCoordNDC = (TapCoord * float(_ProbeSize) + float2(ProbeOffset) + 0.5f / float(_ProbeSize)) * _ScreenSize.zw;
|
||||
float3 WorldPosSample = H_COMPUTE_POSITION_WS(TapCoordNDC, NormalDepthSample.w, H_MATRIX_I_VP);
|
||||
|
||||
// Calculate spatial sample weights
|
||||
float WeightPlane = ProbePlaneWeighting(NormalPlane, WorldPosSample, DepthLinearCenter, 10000);
|
||||
float WeightNormal = saturate(dot(NormalDepthSample.xyz, GeometryNormalCenter));
|
||||
|
||||
float PixelDistanceWeight = distance(float2(pixCoord.xy), (float2(TapCoord * _ProbeSize) + float2(ProbeOffset))) / (float(_ProbeSize + _ProbeSize) - 1.0f);
|
||||
PixelDistanceWeight = 1 - PixelDistanceWeight;
|
||||
|
||||
// Combine all weights and store
|
||||
SampleWeights[i] = WeightPlane * WeightNormal * PixelDistanceWeight;
|
||||
|
||||
if (USE_DIRECTIONAL_OCCLUSION)
|
||||
{
|
||||
float SampleSSAO = H_LOAD(_ProbeSSAO, TapCoord).x;
|
||||
float WeightSSAO = exp2(-20.0 * abs(pow(SampleSSAO, 2) - pow(CenterSSAO, 2)));
|
||||
SampleWeights[i] *= WeightSSAO;
|
||||
}
|
||||
}
|
||||
|
||||
// Stochastically pick one sample
|
||||
int2 SelectedSampleOffset = 0;
|
||||
float RandomValue = GetBNDSequenceSample(pixCoord.xy, uint(_FrameCount) % 16, 5);
|
||||
|
||||
float WeightSumm = 0;
|
||||
for (int t = 0; t < INTERPOLATION_SAMPLES; t++)
|
||||
{
|
||||
WeightSumm += SampleWeights[t];
|
||||
}
|
||||
|
||||
RandomValue *= WeightSumm;
|
||||
|
||||
UNITY_UNROLL
|
||||
for (int k = INTERPOLATION_SAMPLES; k > 0; k--)
|
||||
{
|
||||
float WeightSumm = 0;
|
||||
|
||||
UNITY_UNROLL
|
||||
for (int j = 0; j < k - 1; j++)
|
||||
{
|
||||
WeightSumm += SampleWeights[j];
|
||||
}
|
||||
|
||||
if (RandomValue >= WeightSumm)
|
||||
{
|
||||
SelectedSampleOffset = SampleOffsets[k - 1];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Select normal that will be used for interpolation
|
||||
float3 InterpolationNormal = HBUFFER_NORMAL_WS(pixCoord.xy);
|
||||
if (USE_DIRECTIONAL_OCCLUSION)
|
||||
{
|
||||
InterpolationNormal = BentNormalsSSAO.w > 0.8 ? lerp(BentNormalsSSAO.xyz, InterpolationNormal, BentNormalsSSAO.w) : BentNormalsSSAO.xyz;
|
||||
}
|
||||
|
||||
// Boost normal map details (be careful, it's just an approximation)
|
||||
if (INTERPOLATION_NORMAL_BOOST > 1)
|
||||
{
|
||||
float3 NormalOriginal = InterpolationNormal;
|
||||
float3 NormalDifference = NormalOriginal - GeometryNormalCenter;
|
||||
|
||||
NormalDifference *= INTERPOLATION_NORMAL_BOOST;
|
||||
InterpolationNormal = (NormalDifference + GeometryNormalCenter);
|
||||
|
||||
if (dot(normalize(NormalDifference + GeometryNormalCenter), NormalOriginal) > 0.97)
|
||||
InterpolationNormal = NormalOriginal;
|
||||
|
||||
if (USE_DIRECTIONAL_OCCLUSION)
|
||||
InterpolationNormal = lerp(NormalOriginal, InterpolationNormal, pow(BentNormalsSSAO.w, 3));
|
||||
}
|
||||
|
||||
// Calculate final interpolation coord
|
||||
InterpolationCoord = floor(uint2(InterpolationCoord) / _ProbeSize) + SelectedSampleOffset;
|
||||
|
||||
// Bypass interpolation (for debug)
|
||||
if (DISABLE_INTERPOLATION)
|
||||
{
|
||||
InterpolationCoord = floor(pixCoord.xy / _ProbeSize);
|
||||
InterpolationNormal = UnpackNormal(asuint(H_LOAD(_ProbeNormalDepth, InterpolationCoord).xy));
|
||||
}
|
||||
|
||||
// Load packed SH coefficients
|
||||
uint4 PackedSH_A = asuint(H_LOAD(_PackedSH_A, InterpolationCoord));
|
||||
uint4 PackedSH_B = asuint(H_LOAD(_PackedSH_B, InterpolationCoord));
|
||||
|
||||
// Unpack SH coefficients
|
||||
SH_L2_Color LightingSH;
|
||||
UnpackInterpolationSH(PackedSH_A, PackedSH_B, LightingSH);
|
||||
|
||||
// Evaluate SH coefficients to get the final lighting
|
||||
float3 RadianceInterpolated = EvaluateSHIrradiance(InterpolationNormal.xyz, CosThetaSSAO, LightingSH);
|
||||
|
||||
_Radiance_Output[H_COORD(pixCoord.xy)] = PackToR11G10B10A1f(RadianceInterpolated, WeightSumm > 0.01);
|
||||
}
|
||||
14
Assets/External/HTraceWSGI/Resources/HTraceWSGI/_Shared/Computes/HInterpolation.compute.meta
vendored
Normal file
14
Assets/External/HTraceWSGI/Resources/HTraceWSGI/_Shared/Computes/HInterpolation.compute.meta
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a38055874f454a342bc27fc1d5517895
|
||||
ComputeShaderImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 379716
|
||||
packageName: 'HTrace: World Space Global Illumination URP | Beta'
|
||||
packageVersion: 0.9.6
|
||||
assetPath: Assets/HTraceWSGI/Resources/HTraceWSGI/_Shared/Computes/HInterpolation.compute
|
||||
uploadId: 925118
|
||||
163
Assets/External/HTraceWSGI/Resources/HTraceWSGI/_Shared/Computes/HProbeAmbientOcclusion.compute
vendored
Normal file
163
Assets/External/HTraceWSGI/Resources/HTraceWSGI/_Shared/Computes/HProbeAmbientOcclusion.compute
vendored
Normal file
@ -0,0 +1,163 @@
|
||||
#pragma kernel ProbeAmbientOcclusion
|
||||
#pragma kernel ProbeAmbientOcclusionSpatialFilter
|
||||
#pragma kernel ProbeAmbientOcclusionHistoryUpdate
|
||||
|
||||
#include "../Includes/Config.hlsl"
|
||||
#include "../Includes/Reservoir.hlsl"
|
||||
#include "../Includes/VoxelizationCommon.hlsl"
|
||||
//#include "../Includes/VoxelTraversal.hlsl"
|
||||
|
||||
#pragma multi_compile _ _GBUFFER_NORMALS_OCT
|
||||
|
||||
H_TEXTURE(_RayDirection);
|
||||
H_TEXTURE(_RayDistanceSS);
|
||||
H_TEXTURE(_RayDistanceWS);
|
||||
H_TEXTURE(_ProbeNormalDepth);
|
||||
H_TEXTURE(_ReprojectionWeights);
|
||||
H_TEXTURE(_ProbeAmbientOcclusion);
|
||||
H_TEXTURE(_PersistentReprojectionCoord);
|
||||
H_TEXTURE_ARRAY(_ProbeAmbientOcclusion_History);
|
||||
|
||||
H_TEXTURE_ARRAY(_SpatialWeightsPacked);
|
||||
H_TEXTURE_ARRAY(_SpatialOffsetsPacked);
|
||||
|
||||
H_RW_TEXTURE_ARRAY(uint, _ProbeAmbientOcclusion_ArrayOutput);
|
||||
H_RW_TEXTURE(float, _ProbeAmbientOcclusion_OutputFiltered);
|
||||
H_RW_TEXTURE(uint, _ProbeAmbientOcclusion_Output);
|
||||
|
||||
// ------------------------ PROBE AMBIENT OCCLUSION GATHER & ACCUMULATION ------------------------
|
||||
[numthreads(8, 8, 1)]
|
||||
void ProbeAmbientOcclusion(uint3 pixCoord : SV_DispatchThreadID, uint2 groupThreadID : SV_GroupThreadID)
|
||||
{
|
||||
|
||||
|
||||
// Load probe normal, depth & offset
|
||||
uint2 ProbeOffset;
|
||||
float4 NormalDepth = UnpackNormalDepth(asuint(H_LOAD(_ProbeNormalDepth, pixCoord.xy)).xy, ProbeOffset);
|
||||
float2 ProbeCoordNDC = (pixCoord.xy * _ProbeSize + float2(ProbeOffset) + 0.5f) * _ScreenSize.zw;
|
||||
float3 PositionWS = H_COMPUTE_POSITION_WS(ProbeCoordNDC.xy, NormalDepth.w, H_MATRIX_I_VP);
|
||||
|
||||
float WeightGathered = 0;
|
||||
float OcclusionGathered = 0;
|
||||
float MaxClampDistance = PROBE_AO_CLAMP_DISTANCE;
|
||||
|
||||
// Scale max
|
||||
MaxClampDistance = lerp(MaxClampDistance * 0.1, MaxClampDistance, saturate(length(PositionWS) / 5.0f));
|
||||
|
||||
// Gather hit ray distance across all probe cells
|
||||
for (int x = 0; x < _OctahedralSize; x++)
|
||||
{
|
||||
for (int y = 0; y < _OctahedralSize; y++)
|
||||
{
|
||||
int2 SampleCoord = pixCoord.xy * _OctahedralSize + uint2(x,y);
|
||||
|
||||
// Load SS and WS hit distances and other data
|
||||
bool TracedWorldRay, IsOutsideFrame;
|
||||
float HitDistancWS = H_LOAD(_RayDistanceWS, SampleCoord).x;
|
||||
float HitDistancSS = abs(UnpackHitDistance(asuint(H_LOAD(_RayDistanceSS, SampleCoord).x), IsOutsideFrame, TracedWorldRay));
|
||||
|
||||
// Out ambient occlusion sample is simply our WS hit distance in this case
|
||||
float OcclusionSample = HitDistancWS;
|
||||
|
||||
// We can discard too short WS rays to avoid darkening around the corners and behind objects
|
||||
if (HitDistancWS <= _VoxelSize.x && TracedWorldRay)
|
||||
{
|
||||
OcclusionSample = IsOutsideFrame ? MaxClampDistance : OcclusionSample;
|
||||
OcclusionSample = lerp(MaxClampDistance, OcclusionSample, saturate(length(PositionWS) / 1.0f));
|
||||
}
|
||||
|
||||
// Clamp our sample to the maximum occlusion distance
|
||||
OcclusionSample = clamp(OcclusionSample, 0, MaxClampDistance);
|
||||
|
||||
// Calculate octahedral direction and get cosine weight for this sample
|
||||
float3 RayDirection = OrientedOctahedronToDirection((float2(x, y) + 0.5f) / float(_OctahedralSize), NormalDepth.xyz);
|
||||
float Weight = saturate(dot(RayDirection, NormalDepth.xyz));
|
||||
|
||||
// Of sample (distance) <= 0 - it means that it's a cell culled by checkerboarding
|
||||
if (OcclusionSample > 0)
|
||||
{
|
||||
WeightGathered += MaxClampDistance * Weight;
|
||||
OcclusionGathered += OcclusionSample * Weight;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Weighted average
|
||||
OcclusionGathered = saturate(OcclusionGathered / WeightGathered);
|
||||
|
||||
// Load reprojection coords and weights and normalize them
|
||||
uint ReprojectionIndex;
|
||||
float4 ReprojectionWeights = H_LOAD(_ReprojectionWeights, pixCoord.xy);
|
||||
int2 ReprojectionCoordPacked = asuint(H_LOAD(_PersistentReprojectionCoord, pixCoord.xy).xy);
|
||||
int2 ReprojectionCoord = UnpackPersistentReprojectionCoord(ReprojectionCoordPacked, ReprojectionIndex);
|
||||
|
||||
// Normalize reprojection weights
|
||||
float WeightsSumm = max(ReprojectionWeights.x + ReprojectionWeights.y + ReprojectionWeights.z + ReprojectionWeights.w, 1.0e-3);
|
||||
ReprojectionWeights /= WeightsSumm;
|
||||
|
||||
// Load packed occlusion history samples
|
||||
uint OcclusionHistoryPacked00 = asuint(H_LOAD_ARRAY(_ProbeAmbientOcclusion_History, ReprojectionCoord + uint2(0, 0), GetHistoryIndex(ReprojectionIndex)).x);
|
||||
uint OcclusionHistoryPacked01 = asuint(H_LOAD_ARRAY(_ProbeAmbientOcclusion_History, ReprojectionCoord + uint2(1, 0), GetHistoryIndex(ReprojectionIndex)).x);
|
||||
uint OcclusionHistoryPacked10 = asuint(H_LOAD_ARRAY(_ProbeAmbientOcclusion_History, ReprojectionCoord + uint2(0, 1), GetHistoryIndex(ReprojectionIndex)).x);
|
||||
uint OcclusionHistoryPacked11 = asuint(H_LOAD_ARRAY(_ProbeAmbientOcclusion_History, ReprojectionCoord + uint2(1, 1), GetHistoryIndex(ReprojectionIndex)).x);
|
||||
|
||||
// Unpack occlusion history (.x channel) and its samplecount (.y channel)
|
||||
float2 OcclusionHistory00 = UnpackProbeAO(OcclusionHistoryPacked00, PROBE_AO_MAX_TEMPORAL_SAMPLES) * ReprojectionWeights.xx;
|
||||
float2 OcclusionHistory01 = UnpackProbeAO(OcclusionHistoryPacked01, PROBE_AO_MAX_TEMPORAL_SAMPLES) * ReprojectionWeights.yy;
|
||||
float2 OcclusionHistory10 = UnpackProbeAO(OcclusionHistoryPacked10, PROBE_AO_MAX_TEMPORAL_SAMPLES) * ReprojectionWeights.zz;
|
||||
float2 OcclusionHistory11 = UnpackProbeAO(OcclusionHistoryPacked11, PROBE_AO_MAX_TEMPORAL_SAMPLES) * ReprojectionWeights.ww;
|
||||
|
||||
// Combine bilinear samples
|
||||
float2 OcclusionHistoryReprojected = OcclusionHistory00 + OcclusionHistory01 + OcclusionHistory10 + OcclusionHistory11;
|
||||
|
||||
// Temporally accumulate
|
||||
float SampleCount = min(PROBE_AO_MAX_TEMPORAL_SAMPLES, OcclusionHistoryReprojected.y + 1);
|
||||
OcclusionGathered = lerp(OcclusionGathered, OcclusionHistoryReprojected.x, 1.0f - (1.0f / float(SampleCount)));
|
||||
|
||||
// Output
|
||||
_ProbeAmbientOcclusion_Output[H_COORD(pixCoord.xy)] = PackProbeAO(OcclusionGathered, SampleCount, PROBE_AO_MAX_TEMPORAL_SAMPLES);
|
||||
}
|
||||
|
||||
|
||||
// ------------------------ PROBE AMBIENT OCCLUSION SPATIAL FILTER ------------------------
|
||||
[numthreads(8, 8, 1)]
|
||||
void ProbeAmbientOcclusionSpatialFilter(uint3 pixCoord : SV_DispatchThreadID, uint2 groupThreadID : SV_GroupThreadID, uint groupIndex : SV_GroupIndex, uint groupID : SV_GroupID)
|
||||
{
|
||||
|
||||
|
||||
// Load packed sample weights and coords
|
||||
float SampleWeights[8]; int2 SampleOffsets[8];
|
||||
uint4 PackedSampleOffsets = asuint(H_LOAD_ARRAY(_SpatialOffsetsPacked, pixCoord.xy, 0));
|
||||
uint4 PackedSampleWeights = asuint(H_LOAD_ARRAY(_SpatialWeightsPacked, pixCoord.xy, 0));
|
||||
|
||||
// Unpack sample weights and coords
|
||||
UnpackFilteringOffsetsX8(PackedSampleOffsets, SampleOffsets);
|
||||
UnpackFilteringWeightsX8(PackedSampleWeights, SampleWeights);
|
||||
|
||||
// Unpack center occlusion and samplecount
|
||||
uint ProbeAmbientOcclusionPacked = asuint(H_LOAD(_ProbeAmbientOcclusion, pixCoord.xy).x);
|
||||
float2 ProbeAmbientOcclusion = UnpackProbeAO(ProbeAmbientOcclusionPacked, PROBE_AO_MAX_TEMPORAL_SAMPLES);
|
||||
|
||||
// Scale filter weight based on the accumulated samplecount
|
||||
float SpatialWeight = ProbeAmbientOcclusion.y == PROBE_AO_MAX_TEMPORAL_SAMPLES ? 0 : lerp(1, 0, 1.0f - (1.0f / float(ProbeAmbientOcclusion.y)));
|
||||
|
||||
float AccumulatedWeight = 1;
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
uint ProbeAmbientOcclusionSamplePacked = asuint(H_LOAD(_ProbeAmbientOcclusion, pixCoord.xy + SampleOffsets[i]).x);
|
||||
|
||||
AccumulatedWeight += SampleWeights[i] * SpatialWeight;
|
||||
ProbeAmbientOcclusion.x += UnpackProbeAO(ProbeAmbientOcclusionSamplePacked, 0).x * SampleWeights[i] * SpatialWeight;
|
||||
}
|
||||
|
||||
_ProbeAmbientOcclusion_OutputFiltered[H_COORD(pixCoord.xy)] = ProbeAmbientOcclusion.x / AccumulatedWeight;
|
||||
}
|
||||
|
||||
|
||||
// ------------------------ PROBE AMBIENT OCCLUSION HISTORY UPDATE ------------------------
|
||||
[numthreads(8, 8, 1)]
|
||||
void ProbeAmbientOcclusionHistoryUpdate(uint3 pixCoord : SV_DispatchThreadID, uint2 groupThreadID : SV_GroupThreadID, uint groupIndex : SV_GroupIndex, uint groupID : SV_GroupID)
|
||||
{
|
||||
|
||||
_ProbeAmbientOcclusion_ArrayOutput[uint3(pixCoord.xy, H_INDEX_ARRAY(uint(_FrameCount) % _PersistentHistorySamples))] = asuint(H_LOAD(_ProbeAmbientOcclusion, pixCoord.xy).x);
|
||||
}
|
||||
@ -0,0 +1,14 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dbaeb07454d061d4587d648190df361d
|
||||
ComputeShaderImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 379716
|
||||
packageName: 'HTrace: World Space Global Illumination URP | Beta'
|
||||
packageVersion: 0.9.6
|
||||
assetPath: Assets/HTraceWSGI/Resources/HTraceWSGI/_Shared/Computes/HProbeAmbientOcclusion.compute
|
||||
uploadId: 925118
|
||||
396
Assets/External/HTraceWSGI/Resources/HTraceWSGI/_Shared/Computes/HRadianceCache.compute
vendored
Normal file
396
Assets/External/HTraceWSGI/Resources/HTraceWSGI/_Shared/Computes/HRadianceCache.compute
vendored
Normal file
@ -0,0 +1,396 @@
|
||||
#pragma kernel CacheDataUpdate
|
||||
#pragma kernel CachePrimarySpawn
|
||||
#pragma kernel CacheTracingUpdate
|
||||
#pragma kernel CacheLightEvaluation
|
||||
#pragma kernel CacheDataClear
|
||||
|
||||
#pragma multi_compile _ EVALUATE_PUNCTUAL_LIGHTS
|
||||
#pragma multi_compile _ _ADDITIONAL_LIGHT_SHADOWS
|
||||
|
||||
#include "../Includes/Config.hlsl"
|
||||
#include "../Includes/VoxelTraversal.hlsl"
|
||||
#include "../Includes/SpatialHash.hlsl"
|
||||
#include "../Includes/VoxelLightingEvaluation.hlsl"
|
||||
#include "../Includes/SpatialFilteringFunctions.hlsl"
|
||||
#include "../Includes/ScreenProbesCommon.hlsl"
|
||||
#pragma multi_compile _ _GBUFFER_NORMALS_OCT
|
||||
|
||||
H_TEXTURE(_ReprojectionCoords);
|
||||
H_TEXTURE(_ProbeNormalDepth);
|
||||
H_TEXTURE(g_GeometryNormal);
|
||||
H_TEXTURE(_RadianceAtlas);
|
||||
|
||||
H_RW_TEXTURE3D(float3, _RadianceCacheFiltered_Output);
|
||||
|
||||
float _RayLength;
|
||||
|
||||
uint _HashUpdateFrameIndex;
|
||||
int _FreezeCache;
|
||||
|
||||
|
||||
// ------------------------ FUNCTIONS --------------------------
|
||||
float3 AccumulateCache(float3 RadianceCurr, float3 RadiancePrev, float Min, float Max)
|
||||
{
|
||||
if (!ADAPTIVE_TEMPORAL_WEIGHT)
|
||||
return lerp(RadianceCurr, RadiancePrev, Max);
|
||||
|
||||
float LumaCurr = Luminance(RadianceCurr / min(HGetInverseCurrentExposureMultiplier, 5.0f));
|
||||
float LumaPrev = Luminance(RadiancePrev / min(HGetInverseCurrentExposureMultiplier, 5.0f));
|
||||
|
||||
float Difference = abs(LumaCurr - LumaPrev) / max(LumaCurr, max(LumaPrev, 0.2f));
|
||||
float Weight = 1.0 - Difference;
|
||||
float Feedback = lerp(Max, Min, Weight * Weight);
|
||||
|
||||
return lerp(RadianceCurr, RadiancePrev, Feedback);
|
||||
}
|
||||
|
||||
|
||||
// ------------------------ CACHE SPAWN & UPDATE ON PRIMARY SURFACES --------------------------
|
||||
[numthreads(8, 8, 1)]
|
||||
void CachePrimarySpawn(uint3 pixCoord : SV_DispatchThreadID)
|
||||
{
|
||||
// We jitter pixel every frame to cover full frame over time
|
||||
float2 Jitter;
|
||||
Jitter.x = GetBNDSequenceSample(pixCoord.xy, uint(_FrameCount) % 36, 3);
|
||||
Jitter.y = GetBNDSequenceSample(pixCoord.xy, uint(_FrameCount) % 36, 4);
|
||||
float2 PixelJitter = Jitter.xy * float(_ProbeSize);
|
||||
|
||||
uint2 ProbeOffset;
|
||||
float4 NormalDepth = UnpackNormalDepth(asuint(H_LOAD(_ProbeNormalDepth, pixCoord.xy).xy), ProbeOffset);
|
||||
float3 WorldPos = H_COMPUTE_POSITION_WS((pixCoord.xy * float(_ProbeSize) + float2(ProbeOffset) + 0.5f) * _ScreenSize.zw, NormalDepth.w, H_MATRIX_I_VP);
|
||||
float4 NormalPlane = float4(NormalDepth.xyz, dot(WorldPos, NormalDepth.xyz));
|
||||
|
||||
float3 NormalJittered = H_LOAD(g_GeometryNormal, pixCoord.xy * _ProbeSize + PixelJitter).xyz;
|
||||
float DepthJitterd = HBUFFER_DEPTH(pixCoord.xy * _ProbeSize + PixelJitter);
|
||||
float3 WorldPosJittered = H_COMPUTE_POSITION_WS((pixCoord.xy * float(_ProbeSize) + float2(PixelJitter) + 0.5f) * _ScreenSize.zw, DepthJitterd, H_MATRIX_I_VP);
|
||||
|
||||
// Use the jittered position only if it's on the same plane with our initial positon
|
||||
if (ProbePlaneWeighting(NormalPlane, WorldPosJittered, H_LINEAR_EYE_DEPTH(NormalDepth.w), 1000.0f) > 0.01)
|
||||
{
|
||||
NormalDepth.xyz = NormalJittered;
|
||||
NormalDepth.w = DepthJitterd;
|
||||
WorldPos = WorldPosJittered;
|
||||
}
|
||||
|
||||
// Early out on skybox
|
||||
if (NormalDepth.w <= 1e-7)
|
||||
return;
|
||||
|
||||
float4 CacheRadiance = 0;
|
||||
|
||||
// Gather radiance and evaluate temporal invalidity acrosss an octahedral screen probe
|
||||
for (int x = 0; x < _OctahedralSize; x++)
|
||||
{
|
||||
for (int y = 0; y < _OctahedralSize; y++)
|
||||
{
|
||||
uint2 TapCoord = pixCoord.xy * _OctahedralSize + uint2(x,y);
|
||||
|
||||
// Calculate average ray direction for this octahedral cell
|
||||
float3 RayDirection = OrientedOctahedronToDirection((float2(x, y) + 0.5f) / float(_OctahedralSize), NormalDepth.xyz);
|
||||
|
||||
float4 RadianceSample = H_LOAD(_RadianceAtlas, TapCoord) * 2.0f * saturate(dot(RayDirection, NormalDepth.xyz));
|
||||
|
||||
if (RadianceSample.w > 0)
|
||||
CacheRadiance += float4(RadianceSample.xyz, 1);
|
||||
}
|
||||
}
|
||||
|
||||
// Average cache radiance
|
||||
if (CacheRadiance.w > 0)
|
||||
CacheRadiance.xyz /= CacheRadiance.w;
|
||||
|
||||
if (AnyIsNaN(CacheRadiance) || AnyIsInf(CacheRadiance))
|
||||
CacheRadiance = 0;
|
||||
|
||||
// Calculate cache coords from visible world space position of the primary surface
|
||||
float3 AbsolutePositionWS = H_GET_ABSOLUTE_POSITION_WS(WorldPos);
|
||||
int3 HitCoord = floor((AbsolutePositionWS) * _VoxelPerMeter) + (_VoxelResolution.xzy / 2.0f);
|
||||
int3 VoxelSpans = floor(HitCoord / (_VoxelResolution.xzy));
|
||||
int3 CacheCoord = HitCoord - (VoxelSpans * _VoxelResolution.xzy);
|
||||
|
||||
int3 VoxelCoordAbsolute = floor((AbsolutePositionWS) * _VoxelPerMeter);
|
||||
float3 VoxelHitOffset = float3(VoxelCoordAbsolute) * _VoxelSize - AbsolutePositionWS;
|
||||
|
||||
// Evaluate spatial hash
|
||||
if (!FREEZE_CACHE)
|
||||
{
|
||||
uint HashKey = PackHashKey(CacheCoord, NormalDepth.xyz);
|
||||
|
||||
bool IsEmpty;
|
||||
uint HashRank = 3;
|
||||
uint HashProbingIndex, HashLowestRankIndex;
|
||||
uint HashIndex = HashGetIndex(CacheCoord, PackVoxelNormalIndex(NormalDepth.xyz));
|
||||
bool HashFound = HashFindAny(HashIndex, HashKey, HashRank, HashLowestRankIndex, HashProbingIndex, IsEmpty);
|
||||
|
||||
if (HashFound)
|
||||
{
|
||||
// Load packed radiance cache
|
||||
uint3 RadiancePacked = _HashBuffer_Radiance[HashProbingIndex].xyz;
|
||||
|
||||
// Unpack both near and full caches
|
||||
float3 CacheRadianceFull = UnpackCacheRadianceFull(RadiancePacked.xyz);
|
||||
float3 CacheRadianceNear = UnpackCacheRadianceNear(RadiancePacked.xyz);
|
||||
|
||||
// Accumulate to full range radiance cache
|
||||
CacheRadianceFull = AccumulateCache(CacheRadiance.xyz, CacheRadianceFull, 0.83f, 0.93f);
|
||||
|
||||
_HashBuffer_Radiance[HashProbingIndex] = uint4(PackCacheRadiance(CacheRadianceFull, CacheRadianceNear), 0);
|
||||
_HashBuffer_Counter[HashProbingIndex] = 255;
|
||||
_HashBuffer_Key[HashProbingIndex] = HashKey | 0x3;
|
||||
}
|
||||
else if (IsEmpty) // If we didn't find a valid entry but found an empty cell, we spawn a new entry with radiance in it
|
||||
{
|
||||
_HashBuffer_Position[HashProbingIndex] = uint4(asuint(VoxelCoordAbsolute.xyz), PackHitOffset(VoxelHitOffset));
|
||||
_HashBuffer_Radiance[HashProbingIndex] = 0; //uint4(PackCacheRadiance(CacheRadiance, 0), 0);
|
||||
_HashBuffer_Counter[HashProbingIndex] = 255;
|
||||
_HashBuffer_Key[HashProbingIndex] = HashKey | 0x3;
|
||||
}
|
||||
else if (HashRank != 3) // If neither a valid nor an empty entry was found, we recycle the lowest ranked cell to spawn a new entry with radiance in it
|
||||
{
|
||||
_HashBuffer_Position[HashLowestRankIndex] = uint4(asuint(VoxelCoordAbsolute.xyz), PackHitOffset(VoxelHitOffset));
|
||||
_HashBuffer_Radiance[HashLowestRankIndex] = 0; //uint4(PackCacheRadiance(CacheRadiance, 0), 0);
|
||||
_HashBuffer_Counter[HashLowestRankIndex] = 255;
|
||||
_HashBuffer_Key[HashLowestRankIndex] = HashKey | 0x3;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ------------------------ CACHE TRACING UPDATE --------------------------
|
||||
[numthreads(64, 1, 1)]
|
||||
void CacheTracingUpdate(uint dispatchThreadId : SV_DispatchThreadID)
|
||||
{
|
||||
uint PayloadIndex = dispatchThreadId.x;
|
||||
|
||||
// Offset index to process a new section of the hash
|
||||
dispatchThreadId.x = dispatchThreadId.x + ((_HashUpdateFrameIndex % _HashUpdateFraction) * (_HashStorageSize / _HashUpdateFraction));
|
||||
|
||||
// Read our hash key
|
||||
uint HashKey = _HashBuffer_Key[dispatchThreadId.x];
|
||||
|
||||
// Extract hash rank from hash key
|
||||
int HashRank = HashKey & 0x3;
|
||||
HashKey = HashKey & 0xFFFFFFFC;
|
||||
|
||||
// If hash key is 0 - it's an empty hash cell and we can early out
|
||||
if (HashKey == 0 || FREEZE_CACHE)
|
||||
{
|
||||
_HashBuffer_Payload[PayloadIndex] = 0u;
|
||||
return;
|
||||
}
|
||||
|
||||
// Unpack ray coord and normal from hash key
|
||||
uint3 HitCoord = UnpackHitCoordFromHashKey(HashKey);
|
||||
float3 HitNormal = UnpackHitNormalFromHashKey(HashKey);
|
||||
|
||||
// Pick coordinates for random generator based on the normal
|
||||
float3 HitNormalAbs = abs(HitNormal);
|
||||
float HitNormalMax = max(max(HitNormalAbs.x, HitNormalAbs.y), HitNormalAbs.z);
|
||||
|
||||
// Swizzle coordinates for ray jitter based on the dominant normal
|
||||
uint2 HitRandomCoord = 0;
|
||||
if (HitNormalMax == HitNormalAbs.x)
|
||||
HitRandomCoord = HitCoord.yz;
|
||||
if (HitNormalMax == HitNormalAbs.y)
|
||||
HitRandomCoord = HitCoord.xz;
|
||||
if (HitNormalMax == HitNormalAbs.z)
|
||||
HitRandomCoord = HitCoord.xy;
|
||||
|
||||
// Generate random ray jitter
|
||||
float2 RayJitter;
|
||||
RayJitter.x = GetBNDSequenceSample(HitRandomCoord, _FrameCount, 4);
|
||||
RayJitter.y = GetBNDSequenceSample(HitRandomCoord, _FrameCount, 5);
|
||||
|
||||
// Calculate hash cell tracing position
|
||||
uint4 HashPositionPacked = _HashBuffer_Position[dispatchThreadId.x].xyzw;
|
||||
float3 RayOrigin = asint(HashPositionPacked.xyz) * _VoxelSize;
|
||||
// RayOrigin += UnpackHitOffset(HashPositionPacked.w);
|
||||
RayOrigin += 0.5 * _VoxelSize;
|
||||
|
||||
// Generate new ray direction
|
||||
float3 RayDirection = HSampleHemisphereCosine(RayJitter.x, RayJitter.y, HitNormal);
|
||||
|
||||
// Apply ray bias
|
||||
RayOrigin += RayDirection * _VoxelSize * 0.5f;
|
||||
RayOrigin += HitNormal * _VoxelSize * 0.5f; //(0.6f * (1.0f - max(0.0f, dot(RayDirection, HitNormal))));
|
||||
|
||||
// Initialize voxel ray payload
|
||||
VoxelPayload Payload;
|
||||
InitializePayload(Payload);
|
||||
|
||||
// Calculate ray distance
|
||||
float MaxRayDistance = MaxVoxelRayDistance(RayOrigin, RayDirection);
|
||||
float RayDistance = _RayLength == 0 ? MaxRayDistance : _RayLength;
|
||||
|
||||
// Trace into voxels
|
||||
bool HitFound = TraceVoxelsDiffuse(RayOrigin, RayDirection, RayDistance, 128, Payload);
|
||||
|
||||
// Evaluate sky occlusion
|
||||
float SkyOcclusion = HitFound ? 1 : EvaluateDirectionalShadowOcclusion(RayOrigin + MaxRayDistance * RayDirection);
|
||||
|
||||
// Set hit flag (HitFound & short distance for near field split, !HitFound and direction up for skybox read)
|
||||
bool HitFlag = false;
|
||||
if (HitFound) HitFlag = (Payload.HitDistance < _VoxelSize.x * 4) ? true : false;
|
||||
if (!HitFound) HitFlag = (dot(float3(0,1,0), RayDirection) > _SkyOcclusionCone + 0.05f) ? true : false;
|
||||
|
||||
// Pack and write cache payload
|
||||
float3 VoxelHitOffset = VoxelCoordToAbsoluteWorldPosition(Payload.HitCoord) - Payload.HitPosition;
|
||||
_HashBuffer_Payload[PayloadIndex] = PackCacheHitPayload(VoxelHitOffset, RayDirection, Payload.HitNormal, Payload.HitCoord, SkyOcclusion, HashRank, HitFound, HitFlag);
|
||||
}
|
||||
|
||||
|
||||
// ------------------------ CACHE LIGHT EVALUATION --------------------------
|
||||
[numthreads(64, 1, 1)]
|
||||
void CacheLightEvaluation(uint dispatchThreadId : SV_DispatchThreadID)
|
||||
{
|
||||
uint WriteIndex = dispatchThreadId.x + ((_HashUpdateFrameIndex % _HashUpdateFraction) * (_HashStorageSize / _HashUpdateFraction));
|
||||
|
||||
// Read packed cache payload
|
||||
uint2 CachePayloadPacked = _HashBuffer_Payload[dispatchThreadId.x];
|
||||
|
||||
// If payload is 0 - it's an empty hash cell and we can early out
|
||||
if (CachePayloadPacked.y == 0 || FREEZE_CACHE)
|
||||
return;
|
||||
|
||||
// Initialize voxel payload
|
||||
VoxelPayload Payload;
|
||||
InitializePayload(Payload);
|
||||
|
||||
// Unpack cache payload
|
||||
float3 RayDirection; float3 HitOffset; float SkyOcclusion; uint HashRank; bool HitFlag;
|
||||
bool HitFound = UnpackCacheHitPayload(CachePayloadPacked, RayDirection, HitOffset, Payload.HitNormal, Payload.HitCoord, SkyOcclusion, HashRank, HitFlag);
|
||||
|
||||
// Calculate hit position
|
||||
Payload.HitPosition = VoxelCoordToAbsoluteWorldPosition(Payload.HitCoord) + HitOffset;
|
||||
|
||||
// This is our cached radiance that we aim to update
|
||||
uint3 RadiancePacked = _HashBuffer_Radiance[WriteIndex].xyz;
|
||||
|
||||
// Deal with hash at the hit point
|
||||
if (HitFound)
|
||||
{
|
||||
uint3 HitCacheCoord = ComputeRadianceCacheCoord(Payload.HitCoord);
|
||||
uint HitHashKey = PackHashKey(HitCacheCoord, Payload.HitNormal); ;
|
||||
|
||||
bool IsEmpty;
|
||||
uint HitHashRank = HashRank;
|
||||
uint HashProbingIndex, HashLowestRankIndex;
|
||||
uint HashIndex = HashGetIndex(HitCacheCoord, PackVoxelNormalIndex(Payload.HitNormal));
|
||||
bool HashFound = HashFindAny(HashIndex, HitHashKey, HitHashRank, HashLowestRankIndex, HashProbingIndex, IsEmpty);
|
||||
|
||||
int3 VoxelCoordAbsolute = VoxelCoordToAbsoluteVoxelCoord(Payload.HitCoord);
|
||||
float3 VoxelHitOffset = (float3(VoxelCoordAbsolute) * _VoxelSize) - Payload.HitPosition;
|
||||
|
||||
if (HashFound) // If a valid entry was found we use it to add cache to our ray origin radiance cell
|
||||
{
|
||||
Payload.HitCache = UnpackCacheRadianceFull(_HashBuffer_Radiance[HashProbingIndex].xyz);
|
||||
}
|
||||
else if (IsEmpty) // && HashRank > 0) // If we didn't find a valid entry but found an empty cell, we spawn a new entry
|
||||
{
|
||||
_HashBuffer_Position[HashProbingIndex] = uint4(asuint(VoxelCoordAbsolute.xyz), PackHitOffset(VoxelHitOffset));
|
||||
_HashBuffer_Radiance[HashProbingIndex] = 0;
|
||||
_HashBuffer_Counter[HashProbingIndex] = 255;
|
||||
_HashBuffer_Key[HashProbingIndex] = HitHashKey | max(0, HashRank - 1);
|
||||
}
|
||||
else if (HitHashRank != HashRank) // && HashRank > 0) // If neither a valid nor an empty entry was found, we recycle the lowest ranked cell to spawn a new entry
|
||||
{
|
||||
_HashBuffer_Position[HashLowestRankIndex] = uint4(asuint(VoxelCoordAbsolute.xyz), PackHitOffset(VoxelHitOffset));
|
||||
_HashBuffer_Radiance[HashLowestRankIndex] = 0;
|
||||
_HashBuffer_Counter[HashLowestRankIndex] = 255;
|
||||
_HashBuffer_Key[HashLowestRankIndex] = HitHashKey | max(0, HashRank - 1);
|
||||
}
|
||||
}
|
||||
|
||||
// Evaluate lighting at hit point
|
||||
bool DirectLightingHit = true;
|
||||
if (HitFound)
|
||||
DirectLightingHit = EvaluateHitLighting(Payload);
|
||||
|
||||
// Evaluate sky lighting if missed
|
||||
if (!HitFound && HitFlag)
|
||||
Payload.HitColor += EvaluateSky(RayDirection) * SkyOcclusion;
|
||||
|
||||
// Unpack both near and full caches
|
||||
float3 CacheRadianceFull = UnpackCacheRadianceFull(RadiancePacked.xyz);
|
||||
float3 CacheRadianceNear = UnpackCacheRadianceNear(RadiancePacked.xyz);
|
||||
|
||||
// Clip cache
|
||||
Payload.HitCache *= HGetCurrentExposureMultiplier;
|
||||
Payload.HitCache = HClipRadiance(Payload.HitCache, 10);
|
||||
Payload.HitCache *= HGetInverseCurrentExposureMultiplier;
|
||||
|
||||
// Add cache
|
||||
Payload.HitColor += Payload.HitCache * Payload.HitDiffuse;
|
||||
|
||||
// Accumulate to full range radiance cache
|
||||
CacheRadianceFull = AccumulateCache(Payload.HitColor, CacheRadianceFull, MIN_TEMPORAL_WEIGHT, MAX_TEMPORAL_WEIGHT);
|
||||
|
||||
// Accumulate to near range radiance cache
|
||||
if (!DirectLightingHit || (!HitFound && HitFlag))
|
||||
CacheRadianceNear = AccumulateCache(Payload.HitColor, CacheRadianceNear, 0.3f, 0.90f);
|
||||
|
||||
// Write updated cache
|
||||
_HashBuffer_Radiance[WriteIndex] = uint4(PackCacheRadiance(CacheRadianceFull, CacheRadianceNear), 0);
|
||||
}
|
||||
|
||||
|
||||
// ------------------------ CACHE DATA UPDATE --------------------------
|
||||
[numthreads(64, 1, 1)]
|
||||
void CacheDataUpdate(uint dispatchThreadId : SV_DispatchThreadID)
|
||||
{
|
||||
if (FREEZE_CACHE)
|
||||
return;
|
||||
|
||||
// Load position buffer
|
||||
float3 AbsoluteVoxelPosition = asint(_HashBuffer_Position[dispatchThreadId.x].xyz) * _VoxelSize - _VoxelCameraPos.xyz;
|
||||
|
||||
// Calculate voxel coord from position
|
||||
int3 VoxelCoord = AbsoluteWorldPositionToVoxelCoord(AbsoluteVoxelPosition);
|
||||
|
||||
// If position.xyz is 0 - it's an empty hash cell and we can early out
|
||||
if (AbsoluteVoxelPosition.x + AbsoluteVoxelPosition.y + AbsoluteVoxelPosition.z == 0)
|
||||
return;
|
||||
|
||||
// Use "VoxelOccupancy == 0" below to deallocate hash cells on moving objects. This has a perfromance impact.
|
||||
uint VoxelOccupancy = H_LOAD3D_LOD(_VoxelPositionPyramid, VoxelCoord, 0);
|
||||
|
||||
// Clear the cell in all hash buffers if its position is outside bounds and early out
|
||||
if (!IsVoxelCoordInBounds(VoxelCoord) || VoxelOccupancy == 0 )
|
||||
{
|
||||
_HashBuffer_Radiance[dispatchThreadId.x] = 0;
|
||||
_HashBuffer_Position[dispatchThreadId.x] = 0;
|
||||
_HashBuffer_Counter[dispatchThreadId.x] = 0;
|
||||
_HashBuffer_Key[dispatchThreadId.x] = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
// Load other hash bufffers
|
||||
uint HashKey = _HashBuffer_Key[dispatchThreadId.x];
|
||||
|
||||
// Unpack and decrement decay counter
|
||||
int DecayCounter = _HashBuffer_Counter[dispatchThreadId.x];
|
||||
DecayCounter = max(0, DecayCounter - 1);
|
||||
|
||||
// If the cache entry is old enough - lower its rank
|
||||
if (DecayCounter <= 200)
|
||||
{
|
||||
int Rank = HashKey & 0x3; // Must keep it as int
|
||||
|
||||
// Lower cache rank
|
||||
_HashBuffer_Key[dispatchThreadId.x] = (HashKey & 0xFFFFFFFC) | max(0, Rank - 1);
|
||||
}
|
||||
|
||||
// Update decay counter
|
||||
_HashBuffer_Counter[dispatchThreadId.x] = DecayCounter;
|
||||
}
|
||||
|
||||
|
||||
// ------------------------ CACHE DATA CLEAR --------------------------
|
||||
[numthreads(64, 1, 1)]
|
||||
void CacheDataClear(uint dispatchThreadId : SV_DispatchThreadID)
|
||||
{
|
||||
_HashBuffer_Radiance[dispatchThreadId.x] = 0;
|
||||
_HashBuffer_Position[dispatchThreadId.x] = 0;
|
||||
_HashBuffer_Counter[dispatchThreadId.x] = 0;
|
||||
_HashBuffer_Key[dispatchThreadId.x] = 0;
|
||||
}
|
||||
14
Assets/External/HTraceWSGI/Resources/HTraceWSGI/_Shared/Computes/HRadianceCache.compute.meta
vendored
Normal file
14
Assets/External/HTraceWSGI/Resources/HTraceWSGI/_Shared/Computes/HRadianceCache.compute.meta
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 41218a2257905b649ab7793dc12019d4
|
||||
ComputeShaderImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 379716
|
||||
packageName: 'HTrace: World Space Global Illumination URP | Beta'
|
||||
packageVersion: 0.9.6
|
||||
assetPath: Assets/HTraceWSGI/Resources/HTraceWSGI/_Shared/Computes/HRadianceCache.compute
|
||||
uploadId: 925118
|
||||
144
Assets/External/HTraceWSGI/Resources/HTraceWSGI/_Shared/Computes/HRayGeneration.compute
vendored
Normal file
144
Assets/External/HTraceWSGI/Resources/HTraceWSGI/_Shared/Computes/HRayGeneration.compute
vendored
Normal file
@ -0,0 +1,144 @@
|
||||
#pragma kernel RayGeneration
|
||||
#pragma kernel RayCompaction
|
||||
#pragma kernel IndirectArguments
|
||||
|
||||
#include "../Includes/Config.hlsl"
|
||||
#include "../Includes/Reservoir.hlsl"
|
||||
#pragma multi_compile _ _GBUFFER_NORMALS_OCT
|
||||
|
||||
H_TEXTURE(_HitDistance);
|
||||
H_TEXTURE(_ProbeNormalDepth);
|
||||
H_TEXTURE(_ReprojectionCoords);
|
||||
|
||||
H_RW_TEXTURE(float, _HitDistance_Output);
|
||||
H_RW_TEXTURE(float4, _RayDirectionsJittered_Output);
|
||||
|
||||
RWStructuredBuffer<uint> _RayCounter;
|
||||
RWStructuredBuffer<uint2> _TracingCoords;
|
||||
|
||||
RWStructuredBuffer<uint> _RayCounter_Output;
|
||||
RWStructuredBuffer<uint> _TracingRayCounter_Output;
|
||||
RWStructuredBuffer<uint> _IndirectArguments_Output;
|
||||
|
||||
RWStructuredBuffer<uint2> _TracingCoords_Output;
|
||||
RWStructuredBuffer<uint2> _IndirectCoordsSS_Output;
|
||||
RWStructuredBuffer<uint2> _IndirectCoordsOV_Output;
|
||||
RWStructuredBuffer<uint2> _IndirectCoordsSF_Output;
|
||||
|
||||
int _IndexXR;
|
||||
int _HFrameIndex;
|
||||
uint _RayCounterIndex;
|
||||
uint _ReprojectSkippedFrame;
|
||||
|
||||
|
||||
// ------------------------ RAY COMPACTION -------------------------
|
||||
[numthreads(8, 8, 1)]
|
||||
void RayCompaction(uint3 pixCoord : SV_DispatchThreadID, uint2 groupThreadID : SV_GroupThreadID, uint groupIndex : SV_GroupIndex, uint groupID : SV_GroupID)
|
||||
{
|
||||
uint ArrayOffsetXR = _ScreenSize.x * _ScreenSize.y;
|
||||
|
||||
uint RayIndex = groupID * 64 + groupIndex;
|
||||
if (RayIndex >= _RayCounter[0 + 4 + 10 * _IndexXR])
|
||||
return;
|
||||
|
||||
pixCoord.xy = _TracingCoords[RayIndex + ArrayOffsetXR * _IndexXR];
|
||||
|
||||
bool Unused, TraceWorldRay;
|
||||
uint HitDistancePacked = asuint(H_LOAD(_HitDistance, pixCoord.xy).x);
|
||||
float HitDistance = UnpackHitDistance(HitDistancePacked, Unused, TraceWorldRay);
|
||||
|
||||
if (TraceWorldRay)
|
||||
{
|
||||
uint Index = 0;
|
||||
InterlockedAdd(_TracingRayCounter_Output[0 + 10 * _IndexXR], 1, Index);
|
||||
_TracingCoords_Output[Index + ArrayOffsetXR * _IndexXR] = pixCoord.xy;
|
||||
}
|
||||
|
||||
_HitDistance_Output[H_COORD(pixCoord.xy)] = HitDistance;
|
||||
}
|
||||
|
||||
|
||||
// ------------------------ INDIRECT ARGUMENTS GENERATION -------------------------
|
||||
[numthreads(1, 1, 1)]
|
||||
void IndirectArguments(uint3 pixCoord : SV_DispatchThreadID, uint2 groupThreadID : SV_GroupThreadID, uint2 groupID : SV_GroupID)
|
||||
{
|
||||
|
||||
uint IndirectArgumentsOffsetVR = 3 * pixCoord.z;
|
||||
uint RayCounterOffsetVR = 10 * pixCoord.z;
|
||||
|
||||
uint RayCounterBuffer = _RayCounter[_RayCounterIndex + RayCounterOffsetVR];
|
||||
|
||||
_IndirectArguments_Output[0 + IndirectArgumentsOffsetVR] = (RayCounterBuffer + 63) / 64;
|
||||
_IndirectArguments_Output[1 + IndirectArgumentsOffsetVR] = 1;
|
||||
_IndirectArguments_Output[2 + IndirectArgumentsOffsetVR] = 1;
|
||||
|
||||
_RayCounter[_RayCounterIndex + 0 + RayCounterOffsetVR] = 0;
|
||||
_RayCounter[_RayCounterIndex + 4 + RayCounterOffsetVR] = RayCounterBuffer;
|
||||
}
|
||||
|
||||
|
||||
// ------------------------ RAY GENERATION -------------------------
|
||||
[numthreads(8, 8, 1)]
|
||||
void RayGeneration(uint3 pixCoord : SV_DispatchThreadID, uint2 groupThreadID : SV_GroupThreadID, uint groupIndex : SV_GroupIndex, uint2 groupID : SV_GroupID)
|
||||
{
|
||||
|
||||
uint IndirectCoordOffsetVR = _ScreenSize.x * _ScreenSize.y * pixCoord.z;
|
||||
uint RayCounterOffsetVR = 10 * pixCoord.z;
|
||||
|
||||
// Calculate probe and cell coord
|
||||
uint2 ProbeCoord = floor(pixCoord.xy / _OctahedralSize);
|
||||
float2 CellCoord = pixCoord.xy - floor(pixCoord.xy / _OctahedralSize) * _OctahedralSize;
|
||||
|
||||
// Load depth and normal
|
||||
uint2 Unused;
|
||||
float4 NormalDepth = UnpackNormalDepth(asuint(H_LOAD(_ProbeNormalDepth, ProbeCoord).xy), Unused);
|
||||
|
||||
// Early out on the skybox
|
||||
if (NormalDepth.w <= 1e-7)
|
||||
return;
|
||||
|
||||
// Generate ray jitter for tracing direction
|
||||
float2 RayJitter;
|
||||
RayJitter.x = GetBNDSequenceSample(pixCoord.xy, _HFrameIndex, 0);
|
||||
RayJitter.y = GetBNDSequenceSample(pixCoord.xy, _HFrameIndex, 1);
|
||||
|
||||
// Calculate jittered ray direction for the octahedral cell
|
||||
float3 OctahedralDirectionJittered = OrientedOctahedronToDirection(float2(CellCoord + RayJitter) / float(_OctahedralSize), NormalDepth.xyz);
|
||||
|
||||
uint2 BestOffset; bool ReprojectionFailed;
|
||||
uint2 ReprojectionCoordPacked = asuint(H_LOAD(_ReprojectionCoords, ProbeCoord).xy);
|
||||
uint2 ReprojectionCoord = UnpackBestReprojectionCoord(ReprojectionCoordPacked, BestOffset, ReprojectionFailed);
|
||||
|
||||
bool CullCheckerboard = false;
|
||||
if (((pixCoord.x + pixCoord.y) % 2 == 0 && uint(_FrameCount) % 2 == 0) || ReprojectionFailed)
|
||||
CullCheckerboard = true;
|
||||
if (((pixCoord.x + pixCoord.y) % 2 != 0 && uint(_FrameCount) % 2 != 0) || ReprojectionFailed)
|
||||
CullCheckerboard = true;
|
||||
|
||||
// Tracing indirection
|
||||
if (CullCheckerboard)
|
||||
{
|
||||
uint Index = 0;
|
||||
InterlockedAdd(_RayCounter_Output[0 + RayCounterOffsetVR], 1, Index);
|
||||
_IndirectCoordsSS_Output[Index + IndirectCoordOffsetVR] = pixCoord.xy;
|
||||
}
|
||||
|
||||
// Occlusion validation indirection
|
||||
if (CullCheckerboard)
|
||||
{
|
||||
uint Index = 0;
|
||||
InterlockedAdd(_RayCounter_Output[1 + RayCounterOffsetVR], 1, Index);
|
||||
_IndirectCoordsOV_Output[Index + IndirectCoordOffsetVR] = pixCoord.xy;
|
||||
}
|
||||
|
||||
// Spatial filer indirection
|
||||
if (ReprojectionFailed)
|
||||
{
|
||||
uint Index = 0;
|
||||
InterlockedAdd(_RayCounter_Output[2 + RayCounterOffsetVR], 1, Index);
|
||||
_IndirectCoordsSF_Output[Index + IndirectCoordOffsetVR] = pixCoord.xy;
|
||||
}
|
||||
|
||||
// Output jittered ray directions
|
||||
_RayDirectionsJittered_Output[H_COORD(pixCoord.xy)] = float4(OctahedralDirectionJittered * 0.5f + 0.5f, 1);
|
||||
}
|
||||
14
Assets/External/HTraceWSGI/Resources/HTraceWSGI/_Shared/Computes/HRayGeneration.compute.meta
vendored
Normal file
14
Assets/External/HTraceWSGI/Resources/HTraceWSGI/_Shared/Computes/HRayGeneration.compute.meta
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c8024557b4b500549ba603a5cf9cc018
|
||||
ComputeShaderImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 379716
|
||||
packageName: 'HTrace: World Space Global Illumination URP | Beta'
|
||||
packageVersion: 0.9.6
|
||||
assetPath: Assets/HTraceWSGI/Resources/HTraceWSGI/_Shared/Computes/HRayGeneration.compute
|
||||
uploadId: 925118
|
||||
422
Assets/External/HTraceWSGI/Resources/HTraceWSGI/_Shared/Computes/HReSTIR.compute
vendored
Normal file
422
Assets/External/HTraceWSGI/Resources/HTraceWSGI/_Shared/Computes/HReSTIR.compute
vendored
Normal file
@ -0,0 +1,422 @@
|
||||
#pragma kernel ProbeAtlasTemporalReuse
|
||||
#pragma kernel ProbeAtlasSpatialReuse
|
||||
#pragma kernel ProbeAtlasSpatialReuseDisocclusion
|
||||
#pragma kernel ReservoirHistoryUpdate
|
||||
|
||||
#include "../Includes/Config.hlsl"
|
||||
#include "../Includes/Reservoir.hlsl"
|
||||
#pragma multi_compile _ _GBUFFER_NORMALS_OCT
|
||||
|
||||
H_TEXTURE(_ShadowGuidanceMask);
|
||||
H_TEXTURE(_ReprojectionCoords);
|
||||
|
||||
H_TEXTURE(_SampleCount);
|
||||
H_TEXTURE(_RayDistance);
|
||||
H_TEXTURE(_RayDirection);
|
||||
H_TEXTURE(_RadianceAtlas);
|
||||
H_TEXTURE(_ProbeNormalDepth);
|
||||
H_TEXTURE(_ReprojectionWeights);
|
||||
H_TEXTURE(_PersistentReprojectionCoord);
|
||||
|
||||
H_TEXTURE_ARRAY(_SpatialWeightsPacked);
|
||||
H_TEXTURE_ARRAY(_SpatialOffsetsPacked);
|
||||
|
||||
H_RW_TEXTURE(float, _ShadowGuidanceMaskTest_Output);
|
||||
|
||||
RWStructuredBuffer<uint2> _TracingCoords;
|
||||
RWStructuredBuffer<uint> _RayCounter;
|
||||
|
||||
int _IndexXR;
|
||||
int _PassNumber;
|
||||
int _DisocclusionPass;
|
||||
|
||||
|
||||
// ------------------------ PROBE ATLAS TEMPORAL REUSE ------------------------
|
||||
[numthreads(8, 8, 1)]
|
||||
void ProbeAtlasTemporalReuse(uint3 pixCoord : SV_DispatchThreadID, uint2 groupThreadID : SV_GroupThreadID, uint groupIndex : SV_GroupIndex, uint groupID : SV_GroupID)
|
||||
{
|
||||
|
||||
|
||||
// Calculate probe coords
|
||||
int2 ProbeCoord = floor(pixCoord.xy / _OctahedralSize);
|
||||
int2 CellCoord = pixCoord.xy - floor(pixCoord.xy / _OctahedralSize) * _OctahedralSize;
|
||||
|
||||
// Load and clip center radiance
|
||||
bool Unused;
|
||||
float3 Radiance = H_LOAD(_RadianceAtlas, pixCoord.xy).xyz; // UnpackFromR11G10B10A1f(asuint(H_LOAD(_RadianceAtlas, pixCoord.xy)), Unused);
|
||||
Radiance *= HGetCurrentExposureMultiplier;
|
||||
Radiance = HClipRadiance(Radiance, 10.0f);
|
||||
|
||||
// Load reprojection coords and weights and normalize them
|
||||
uint ReprojectionIndex;
|
||||
float4 ReprojectionWeights = H_LOAD(_ReprojectionWeights, ProbeCoord);
|
||||
int2 ReprojectionCoordPacked = asuint(H_LOAD(_PersistentReprojectionCoord, ProbeCoord).xy);
|
||||
int2 ReprojectionCoord = UnpackPersistentReprojectionCoord(ReprojectionCoordPacked, ReprojectionIndex);
|
||||
|
||||
// Normalize reprojection weights
|
||||
float WeightsSumm = max(ReprojectionWeights.x + ReprojectionWeights.y + ReprojectionWeights.z + ReprojectionWeights.w, 1.0e-3);
|
||||
ReprojectionWeights /= WeightsSumm;
|
||||
|
||||
uint2 ProbeOffset;
|
||||
float3 RayOriginNormal = UnpackNormalDepth(asuint(H_LOAD(_ProbeNormalDepth, ProbeCoord).xy), ProbeOffset).xyz;
|
||||
|
||||
// Prepare diffuse and random values for reservoir exchange
|
||||
float3 Diffuse = GetReservoirDiffuse(ProbeCoord);
|
||||
uint ReservoirUpdateRandom = Hash3(uint3(pixCoord.xy, _FrameCount));
|
||||
|
||||
// Initialize and fill main reservoir
|
||||
Reservoir Reservoir;
|
||||
ReservoirInitialize(pixCoord.xy, Reservoir);
|
||||
|
||||
Reservoir.Radiance.Color = Radiance;
|
||||
Reservoir.Radiance.Wsum = Luminance(Radiance * Diffuse);
|
||||
Reservoir.Radiance.W = 0;
|
||||
Reservoir.Radiance.M = 1;
|
||||
|
||||
Reservoir.Ray.OriginNormal = RayOriginNormal;
|
||||
Reservoir.Ray.Direction = H_LOAD(_RayDirection, pixCoord.xy).xyz * 2 - 1;
|
||||
Reservoir.Ray.Distance = H_LOAD(_RayDistance, pixCoord.xy).x;
|
||||
|
||||
float ReservoirHistoryClamp = RESTIR_MAX_HISTORY;
|
||||
ReservoirHistoryClamp = (ReservoirHistoryClamp / float(ReprojectionIndex + 1));
|
||||
|
||||
// Checkerboard handling:
|
||||
// 1. If ray distance > 0 - this cell is not culled by checkerboarding (we have a minimum dist 0.001 for active cells)
|
||||
// 2. If the reproj. index > 0 - this cell is also not culled by checkerboarding (we trace new rays if we couldn't reproject from N-1 frame)
|
||||
if (Reservoir.Ray.Distance <= 0 && ReprojectionIndex == 0)
|
||||
{
|
||||
Reservoir.Radiance.M = 0; // Kills reservoir weight, allowing history reservoirs take precedence
|
||||
ReservoirHistoryClamp /= 2;
|
||||
}
|
||||
|
||||
// Calculate cell coordinates
|
||||
int2 CellTapCoord00 = ReprojectionCoord * _OctahedralSize + uint2(0, 0) * _OctahedralSize + CellCoord;
|
||||
int2 CellTapCoord01 = ReprojectionCoord * _OctahedralSize + uint2(1, 0) * _OctahedralSize + CellCoord;
|
||||
int2 CellTapCoord10 = ReprojectionCoord * _OctahedralSize + uint2(0, 1) * _OctahedralSize + CellCoord;
|
||||
int2 CellTapCoord11 = ReprojectionCoord * _OctahedralSize + uint2(1, 1) * _OctahedralSize + CellCoord;
|
||||
|
||||
// Load packed history reservoir samples
|
||||
uint4 ReservoirHistoryPacked00 = asuint(H_LOAD_ARRAY(_ReservoirAtlas_History, CellTapCoord00, GetHistoryIndex(ReprojectionIndex)));
|
||||
uint4 ReservoirHistoryPacked01 = asuint(H_LOAD_ARRAY(_ReservoirAtlas_History, CellTapCoord01, GetHistoryIndex(ReprojectionIndex)));
|
||||
uint4 ReservoirHistoryPacked10 = asuint(H_LOAD_ARRAY(_ReservoirAtlas_History, CellTapCoord10, GetHistoryIndex(ReprojectionIndex)));
|
||||
uint4 ReservoirHistoryPacked11 = asuint(H_LOAD_ARRAY(_ReservoirAtlas_History, CellTapCoord11, GetHistoryIndex(ReprojectionIndex)));
|
||||
|
||||
float4 NormalWeights;
|
||||
NormalWeights.x = saturate(dot(UnpackDirection24bit(ReservoirHistoryPacked00.w), RayOriginNormal));
|
||||
NormalWeights.y = saturate(dot(UnpackDirection24bit(ReservoirHistoryPacked01.w), RayOriginNormal));
|
||||
NormalWeights.z = saturate(dot(UnpackDirection24bit(ReservoirHistoryPacked10.w), RayOriginNormal));
|
||||
NormalWeights.w = saturate(dot(UnpackDirection24bit(ReservoirHistoryPacked11.w), RayOriginNormal));
|
||||
|
||||
// Continious disocclusion check based on the normal stored in the resevoir, helps with reducing reprojection artifacts over time
|
||||
if (any(NormalWeights * ReprojectionWeights > 0.25))
|
||||
ReprojectionWeights *= NormalWeights;
|
||||
|
||||
|
||||
// Merge with center reservoir
|
||||
uint4 Merged = 0;
|
||||
if (!DISABLE_RESTIR_TEMPORAL)
|
||||
{
|
||||
Merged.x = ReservoirMergeTemporal(CellTapCoord00, ReservoirHistoryPacked00, GetHistoryIndex(ReprojectionIndex), ReprojectionWeights.x, Diffuse, ReservoirUpdateRandom, Reservoir);
|
||||
Merged.y = ReservoirMergeTemporal(CellTapCoord01, ReservoirHistoryPacked01, GetHistoryIndex(ReprojectionIndex), ReprojectionWeights.y, Diffuse, ReservoirUpdateRandom, Reservoir);
|
||||
Merged.z = ReservoirMergeTemporal(CellTapCoord10, ReservoirHistoryPacked10, GetHistoryIndex(ReprojectionIndex), ReprojectionWeights.z, Diffuse, ReservoirUpdateRandom, Reservoir);
|
||||
Merged.w = ReservoirMergeTemporal(CellTapCoord11, ReservoirHistoryPacked11, GetHistoryIndex(ReprojectionIndex), ReprojectionWeights.w, Diffuse, ReservoirUpdateRandom, Reservoir);
|
||||
}
|
||||
|
||||
float3 ResDirection = Reservoir.Ray.Direction;
|
||||
float ResDistance = Reservoir.Ray.Distance;
|
||||
|
||||
// Load probe normal, depth & offset
|
||||
float4 RayOriginNormalDepth = UnpackNormalDepth(asuint(H_LOAD(_ProbeNormalDepth, ProbeCoord).xy), ProbeOffset);
|
||||
float2 ProbeCoordNDC = (ProbeCoord.xy * float(_ProbeSize) + float2(ProbeOffset) + 0.5f) * _ScreenSize.zw;
|
||||
|
||||
float3 PositionWS = H_COMPUTE_POSITION_WS(ProbeCoordNDC.xy, RayOriginNormalDepth.w, H_MATRIX_I_VP);
|
||||
|
||||
float3 PositionOriginal = PositionWS;
|
||||
|
||||
// PositionWS += 0.01 * RayOriginNormalDepth.xyz;
|
||||
// PositionWS += 0.01 * ResDirection;
|
||||
|
||||
// float3 NormalForBias = GeometryNormalWS;
|
||||
float3 NormalForBias = dot(RayOriginNormalDepth.xyz, Reservoir.Ray.Direction) < 0 ? -RayOriginNormalDepth.xyz : RayOriginNormalDepth.xyz;
|
||||
|
||||
// Calculate normal bias
|
||||
float2 CornerCoordNDC = ProbeCoordNDC + 0.5f * _ScreenSize.zw * float(_OctahedralSize);
|
||||
float3 CornerPositionWS = H_COMPUTE_POSITION_WS(CornerCoordNDC.xy, RayOriginNormalDepth.w, H_MATRIX_I_VP);
|
||||
float NormalBias = abs(dot(CornerPositionWS - PositionWS, NormalForBias)) * 2.0f;
|
||||
|
||||
// This can push the ray origin off-screen causing black pixels on the border
|
||||
PositionWS += NormalForBias * NormalBias;
|
||||
PositionWS += 0.01 * ResDirection;
|
||||
|
||||
float Dist = 0;
|
||||
|
||||
bool IsHit = false;
|
||||
float3 PosPrev = PositionWS;
|
||||
for (int i = 0; i < 40; i++)
|
||||
{
|
||||
// if (length(PositionWS - PositionOriginal) >= ResDistance)
|
||||
// break;
|
||||
|
||||
// Move along the ray with fixed steps
|
||||
float3 PositionLocalWS = PositionWS + ResDirection * 0.01 * float(i);
|
||||
float3 PositionNDC = H_COMPUTE_NDC_Z(PositionLocalWS, UNITY_MATRIX_VP).xyz;
|
||||
|
||||
if (all(PositionNDC.xy > 0) && all(PositionNDC.xy < 1))
|
||||
{
|
||||
// Sample depth along the ray
|
||||
float Depth = HBUFFER_DEPTH(PositionNDC.xy * _ScreenSize.xy); //(_DepthPyramid, PositionNDC.xy * _ScreenSize.xy);
|
||||
Depth = H_LOAD(g_HTraceDepthPyramidWSGI, PositionNDC.xy * _ScreenSize.xy).x;
|
||||
|
||||
float DepthLinear = H_LINEAR_EYE_DEPTH(Depth);
|
||||
float PositionLinear = H_LINEAR_EYE_DEPTH(PositionNDC.z);
|
||||
|
||||
if (Depth <= 1e-7)
|
||||
break;
|
||||
|
||||
// Decrement thickness counter each time the ray is above surface
|
||||
if (DepthLinear < PositionLinear)
|
||||
{
|
||||
if ( abs(PositionLinear - DepthLinear) < 0.035)
|
||||
{
|
||||
Dist = length(PositionOriginal - PositionLocalWS);
|
||||
IsHit = true;
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
PosPrev = PositionLocalWS;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
float HitDistanceWS = ResDistance;
|
||||
|
||||
float DebugOutput = 1;
|
||||
|
||||
if (IsHit)
|
||||
HitDistanceWS = length(PositionOriginal - PositionWS);
|
||||
|
||||
float Test = 1;
|
||||
// If the distance difference is relatively high
|
||||
if (abs(Dist - ResDistance) / (ResDistance + ResDistance) > 0.35)
|
||||
{
|
||||
if (IsHit && Dist <= ResDistance )
|
||||
{
|
||||
// Reservoir.Radiance.Color = float3(1,0,0);
|
||||
// Test = 0;
|
||||
// ReservoirHistoryClamp = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Clamp reservoir history
|
||||
if (Reservoir.Radiance.M > ReservoirHistoryClamp)
|
||||
{
|
||||
Reservoir.Radiance.Wsum *= ReservoirHistoryClamp / Reservoir.Radiance.M;
|
||||
Reservoir.Radiance.M = ReservoirHistoryClamp;
|
||||
}
|
||||
|
||||
// Recalculate W
|
||||
Reservoir.Radiance.W = Reservoir.Radiance.Wsum / max(Reservoir.Radiance.M * Luminance(Reservoir.Radiance.Color * Diffuse), 1e-7) ;
|
||||
|
||||
// Apply exposure control
|
||||
if (RESTIR_EXPOSURE_CONTROL)
|
||||
{
|
||||
float ExposurePrevious = HGetPreviousExposureMultiplier;
|
||||
float ExposureCurrent = HGetCurrentExposureMultiplier;
|
||||
|
||||
float ExposureRatio = (ExposurePrevious * ExposureCurrent) != 0.0 ? ExposureCurrent / ExposurePrevious : 100.0;
|
||||
|
||||
if (max(ExposureRatio, 1.0 / ExposureRatio) < 2.0)
|
||||
Reservoir.Radiance.W = Reservoir.Radiance.W * HGetInversePreviousExposureMultiplier * ExposureCurrent;
|
||||
}
|
||||
|
||||
// Pack radiance and ray datas
|
||||
uint2 RadianceDataPacked = PackRadianceData(Reservoir.Radiance);
|
||||
uint2 RayDataPacked = PackRayData(Reservoir.Ray);
|
||||
|
||||
// float ShadowGuidanceMask = H_LOAD(_ShadowGuidanceMask, pixCoord.xy);
|
||||
|
||||
// Output reservoir atlas for history
|
||||
_ReservoirAtlas_Output[H_COORD(pixCoord.xy)] = uint4(RadianceDataPacked.xy, RayDataPacked.xy);
|
||||
|
||||
// if (all(Merged == 0))
|
||||
// Test = 1;
|
||||
|
||||
RadianceDataPacked.x |= PackOcclusion(1, 1-Test);
|
||||
|
||||
// Output radiance & ray datas for spatial reuse passes
|
||||
_ReservoirAtlasRadianceData_Output[H_COORD(pixCoord.xy)] = RadianceDataPacked.xy;
|
||||
_ReservoirAtlasRayData_Output[H_COORD(pixCoord.xy)] = RayDataPacked.x;
|
||||
}
|
||||
|
||||
|
||||
// ------------------------ PROBE ATLAS SPATIAL REUSE ------------------------
|
||||
[numthreads(8, 8, 1)]
|
||||
void ProbeAtlasSpatialReuse(uint3 pixCoord : SV_DispatchThreadID, uint2 groupThreadID : SV_GroupThreadID, uint groupIndex : SV_GroupIndex, uint2 groupID : SV_GroupID)
|
||||
{
|
||||
|
||||
|
||||
// Calculate probe and cell coord
|
||||
int2 ProbeCoord = floor(pixCoord.xy / _OctahedralSize);
|
||||
int2 CellCoord = pixCoord.xy - floor(pixCoord.xy / _OctahedralSize) * _OctahedralSize;
|
||||
|
||||
// Prepare diffuse and random values for reservoir exchange
|
||||
float3 Diffuse = GetReservoirDiffuse(ProbeCoord);
|
||||
uint ReservoirUpdateRandom = Hash3(uint3(pixCoord.xy, _FrameCount));
|
||||
|
||||
// Initialize reservoir
|
||||
Reservoir Reservoir;
|
||||
ReservoirInitialize(pixCoord.xy, Reservoir);
|
||||
|
||||
// Load and unpack radiance data to reservoir
|
||||
uint2 RadianceDataPacked = asuint(H_LOAD(_ReservoirAtlasRadianceData, pixCoord.xy).xy);
|
||||
UnpackRadianceData(RadianceDataPacked, Diffuse, Reservoir.Radiance);
|
||||
|
||||
// Unpack occlusion (passed with packed radiance data)
|
||||
bool IsDisocclusionCenter;
|
||||
float ReservoirCenterOcclusion = UnpackOcclusion(RadianceDataPacked.x, IsDisocclusionCenter);
|
||||
|
||||
// Load packed sample weights and coords
|
||||
float SampleWeights[8]; int2 SampleOffsets[8];
|
||||
uint4 PackedSampleOffsets = asuint(H_LOAD_ARRAY(_SpatialOffsetsPacked, ProbeCoord, _PassNumber));
|
||||
uint4 PackedSampleWeights = asuint(H_LOAD_ARRAY(_SpatialWeightsPacked, ProbeCoord, _PassNumber));
|
||||
|
||||
// Unpack sample weights and coords
|
||||
UnpackFilteringOffsetsX8(PackedSampleOffsets, SampleOffsets);
|
||||
UnpackFilteringWeightsX8(PackedSampleWeights, SampleWeights);
|
||||
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
if (DISABLE_RESTIR_SPATIAL)
|
||||
continue;
|
||||
|
||||
// Calculate sample cell coord
|
||||
uint2 CellTapCoord = ProbeCoord * _OctahedralSize + SampleOffsets[i] * _OctahedralSize + CellCoord;
|
||||
|
||||
// Load packed sample reservoir and extract occlusion value from it
|
||||
bool IsDisocclusionSample;
|
||||
uint2 ReservoirSamplePacked = asuint(H_LOAD(_ReservoirAtlasRadianceData, CellTapCoord).xy);
|
||||
float ReservoirSampleOcclusion = UnpackOcclusion(ReservoirSamplePacked.x, IsDisocclusionSample);
|
||||
|
||||
// Calculate shadow guidance cutoff
|
||||
float ShadowGuidanceWeight = exp2(-min(Reservoir.Radiance.M, 20) * abs(ReservoirCenterOcclusion - ReservoirSampleOcclusion));
|
||||
|
||||
// Merge with center reservoir
|
||||
ReservoirMergeSpatial(CellTapCoord, ReservoirSamplePacked, SampleWeights[i] * ShadowGuidanceWeight, Diffuse, Reservoir, ReservoirUpdateRandom);
|
||||
}
|
||||
|
||||
// Recalculate W
|
||||
Reservoir.Radiance.W = Reservoir.Radiance.Wsum / max(Reservoir.Radiance.M * Luminance(Reservoir.Radiance.Color * Diffuse), 1e-7) ;
|
||||
|
||||
// Pack radiance data and occlusion back
|
||||
RadianceDataPacked = PackRadianceData(Reservoir.Radiance);
|
||||
RadianceDataPacked.x |= PackOcclusion(ReservoirCenterOcclusion, IsDisocclusionCenter);
|
||||
|
||||
// Output main and data reservoirs
|
||||
_ReservoirAtlasRadianceData_Output[H_COORD(pixCoord.xy)] = RadianceDataPacked;
|
||||
_ReservoirAtlasRayData_Output[H_COORD(pixCoord.xy)] = asuint(H_LOAD(_ReservoirAtlasRayData, Reservoir.MergedCoord).x);
|
||||
}
|
||||
|
||||
|
||||
// ------------------------ PROBE ATLAS SPATIAL REUSE DISOCCLUSION------------------------
|
||||
[numthreads(8, 8, 1)]
|
||||
void ProbeAtlasSpatialReuseDisocclusion(uint3 pixCoord : SV_DispatchThreadID, uint2 groupThreadID : SV_GroupThreadID, uint groupIndex : SV_GroupIndex, uint groupID : SV_GroupID)
|
||||
{
|
||||
uint IndirectCoordOffsetVR = _ScreenSize.x * _ScreenSize.y * _IndexXR;
|
||||
uint RayCounterOffsetVR = 10 * _IndexXR;
|
||||
|
||||
uint RayIndex = groupID * 64 + groupIndex;
|
||||
if (RayIndex >= _RayCounter[2 + 4 + RayCounterOffsetVR])
|
||||
return;
|
||||
|
||||
pixCoord.xy = _TracingCoords[RayIndex + IndirectCoordOffsetVR];
|
||||
|
||||
// Calculate probe and cell coord
|
||||
int2 ProbeCoord = floor(pixCoord.xy / _OctahedralSize);
|
||||
int2 CellCoord = pixCoord.xy - floor(pixCoord.xy / _OctahedralSize) * _OctahedralSize;
|
||||
|
||||
// Prepare diffuse and random values for reservoir exchange
|
||||
float3 Diffuse = GetReservoirDiffuse(ProbeCoord);
|
||||
uint ReservoirUpdateRandom = Hash3(uint3(pixCoord.xy, _FrameCount));
|
||||
|
||||
// Initialize reservoir
|
||||
Reservoir Reservoir;
|
||||
ReservoirInitialize(pixCoord.xy, Reservoir);
|
||||
|
||||
// Load and unpack radiance data to reservoir
|
||||
uint2 RadianceDataPacked = asuint(H_LOAD(_ReservoirAtlasRadianceData, pixCoord.xy).xy);
|
||||
UnpackRadianceData(RadianceDataPacked, Diffuse, Reservoir.Radiance);
|
||||
|
||||
// Load packed sample weights and coords
|
||||
float SampleWeights[8]; int2 SampleOffsets[8];
|
||||
uint4 PackedSampleOffsets = asuint(H_LOAD_ARRAY(_SpatialOffsetsPacked, ProbeCoord, 1));
|
||||
uint4 PackedSampleWeights = asuint(H_LOAD_ARRAY(_SpatialWeightsPacked, ProbeCoord, 1));
|
||||
|
||||
// Unpack sample weights and coords
|
||||
UnpackFilteringOffsetsX8(PackedSampleOffsets, SampleOffsets);
|
||||
UnpackFilteringWeightsX8(PackedSampleWeights, SampleWeights);
|
||||
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
// Calculate sample cell coord
|
||||
uint2 CellTapCoord = ProbeCoord * _OctahedralSize + SampleOffsets[i] * _OctahedralSize + CellCoord;
|
||||
|
||||
uint2 ReservoirSamplePacked = asuint(H_LOAD(_ReservoirAtlasRadianceData, CellTapCoord).xy);
|
||||
|
||||
// Merge with center reservoir
|
||||
ReservoirMergeSpatial(CellTapCoord, ReservoirSamplePacked, SampleWeights[i], Diffuse, Reservoir, ReservoirUpdateRandom);
|
||||
}
|
||||
|
||||
PackedSampleOffsets = asuint(H_LOAD_ARRAY(_SpatialOffsetsPacked, ProbeCoord, 2));
|
||||
PackedSampleWeights = asuint(H_LOAD_ARRAY(_SpatialWeightsPacked, ProbeCoord, 2));
|
||||
|
||||
// Unpack sample weights and coords
|
||||
UnpackFilteringOffsetsX8(PackedSampleOffsets, SampleOffsets);
|
||||
UnpackFilteringWeightsX8(PackedSampleWeights, SampleWeights);
|
||||
|
||||
for (int t = 0; t < 4; t++)
|
||||
{
|
||||
// Calculate sample cell coord
|
||||
uint2 CellTapCoord = ProbeCoord * _OctahedralSize + SampleOffsets[t] * _OctahedralSize + CellCoord;
|
||||
|
||||
uint2 ReservoirSamplePacked = asuint(H_LOAD(_ReservoirAtlasRadianceData, CellTapCoord).xy);
|
||||
|
||||
// Merge with center reservoir
|
||||
ReservoirMergeSpatial(CellTapCoord, ReservoirSamplePacked, SampleWeights[t], Diffuse, Reservoir, ReservoirUpdateRandom);
|
||||
}
|
||||
|
||||
PackedSampleOffsets = asuint(H_LOAD_ARRAY(_SpatialOffsetsPacked, ProbeCoord, 3));
|
||||
PackedSampleWeights = asuint(H_LOAD_ARRAY(_SpatialWeightsPacked, ProbeCoord, 3));
|
||||
|
||||
// Unpack sample weights and coords
|
||||
UnpackFilteringOffsetsX8(PackedSampleOffsets, SampleOffsets);
|
||||
UnpackFilteringWeightsX8(PackedSampleWeights, SampleWeights);
|
||||
|
||||
for (int k = 0; k < 4; k++)
|
||||
{
|
||||
// Calculate sample cell coord
|
||||
uint2 CellTapCoord = ProbeCoord * _OctahedralSize + SampleOffsets[k] * _OctahedralSize + CellCoord;
|
||||
|
||||
uint2 ReservoirSamplePacked = asuint(H_LOAD(_ReservoirAtlasRadianceData, CellTapCoord).xy);
|
||||
|
||||
// Merge with center reservoir
|
||||
ReservoirMergeSpatial(CellTapCoord, ReservoirSamplePacked, SampleWeights[k], Diffuse, Reservoir, ReservoirUpdateRandom);
|
||||
}
|
||||
|
||||
_ReservoirAtlasRayData_Output[H_COORD(pixCoord.xy)] = asuint(H_LOAD(_ReservoirAtlasRayData, Reservoir.MergedCoord).x);
|
||||
}
|
||||
|
||||
|
||||
// ------------------------ RESERVOIR HISTORY UPDATE ------------------------
|
||||
[numthreads(8, 8, 1)]
|
||||
void ReservoirHistoryUpdate(uint3 pixCoord : SV_DispatchThreadID, uint2 groupThreadID : SV_GroupThreadID, uint groupIndex : SV_GroupIndex, uint groupID : SV_GroupID)
|
||||
{
|
||||
|
||||
_ReservoirAtlas_ArrayOutput[uint3(pixCoord.xy, H_INDEX_ARRAY(uint(_FrameCount) % _PersistentHistorySamples))] = asuint(H_LOAD(_ReservoirAtlas, pixCoord.xy));
|
||||
}
|
||||
14
Assets/External/HTraceWSGI/Resources/HTraceWSGI/_Shared/Computes/HReSTIR.compute.meta
vendored
Normal file
14
Assets/External/HTraceWSGI/Resources/HTraceWSGI/_Shared/Computes/HReSTIR.compute.meta
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3e71db818c55e8d4caee42bbcc86f664
|
||||
ComputeShaderImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 379716
|
||||
packageName: 'HTrace: World Space Global Illumination URP | Beta'
|
||||
packageVersion: 0.9.6
|
||||
assetPath: Assets/HTraceWSGI/Resources/HTraceWSGI/_Shared/Computes/HReSTIR.compute
|
||||
uploadId: 925118
|
||||
147
Assets/External/HTraceWSGI/Resources/HTraceWSGI/_Shared/Computes/HReflectionProbeCompose.compute
vendored
Normal file
147
Assets/External/HTraceWSGI/Resources/HTraceWSGI/_Shared/Computes/HReflectionProbeCompose.compute
vendored
Normal file
@ -0,0 +1,147 @@
|
||||
#pragma kernel RenderVoxelsForReflectionProbes
|
||||
|
||||
#include "../Includes/Config.hlsl"
|
||||
#include "../Includes/SpatialHash.hlsl"
|
||||
#include "../Includes/VoxelTraversal.hlsl"
|
||||
#pragma multi_compile _ _GBUFFER_NORMALS_OCT
|
||||
|
||||
// Output Buffers
|
||||
H_RW_TEXTURE(float3, _Output);
|
||||
|
||||
[numthreads(8, 8, 1)]
|
||||
void RenderVoxelsForReflectionProbes(uint3 pixCoord : SV_DispatchThreadID)
|
||||
{
|
||||
// Get world space position
|
||||
float3 WorldPosition = H_COMPUTE_POSITION_WS((pixCoord.xy + 0.5) * _ScreenSize.zw, HBUFFER_DEPTH(pixCoord.xy), H_MATRIX_I_VP);
|
||||
float3 AbsolutePositionWS = H_GET_ABSOLUTE_POSITION_WS(WorldPosition);
|
||||
|
||||
// Calculate voxel coord from position
|
||||
int3 VoxelBoxCenter = int3(_VoxelResolution.xzy / 2);
|
||||
int3 VoxelPosition = floor((AbsolutePositionWS - _VoxelCameraPos) / _VoxelSize);
|
||||
float3 VoxelCoord = VoxelBoxCenter + VoxelPosition;
|
||||
|
||||
// Load normal
|
||||
float3 Normal = HBUFFER_NORMAL_WS(pixCoord.xy);
|
||||
float3 NormalAbs = abs(Normal);
|
||||
float NormalMax = max(max(NormalAbs.x, NormalAbs.y), NormalAbs.z);
|
||||
|
||||
float3 CacheNormal = 0;
|
||||
float3 CacheNormalSign = 0;
|
||||
float3 GatherDirection = 0;
|
||||
|
||||
if (NormalMax == NormalAbs.x)
|
||||
{
|
||||
CacheNormal = float3(1,0,0);
|
||||
GatherDirection = float3(0,1,1);
|
||||
CacheNormalSign.x = sign(Normal.x);
|
||||
}
|
||||
if (NormalMax == NormalAbs.y)
|
||||
{
|
||||
CacheNormal = float3(0,1,0);
|
||||
GatherDirection = float3(1,0,1);
|
||||
CacheNormalSign.y = sign(Normal.y);
|
||||
|
||||
}
|
||||
if (NormalMax == NormalAbs.z)
|
||||
{
|
||||
CacheNormal = float3(0,0,1);
|
||||
GatherDirection = float3(1,1,0);
|
||||
CacheNormalSign.z = sign(Normal.z);
|
||||
}
|
||||
|
||||
// Offsets used for gather
|
||||
int2 Offsets5x5[25] = {int2( 0, 0), int2( 0, 1), int2( 1, 0), int2( 1, 1), int2(-1, 0),
|
||||
int2(-1, 1), int2(-1, -1), int2( 0, -1), int2( 1, -1), int2(-2, 0),
|
||||
int2( 0, -2), int2( 2, 0), int2( 0, 2), int2(-1, 2), int2(-2, 1),
|
||||
int2( 1, -2), int2( 2, -1), int2(-2, -1), int2(-1, -2), int2( 2, 1),
|
||||
int2( 1, 2), int2(-2, 2), int2( 2, 2), int2( 2, -2), int2(-2, -2)};
|
||||
|
||||
|
||||
// Check neighbours for occlusions
|
||||
if (OCCLUSION_CHECK)
|
||||
{
|
||||
int2 Offsets3x3[12] = { int2( 0, 1), int2( 1, 0), int2( 1, 1), int2(-1, 0),
|
||||
int2(-1, 1), int2(-1, -1), int2( 0, -1), int2( 1, -1),
|
||||
int2(-2, 0), int2( 2, 0), int2( 0, -2), int2( 0, 2) };
|
||||
|
||||
for (int i = 0; i < 12; i++)
|
||||
{
|
||||
float3 Offset;
|
||||
Offset.x = Offsets3x3[i].x;
|
||||
Offset.y = Offsets3x3[i].y;
|
||||
Offset.z = Offsets3x3[i][GatherDirection.x];
|
||||
|
||||
Offset.x *= GatherDirection.x;
|
||||
Offset.y *= GatherDirection.y;
|
||||
Offset.z *= GatherDirection.z;
|
||||
|
||||
uint VoxelOccupancy = asuint(H_LOAD3D_LOD(_VoxelPositionPyramid, VoxelCoord + Offset + float3(1,1,1) * CacheNormal * CacheNormalSign, 0));
|
||||
|
||||
if (VoxelOccupancy > 0)
|
||||
{
|
||||
Offsets5x5[i + 1] = 0;
|
||||
|
||||
if (i == 0) { Offsets5x5[13] = 0; Offsets5x5[12] = 0; Offsets5x5[20] = 0; }
|
||||
if (i == 1) { Offsets5x5[19] = 0; Offsets5x5[11] = 0; Offsets5x5[16] = 0; }
|
||||
if (i == 2) { Offsets5x5[20] = 0; Offsets5x5[22] = 0; Offsets5x5[19] = 0; }
|
||||
if (i == 3) { Offsets5x5[14] = 0; Offsets5x5[ 9] = 0; Offsets5x5[17] = 0; }
|
||||
if (i == 4) { Offsets5x5[13] = 0; Offsets5x5[21] = 0; Offsets5x5[14] = 0; }
|
||||
if (i == 5) { Offsets5x5[17] = 0; Offsets5x5[24] = 0; Offsets5x5[18] = 0; }
|
||||
if (i == 6) { Offsets5x5[18] = 0; Offsets5x5[10] = 0; Offsets5x5[15] = 0; }
|
||||
if (i == 7) { Offsets5x5[15] = 0; Offsets5x5[23] = 0; Offsets5x5[16] = 0; }
|
||||
|
||||
if (i == 8) { Offsets5x5[14] = 0; Offsets5x5[ 9] = 0; Offsets5x5[17] = 0; }
|
||||
if (i == 9) { Offsets5x5[19] = 0; Offsets5x5[11] = 0; Offsets5x5[16] = 0; }
|
||||
if (i == 10) { Offsets5x5[18] = 0; Offsets5x5[10] = 0; Offsets5x5[15] = 0; }
|
||||
if (i == 11) { Offsets5x5[13] = 0; Offsets5x5[12] = 0; Offsets5x5[20] = 0; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
float3 AccumulateCache = 0;
|
||||
float AccumulatedWeight = 0;
|
||||
|
||||
// Accumulate radiance cache spatially
|
||||
for (int i = 0; i < SPATIAL_SAMPLES; i++)
|
||||
{
|
||||
int3 SampleCoord = VoxelCoord;
|
||||
|
||||
// Apply sample offset
|
||||
float3 Offset;
|
||||
Offset.x = Offsets5x5[i].x;
|
||||
Offset.y = Offsets5x5[i].y;
|
||||
Offset.z = Offsets5x5[i][GatherDirection.x];
|
||||
|
||||
// Apply per-pixel jitter
|
||||
float PixelJitter = GetBNDSequenceSample(pixCoord.xy, _FrameCount * JITTER_TEMPORAL, 0);
|
||||
Offset.x += Offsets5x5[PixelJitter * JITTER_STRENGTH].x;
|
||||
Offset.y += Offsets5x5[PixelJitter * JITTER_STRENGTH].y;
|
||||
Offset.z += Offsets5x5[PixelJitter * JITTER_STRENGTH][GatherDirection.x];
|
||||
|
||||
SampleCoord.x += Offset.x * GatherDirection.x;
|
||||
SampleCoord.y += Offset.y * GatherDirection.y;
|
||||
SampleCoord.z += Offset.z * GatherDirection.z;
|
||||
|
||||
// Get hash cell
|
||||
uint HashIndex = HashGetIndex(ComputeRadianceCacheCoord(SampleCoord), PackVoxelNormalIndex(Normal));
|
||||
|
||||
uint HashIndexFound;
|
||||
uint HashKey = PackHashKey(ComputeRadianceCacheCoord(SampleCoord), Normal);
|
||||
bool HashFound = HashFindValid(HashIndex, HashKey, HashIndexFound);
|
||||
|
||||
if (HashFound)
|
||||
{
|
||||
float3 RadianceCacheSample = UnpackCacheRadianceFull(_HashBuffer_Radiance[HashIndexFound].xyz);
|
||||
AccumulateCache += RadianceCacheSample * HGetCurrentExposureMultiplier;
|
||||
AccumulatedWeight += 1;
|
||||
}
|
||||
}
|
||||
|
||||
// Normalize
|
||||
if (AccumulatedWeight > 0)
|
||||
AccumulateCache /= AccumulatedWeight;
|
||||
|
||||
// Combine and output
|
||||
_Output[H_COORD(pixCoord.xy)] = AccumulateCache * HBUFFER_DIFFUSE(pixCoord.xy).xyz + HBUFFER_COLOR(pixCoord.xy).xyz;
|
||||
}
|
||||
@ -0,0 +1,14 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1bdf55fd1904a124caff462bdbc29873
|
||||
ComputeShaderImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 379716
|
||||
packageName: 'HTrace: World Space Global Illumination URP | Beta'
|
||||
packageVersion: 0.9.6
|
||||
assetPath: Assets/HTraceWSGI/Resources/HTraceWSGI/_Shared/Computes/HReflectionProbeCompose.compute
|
||||
uploadId: 925118
|
||||
364
Assets/External/HTraceWSGI/Resources/HTraceWSGI/_Shared/Computes/HRenderAO.compute
vendored
Normal file
364
Assets/External/HTraceWSGI/Resources/HTraceWSGI/_Shared/Computes/HRenderAO.compute
vendored
Normal file
@ -0,0 +1,364 @@
|
||||
#pragma kernel HorizonTracing
|
||||
#pragma kernel OcclusionInterpolation
|
||||
#pragma kernel OcclusionAccumulation
|
||||
|
||||
#include "../Includes/SpatialFilteringFunctions.hlsl"
|
||||
#include "../Includes/VoxelTraversal.hlsl"
|
||||
#include "../Includes/Reservoir.hlsl"
|
||||
#pragma multi_compile _ _GBUFFER_NORMALS_OCT
|
||||
|
||||
// Properties
|
||||
float _Camera_FOV;
|
||||
|
||||
H_TEXTURE(_SampleCount_History);
|
||||
H_TEXTURE(_NormalDepthHalf);
|
||||
H_TEXTURE(_AmbientOcclusion);
|
||||
H_TEXTURE(_AmbientOcclusion_History);
|
||||
H_TEXTURE(_Depth_History);
|
||||
H_TEXTURE(_Normal_History);
|
||||
H_TEXTURE(_NormalDepth_History);
|
||||
|
||||
|
||||
// Output Buffers
|
||||
H_RW_TEXTURE(float4, _NormalDepthDownsampled_Output);
|
||||
H_RW_TEXTURE(uint ,_NormalDepthDownsampledPacked_Output);
|
||||
H_RW_TEXTURE(float3 ,_NormalDepthDownsampled2_Output);
|
||||
H_RW_TEXTURE(float, _DepthDownsampled_Output);
|
||||
H_RW_TEXTURE(float4, _BentNormalAmbientOcclusion_Output);
|
||||
H_RW_TEXTURE(float4, _NormalDepthHalf_Output);
|
||||
H_RW_TEXTURE(float4, _BentNormalAO_Output);
|
||||
H_RW_TEXTURE(uint, _SampleCount_Output);
|
||||
H_RW_TEXTURE(float4, _GeometryNormal_Output);
|
||||
H_RW_TEXTURE(float4, _RayDirectionTest_Output);
|
||||
H_RW_TEXTURE(float, _AmbientOcclusion_Output);
|
||||
|
||||
H_RW_TEXTURE(uint4, _NormalTBN_Output);
|
||||
|
||||
RWStructuredBuffer<uint> _RayCounter;
|
||||
RWStructuredBuffer<uint2> _TracingCoords;
|
||||
|
||||
// ------------------------ FUNCTIONS ------------------------
|
||||
|
||||
|
||||
float PrepareHorizon(float Horizon, float Sign, float N)
|
||||
{
|
||||
float PreparedHorizon = HFastACos(clamp(Horizon, -1, 1));
|
||||
PreparedHorizon = saturate(((Sign * -PreparedHorizon) + N + H_PI_HALF) / H_PI); // TODO: +PreparedHorizon ?
|
||||
return max(PreparedHorizon, 1e-7);
|
||||
}
|
||||
|
||||
float IntegrateHalfArc(float AcosHorizon, float n, float cosN, float sinN)
|
||||
{
|
||||
float HalfArc = (cosN + 2.0f * AcosHorizon * sinN - cos(2.0f * AcosHorizon - n)) / 4.0f;
|
||||
return HalfArc;
|
||||
}
|
||||
|
||||
float TestConeIntersection(float FirstHorizon, float SecondHorizon, inout uint Mask)
|
||||
{
|
||||
uint FirstHorizonToInt = FirstHorizon * 32; // TODO: ceil(FirstHorizon * 32) ?
|
||||
uint SecondHorizonToInt = ceil(saturate(SecondHorizon - FirstHorizon) * 32);
|
||||
uint HorizonsToBit = SecondHorizonToInt > 0 ? (0xFFFFFFFF >> (32 - SecondHorizonToInt)) : 0;
|
||||
uint AngleToBit = HorizonsToBit << FirstHorizonToInt;
|
||||
|
||||
uint MaskTest = AngleToBit & (~Mask);;
|
||||
Mask = Mask | MaskTest;
|
||||
|
||||
return countbits(MaskTest);
|
||||
}
|
||||
|
||||
float2 PrepareHorizonPair(float HorizonAcos1, float HorizonAcos2, float N, float Side)
|
||||
{
|
||||
float HorizonPrepared1 = saturate((N - HorizonAcos1 + H_PI_HALF) / H_PI);
|
||||
float HorizonPrepared2 = saturate((N - HorizonAcos2 + H_PI_HALF) / H_PI);
|
||||
|
||||
HorizonPrepared1 = max(HorizonPrepared1, 1e-7);
|
||||
HorizonPrepared2 = max(HorizonPrepared2, 1e-7);
|
||||
|
||||
float2 HorizonPair = Side > 0 ? float2(HorizonPrepared2, HorizonPrepared1) : float2(HorizonPrepared1, HorizonPrepared2);
|
||||
return HorizonPair;
|
||||
}
|
||||
|
||||
// Accepts Linear Depth and pixCoord, returns World Position in View Space
|
||||
float3 GetPosition(float2 UV, float Depth)
|
||||
{
|
||||
float2 p11_22 = float2(UNITY_MATRIX_P._11, UNITY_MATRIX_P._22);
|
||||
float2 p13_31 = float2(UNITY_MATRIX_P._13, UNITY_MATRIX_P._23);
|
||||
float3 Position = float3((UV * 2 - 1 - p13_31) / p11_22 , 1) * Depth;
|
||||
return Position;
|
||||
}
|
||||
|
||||
float CalculateScreenSpaceRadius(float CameraFOV, float DepthLinear, float Radius)
|
||||
{
|
||||
float FovRadians = radians(CameraFOV);
|
||||
float TanHalfFOVY = tan(FovRadians * 0.5f);
|
||||
float TanHalfFOVX = TanHalfFOVY * (_ScreenSize.x / _ScreenSize.y);
|
||||
float2 CameraTanHalfFOV = float2(TanHalfFOVX, TanHalfFOVY);
|
||||
float2 NDCToViewMul = float2(CameraTanHalfFOV.x * 2.0f, CameraTanHalfFOV.y * -2.0f);
|
||||
float2 NDCToViewMul_X_PixelSize = float2(NDCToViewMul.x * _ScreenSize.z, NDCToViewMul.y * _ScreenSize.w);
|
||||
return Radius / (DepthLinear * NDCToViewMul_X_PixelSize.x);
|
||||
}
|
||||
|
||||
// ------------------------ RESTIR TEMPORAL KERNEL ------------------------
|
||||
|
||||
[numthreads(8, 8, 1)]
|
||||
void HorizonTracing(uint3 pixCoord : SV_DispatchThreadID, uint groupIndex : SV_GroupIndex, uint groupID : SV_GroupID)
|
||||
{
|
||||
|
||||
|
||||
pixCoord.xy *= 2;
|
||||
float2 pixCoordNDC = (pixCoord.xy + 0.5f) * _ScreenSize.zw;
|
||||
|
||||
// Load center depth and mask data
|
||||
float DepthCenterRaw = HBUFFER_DEPTH(pixCoord.xy);
|
||||
|
||||
// Load main center pixel data
|
||||
float DepthCenterLinear = H_LINEAR_EYE_DEPTH(DepthCenterRaw);
|
||||
float3 NormalCenterWS = HBUFFER_NORMAL_WS(pixCoord.xy);
|
||||
float3 NormalCenterVS = H_TRANSFORM_WORLD_TO_VIEW_NORMAL(NormalCenterWS) * float3(1, -1, -1);
|
||||
float3 WorldPosCenterVS = GetPosition(pixCoordNDC, DepthCenterLinear);
|
||||
float3 ViewDirection = normalize(-WorldPosCenterVS);
|
||||
|
||||
// Main constants
|
||||
float Radius = 0.5; //_Radius; // TODO: expose in UI
|
||||
float DistributionPower = 3.2;
|
||||
float FalloffRange = 0.6f * Radius;
|
||||
float FalloffFrom = Radius * (1.0f - 0.615f);
|
||||
float FalloffMul = -1.0f / FalloffRange;
|
||||
float FalloffAdd = FalloffFrom / FalloffRange + 1.0f;
|
||||
float SliceCount = 2;
|
||||
|
||||
// Calculate sampling radius in meters
|
||||
float ScreenSpaceRadius = CalculateScreenSpaceRadius(_Camera_FOV, DepthCenterLinear, Radius);
|
||||
|
||||
// Prepare noise
|
||||
float NoiseSlice = GetBNDSequenceSample(pixCoord.xy / 1, uint(_FrameCount) % 16, 0);
|
||||
float NoiseSample = GetBNDSequenceSample(pixCoord.xy / 1, uint(_FrameCount) % 16, 1);
|
||||
float JitterSample = Random(pixCoordNDC) * 2.0f - 1.0f;
|
||||
|
||||
// Initialize ambient occlusion values
|
||||
float AmbientOcclusion = 0 + saturate((10 - ScreenSpaceRadius) / 100) * 0.5f;
|
||||
float2 BentHorizons = 0;
|
||||
float3 BentNormal = 0;
|
||||
|
||||
float BitfieldAO = 0;
|
||||
|
||||
|
||||
// ------------------------ BEGIN MAIN LOOP ------------------------
|
||||
UNITY_LOOP
|
||||
for (int Slice = 0; Slice < SliceCount; Slice++)
|
||||
{
|
||||
float SliceSeed = float(Slice + NoiseSlice) / float(SliceCount);
|
||||
float Phi = SliceSeed * 1 * H_PI;
|
||||
float cosPhi = cos(Phi);
|
||||
float sinPhi = sin(Phi);
|
||||
|
||||
float3 SliceDirection = float3(cosPhi, sinPhi, 0);
|
||||
float2 SamplingDirection = float2(SliceDirection.x, -SliceDirection.y);
|
||||
|
||||
float3 OrthoDirectionVec = SliceDirection - (dot(SliceDirection, ViewDirection) * ViewDirection);
|
||||
float3 AxisVec = normalize(cross(OrthoDirectionVec, ViewDirection));
|
||||
float3 ProjectedNormal = NormalCenterVS - AxisVec * dot(NormalCenterVS , AxisVec);
|
||||
float signNorm = sign(dot(OrthoDirectionVec, ProjectedNormal));
|
||||
float ProjectedNormalLength = length(ProjectedNormal);
|
||||
float cosN = saturate(dot(ProjectedNormal, ViewDirection) / ProjectedNormalLength);
|
||||
float N = signNorm * HFastACos(cosN);
|
||||
float sinN = sin(N);
|
||||
|
||||
float OcclusionAccumulation = 0;
|
||||
uint OcclusionMaskSSGI = 0;
|
||||
|
||||
for (int Side = 0; Side < 2; Side++)
|
||||
{
|
||||
float SideDirection = -1 + 2 * Side;
|
||||
float LowestHorizon = cos(N + (H_PI_HALF * SideDirection));
|
||||
float MaxHorizonAO = LowestHorizon;
|
||||
|
||||
float StepCount = 10;
|
||||
|
||||
for (int Step = 0; Step < StepCount; Step ++)
|
||||
{
|
||||
// Jitter step
|
||||
float StepSeed = float(Step * StepCount) * JitterSample;
|
||||
float StepNoise = frac(NoiseSample + StepSeed);
|
||||
|
||||
float StepStride = (Step + StepNoise) / (StepCount);
|
||||
StepStride = pow(abs(StepStride), DistributionPower);
|
||||
float2 SampleOffset = StepStride * SamplingDirection * ScreenSpaceRadius;
|
||||
float SampleOffsetLength = length(SampleOffset);
|
||||
SampleOffset = round(SampleOffset) * _ScreenSize.zw;
|
||||
float2 SampleCoordNDC = pixCoordNDC + SampleOffset * SideDirection;
|
||||
|
||||
// Early-out if we are outside the frame
|
||||
if (SampleCoordNDC.x <= 0 || SampleCoordNDC.y <= 0 || SampleCoordNDC.x >= 1 || SampleCoordNDC.y >= 1)
|
||||
break;
|
||||
|
||||
// Texture LOD acceleration structure
|
||||
uint DepthLOD = clamp(log2(SampleOffsetLength) - 4, 0, 4) ;
|
||||
|
||||
// Read FRONT and BACK depth buffers
|
||||
float2 DepthFrontBackRaw = H_LOAD_LOD(g_HTraceDepthPyramidWSGI, (SampleCoordNDC * _ScreenSize.xy) / pow(2, DepthLOD) , DepthLOD).x; //H_SAMPLE_LOD(_DepthPyramid, H_SAMPLER_POINT_CLAMP, SampleCoordNDC * _RTHandleScale, DepthLOD).xy;
|
||||
|
||||
// Compute FRONT horizon
|
||||
float DepthFrontRaw = DepthFrontBackRaw.x;
|
||||
bool IsMoving = DepthFrontRaw < 0 ? true : false;
|
||||
DepthFrontRaw = abs(DepthFrontRaw) * 0.9992f;
|
||||
float DepthFrontLinear = H_LINEAR_EYE_DEPTH(DepthFrontRaw);
|
||||
float3 SampleDeltaFront = GetPosition(SampleCoordNDC, DepthFrontLinear) - WorldPosCenterVS; //TransformWorldToView(H_COMPUTE_POSITION_WS(SampleCoordNDC, DepthFrontRaw, H_MATRIX_I_VP)); // GetPosition(SampleCoordNDC, DepthFrontLinear) - WorldPosCenterVS;
|
||||
float HorizonFront = dot(normalize(SampleDeltaFront), ViewDirection); //ViewDirection
|
||||
float HorizonAcosFront = HFastACos(clamp(HorizonFront, -1, 1)) * SideDirection;
|
||||
|
||||
|
||||
// Calculate BACK horizon with standard depth
|
||||
// float DepthBackLinear = DepthFrontLinear + 0.1; // / _TraceThickness.x + _TraceThickness.y + 0.01f;
|
||||
// float3 Position = GetPosition(SampleCoordNDC, DepthBackLinear);
|
||||
// float3 SampleDeltaBack = Position - WorldPosCenterVS;
|
||||
// float HorizonBack = dot(normalize(SampleDeltaBack), ViewDirection); //ViewDirection
|
||||
// float HorizonAcosBack = HFastACos(clamp(HorizonBack, -1, 1)) * SideDirection;
|
||||
// float2 HorizonPair = PrepareHorizonPair(HorizonAcosFront, HorizonAcosBack, N, SideDirection);
|
||||
//
|
||||
//float ConeIntersection = TestConeIntersection(HorizonPair.x, HorizonPair.y, OcclusionMaskSSGI);
|
||||
|
||||
float WeightBase = length(float3(SampleDeltaFront.x, SampleDeltaFront.y, SampleDeltaFront.z * 4.0f)) * Radius;
|
||||
float HorizonWeight = saturate(WeightBase * min(FalloffMul * (0.5f / 0.3), FalloffMul) + FalloffAdd);
|
||||
// float HorizonWeight = saturate(WeightBase * FalloffMul * 3.0 + FalloffAdd);
|
||||
HorizonFront = lerp(LowestHorizon, HorizonFront, HorizonWeight);
|
||||
MaxHorizonAO = max(MaxHorizonAO, HorizonFront);
|
||||
}
|
||||
|
||||
// Integrate Ambient Occlusion
|
||||
OcclusionAccumulation += IntegrateHalfArc(HFastACos(MaxHorizonAO) * SideDirection, N, cosN, sinN);
|
||||
|
||||
if (Side == 0) BentHorizons.x = MaxHorizonAO;
|
||||
else BentHorizons.y = MaxHorizonAO;
|
||||
}
|
||||
|
||||
AmbientOcclusion += OcclusionAccumulation * ProjectedNormalLength;
|
||||
|
||||
BitfieldAO += float(countbits(OcclusionMaskSSGI)) / 32.0f;
|
||||
|
||||
// ------------------------ BENT NORMALS ------------------------
|
||||
|
||||
float h0 = -HFastACos(BentHorizons.x);
|
||||
float h1 = HFastACos(BentHorizons.y);
|
||||
float t0 = (6*sin(h0-N)-sin(3*h0-N)+6*sin(h1-N)-sin(3*h1-N)+16*sin(N)-3*(sin(h0+N)+sin(h1+N)))/12;
|
||||
float t1 = (-cos(3*h0-N)-cos(3*h1-N)+8*cos(N)-3*(cos(h0+N)+cos(h1+N)))/12;
|
||||
float3 LocalBentNormal = float3( SliceDirection.x * t0, SliceDirection.y * t0, - t1);
|
||||
LocalBentNormal = mul(RotFromToMatrix(float3(0,0,-1), ViewDirection), LocalBentNormal ) * ProjectedNormalLength;
|
||||
BentNormal += LocalBentNormal;
|
||||
|
||||
// ------------------------ RAY CULLING ------------------------
|
||||
|
||||
|
||||
}
|
||||
|
||||
// Finalize values
|
||||
AmbientOcclusion /= SliceCount;
|
||||
BentNormal = normalize(BentNormal);
|
||||
AmbientOcclusion = saturate(AmbientOcclusion);
|
||||
AmbientOcclusion = pow(AmbientOcclusion, 1);
|
||||
|
||||
BitfieldAO /= SliceCount;
|
||||
BitfieldAO = 1 - saturate(BitfieldAO);
|
||||
//AmbientOcclusion = pow(BitfieldAO, 3);
|
||||
|
||||
// Calculate specular occlusion
|
||||
float3 ViewDirWS = H_TRANSFORM_VIEW_TO_WORLD_DIR(float3(ViewDirection * float3(1, -1, -1)));
|
||||
float3 BentNormalWS = H_TRANSFORM_VIEW_TO_WORLD_NORMAL(float3(BentNormal * float3(1, -1, -1)));
|
||||
float Roughness = HBUFFER_ROUGHNESS(pixCoord.xy);
|
||||
// float ReflectionOcclusion = SpecularOcclusion(ViewDirWS, BentNormalWS, NormalCenterWS, saturate(AmbientOcclusion), Roughness);
|
||||
// ReflectionOcclusion = max(ReflectionOcclusion, 0);
|
||||
|
||||
_NormalDepthHalf_Output[H_COORD(pixCoord.xy / 2)] = float4(NormalCenterWS.xyz, DepthCenterRaw.x);
|
||||
_BentNormalAmbientOcclusion_Output[H_COORD(pixCoord.xy / 2)] = float4(BentNormalWS, AmbientOcclusion);
|
||||
}
|
||||
|
||||
[numthreads(8, 8, 1)]
|
||||
void OcclusionInterpolation(uint3 pixCoord : SV_DispatchThreadID)
|
||||
{
|
||||
|
||||
|
||||
float DepthCenter = HBUFFER_DEPTH(pixCoord.xy);
|
||||
float DepthCenterLinear = H_LINEAR_EYE_DEPTH(DepthCenter);
|
||||
float3 NormalCenter = HBUFFER_NORMAL_WS(pixCoord.xy);
|
||||
|
||||
float2 pixCoordNDC = (pixCoord.xy + 0.5f) * _ScreenSize.zw;
|
||||
float3 WorldPosCenter = H_COMPUTE_POSITION_WS(pixCoordNDC, DepthCenter, H_MATRIX_I_VP);
|
||||
float4 Plane = float4(NormalCenter.xyz, dot(WorldPosCenter, NormalCenter.xyz));
|
||||
|
||||
float AccumulatedWeight = 0;
|
||||
float4 InterpolatedOcclusion = 0;
|
||||
|
||||
for (int x = 0; x < 2; x++)
|
||||
{
|
||||
for (int y = 0; y < 2; y++)
|
||||
{
|
||||
int2 TapCoord = pixCoord.xy / 2 + uint2(x, y);
|
||||
float2 TapCoordNDC = (floor(pixCoord.xy / 2) * 2 + 0.5f) * _ScreenSize.zw;
|
||||
|
||||
float4 NormalDepthSample = H_LOAD(_NormalDepthHalf, TapCoord);
|
||||
|
||||
float DepthSample = H_LINEAR_EYE_DEPTH(NormalDepthSample.w);
|
||||
float DepthWeight = DepthWeighting(DepthCenterLinear, DepthSample, 1.0f);
|
||||
float3 WorldPos = H_COMPUTE_POSITION_WS(TapCoordNDC, NormalDepthSample.w, H_MATRIX_I_VP);
|
||||
float PlaneWeight = ProbePlaneWeighting(Plane, WorldPos, DepthCenterLinear, 100);
|
||||
float NormalWeight = saturate(dot(NormalDepthSample.xyz, NormalCenter));
|
||||
|
||||
float4 OcclusionSample = H_LOAD(_AmbientOcclusion, TapCoord);
|
||||
|
||||
InterpolatedOcclusion += OcclusionSample * PlaneWeight * NormalWeight;
|
||||
|
||||
float Weight = 1 * PlaneWeight * NormalWeight;
|
||||
AccumulatedWeight += Weight;
|
||||
}
|
||||
}
|
||||
|
||||
if (AccumulatedWeight > 0)
|
||||
InterpolatedOcclusion /= AccumulatedWeight;
|
||||
|
||||
|
||||
float3 GeometryNormal = HBUFFER_GEOMETRICAL_NORMAL_FROM_DEPTH(pixCoord.xy);
|
||||
_GeometryNormal_Output[H_COORD(pixCoord.xy)] = float4(GeometryNormal, 1);
|
||||
|
||||
_BentNormalAO_Output[H_COORD(pixCoord.xy)] = InterpolatedOcclusion; // H_LOAD(_AmbientOcclusion, pixCoord.xy / 2);;
|
||||
}
|
||||
|
||||
[numthreads(8, 8, 1)]
|
||||
void OcclusionAccumulation(uint3 pixCoord : SV_DispatchThreadID, uint2 groupThreadID : SV_GroupThreadID)
|
||||
{
|
||||
|
||||
|
||||
float2 MotionVectors = HBUFFER_MOTION_VECTOR(pixCoord.xy);
|
||||
float2 ReprojectionCoordNDC = (pixCoord.xy + 0.5f) * _ScreenSize.zw - MotionVectors;
|
||||
|
||||
float DepthCurrent = HBUFFER_DEPTH(pixCoord.xy);
|
||||
float3 NormalCurrent = HBUFFER_NORMAL_WS(pixCoord.xy);
|
||||
float3 WorldPosCurrent = H_COMPUTE_POSITION_WS((pixCoord.xy + 0.5f) * _ScreenSize.zw, DepthCurrent, H_MATRIX_I_VP);
|
||||
float4 NormalPlane = float4(NormalCurrent.xyz, dot(WorldPosCurrent, NormalCurrent.xyz));
|
||||
|
||||
float4 AmbientOcclusionHistory = 0;
|
||||
float4 AmbientOcclusion = H_LOAD(_AmbientOcclusion, pixCoord.xy);
|
||||
|
||||
uint SampleCount = 1;
|
||||
if (all(ReprojectionCoordNDC > 0) && all(ReprojectionCoordNDC < 1))
|
||||
{
|
||||
uint2 NormalDepthHistoryPacked = asuint(H_SAMPLE_LOD(_NormalDepth_History, H_SAMPLER_LINEAR_CLAMP, ReprojectionCoordNDC * HRenderScale.xy, 0).xy);
|
||||
float4 NormalDepthReprojected = UnpackNormalDepthFull(NormalDepthHistoryPacked);
|
||||
|
||||
float3 WorldPosPrevious = H_COMPUTE_POSITION_WS(ReprojectionCoordNDC, NormalDepthReprojected.w, H_MATRIX_PREV_I_VP);
|
||||
float PlaneWeight = ProbePlaneWeighting(NormalPlane, WorldPosPrevious, H_LINEAR_EYE_DEPTH(DepthCurrent), 100);
|
||||
|
||||
if (PlaneWeight > 0.1f)
|
||||
{
|
||||
AmbientOcclusionHistory = H_SAMPLE_LOD(_AmbientOcclusion_History, H_SAMPLER_LINEAR_CLAMP, ReprojectionCoordNDC * HRenderScale.xy, 0);
|
||||
uint SampleCountHistory = asuint(H_SAMPLE_LOD(_SampleCount_History, H_SAMPLER_LINEAR_CLAMP, ReprojectionCoordNDC * HRenderScale.xy, 0).x);
|
||||
SampleCount = min(8, SampleCountHistory + 1);
|
||||
}
|
||||
}
|
||||
|
||||
float TemporalWeight = 1.0f - (1.0f / float(SampleCount));
|
||||
AmbientOcclusion = lerp(AmbientOcclusion, AmbientOcclusionHistory, 0);
|
||||
|
||||
_AmbientOcclusion_Output[H_COORD(pixCoord.xy)] = AmbientOcclusion.w;
|
||||
_SampleCount_Output[H_COORD(pixCoord.xy)] = SampleCount;
|
||||
_BentNormalAO_Output[H_COORD(pixCoord.xy)] = AmbientOcclusion;
|
||||
}
|
||||
14
Assets/External/HTraceWSGI/Resources/HTraceWSGI/_Shared/Computes/HRenderAO.compute.meta
vendored
Normal file
14
Assets/External/HTraceWSGI/Resources/HTraceWSGI/_Shared/Computes/HRenderAO.compute.meta
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 370dd8403c3da0b4cacbfcec52a69468
|
||||
ComputeShaderImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 379716
|
||||
packageName: 'HTrace: World Space Global Illumination URP | Beta'
|
||||
packageVersion: 0.9.6
|
||||
assetPath: Assets/HTraceWSGI/Resources/HTraceWSGI/_Shared/Computes/HRenderAO.compute
|
||||
uploadId: 925118
|
||||
306
Assets/External/HTraceWSGI/Resources/HTraceWSGI/_Shared/Computes/HReservoirValidation.compute
vendored
Normal file
306
Assets/External/HTraceWSGI/Resources/HTraceWSGI/_Shared/Computes/HReservoirValidation.compute
vendored
Normal file
@ -0,0 +1,306 @@
|
||||
#pragma kernel OcclusionValidation
|
||||
#pragma kernel OcclusionReprojection
|
||||
#pragma kernel OcclusionSpatialFilter
|
||||
#pragma kernel OcclusionTemporalFilter
|
||||
|
||||
#pragma warning (disable : 3206)
|
||||
|
||||
#include "../Includes/Config.hlsl"
|
||||
#include "../Includes/Reservoir.hlsl"
|
||||
#include "../Includes/ScreenTraversal.hlsl"
|
||||
#include "../Includes/VoxelTraversal.hlsl"
|
||||
#pragma multi_compile _ _GBUFFER_NORMALS_OCT
|
||||
|
||||
H_TEXTURE(_SampleCount);
|
||||
H_TEXTURE(_ProbeNormalDepth);
|
||||
H_TEXTURE(_ShadowGuidanceMask);
|
||||
H_TEXTURE(_ReprojectionCoords);
|
||||
H_TEXTURE(_SampleCount_History);
|
||||
H_TEXTURE(_ReprojectionWeights);
|
||||
H_TEXTURE(_ProbeAmbientOcclusion);
|
||||
H_TEXTURE(_ShadowGuidanceMask_History);
|
||||
|
||||
H_TEXTURE_ARRAY(_SpatialWeightsPacked);
|
||||
H_TEXTURE_ARRAY(_SpatialOffsetsPacked);
|
||||
|
||||
H_TEXTURE(_ShadowGuidanceMaskTest);
|
||||
|
||||
H_RW_TEXTURE(float, _SampleCount_Output);
|
||||
H_RW_TEXTURE(float, _ShadowGuidanceMask_Output);
|
||||
|
||||
RWStructuredBuffer<uint> _RayCounter;
|
||||
RWStructuredBuffer<uint2> _TracingCoords;
|
||||
StructuredBuffer<float2> _PointDistribution;
|
||||
|
||||
int _IndexXR;
|
||||
|
||||
// ------------------------ OCCLUSION CHECKERBOARD REPROJECTION -----------------------
|
||||
[numthreads(8, 8, 1)]
|
||||
void OcclusionReprojection(uint3 pixCoord : SV_DispatchThreadID, uint groupIndex : SV_GroupIndex, uint groupID : SV_GroupID)
|
||||
{
|
||||
|
||||
|
||||
// Calculate probe coords
|
||||
int2 ProbeCoord = floor(pixCoord.xy / _OctahedralSize);
|
||||
int2 CellCoord = pixCoord.xy - floor(pixCoord.xy / _OctahedralSize) * _OctahedralSize;
|
||||
|
||||
// Get reprojection coords for previous frame
|
||||
uint2 BestOffset; bool ReprojectionFailed;
|
||||
uint2 ReprojectionCoordPacked = asuint(H_LOAD(_ReprojectionCoords, ProbeCoord)).xy;
|
||||
uint2 ReprojectionCoord = UnpackBestReprojectionCoord(ReprojectionCoordPacked, BestOffset, ReprojectionFailed);
|
||||
|
||||
ReprojectionCoord = ReprojectionCoord * _OctahedralSize + BestOffset * _OctahedralSize + CellCoord;
|
||||
|
||||
// Reproject if possible, otherwise use probe ambient occlusion as a fallback instead
|
||||
if (!ReprojectionFailed && all((float2)ReprojectionCoord < _ScreenSize.xy / _ProbeSize * _OctahedralSize) && all(ReprojectionCoord > 0))
|
||||
{
|
||||
_ShadowGuidanceMask_Output[H_COORD(pixCoord.xy)] = H_LOAD(_ShadowGuidanceMask_History, ReprojectionCoord).x;
|
||||
}
|
||||
else
|
||||
{
|
||||
_ShadowGuidanceMask_Output[H_COORD(pixCoord.xy)] = 0; //H_LOAD(_ProbeAmbientOcclusion, ProbeCoord);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ------------------------ OCCLUSION VALIDATION -----------------------
|
||||
[numthreads(8, 8, 1)]
|
||||
void OcclusionValidation(uint3 pixCoord : SV_DispatchThreadID, uint groupIndex : SV_GroupIndex, uint groupID : SV_GroupID)
|
||||
{
|
||||
uint IndirectCoordOffsetVR = _ScreenSize.x * _ScreenSize.y * _IndexXR;
|
||||
uint RayCounterOffsetVR = 10 * _IndexXR;
|
||||
|
||||
uint RayIndex = groupID * 64 + groupIndex;
|
||||
if (RayIndex >= _RayCounter[1 + 4 + RayCounterOffsetVR])
|
||||
return;
|
||||
|
||||
pixCoord.xy = _TracingCoords[RayIndex + IndirectCoordOffsetVR];
|
||||
|
||||
int2 ProbeCoord = floor(pixCoord.xy / _OctahedralSize);
|
||||
int2 CellCoord = pixCoord.xy - floor(pixCoord.xy / _OctahedralSize) * _OctahedralSize;
|
||||
|
||||
// Load probe normal, depth & offset
|
||||
uint2 ProbeOffset;
|
||||
float4 NormalDepth = UnpackNormalDepth(asuint(H_LOAD(_ProbeNormalDepth, ProbeCoord).xy), ProbeOffset);
|
||||
float2 ProbeCoordNDC = (ProbeCoord.xy * float(_ProbeSize) + float2(ProbeOffset) + 0.5f) * _ScreenSize.zw;
|
||||
|
||||
// Get reprojection coords for previous frame
|
||||
uint2 BestOffset; bool ReprojectionFailed;
|
||||
uint2 ReprojectionCoordPacked = asuint(H_LOAD(_ReprojectionCoords, ProbeCoord).xy);
|
||||
uint2 ReprojectionCoord = UnpackBestReprojectionCoord(ReprojectionCoordPacked, BestOffset, ReprojectionFailed);
|
||||
ReprojectionCoord = ReprojectionCoord * _OctahedralSize + BestOffset * _OctahedralSize + CellCoord;
|
||||
|
||||
// Initialize center reservoir
|
||||
Reservoir ReprojectedReservoir;
|
||||
ReservoirInitialize(pixCoord.xy, ReprojectedReservoir);
|
||||
|
||||
// Load ray data
|
||||
uint2 RayDataPacked = asuint(H_LOAD(_ReservoirAtlasRayData, ReprojectionCoord).xy);
|
||||
if (ReprojectionFailed)
|
||||
RayDataPacked = asuint(H_LOAD(_ReservoirAtlasRayData_Disocclusion, pixCoord.xy).xy);
|
||||
|
||||
// Unpack ray data
|
||||
UnpackRayData(RayDataPacked, ReprojectedReservoir.Ray);
|
||||
|
||||
// Get max ray distance for tracing
|
||||
float OcclusionTracingDistance = min(MAX_OCCLUSION_TRACING_DISTANCE, ReprojectedReservoir.Ray.Distance);
|
||||
|
||||
// Initialize both screen-space and world-space hits to false
|
||||
bool HitFoundWS = false;
|
||||
bool HitFoundSS = false;
|
||||
|
||||
// Load center pixel data
|
||||
float3 RayDirectionWS = ReprojectedReservoir.Ray.Direction;
|
||||
float3 PositionWS = H_COMPUTE_POSITION_WS(ProbeCoordNDC.xy, NormalDepth.w, H_MATRIX_I_VP);
|
||||
|
||||
// Calculate biased ray origin and ray directrion in NDC space
|
||||
float3 RayStartPositionNDC, RayDirectionNDC;
|
||||
GetRayOriginAndDirectionNDC(NormalDepth.w, OcclusionTracingDistance, ProbeCoordNDC, PositionWS, RayDirectionWS, NormalDepth.xyz, RayStartPositionNDC, RayDirectionNDC);
|
||||
|
||||
// Raymarch Hi-Z depth buffer
|
||||
float3 HitPositionNDC, LastAboveSurfacePositionNDC;
|
||||
HierarchicalRaymarch(RayStartPositionNDC, RayDirectionNDC, 30, HitPositionNDC, LastAboveSurfacePositionNDC);
|
||||
HitPositionNDC.xy = floor(HitPositionNDC.xy * _ScreenSize.xy) * _ScreenSize.zw + (0.5 * _ScreenSize.zw);
|
||||
|
||||
// Get hit point depth, position & ray distance
|
||||
float3 HitPositionWS = HitPositionNDC.z > 1e-7 ? H_COMPUTE_POSITION_WS(HitPositionNDC.xy, HitPositionNDC.z, H_MATRIX_I_VP) : PositionWS;
|
||||
float HitSurfaceLinear = H_LINEAR_EYE_DEPTH(H_LOAD(g_HTraceDepthPyramidWSGI, HitPositionNDC.xy * _ScreenSize.xy).x);
|
||||
float HitDepthLinear = H_LINEAR_EYE_DEPTH(HitPositionNDC.z);
|
||||
float HitDistanceWS = length(PositionWS - HitPositionWS);
|
||||
|
||||
// Evaluate occluder thickness
|
||||
float Thickness = AdaptiveThicknessSearch(HitPositionWS, RayDirectionWS);
|
||||
|
||||
// Evaluate validity of the screen-space hit
|
||||
if (abs(HitDepthLinear - HitSurfaceLinear) < Thickness && HitDepthLinear > HitSurfaceLinear)
|
||||
HitFoundSS = true;
|
||||
|
||||
// Initialize voxel ray payload
|
||||
VoxelPayload Payload;
|
||||
InitializePayload(Payload);
|
||||
|
||||
// If our screen-space hit is invalid and the remaining tracing distance is larger than a voxel - continue in world-space
|
||||
if (HitFoundSS != true && HitDistanceWS < OcclusionTracingDistance - _VoxelSize)
|
||||
{
|
||||
// Start world space tracing where the screen space part finished
|
||||
float3 RayOriginWS = PositionWS + HitDistanceWS * RayDirectionWS;
|
||||
|
||||
//If the ray travelled less than half a voxel - reset it to origin
|
||||
if (HitDistanceWS <= _VoxelSize * 0.5f)
|
||||
{
|
||||
RayOriginWS = PositionWS;
|
||||
HitDistanceWS = 0;
|
||||
}
|
||||
|
||||
// Apply voxel bias
|
||||
VoxelBias(pixCoord.xy, _PointDistribution, NormalDepth.w, HitDistanceWS, NormalDepth.xyz, RayDirectionWS, RayOriginWS);
|
||||
|
||||
// Trace into Voxels
|
||||
HitFoundWS = TraceVoxelsOcclusion(RayOriginWS, RayDirectionWS.xyz, OcclusionTracingDistance - HitDistanceWS, 50, Payload.HitDistance);
|
||||
|
||||
// If hit wasn't found
|
||||
if (!HitFoundWS)
|
||||
Payload.HitDistance = OcclusionTracingDistance;
|
||||
|
||||
HitDistanceWS += Payload.HitDistance;
|
||||
}
|
||||
|
||||
float ShadowGuidanceMask = 1;
|
||||
|
||||
// If we have a hit either in screen-space or in world-space
|
||||
if (HitFoundWS || HitFoundSS)
|
||||
{
|
||||
// If the distance difference is relatively high
|
||||
if (abs(HitDistanceWS - ReprojectedReservoir.Ray.Distance) / (ReprojectedReservoir.Ray.Distance + ReprojectedReservoir.Ray.Distance) > 0.25)
|
||||
{
|
||||
ShadowGuidanceMask = lerp(0, 1, saturate(HitDistanceWS / OcclusionTracingDistance));
|
||||
}
|
||||
}
|
||||
|
||||
// This helps to hide voxel artifacts which appear when ss rays go behind surfaces or offscreen
|
||||
if (HitDistanceWS <= _VoxelSize.x && !HitFoundSS)
|
||||
ShadowGuidanceMask = lerp(1, ShadowGuidanceMask, saturate(length(PositionWS) / 5.0f));
|
||||
|
||||
// if (ReprojectionFailed) // && (pixCoord.y / 4 * 6 > _ScreenSize.y * 0.5))
|
||||
// ShadowGuidanceMask = 1; //H_LOAD(_ProbeAmbientOcclusion, ProbeCoord);
|
||||
//
|
||||
|
||||
// Output
|
||||
_ShadowGuidanceMask_Output[H_COORD(pixCoord.xy)] = ShadowGuidanceMask;
|
||||
}
|
||||
|
||||
|
||||
// ------------------------ OCCLUSION TEMPORAL FILTER ----------------------
|
||||
[numthreads(8, 8, 1)]
|
||||
void OcclusionTemporalFilter(uint3 pixCoord : SV_DispatchThreadID, uint groupIndex : SV_GroupIndex, uint groupID : SV_GroupID)
|
||||
{
|
||||
|
||||
// Calculate probe coords
|
||||
int2 ProbeCoord = floor(pixCoord.xy / _OctahedralSize);
|
||||
int2 CellCoord = pixCoord.xy - floor(pixCoord.xy / _OctahedralSize) * _OctahedralSize;
|
||||
|
||||
// Load reprojection coords and weights
|
||||
int2 ReprojectionCoord = UnpackReprojectionCoord(asuint(H_LOAD(_ReprojectionCoords, ProbeCoord)).xy);
|
||||
float4 ReprojectionWeights = H_LOAD(_ReprojectionWeights, ProbeCoord);
|
||||
|
||||
// Normalize reprojection weights
|
||||
float WeightsSumm = max(ReprojectionWeights.x + ReprojectionWeights.y + ReprojectionWeights.z + ReprojectionWeights.w, 1.0e-3);
|
||||
ReprojectionWeights /= WeightsSumm;
|
||||
|
||||
// Reproject samplecount
|
||||
float4 SampleCountHistory;
|
||||
SampleCountHistory.x = H_LOAD(_SampleCount_History, ReprojectionCoord).x * ReprojectionWeights.x;
|
||||
SampleCountHistory.y = H_LOAD(_SampleCount_History, ReprojectionCoord).x * ReprojectionWeights.y;
|
||||
SampleCountHistory.z = H_LOAD(_SampleCount_History, ReprojectionCoord).x * ReprojectionWeights.z;
|
||||
SampleCountHistory.w = H_LOAD(_SampleCount_History, ReprojectionCoord).x * ReprojectionWeights.w;
|
||||
float SampleCountReprojected = SampleCountHistory.x + SampleCountHistory.y + SampleCountHistory.z + SampleCountHistory.w;
|
||||
|
||||
// Reproject shadow guidance mask
|
||||
float4 ShadowGuidanceMaskHistory;
|
||||
ShadowGuidanceMaskHistory.x = H_LOAD(_ShadowGuidanceMask_History, ReprojectionCoord * _OctahedralSize + uint2(0, 0) * _OctahedralSize + CellCoord).x * ReprojectionWeights.x;
|
||||
ShadowGuidanceMaskHistory.y = H_LOAD(_ShadowGuidanceMask_History, ReprojectionCoord * _OctahedralSize + uint2(1, 0) * _OctahedralSize + CellCoord).x * ReprojectionWeights.y;
|
||||
ShadowGuidanceMaskHistory.z = H_LOAD(_ShadowGuidanceMask_History, ReprojectionCoord * _OctahedralSize + uint2(0, 1) * _OctahedralSize + CellCoord).x * ReprojectionWeights.z;
|
||||
ShadowGuidanceMaskHistory.w = H_LOAD(_ShadowGuidanceMask_History, ReprojectionCoord * _OctahedralSize + uint2(1, 1) * _OctahedralSize + CellCoord).x * ReprojectionWeights.w;
|
||||
float ShadowGuidanceMaskReprojected = ShadowGuidanceMaskHistory.x + ShadowGuidanceMaskHistory.y + ShadowGuidanceMaskHistory.z + ShadowGuidanceMaskHistory.w;
|
||||
|
||||
// Update samplecount
|
||||
float SampleCount = min(MAX_OCCLUSION_TEMPORAL_SAMPLES, SampleCountReprojected + 1);
|
||||
float TemporalWeight = 1.0f - (1.0f / float(SampleCount));
|
||||
|
||||
// Temporally accumulate shadow guidance mask
|
||||
float ShadowGuidanceMask = H_LOAD(_ShadowGuidanceMask, pixCoord.xy).x;
|
||||
ShadowGuidanceMask = lerp(ShadowGuidanceMask, ShadowGuidanceMaskReprojected, TemporalWeight);
|
||||
|
||||
// Output
|
||||
_ShadowGuidanceMask_Output[H_COORD(pixCoord.xy)] = ShadowGuidanceMask;
|
||||
_SampleCount_Output[H_COORD(pixCoord.xy / _OctahedralSize)] = SampleCount;
|
||||
}
|
||||
|
||||
|
||||
// ------------------------ OCCLUSION SPATIAL FILTER -----------------------
|
||||
[numthreads(8, 8, 1)]
|
||||
void OcclusionSpatialFilter(uint3 pixCoord : SV_DispatchThreadID, uint groupIndex : SV_GroupIndex, uint groupID : SV_GroupID)
|
||||
{
|
||||
|
||||
|
||||
// Calculate probe and cell coord
|
||||
int2 ProbeCoord = floor(pixCoord.xy / _OctahedralSize);
|
||||
int2 CellCoord = pixCoord.xy - floor(pixCoord.xy / _OctahedralSize) * _OctahedralSize;
|
||||
|
||||
// Unpack occlusion (passed with packed radiance data)
|
||||
float ShadowGuidanceMask = H_LOAD(_ShadowGuidanceMask, pixCoord.xy).x;
|
||||
float WeightAccumualated = 1;
|
||||
|
||||
// Scale filter weight based on the accumulated samplecount
|
||||
float SampleCount = H_LOAD(_SampleCount, ProbeCoord).x;
|
||||
float SpatialWeight = lerp(1, 0, (SampleCount / 16));
|
||||
|
||||
// Load packed sample weights and coords
|
||||
float SampleWeights[8]; int2 SampleOffsets[8];
|
||||
uint4 PackedSampleOffsets = asuint(H_LOAD_ARRAY(_SpatialOffsetsPacked, ProbeCoord, 0));
|
||||
uint4 PackedSampleWeights = asuint(H_LOAD_ARRAY(_SpatialWeightsPacked, ProbeCoord, 0));
|
||||
|
||||
// Unpack sample weights and coords
|
||||
UnpackFilteringOffsetsX8(PackedSampleOffsets, SampleOffsets);
|
||||
UnpackFilteringWeightsX8(PackedSampleWeights, SampleWeights);
|
||||
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
int2 CellTapCoord = ProbeCoord * _OctahedralSize + SampleOffsets[i] * _OctahedralSize + CellCoord;
|
||||
ShadowGuidanceMask += H_LOAD(_ShadowGuidanceMask, CellTapCoord).x * SampleWeights[i] * SpatialWeight;
|
||||
WeightAccumualated += SampleWeights[i] * SpatialWeight;
|
||||
}
|
||||
|
||||
ShadowGuidanceMask /= WeightAccumualated;
|
||||
|
||||
// Load packed reservoir with radiance data
|
||||
uint2 RadianceDataPacked = asuint(H_LOAD(_ReservoirAtlasRadianceData_Inout, pixCoord.xy).xy);
|
||||
|
||||
bool TemporalInvalidation;
|
||||
UnpackOcclusion(RadianceDataPacked.x, TemporalInvalidation);
|
||||
|
||||
RadianceDataPacked.x &= 0xFFFFFF;
|
||||
|
||||
float Gathered;
|
||||
int2 TestCoord = floor(pixCoord.xy / _OctahedralSize);
|
||||
// for (int x = 0; x < 4; x++)
|
||||
// {
|
||||
// for (int y = 0; y < 4; y++)
|
||||
// {
|
||||
// Gathered += H_LOAD(_ShadowGuidanceMask, TestCoord * 4 + int2(x,y));
|
||||
// }
|
||||
// }
|
||||
|
||||
Gathered /= 16.0f;
|
||||
|
||||
// if (SampleCount == 1)
|
||||
// ShadowGuidanceMask = 1;
|
||||
|
||||
// Combine radiance data with shadow guidance mask
|
||||
RadianceDataPacked.x |= PackOcclusion(ShadowGuidanceMask, TemporalInvalidation);
|
||||
|
||||
// Output for reservoir spatial reuse
|
||||
_ReservoirAtlasRadianceData_Inout[H_COORD(pixCoord.xy)] = RadianceDataPacked.xy;
|
||||
|
||||
_ShadowGuidanceMask_Output[H_COORD(pixCoord.xy)] = ShadowGuidanceMask;
|
||||
}
|
||||
@ -0,0 +1,14 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9d0510465eff9c14ebfa427c933f197a
|
||||
ComputeShaderImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 379716
|
||||
packageName: 'HTrace: World Space Global Illumination URP | Beta'
|
||||
packageVersion: 0.9.6
|
||||
assetPath: Assets/HTraceWSGI/Resources/HTraceWSGI/_Shared/Computes/HReservoirValidation.compute
|
||||
uploadId: 925118
|
||||
297
Assets/External/HTraceWSGI/Resources/HTraceWSGI/_Shared/Computes/HSpatialPrepass.compute
vendored
Normal file
297
Assets/External/HTraceWSGI/Resources/HTraceWSGI/_Shared/Computes/HSpatialPrepass.compute
vendored
Normal file
@ -0,0 +1,297 @@
|
||||
#pragma kernel SpatialPrepass
|
||||
#pragma kernel GeometryNormals
|
||||
#pragma kernel GBufferDownsample
|
||||
#pragma kernel PointDistributionFill
|
||||
#pragma kernel SpatialOffsetsBufferFill
|
||||
#pragma kernel GeometryNormalsSmoothing
|
||||
|
||||
#pragma multi_compile _ USE_DIRECTIONAL_OCCLUSION
|
||||
#pragma multi_compile _ DIFFUSE_BUFFER_UNAVAILABLE
|
||||
|
||||
#include "../Includes/Config.hlsl"
|
||||
#include "../Includes/Reservoir.hlsl"
|
||||
#include "../Includes/SpatialFilteringFunctions.hlsl"
|
||||
#pragma multi_compile _ _GBUFFER_NORMALS_OCT
|
||||
|
||||
|
||||
H_TEXTURE(_SSAO);
|
||||
H_TEXTURE(g_GeometryNormal);
|
||||
H_TEXTURE(_ProbeNormalDepth);
|
||||
H_TEXTURE(_ProbeAmbientOcclusion);
|
||||
H_TEXTURE(_NormalDepthDownsampled);
|
||||
|
||||
H_RW_TEXTURE_ARRAY(uint4, _SpatialOffsets_Output);
|
||||
H_RW_TEXTURE_ARRAY(uint4, _SpatialWeights_Output);
|
||||
|
||||
H_RW_TEXTURE(float, _ProbeSSAO_Output);
|
||||
H_RW_TEXTURE(float3, _ProbeDiffuse_Output);
|
||||
H_RW_TEXTURE(float4, _GeometryNormal_Output);
|
||||
H_RW_TEXTURE(uint2, _ProbeNormalDepth_Output);
|
||||
|
||||
StructuredBuffer<float2> _PointDistribution;
|
||||
StructuredBuffer<int2> _SpatialOffsetsBuffer;
|
||||
RWStructuredBuffer<float2> _PointDistribution_Output;
|
||||
RWStructuredBuffer<int2> _SpatialOffsetsBuffer_Output;
|
||||
|
||||
uint _DiffuseBufferUnavailable;
|
||||
|
||||
void ClearArrays(inout int2 SampleCoords[8], inout float SampleWeights[8])
|
||||
{
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
SampleCoords[i] = int2(0, 0);
|
||||
SampleWeights[i] = 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ------------------------ POINT DISTRIBUTION BUFFER ------------------------
|
||||
[numthreads(128, 1, 1)]
|
||||
void PointDistributionFill(uint pixCoord : SV_DispatchThreadID)
|
||||
{
|
||||
_PointDistribution_Output[pixCoord.x] = HSampleDiskCubic(GetLDSequenceSampleFloat(pixCoord.x, 0), GetLDSequenceSampleFloat(pixCoord.x, 1));
|
||||
}
|
||||
|
||||
|
||||
// ------------------------ SPATIAL OFFSETS BUFFER ------------------------
|
||||
[numthreads(1, 1, 1)]
|
||||
void SpatialOffsetsBufferFill(uint pixCoord : SV_DispatchThreadID)
|
||||
{
|
||||
int2 SampleOffsets[80] = {int2( 0, 1), int2( 1, 0), int2( 1, 1), int2(-1, 0), int2(-1, 1), int2(-1, -1), int2( 0, -1), int2( 1, -1),
|
||||
int2(-2, 0), int2( 0, -2), int2( 2, 0), int2( 0, 2), int2(-1, 2), int2(-2, 1), int2( 1, -2), int2( 2, -1),
|
||||
int2(-2, -1), int2(-1, -2), int2( 2, 1), int2( 1, 2), int2(-2, 2), int2( 2, 2), int2( 2, -2), int2(-2, 2),
|
||||
int2( 0, -3), int2( 0, 3), int2(-3, 0), int2( 3, 0), int2(-3, -1), int2( 3, 1), int2(-1, -3), int2( 1, 3),
|
||||
int2(-3, 1), int2( 3, -1), int2(-1, 3), int2( 1, -3), int2(-2, 3), int2( 3, -2), int2( 3, 2), int2(-3, -2),
|
||||
int2( 2, 3), int2(-2, -3), int2(-3, 2), int2( 2, -3), int2(-3, 3), int2( 3, -3), int2( 3, 3), int2(-3, -3),
|
||||
int2( 0, 4), int2( 0, -4), int2(-4, 0), int2( 4, 0), int2(-4, 1), int2( 1, -4), int2(-1, 4), int2( 4, -1),
|
||||
int2(-4, 1), int2( 1, 4), int2(-1, -4), int2( 4, 1), int2(-4, 2), int2( 4, 2), int2( 4, -2), int2(-4, 2),
|
||||
int2( 2, -4), int2(-2, 4), int2(-2, -4), int2( 2, 4), int2(-3, -4), int2( 4, 3), int2(-4, -3), int2( 3, 4),
|
||||
int2( 3, -4), int2(-4, 3), int2( 4, -3), int2(-3, 4), int2( 4, -4), int2(-4, -4), int2( 4, 4), int2(-4, 4)};
|
||||
|
||||
for (int i = 0; i < 80; i++)
|
||||
{
|
||||
_SpatialOffsetsBuffer_Output[i] = SampleOffsets[i];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ------------------------ GEOMETRY NORMALS ------------------------
|
||||
[numthreads(8, 8, 1)]
|
||||
void GeometryNormals(uint3 pixCoord : SV_DispatchThreadID, uint2 groupThreadID : SV_GroupThreadID)
|
||||
{
|
||||
|
||||
|
||||
float3 GeometryNormal = HBUFFER_GEOMETRICAL_NORMAL_FROM_DEPTH(pixCoord.xy);
|
||||
_GeometryNormal_Output[H_COORD(pixCoord.xy)] = float4(GeometryNormal, 1);
|
||||
}
|
||||
|
||||
|
||||
// ------------------------ GBUFFER DOWNSAMPLE ------------------------
|
||||
[numthreads(8, 8, 1)]
|
||||
void GBufferDownsample(uint3 pixCoord : SV_DispatchThreadID, uint2 groupThreadID : SV_GroupThreadID)
|
||||
{
|
||||
|
||||
|
||||
uint2 ProbeOffset = CalculateHaltonSequence(uint(_FrameCount) % _PersistentHistorySamples) * float(_ProbeSize);
|
||||
|
||||
if (DISABLE_PROBE_JITTER)
|
||||
ProbeOffset = uint2(0,0);
|
||||
|
||||
float Depth = HBUFFER_DEPTH(pixCoord.xy * _ProbeSize + ProbeOffset);
|
||||
float3 GeometryNormal = H_LOAD(g_GeometryNormal, pixCoord.xy * _ProbeSize + ProbeOffset).xyz;
|
||||
float3 Diffuse = float3(1.0f, 1.0f, 1.0f);
|
||||
|
||||
#ifndef DIFFUSE_BUFFER_UNAVAILABLE
|
||||
Diffuse = HBUFFER_DIFFUSE(pixCoord.xy * _ProbeSize + ProbeOffset).xyz;
|
||||
#endif
|
||||
|
||||
#if USE_DIRECTIONAL_OCCLUSION
|
||||
_ProbeSSAO_Output[H_COORD(pixCoord.xy)] = H_LOAD(_SSAO, pixCoord.xy * _ProbeSize + ProbeOffset).w;
|
||||
#endif
|
||||
|
||||
_ProbeDiffuse_Output[H_COORD(pixCoord.xy)] = Diffuse;
|
||||
_ProbeNormalDepth_Output[H_COORD(pixCoord.xy)] = PackNormalDepth2(GeometryNormal, Depth, ProbeOffset);
|
||||
}
|
||||
|
||||
|
||||
// ------------------------ SMOOTH GEOMETRY NORMALS ------------------------
|
||||
[numthreads(8, 8, 1)]
|
||||
void GeometryNormalsSmoothing(uint3 pixCoord : SV_DispatchThreadID, uint2 groupThreadID : SV_GroupThreadID)
|
||||
{
|
||||
|
||||
|
||||
uint2 ProbeOffset;
|
||||
float4 NormalDepthCenter = UnpackNormalDepth(asuint(H_LOAD(_ProbeNormalDepth, pixCoord.xy).xy), ProbeOffset);
|
||||
float3 WorldPosCenter = H_COMPUTE_POSITION_WS((pixCoord.xy * float(_ProbeSize) + float2(ProbeOffset) + 0.5f) * _ScreenSize.zw, NormalDepthCenter.w, H_MATRIX_I_VP);
|
||||
|
||||
float3 NormalGathered = NormalDepthCenter.xyz;
|
||||
|
||||
for (int x = -4; x <= 4; x++)
|
||||
{
|
||||
for (int y = -5; y <= 4; y++)
|
||||
{
|
||||
if (x == 0 && y == 0)
|
||||
continue;
|
||||
|
||||
int2 TapOffset = int2(x,y);
|
||||
int2 TapCoord = pixCoord.xy + TapOffset;
|
||||
|
||||
// if (any(TapCoord.xy < 0) || any(TapCoord.xy > _ScreenSize.xy * _ProbeSize))
|
||||
// continue;
|
||||
|
||||
uint2 ProbeOffset;
|
||||
float4 NormalDepthSample = UnpackNormalDepth(asuint(H_LOAD(_ProbeNormalDepth, TapCoord.xy).xy), ProbeOffset);
|
||||
float3 WorldPosSample = H_COMPUTE_POSITION_WS((TapCoord * float(_ProbeSize) + float2(ProbeOffset) + 0.5f) * _ScreenSize.zw, NormalDepthSample.w, H_MATRIX_I_VP);
|
||||
|
||||
float NormalWeight = saturate(dot(NormalDepthCenter.xyz, NormalDepthSample.xyz));
|
||||
float PlaneWeight = PlaneWeighting(WorldPosCenter, WorldPosSample, NormalDepthCenter.xyz, NormalDepthSample.xyz, 1);
|
||||
|
||||
NormalGathered += NormalDepthSample.xyz * PlaneWeight * pow(NormalWeight, 2);
|
||||
}
|
||||
}
|
||||
|
||||
float3 NormalDepthSmoothed = HSafeNormalize(NormalGathered);
|
||||
|
||||
_ProbeNormalDepth_Output[H_COORD(pixCoord.xy)] = PackNormalDepth2(NormalDepthSmoothed.xyz, NormalDepthCenter.w, ProbeOffset);
|
||||
}
|
||||
|
||||
|
||||
// ------------------------ FILTERING WEIGHTS & OFFSETS RPEPASS ------------------------
|
||||
[numthreads(8, 8, 1)]
|
||||
void SpatialPrepass(uint3 pixCoord : SV_DispatchThreadID, uint2 groupThreadID : SV_GroupThreadID)
|
||||
{
|
||||
|
||||
|
||||
// Load center pixel data
|
||||
uint2 ProbeOffset;
|
||||
float4 NormalDepthCenter = UnpackNormalDepth(asuint(H_LOAD(_ProbeNormalDepth, pixCoord.xy).xy), ProbeOffset);
|
||||
float2 pixCoordNDC = (pixCoord.xy * float(_ProbeSize) + float2(ProbeOffset) + 0.5f) * _ScreenSize.zw;
|
||||
|
||||
float2 AmbientOcclusion = UnpackProbeAO(asuint(H_LOAD(_ProbeAmbientOcclusion, pixCoord.xy).x), PROBE_AO_MAX_TEMPORAL_SAMPLES);
|
||||
float3 WorldPosCenter = H_COMPUTE_POSITION_WS(pixCoordNDC, NormalDepthCenter.w, H_MATRIX_I_VP);
|
||||
float4 NormalPlane = float4(NormalDepthCenter.xyz, dot(WorldPosCenter, NormalDepthCenter.xyz));
|
||||
float3 NormalCenter = NormalDepthCenter.xyz;
|
||||
|
||||
// Prepare offset and weight buffers
|
||||
int2 BoxTapOffsets[8] = {int2(0, 1), int2(1, 0), int2(0, -1), int2(-1, 0), int2(-1, 1), int2(-1, -1), int2(1, 1), int2(1, -1)};
|
||||
int2 SampleOffsetsX8[8] = {int2(0, 0), int2(0, 0), int2(0, 0), int2(0, 0), int2(0, 0), int2(0, 0), int2(0, 0), int2(0, 0)};
|
||||
float SampleWeightsX8[8] = {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f};
|
||||
|
||||
// -------------------------- BOX PASS -------------------------- //
|
||||
int NumSamplesFound = 0;
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
// if (NumSamplesFound >= 8)
|
||||
// break;
|
||||
|
||||
int2 TapOffset = BoxTapOffsets[i];
|
||||
int2 TapCoord = pixCoord.xy + TapOffset;
|
||||
|
||||
// if (any(TapCoord.xy < 0) || any(TapCoord.xy > _ScreenSize.xy * _ProbeSize)) // TODO: do we need this?
|
||||
// continue;
|
||||
|
||||
uint2 ProbeOffset;
|
||||
float4 NormalDepthSample = UnpackNormalDepth(asuint(H_LOAD(_ProbeNormalDepth, TapCoord).xy), ProbeOffset);
|
||||
float3 WorldPosSample = H_COMPUTE_POSITION_WS((TapCoord * float(_ProbeSize) + float2(ProbeOffset) + 0.5f) * _ScreenSize.zw, NormalDepthSample.w, H_MATRIX_I_VP);
|
||||
|
||||
float NormalWeight = saturate(dot(NormalCenter, NormalDepthSample.xyz));
|
||||
float PlaneWeight = ProbePlaneWeighting(NormalPlane, WorldPosSample, H_LINEAR_EYE_DEPTH(NormalDepthSample.w), 1000.0f);
|
||||
//PlaneWeight = PlaneWeighting(WorldPosCenter, WorldPosSample, NormalCenter, NormalDepthSample.xyz, 4);
|
||||
|
||||
float Weight = NormalWeight * PlaneWeight;
|
||||
|
||||
// if (Weight > BOX_FILTER_MINIMUM_ACCEPT_WEIGHT)
|
||||
// {
|
||||
// SampleOffsetsX8[NumSamplesFound] = TapCoord - pixCoord.xy;
|
||||
// SampleWeightsX8[NumSamplesFound] = Weight;
|
||||
// NumSamplesFound++;
|
||||
// }
|
||||
|
||||
SampleOffsetsX8[i] = TapCoord - pixCoord.xy;
|
||||
SampleWeightsX8[i] = Weight;
|
||||
}
|
||||
|
||||
_SpatialWeights_Output[uint3(pixCoord.xy, H_INDEX_ARRAY(0))] = PackFilteringWeightsX8(SampleWeightsX8);
|
||||
_SpatialOffsets_Output[uint3(pixCoord.xy, H_INDEX_ARRAY(0))] = PackFilteringOffsetsX8(SampleOffsetsX8);
|
||||
|
||||
|
||||
// -------------------------- DISK PASSES -------------------------- //
|
||||
float DistanceToPoint = length(H_GET_ABSOLUTE_POSITION_WS(WorldPosCenter) - H_GET_CAMERA_POSITION_WS());// length(WorldPosCenter);
|
||||
float3x3 OrthoBasis = HGetLocalFrame(NormalCenter);
|
||||
|
||||
float RadiusScale = lerp(5.0f, 50.0f, saturate(DistanceToPoint / 500.0f));
|
||||
float AmbientOcclusionRadiusScale = lerp(0.3f, 1.0f, pow(AmbientOcclusion.x, 3));
|
||||
float TemporalAccumulationWeight = AmbientOcclusion.y / float(PROBE_AO_MAX_TEMPORAL_SAMPLES);
|
||||
|
||||
float FilterRadius = DISK_FILTER_MIN_RADIUS;
|
||||
float RadiusStep = DISK_FILTER_STEP_SIZE;
|
||||
|
||||
UNITY_UNROLL
|
||||
for (int k = 0; k < 3; k++)
|
||||
{
|
||||
float Jitter = GetBNDSequenceSample(pixCoord.xy, 0, 3 + k);
|
||||
float Radius = DistanceToPoint * FilterRadius / RadiusScale * lerp(1.5, 1, TemporalAccumulationWeight);
|
||||
// ClearArrays(SampleOffsetsX8, SampleWeightsX8); // TODO: do we need this?
|
||||
|
||||
if (DISK_FILTER_USE_AO_GUIDED_RADIUS)
|
||||
{
|
||||
float RadiusUnscaled = Radius;
|
||||
Radius *= AmbientOcclusionRadiusScale;
|
||||
Radius = min(max(Radius, 0.05), RadiusUnscaled);
|
||||
}
|
||||
|
||||
float Sigma = 0.9f * Radius;
|
||||
|
||||
int NumSamplesFound = 0;
|
||||
for (int i = 0; i < DISK_FILTER_MAX_SEARCH_SAMPLES; i++)
|
||||
{
|
||||
if (NumSamplesFound >= 8)
|
||||
break;
|
||||
|
||||
// Calculate sample coords
|
||||
float2 Sample = _PointDistribution[i + Jitter * 56] * Radius;
|
||||
float3 SamplePosWS = WorldPosCenter + OrthoBasis[0] * Sample.x + OrthoBasis[1] * Sample.y;
|
||||
float4 SamplePosHC = H_TRANSFORM_WORLD_TO_H_CLIP(SamplePosWS);
|
||||
SamplePosHC.xyz /= SamplePosHC.w;
|
||||
float2 SamplePosSS = SamplePosHC.xy * 0.5f + 0.5f;
|
||||
SamplePosSS.y = 1.0f - SamplePosSS.y;
|
||||
int2 TapCoord = (SamplePosSS * _ScreenSize.xy) / _ProbeSize;
|
||||
float2 TapCoordNDC = (TapCoord + 0.5f) * _ScreenSize.zw * float(_ProbeSize);
|
||||
|
||||
if (any(SamplePosHC.xy > 1.0f) || any(SamplePosHC.xy < -1.0f)) // TODO: do we need this?
|
||||
continue;
|
||||
|
||||
// Load sample data
|
||||
uint2 ProbeOffset;
|
||||
float4 NormalDepthSample = UnpackNormalDepth(asuint(H_LOAD(_ProbeNormalDepth, TapCoord).xy), ProbeOffset); //npackNormalDepth(asuint(H_LOAD(_NormalDepthDownsampled, TapCoord)));
|
||||
float3 WorldPosSample = H_COMPUTE_POSITION_WS((TapCoord * float(_ProbeSize) + float2(ProbeOffset) + 0.5f) * _ScreenSize.zw, NormalDepthSample.w, H_MATRIX_I_VP);
|
||||
|
||||
float SampleRadius = length(Sample);
|
||||
|
||||
// Calculate sample normal & plane weights
|
||||
float NormalWeight = saturate(dot(NormalCenter, NormalDepthSample.xyz));
|
||||
float PlaneWeight = ProbePlaneWeighting(NormalPlane, WorldPosSample, H_LINEAR_EYE_DEPTH(NormalDepthSample.w), 1000.0f);
|
||||
float GaussianWeight = SampleRadius > 0.001f ? GaussianWeighting(SampleRadius, Sigma) : 1.0f;
|
||||
|
||||
// If the distance to the sample is acceptable - use more accurate plane estimation
|
||||
if (abs(H_LINEAR_EYE_DEPTH(NormalDepthSample.w) - SamplePosHC.w) < 0.1)
|
||||
PlaneWeight = PlaneWeighting(WorldPosCenter, WorldPosSample, NormalCenter, NormalDepthSample.xyz, 4);
|
||||
|
||||
// Combine all weights
|
||||
float Weight = NormalWeight * PlaneWeight * lerp(1, GaussianWeight, TemporalAccumulationWeight);
|
||||
|
||||
// Store sample weight & offset if it is above the threshold
|
||||
if (Weight > DISK_FILTER_MINIMUM_ACCEPT_WEIGHT)
|
||||
{
|
||||
SampleOffsetsX8[NumSamplesFound] = TapCoord - pixCoord.xy;
|
||||
SampleWeightsX8[NumSamplesFound] = Weight;
|
||||
NumSamplesFound++;
|
||||
}
|
||||
}
|
||||
|
||||
_SpatialWeights_Output[uint3(pixCoord.xy, H_INDEX_ARRAY(1 + k))] = PackFilteringWeightsX8(SampleWeightsX8);
|
||||
_SpatialOffsets_Output[uint3(pixCoord.xy, H_INDEX_ARRAY(1 + k))] = PackFilteringOffsetsX8(SampleOffsetsX8);
|
||||
|
||||
FilterRadius += RadiusStep;
|
||||
}
|
||||
}
|
||||
14
Assets/External/HTraceWSGI/Resources/HTraceWSGI/_Shared/Computes/HSpatialPrepass.compute.meta
vendored
Normal file
14
Assets/External/HTraceWSGI/Resources/HTraceWSGI/_Shared/Computes/HSpatialPrepass.compute.meta
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1a7c84891a83d924996e32cd4dd8502a
|
||||
ComputeShaderImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 379716
|
||||
packageName: 'HTrace: World Space Global Illumination URP | Beta'
|
||||
packageVersion: 0.9.6
|
||||
assetPath: Assets/HTraceWSGI/Resources/HTraceWSGI/_Shared/Computes/HSpatialPrepass.compute
|
||||
uploadId: 925118
|
||||
247
Assets/External/HTraceWSGI/Resources/HTraceWSGI/_Shared/Computes/HTemporalDenoiser.compute
vendored
Normal file
247
Assets/External/HTraceWSGI/Resources/HTraceWSGI/_Shared/Computes/HTemporalDenoiser.compute
vendored
Normal file
@ -0,0 +1,247 @@
|
||||
#pragma kernel TemporalDenoising
|
||||
#pragma kernel SpatialCleanup
|
||||
|
||||
#include "../Includes/Config.hlsl"
|
||||
#include "../Includes/Reservoir.hlsl"
|
||||
#pragma multi_compile _ _GBUFFER_NORMALS_OCT
|
||||
|
||||
H_TEXTURE(_Radiance);
|
||||
H_TEXTURE(g_GeometryNormal);
|
||||
H_TEXTURE(_Radiance_History);
|
||||
H_TEXTURE(_NormalDepth_History);
|
||||
H_RW_TEXTURE(float4, _Radiance_Output);
|
||||
|
||||
groupshared uint RadianceLDS[16][16];
|
||||
|
||||
|
||||
void FillRadianceLDS(int2 pixCoord, int2 groupThreadID)
|
||||
{
|
||||
pixCoord.xy -= 4;
|
||||
|
||||
RadianceLDS[groupThreadID.x + 0][groupThreadID.y + 0] = asuint(H_LOAD(_Radiance, pixCoord.xy + int2(0, 0)).x);
|
||||
RadianceLDS[groupThreadID.x + 8][groupThreadID.y + 0] = asuint(H_LOAD(_Radiance, pixCoord.xy + int2(8, 0)).x);
|
||||
RadianceLDS[groupThreadID.x + 0][groupThreadID.y + 8] = asuint(H_LOAD(_Radiance, pixCoord.xy + int2(0, 8)).x);
|
||||
RadianceLDS[groupThreadID.x + 8][groupThreadID.y + 8] = asuint(H_LOAD(_Radiance, pixCoord.xy + int2(8, 8)).x);
|
||||
}
|
||||
|
||||
float DisocclusionDetection(CurrentFrameData CurrentData, PrevFrameData PrevData)
|
||||
{
|
||||
float PlaneMultiplier = CurrentData.MovingPixel ? 100.0f : 100000.0f; //TODO: make it 5000 for the editor window
|
||||
float DepthMultiplier = CurrentData.MovingPixel ? 20.0f : 1.0f;
|
||||
|
||||
float PlaneDistance = abs(dot(PrevData.WorldPos - CurrentData.WorldPos, CurrentData.Normal));
|
||||
float RelativeDepthDifference = PlaneDistance / CurrentData.DepthLinear;
|
||||
if (exp2(-PlaneMultiplier * (RelativeDepthDifference * RelativeDepthDifference )) < 0.1f)
|
||||
return 0;
|
||||
|
||||
float DepthThreshold = lerp(1e-2f, 1e-1f, CurrentData.AligmentZ);
|
||||
if (abs((PrevData.DepthLinear - CurrentData.DepthLinear) / CurrentData.DepthLinear) >= DepthThreshold * DepthMultiplier)
|
||||
return 0;
|
||||
|
||||
if (USE_NORMAL_REJECTION)
|
||||
{
|
||||
float NormalThreshold = lerp(1, CurrentData.AligmentZ, saturate(length(CurrentData.WorldPos) / 5));
|
||||
if (dot(PrevData.Normal, CurrentData.Normal) < lerp(0.0, 0.95, NormalThreshold))
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// ------------------------ TEMPORAL DENOISING KERNEL ------------------------
|
||||
[numthreads(8, 8, 1)]
|
||||
void TemporalDenoising(uint3 pixCoord : SV_DispatchThreadID, uint2 groupThreadID : SV_GroupThreadID, uint2 groupId : SV_GroupID)
|
||||
{
|
||||
|
||||
|
||||
// Transfer data to LDS
|
||||
FillRadianceLDS(pixCoord.xy, groupThreadID);
|
||||
GroupMemoryBarrierWithGroupSync();
|
||||
groupThreadID += 4;
|
||||
|
||||
// Fetch current center radiance from LDS
|
||||
bool IsValid;
|
||||
float3 Radiance = UnpackFromR11G10B10A1f(RadianceLDS[groupThreadID.x][groupThreadID.y], IsValid);
|
||||
|
||||
// Calculate history coord
|
||||
float2 CoordHistoryNDC = ((pixCoord.xy - HBUFFER_MOTION_VECTOR(pixCoord.xy) * _ScreenSize.xy) + 0.5f) / _ScreenSize.xy;
|
||||
|
||||
// If history coords are off screen - early out
|
||||
if (any(CoordHistoryNDC < 0) || any(CoordHistoryNDC > 1))
|
||||
{
|
||||
_Radiance_Output[H_COORD(pixCoord.xy)] = float4(Radiance, 1);
|
||||
return;
|
||||
}
|
||||
|
||||
// Load current frame data
|
||||
CurrentFrameData CurrentData;
|
||||
CurrentData.DepthRaw = HBUFFER_DEPTH(pixCoord.xy);
|
||||
CurrentData.Normal = H_LOAD(g_GeometryNormal, pixCoord.xy).xyz;
|
||||
CurrentData.WorldPos = H_COMPUTE_POSITION_WS((pixCoord.xy + 0.5f) * _ScreenSize.zw, CurrentData.DepthRaw, H_MATRIX_I_VP);
|
||||
CurrentData.DepthLinear = H_LINEAR_EYE_DEPTH(CurrentData.WorldPos, H_MATRIX_V);
|
||||
CurrentData.AligmentZ = 1.0f - dot(-normalize(H_GET_ABSOLUTE_POSITION_WS((CurrentData.WorldPos)) - _WorldSpaceCameraPos), CurrentData.Normal);
|
||||
CurrentData.MovingPixel = HBUFFER_MOTION_MASK(pixCoord.xy);
|
||||
|
||||
// Early-out on the skybox
|
||||
if (CurrentData.DepthRaw <= 1e-7)
|
||||
{
|
||||
_Radiance_Output[H_COORD(pixCoord.xy)] = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
// Calculate manual bilinear sample offsets and weights
|
||||
float UVx = frac(float(_ScreenSize.x) * CoordHistoryNDC.x + 0.5);
|
||||
float UVy = frac(float(_ScreenSize.y) * CoordHistoryNDC.y + 0.5);
|
||||
int2 ReprojectionCoord = int2(_ScreenSize.xy * CoordHistoryNDC - 0.5);
|
||||
|
||||
float4 ReprojectionWeights;
|
||||
ReprojectionWeights.x = (1.0f - UVx) * (1.0f - UVy);
|
||||
ReprojectionWeights.y = (UVx) * (1.0f - UVy);
|
||||
ReprojectionWeights.z = (1.0f - UVx) * (UVy);
|
||||
ReprojectionWeights.w = (UVx) * (UVy);
|
||||
|
||||
uint2 ReprojectionOffsets[4] = {uint2(0, 0), uint2(1, 0), uint2(0, 1), uint2(1, 1)};
|
||||
|
||||
UNITY_UNROLL // Go through all bilinear samples and check disocclusion for each sample
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
int2 SampleCoord = ReprojectionCoord + ReprojectionOffsets[i];
|
||||
float4 NormalDepthHistory = UnpackNormalDepthFull(asuint(H_LOAD(_NormalDepth_History, SampleCoord).xy));
|
||||
|
||||
PrevFrameData PrevData;
|
||||
PrevData.WorldPos = H_COMPUTE_POSITION_WS((SampleCoord + 0.5f) / _ScreenSize.xy, NormalDepthHistory.w, H_MATRIX_PREV_I_VP);
|
||||
PrevData.DepthLinear = H_LINEAR_EYE_DEPTH(PrevData.WorldPos, H_MATRIX_V);
|
||||
PrevData.Normal = NormalDepthHistory.xyz;
|
||||
|
||||
ReprojectionWeights[i] *= DisocclusionDetection(CurrentData, PrevData);
|
||||
}
|
||||
|
||||
// Normalize reprojection weights
|
||||
float WeightsSumm = max(ReprojectionWeights.x + ReprojectionWeights.y + ReprojectionWeights.z + ReprojectionWeights.w, 1.0e-3);
|
||||
ReprojectionWeights /= WeightsSumm;
|
||||
|
||||
// Load 4 bilinear samples of our history
|
||||
float4 RadianceHistory = 0;
|
||||
RadianceHistory += H_LOAD(_Radiance_History, ReprojectionCoord + uint2(0, 0)) * ReprojectionWeights.x;
|
||||
RadianceHistory += H_LOAD(_Radiance_History, ReprojectionCoord + uint2(1, 0)) * ReprojectionWeights.y;
|
||||
RadianceHistory += H_LOAD(_Radiance_History, ReprojectionCoord + uint2(0, 1)) * ReprojectionWeights.z;
|
||||
RadianceHistory += H_LOAD(_Radiance_History, ReprojectionCoord + uint2(1, 1)) * ReprojectionWeights.w;
|
||||
|
||||
// SampleCount is stored in the alpha channel
|
||||
float SampleCount = RadianceHistory.w;
|
||||
|
||||
float3 Moment1;
|
||||
float3 Moment2;
|
||||
float GatheredWeight = 0;
|
||||
|
||||
// Gather local statistics
|
||||
for (int x = -3; x <= 3; x++)
|
||||
{
|
||||
for (int y = -3; y <= 3; y++)
|
||||
{
|
||||
float3 RadianceSample = UnpackFromR11G10B10A1f(RadianceLDS[groupThreadID.x + x][groupThreadID.y + y]);
|
||||
|
||||
float Weight = exp(-3.0 * float(x * x + y * y) / float((3 + 1) * (3 + 1)));
|
||||
|
||||
Moment1 += RadianceSample * Weight;
|
||||
Moment2 += RadianceSample * RadianceSample * Weight;
|
||||
|
||||
GatheredWeight += Weight;
|
||||
}
|
||||
}
|
||||
|
||||
Moment1 /= GatheredWeight;
|
||||
Moment2 /= GatheredWeight;
|
||||
|
||||
float3 StdDev = sqrt(abs(Moment2 - Moment1 * Moment1));
|
||||
|
||||
// Calculates AABB box extents
|
||||
float3 ClampMin = Radiance - StdDev * AABB_CLIP_EXTENT;
|
||||
float3 ClampMax = Radiance + StdDev * AABB_CLIP_EXTENT;
|
||||
|
||||
// Backup unclamped history
|
||||
float3 RadianceHistoryUnclamped = RadianceHistory.xyz;
|
||||
|
||||
|
||||
// Clamp history to AABB box
|
||||
RadianceHistory.xyz = DirectClipToAABB(RadianceHistory.xyz, ClampMin, ClampMax);
|
||||
|
||||
float lum0 = Luminance(Radiance.rgb);
|
||||
float lum1 = Luminance(RadianceHistory.rgb);
|
||||
|
||||
float unbiased_diff = abs(lum0 - lum1) / max(lum0, max(lum1, 0.2));
|
||||
float unbiased_weight = 1.0 - unbiased_diff;
|
||||
float unbiased_weight_sqr = unbiased_weight * unbiased_weight;
|
||||
float MaxSampleCount = lerp(MAX_SAMPLECOUNT / 2, MAX_SAMPLECOUNT, unbiased_weight_sqr);
|
||||
|
||||
SampleCount = min(MaxSampleCount, SampleCount + 1);
|
||||
|
||||
float TemporalWeight = 1.0f - (1.0f / float(SampleCount));
|
||||
|
||||
// If current radiance is invalid (interpolation has failed) then we replace it with the history radiance if possible
|
||||
if (!IsValid && any(ReprojectionWeights > 0.1))
|
||||
{
|
||||
// Trade off between reconstruction accuracy and lighting response speed
|
||||
float MaxLumaDifference = 2;
|
||||
RadianceHistoryUnclamped *= clamp(Luminance(RadianceHistory.xyz) / max(1e-8, Luminance(RadianceHistoryUnclamped)) * MaxLumaDifference, 0.01, 1.0);
|
||||
|
||||
|
||||
// We must use unclamped history radiance as our replacement.
|
||||
RadianceHistory.xyz = RadianceHistoryUnclamped;
|
||||
SampleCount = MAX_SAMPLECOUNT;
|
||||
TemporalWeight = 0.99f;
|
||||
}
|
||||
|
||||
if (DISABLE_TEMPORAL_DENOISER)
|
||||
TemporalWeight = 0;
|
||||
|
||||
if (TEMPORAL_DENOISER_EXPOSURE_CONTROL)
|
||||
{
|
||||
// Grab the previous frame and current frame exposures
|
||||
float ExposurePrevious = HGetPreviousExposureMultiplier;
|
||||
float ExposureCurrent = HGetCurrentExposureMultiplier;
|
||||
|
||||
// Compute the exposure ratio (while avoiding zeros)
|
||||
float ExposureRatio = (ExposurePrevious * ExposureCurrent) != 0.0 ? ExposureCurrent / ExposurePrevious : 100.0;
|
||||
|
||||
// Evaluate if the exposure multiplier was at least twice bigger or smaller
|
||||
bool IsExposureValid = max(ExposureRatio, 1.0 / ExposureRatio) < 2.0;
|
||||
|
||||
// If the exposure change was considered valid, we can keep the result and re-exposed it. Otherwise, we cannot use the history buffer
|
||||
if (IsExposureValid)
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
TemporalWeight = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Blend with history
|
||||
|
||||
Radiance = lerp(Radiance, RadianceHistory.xyz, TemporalWeight) ; //TemporalWeight);
|
||||
if (AnyIsNaN(Radiance.xyz)) //Black waves in SceneView after entering Runtime
|
||||
Radiance.xyz = 0;
|
||||
|
||||
// Output radiance & samplecount
|
||||
_Radiance_Output[H_COORD(pixCoord.xy)] = float4(Radiance, SampleCount);
|
||||
}
|
||||
|
||||
|
||||
H_RW_TEXTURE(uint2, _NormalDepth_HistoryOutput);
|
||||
H_RW_TEXTURE(float4, _Radiance_HistoryOutput);
|
||||
|
||||
[numthreads(8, 8, 1)]
|
||||
void SpatialCleanup(uint3 pixCoord : SV_DispatchThreadID, int2 groupThreadID : SV_GroupThreadID, uint2 groupId : SV_GroupID)
|
||||
{
|
||||
|
||||
|
||||
float Depth = HBUFFER_DEPTH(pixCoord.xy);
|
||||
float3 Normal = float4(H_LOAD(g_GeometryNormal, pixCoord.xy)).xyz;
|
||||
_NormalDepth_HistoryOutput[H_COORD(pixCoord.xy)] = PackNormalDepth(Normal, Depth);
|
||||
|
||||
float4 Radiance = H_LOAD(_Radiance, pixCoord.xy);
|
||||
_Radiance_HistoryOutput[H_COORD(pixCoord.xy)] = Radiance;
|
||||
}
|
||||
14
Assets/External/HTraceWSGI/Resources/HTraceWSGI/_Shared/Computes/HTemporalDenoiser.compute.meta
vendored
Normal file
14
Assets/External/HTraceWSGI/Resources/HTraceWSGI/_Shared/Computes/HTemporalDenoiser.compute.meta
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e764d5314f178c1499151299696dcfb9
|
||||
ComputeShaderImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 379716
|
||||
packageName: 'HTrace: World Space Global Illumination URP | Beta'
|
||||
packageVersion: 0.9.6
|
||||
assetPath: Assets/HTraceWSGI/Resources/HTraceWSGI/_Shared/Computes/HTemporalDenoiser.compute
|
||||
uploadId: 925118
|
||||
299
Assets/External/HTraceWSGI/Resources/HTraceWSGI/_Shared/Computes/HTemporalReprojection.compute
vendored
Normal file
299
Assets/External/HTraceWSGI/Resources/HTraceWSGI/_Shared/Computes/HTemporalReprojection.compute
vendored
Normal file
@ -0,0 +1,299 @@
|
||||
#pragma kernel ProbeReprojection
|
||||
#pragma kernel HistoryIndirectionScroll
|
||||
#pragma kernel HistoryIndirectionUpdate
|
||||
#pragma kernel HistoryProbeBuffersUpdate
|
||||
#pragma kernel CopyHistoryURP
|
||||
#pragma kernel CopyHistoryBIRP
|
||||
|
||||
#pragma warning (disable : 3206)
|
||||
|
||||
#include "../Includes/Config.hlsl"
|
||||
#include "../Includes/Reservoir.hlsl"
|
||||
#pragma multi_compile _ _GBUFFER_NORMALS_OCT
|
||||
|
||||
H_TEXTURE(_ProbeNormalDepth);
|
||||
H_TEXTURE(_ReprojectionCoord);
|
||||
H_TEXTURE_ARRAY(_ProbeWorldPosNormal_History);
|
||||
|
||||
H_RW_TEXTURE(float4, _ReprojectionWeights_Output);
|
||||
H_RW_TEXTURE(float4, _PersistentReprojectionWeights_Output);
|
||||
H_RW_TEXTURE(uint2, _ReprojectionCoords_Output);
|
||||
H_RW_TEXTURE(uint2, _PersistentReprojectionCoord_Output);
|
||||
|
||||
H_RW_TEXTURE_ARRAY(uint2, _HistoryIndirection);
|
||||
H_RW_TEXTURE_ARRAY(uint4, _ProbeWorldPosNormal_HistoryOutput);
|
||||
|
||||
int _HistoryArrayIndex;
|
||||
|
||||
|
||||
// ------------------------ PROBE TEMPORAL REPROJECTION ------------------------
|
||||
[numthreads(8, 8, 1)]
|
||||
void ProbeReprojection(int3 pixCoord : SV_DispatchThreadID, uint2 groupThreadID : SV_GroupThreadID)
|
||||
{
|
||||
|
||||
uint2 ProbeOffset;
|
||||
float4 NormalDepthDownsampled = UnpackNormalDepth(asuint(H_LOAD(_ProbeNormalDepth, pixCoord.xy).xy), ProbeOffset);
|
||||
|
||||
// Fill current frame data
|
||||
CurrentFrameData CurrentData;
|
||||
CurrentData.Normal = NormalDepthDownsampled.xyz;
|
||||
CurrentData.DepthRaw = NormalDepthDownsampled.w;
|
||||
CurrentData.DepthLinear = H_LINEAR_EYE_DEPTH(CurrentData.DepthRaw);
|
||||
CurrentData.WorldPos = H_COMPUTE_POSITION_WS((pixCoord.xy * float(_ProbeSize) + float2(ProbeOffset) + 0.5f) / _ScreenSize.xy, CurrentData.DepthRaw, H_MATRIX_I_VP);
|
||||
CurrentData.WorldPos = H_GET_ABSOLUTE_POSITION_WS(CurrentData.WorldPos);
|
||||
CurrentData.AligmentZ = 1.0f - dot(-normalize((CurrentData.WorldPos) - _WorldSpaceCameraPos), CurrentData.Normal);
|
||||
CurrentData.MovingPixel = HBUFFER_MOTION_MASK(pixCoord.xy * float(_ProbeSize));
|
||||
|
||||
float4 RelaxedWeights[4]; // Relaxed weights are equal to reprojection weights but with a less strict normal cutoff
|
||||
float4 ReprojectionWeights; float4 BilinearWeights;
|
||||
int2 PersistentHistoryCoord; int2 ReprojectionCoord;
|
||||
|
||||
// Load and dilate motion vectors
|
||||
float2 MotionVectors; float ClosestDepth = FLT_MAX;
|
||||
for (int x = -1; x <= 1; x++)
|
||||
{
|
||||
for (int y = -1; y <= 1; y++)
|
||||
{
|
||||
uint2 Unused;
|
||||
float2 MotionVectorsSample = HBUFFER_MOTION_VECTOR(pixCoord.xy * _ProbeSize + int2(x,y) * _ProbeSize);
|
||||
float4 NormalDepthDownsampled = UnpackNormalDepth(asuint(H_LOAD(_ProbeNormalDepth, pixCoord.xy + int2(x,y)).xy), Unused);
|
||||
|
||||
if (NormalDepthDownsampled.w < ClosestDepth && NormalDepthDownsampled.w > 0)
|
||||
{
|
||||
ClosestDepth = NormalDepthDownsampled.w;
|
||||
MotionVectors = MotionVectorsSample;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Get initial reprojection (for N-1 frame) and bilinear reprojection weights
|
||||
GetReprojectionCoord(pixCoord.xy, MotionVectors, BilinearWeights, ReprojectionCoord);
|
||||
|
||||
// Reprojection weights start with simple bilinear weights and will be later multiplied by disocclusion rejection weights
|
||||
RelaxedWeights[0] = BilinearWeights;
|
||||
ReprojectionWeights = BilinearWeights;
|
||||
PersistentHistoryCoord = ReprojectionCoord;
|
||||
|
||||
// Find best reprojection offset based on the highest reprojection (still only bilinear) weight
|
||||
uint2 ReprojectionOffsets[4] = {uint2(0, 0), uint2(1, 0), uint2(0, 1), uint2(1, 1)};
|
||||
float BestReprojectionWeight = 0;
|
||||
uint2 BestReprojectionOffset = 0;
|
||||
|
||||
// Cycle through all weigths
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
if (ReprojectionWeights[i] > BestReprojectionWeight)
|
||||
{
|
||||
BestReprojectionWeight = ReprojectionWeights[i];
|
||||
BestReprojectionOffset = ReprojectionOffsets[i];
|
||||
}
|
||||
}
|
||||
|
||||
// Get reprojection weights for N-1 frame
|
||||
bool IsDisocclusion = GetReprojectionWeights(_ProbeWorldPosNormal_History, CurrentData, ReprojectionCoord, GetHistoryIndex(0), ReprojectionWeights, RelaxedWeights[0]);
|
||||
float BestWeightSumm = ReprojectionWeights.x + ReprojectionWeights.y + ReprojectionWeights.z + ReprojectionWeights.w;
|
||||
uint ReprojectionIndex = 0;
|
||||
|
||||
// If reprojection weights summ is 0 or reprojection coords lead outside probe atlas - it means we couldn't reproject N-1 frame
|
||||
bool ReprojectionFailed = false;
|
||||
int2 MaxAtlasReprojectionCoord = ReprojectionCoord * _OctahedralSize + BestReprojectionOffset * _OctahedralSize + _OctahedralSize;
|
||||
if (any(MaxAtlasReprojectionCoord > _ScreenSize.xy / _ProbeSize * _OctahedralSize) || BestWeightSumm <= 0.1)
|
||||
ReprojectionFailed = true;
|
||||
|
||||
// Output reprojection coords and weights and coords for N-1 frame
|
||||
_ReprojectionWeights_Output[H_COORD(pixCoord.xy)] = ReprojectionWeights;
|
||||
_ReprojectionCoords_Output[H_COORD(pixCoord.xy)] = PackReprojectionCoord(ReprojectionCoord, BestReprojectionOffset, ReprojectionFailed);
|
||||
|
||||
uint MaxHistoryFrames = DISABLE_PROBE_JITTER ? 1 : _PersistentHistorySamples;
|
||||
|
||||
// Search candidates in persistant history frames (up to N - MaxIterations), starting with (N-2)
|
||||
for (uint t = 1; t < MaxHistoryFrames; t++)
|
||||
{
|
||||
// Good enough, stop the search
|
||||
if (BestWeightSumm > 0.1)
|
||||
break;
|
||||
|
||||
RelaxedWeights[t] = BilinearWeights;
|
||||
float4 SampleReprojectionWeights = BilinearWeights;
|
||||
|
||||
// Get persistant history coordinates
|
||||
int2 SamplePersistentHistoryCoord = asuint(H_LOAD_ARRAY(_HistoryIndirection, ReprojectionCoord, t).xy);
|
||||
|
||||
// Calculate new reprojection weights
|
||||
IsDisocclusion = GetReprojectionWeights(_ProbeWorldPosNormal_History, CurrentData, SamplePersistentHistoryCoord, GetHistoryIndex(t), SampleReprojectionWeights, RelaxedWeights[t]);
|
||||
float SampleBestWeightSumm = SampleReprojectionWeights.x + SampleReprojectionWeights.y + SampleReprojectionWeights.z + SampleReprojectionWeights.w;
|
||||
|
||||
// Accept this sample if it's better than previous samples
|
||||
if (SampleBestWeightSumm > BestWeightSumm)
|
||||
{
|
||||
ReprojectionIndex = t;
|
||||
BestWeightSumm = SampleBestWeightSumm;
|
||||
ReprojectionWeights = SampleReprojectionWeights;
|
||||
PersistentHistoryCoord = SamplePersistentHistoryCoord;
|
||||
|
||||
// Prevents sampling outside of persistant history frames
|
||||
if (SamplePersistentHistoryCoord.x + SamplePersistentHistoryCoord.y == 0)
|
||||
ReprojectionWeights = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Search reprojection candidate in 3x3 neighbourhood
|
||||
if (REPROJECTION_AREA_SEARCH)
|
||||
{
|
||||
int2 BoxSampleOffsets[8] = {int2(0, 1), int2(1, 0), int2(0, -1), int2(-1, 0), int2(-1, 1), int2(-1, -1), int2(1, 1), int2(1, -1)};
|
||||
|
||||
// Do the search only if the current reprojection weight is too low and it's not an obvious disocclusion
|
||||
if (BestWeightSumm < 0.1 && !IsDisocclusion)
|
||||
{
|
||||
for (uint i = 0; i < MaxHistoryFrames; i++)
|
||||
{
|
||||
for (int s = 0; s < 8; s++)
|
||||
{
|
||||
int2 SampleReprojectionCoord;
|
||||
float4 SampleReprojectionWeights, WeightsUnused;
|
||||
|
||||
// Get new reprojection coordinates with offset
|
||||
GetReprojectionCoord(pixCoord.xy + BoxSampleOffsets[s], MotionVectors, SampleReprojectionWeights, SampleReprojectionCoord);
|
||||
int2 SamplePersistentHistoryCoord = asuint(H_LOAD_ARRAY(_HistoryIndirection, SampleReprojectionCoord, i));
|
||||
|
||||
if (any(SampleReprojectionCoord * _OctahedralSize + int2(0, 0) * _OctahedralSize + _OctahedralSize >= _ScreenSize.xy / _ProbeSize * _OctahedralSize))
|
||||
SampleReprojectionWeights.x = 0;
|
||||
|
||||
if (any(SampleReprojectionCoord * _OctahedralSize + int2(1, 0) * _OctahedralSize + _OctahedralSize >= _ScreenSize.xy / _ProbeSize * _OctahedralSize))
|
||||
SampleReprojectionWeights.y = 0;
|
||||
|
||||
if (any(SampleReprojectionCoord * _OctahedralSize + int2(0, 1) * _OctahedralSize + _OctahedralSize >= _ScreenSize.xy / _ProbeSize * _OctahedralSize))
|
||||
SampleReprojectionWeights.z = 0;
|
||||
|
||||
if (any(SampleReprojectionCoord * _OctahedralSize + int2(1, 1) * _OctahedralSize + _OctahedralSize >= _ScreenSize.xy / _ProbeSize * _OctahedralSize))
|
||||
SampleReprojectionWeights.w = 0;
|
||||
|
||||
// Calculate new reprojection weights
|
||||
GetReprojectionWeights(_ProbeWorldPosNormal_History, CurrentData, SamplePersistentHistoryCoord, GetHistoryIndex(i), SampleReprojectionWeights, WeightsUnused);
|
||||
float SampleBestWeightSumm = SampleReprojectionWeights.x + SampleReprojectionWeights.y + SampleReprojectionWeights.z + SampleReprojectionWeights.w;
|
||||
|
||||
// Accept this sample if it's better than previous samples
|
||||
if (SampleBestWeightSumm > BestWeightSumm)
|
||||
{
|
||||
ReprojectionIndex = i;
|
||||
BestWeightSumm = SampleBestWeightSumm;
|
||||
ReprojectionWeights = SampleReprojectionWeights;
|
||||
PersistentHistoryCoord = SamplePersistentHistoryCoord;
|
||||
|
||||
// Prevents sampling outside of persistant history frames
|
||||
if (SamplePersistentHistoryCoord.x + SamplePersistentHistoryCoord.y == 0)
|
||||
ReprojectionWeights = 0;
|
||||
|
||||
// Good enough, stop the search
|
||||
if (SampleBestWeightSumm > 0.1)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Use best relaxed weight (meaning soft normal cutoff) as a last-ditch effort
|
||||
if (REPROJECTION_WITH_RELAXED_WEIGHTS)
|
||||
{
|
||||
for (uint i = 0; i < MaxHistoryFrames; i++)
|
||||
{
|
||||
// Good enough, stop the search
|
||||
if (BestWeightSumm > 0.1)
|
||||
break;
|
||||
|
||||
float SampleBestWeightSumm = RelaxedWeights[i].x + RelaxedWeights[i].y + RelaxedWeights[i].z + RelaxedWeights[i].w;
|
||||
|
||||
// Accept this sample if it's better than previous samples
|
||||
if (SampleBestWeightSumm > BestWeightSumm)
|
||||
{
|
||||
ReprojectionIndex = i;
|
||||
BestWeightSumm = SampleBestWeightSumm;
|
||||
ReprojectionWeights = RelaxedWeights[i];
|
||||
PersistentHistoryCoord = asuint(H_LOAD_ARRAY(_HistoryIndirection, ReprojectionCoord, i));
|
||||
|
||||
// Prevents sampling outside of persistant history frames
|
||||
if (PersistentHistoryCoord.x + PersistentHistoryCoord.y == 0)
|
||||
ReprojectionWeights = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (any(PersistentHistoryCoord * _OctahedralSize + int2(0, 0) * _OctahedralSize + _OctahedralSize > _ScreenSize.xy / _ProbeSize * _OctahedralSize))
|
||||
ReprojectionWeights.x = 0;
|
||||
|
||||
if (any(PersistentHistoryCoord * _OctahedralSize + int2(1, 0) * _OctahedralSize + _OctahedralSize > _ScreenSize.xy / _ProbeSize * _OctahedralSize))
|
||||
ReprojectionWeights.y = 0;
|
||||
|
||||
if (any(PersistentHistoryCoord * _OctahedralSize + int2(0, 1) * _OctahedralSize + _OctahedralSize > _ScreenSize.xy / _ProbeSize * _OctahedralSize))
|
||||
ReprojectionWeights.z = 0;
|
||||
|
||||
if (any(PersistentHistoryCoord * _OctahedralSize + int2(1, 1) * _OctahedralSize + _OctahedralSize > _ScreenSize.xy / _ProbeSize * _OctahedralSize))
|
||||
ReprojectionWeights.w = 0;
|
||||
|
||||
// Output reprojection weights and coords
|
||||
_PersistentReprojectionWeights_Output[H_COORD(pixCoord.xy)] = ReprojectionWeights;
|
||||
_PersistentReprojectionCoord_Output[H_COORD(pixCoord.xy)] = PackPersistentReprojectionCoord(PersistentHistoryCoord, ReprojectionIndex);
|
||||
}
|
||||
|
||||
|
||||
// ------------------------ HISTORY INDIRECTION SCROLL ------------------------
|
||||
[numthreads(8, 8, 1)]
|
||||
void HistoryIndirectionScroll(uint3 pixCoord : SV_DispatchThreadID, uint2 groupThreadID : SV_GroupThreadID, uint groupIndex : SV_GroupIndex, uint groupID : SV_GroupID)
|
||||
{
|
||||
|
||||
|
||||
uint2 BestOffset; bool ReprojectionFailed;
|
||||
uint2 ReprojectionCoordPacked = asuint(H_LOAD(_ReprojectionCoord, pixCoord.xy).xy);
|
||||
uint2 ReprojectionCoord = UnpackBestReprojectionCoord(ReprojectionCoordPacked, BestOffset, ReprojectionFailed);
|
||||
|
||||
_HistoryIndirection[uint3(pixCoord.xy, H_INDEX_ARRAY(_HistoryArrayIndex))] = asuint(H_LOAD_ARRAY(_HistoryIndirection, ReprojectionCoord + BestOffset, _HistoryArrayIndex - 1));
|
||||
}
|
||||
|
||||
|
||||
// ------------------------ HISTORY INDIRECTION UPDATE ------------------------
|
||||
[numthreads(8, 8, 1)]
|
||||
void HistoryIndirectionUpdate(uint3 pixCoord : SV_DispatchThreadID, uint2 groupThreadID : SV_GroupThreadID, uint groupIndex : SV_GroupIndex, uint groupID : SV_GroupID)
|
||||
{
|
||||
|
||||
|
||||
_HistoryIndirection[uint3(pixCoord.xy, H_INDEX_ARRAY(0))] = pixCoord.xy;
|
||||
}
|
||||
|
||||
|
||||
// ------------------------ HISTORY PROBE BUFFERS UPDATE ------------------------
|
||||
[numthreads(8, 8, 1)]
|
||||
void HistoryProbeBuffersUpdate(uint3 pixCoord : SV_DispatchThreadID, uint2 groupThreadID : SV_GroupThreadID, uint groupIndex : SV_GroupIndex, uint groupID : SV_GroupID)
|
||||
{
|
||||
|
||||
|
||||
uint2 ProbeOffset;
|
||||
float4 NormalDepthDownsampled = UnpackNormalDepth(asuint(H_LOAD(_ProbeNormalDepth, pixCoord.xy).xy), ProbeOffset);
|
||||
float3 WorldPosition = H_COMPUTE_POSITION_WS((pixCoord.xy * float(_ProbeSize) + float2(ProbeOffset) + 0.5f) / _ScreenSize.xy, NormalDepthDownsampled.w, H_MATRIX_I_VP);
|
||||
WorldPosition = H_GET_ABSOLUTE_POSITION_WS(WorldPosition);
|
||||
|
||||
_ProbeWorldPosNormal_HistoryOutput[uint3(pixCoord.xy, H_INDEX_ARRAY(uint(_FrameCount) % _PersistentHistorySamples))] = PackWorldPosNormal(WorldPosition.xyz, NormalDepthDownsampled.xyz);
|
||||
}
|
||||
|
||||
|
||||
H_TEXTURE(_HTraceBufferGI);
|
||||
H_RW_TEXTURE(float3, _Radiance_Output);
|
||||
|
||||
// ------------------------ HISTORY COPYING -----------------------
|
||||
[numthreads(8, 8, 1)]
|
||||
void CopyHistoryURP(uint3 pixCoord : SV_DispatchThreadID, uint groupIndex : SV_GroupIndex, uint groupID : SV_GroupID)
|
||||
{
|
||||
float3 IndirectLighting = H_LOAD(_HTraceBufferGI, pixCoord.xy).xyz;
|
||||
float3 DiffuseColor = HBUFFER_DIFFUSE(pixCoord.xy).xyz;
|
||||
float Metallic = H_LOAD(g_HTraceGBuffer1, pixCoord.xy).x;
|
||||
|
||||
// No Indirect Intensity multiplier here to avoid overblown lighting through the temporal loop
|
||||
float3 FinalIndirectLighting = IndirectLighting * DiffuseColor * (1 - Metallic);
|
||||
|
||||
_Radiance_Output[H_COORD(pixCoord.xy)] = float4(HBUFFER_COLOR(pixCoord.xy).xyz + FinalIndirectLighting, 0);
|
||||
}
|
||||
|
||||
[numthreads(8, 8, 1)]
|
||||
void CopyHistoryBIRP(uint3 pixCoord : SV_DispatchThreadID, uint groupIndex : SV_GroupIndex, uint groupID : SV_GroupID)
|
||||
{
|
||||
}
|
||||
@ -0,0 +1,14 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 852fce6b91aadfb44909f00fe7e0c637
|
||||
ComputeShaderImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 379716
|
||||
packageName: 'HTrace: World Space Global Illumination URP | Beta'
|
||||
packageVersion: 0.9.6
|
||||
assetPath: Assets/HTraceWSGI/Resources/HTraceWSGI/_Shared/Computes/HTemporalReprojection.compute
|
||||
uploadId: 925118
|
||||
277
Assets/External/HTraceWSGI/Resources/HTraceWSGI/_Shared/Computes/HTracingScreenSpace.compute
vendored
Normal file
277
Assets/External/HTraceWSGI/Resources/HTraceWSGI/_Shared/Computes/HTracingScreenSpace.compute
vendored
Normal file
@ -0,0 +1,277 @@
|
||||
#pragma kernel LightEvaluation
|
||||
#pragma kernel ScreenSpaceTracing
|
||||
|
||||
#pragma warning (disable : 4000)
|
||||
|
||||
#pragma multi_compile _ PROBE_VOLUMES_L1 PROBE_VOLUMES_L2
|
||||
#pragma multi_compile _ HIT_SCREEN_SPACE_LIGHTING
|
||||
|
||||
#include "../Includes/Config.hlsl"
|
||||
|
||||
#include "../Includes/VoxelTraversal.hlsl"
|
||||
#include "../Includes/ScreenTraversal.hlsl"
|
||||
#include "../Includes/SpatialFilteringFunctions.hlsl"
|
||||
#include "../Includes/VoxelLightingEvaluation.hlsl"
|
||||
#include "../Includes/FallbackAPV.hlsl"
|
||||
#pragma multi_compile _ _GBUFFER_NORMALS_OCT
|
||||
|
||||
#define AO_IN_GBUFFER3_TAG float3((1 << 11), 1, (1 << 10))
|
||||
|
||||
H_TEXTURE(_ColorPyramid_History);
|
||||
H_TEXTURE(_NormalDepth_History);
|
||||
H_TEXTURE(_ProbeNormalDepth);
|
||||
H_TEXTURE(_Radiance_History);
|
||||
H_TEXTURE(g_GeometryNormal);
|
||||
H_TEXTURE(_RayDirection);
|
||||
H_TEXTURE(_HitCoord);
|
||||
H_TEXTURE(_ProbeSeed);
|
||||
H_TEXTURE(_GBufferTexture3);
|
||||
|
||||
H_RW_TEXTURE(float, _TracingTemporalValidity_Output);
|
||||
H_RW_TEXTURE(float4, _HitRadiance_Output);
|
||||
H_RW_TEXTURE(float3, _HitNormal_Output);
|
||||
H_RW_TEXTURE(uint, _HitDistance_Output);
|
||||
H_RW_TEXTURE(uint2, _HitCoord_Output);
|
||||
|
||||
RWStructuredBuffer<uint2> _TracingCoords;
|
||||
RWStructuredBuffer<uint> _RayCounter;
|
||||
|
||||
int _IndexXR;
|
||||
|
||||
// ------------------------ FUNCTIONS ------------------------
|
||||
bool RadianceValidation(uint2 pixCoord, float3 HitPositionNDC, float3 RayDirectionWS, float3 HitPositionWS, float3 PositionWS, float Thickness, bool IsInsideVoxelBound, inout float3 HitRadiance)
|
||||
{
|
||||
// Reject hits outside the frame
|
||||
if (all(HitPositionNDC.xy > 0) && all(HitPositionNDC.xy < 1))
|
||||
{
|
||||
float HitSurface = H_LOAD(g_HTraceDepthPyramidWSGI, HitPositionNDC.xy * _ScreenSize.xy).x;
|
||||
|
||||
// Reject hits on sky (or other) infinitely distant pixels
|
||||
if (HitSurface > 1e-7)
|
||||
{
|
||||
float HitSurfaceLinear = H_LINEAR_EYE_DEPTH(HitSurface);
|
||||
float HitDepthLinear = H_LINEAR_EYE_DEPTH(HitPositionNDC.z);
|
||||
|
||||
// Reject hits that are too deep beneath the surface (or above it)
|
||||
Thickness = IsInsideVoxelBound ? Thickness : 0.05f * max(HitSurfaceLinear, 0.00001f);
|
||||
if (abs(HitDepthLinear - HitSurfaceLinear) < Thickness && HitSurfaceLinear < HitDepthLinear)
|
||||
{
|
||||
float3 HitNormal = H_LOAD(g_GeometryNormal, HitPositionNDC.xy * _ScreenSize.xy).xyz;
|
||||
float HitDistance = length(PositionWS - HitPositionWS);
|
||||
|
||||
float2 ReprojectedHitNDC = HitPositionNDC.xy - HBUFFER_MOTION_VECTOR(HitPositionNDC.xy * _ScreenSize.xy).xy;
|
||||
if (any(ReprojectedHitNDC < 0) || any(ReprojectedHitNDC > 1))
|
||||
return false;
|
||||
|
||||
// Load previous normal and depth
|
||||
uint2 NormalDepthHistoryPacked = asuint(H_LOAD(_NormalDepth_History, ReprojectedHitNDC * _ScreenSize.xy).xy);
|
||||
float4 NormalDepthReprojected = UnpackNormalDepthFull(NormalDepthHistoryPacked);
|
||||
float3 HitNormalReprojected = NormalDepthReprojected.xyz;
|
||||
float HitSurfaceReprojected = NormalDepthReprojected.w;
|
||||
float HitSurfaceReprojectedLinear = H_LINEAR_EYE_DEPTH(HitSurfaceReprojected);
|
||||
|
||||
// Accept previous color buffer based on depth and normal differences
|
||||
float ReprojectionDepthWeight = PixelDepthWeighting(HitSurfaceReprojectedLinear, HitSurfaceLinear, 35);
|
||||
float ReprojectionNormalWeight = dot(HitNormalReprojected, HitNormal);
|
||||
if (ReprojectionDepthWeight <= 0 || ReprojectionNormalWeight < 0.25f)
|
||||
if (HitDistance > _VoxelSize) return false; else return true;
|
||||
|
||||
// TODO: check if we can use higher LODs
|
||||
int RadianceLOD = 0; //lerp(0, 4, saturate(HitDistance / 5.0f));
|
||||
|
||||
// If the surface is hit from behind - skip reading color buffer and output zero
|
||||
if (dot(RayDirectionWS, HitNormal) < 0)
|
||||
{
|
||||
#ifdef HIT_SCREEN_SPACE_LIGHTING
|
||||
_HitCoord_Output[H_COORD(pixCoord.xy)] = floor(HitPositionNDC.xy * _ScreenSize.xy);
|
||||
#else
|
||||
// Calculate dimming value proprtional to the viewing angle
|
||||
float3 HitToCameraDir = -normalize(H_GET_ABSOLUTE_POSITION_WS(HitPositionWS) - _WorldSpaceCameraPos);
|
||||
float AngleDimming =(sqrt(sqrt(sqrt(dot(HitToCameraDir, HitNormal)))));
|
||||
|
||||
HitRadiance = H_LOAD(_ColorPyramid_History, ReprojectedHitNDC * _ScreenSize.xy); // HBUFFER_COLOR(ReprojectedHitNDC * _ScreenSize.xy);
|
||||
// #ifdef H_BIRP
|
||||
// HitRadiance = HBUFFER_COLOR(HitPositionNDC.xy * _ScreenSize.xy);
|
||||
// #endif
|
||||
|
||||
HitRadiance *= HGetInversePreviousExposureMultiplier;
|
||||
HitRadiance *= AngleDimming;
|
||||
#endif
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// ------------------------ SCREEN SPACE TRACING ------------------------
|
||||
[numthreads(8, 8, 1)]
|
||||
void ScreenSpaceTracing(uint3 pixCoord : SV_DispatchThreadID, uint groupIndex : SV_GroupIndex, uint groupID : SV_GroupID)
|
||||
{
|
||||
uint IndirectCoordOffsetVR = _ScreenSize.x * _ScreenSize.y * _IndexXR;
|
||||
uint RayCounterOffsetVR = 10 * _IndexXR;
|
||||
|
||||
uint RayIndex = groupID * 64 + groupIndex;
|
||||
if (RayIndex >= _RayCounter[0 + 4 + RayCounterOffsetVR])
|
||||
return;
|
||||
|
||||
pixCoord.xy = _TracingCoords[RayIndex + IndirectCoordOffsetVR];
|
||||
|
||||
// Load normal, depth and offset
|
||||
uint2 ProbeOffset;
|
||||
float4 NormalDepth = UnpackNormalDepth(asuint(H_LOAD(_ProbeNormalDepth, pixCoord.xy / _OctahedralSize).xy), ProbeOffset);
|
||||
|
||||
// Calculate probe coord
|
||||
int2 ProbeCoord = floor(pixCoord.xy / _OctahedralSize);
|
||||
float2 ProbeCoordNDC = (ProbeCoord.xy * float(_ProbeSize) + float2(ProbeOffset) + 0.5f) * _ScreenSize.zw ;
|
||||
|
||||
// Load center pixel data
|
||||
float3 RayDirectionWS = H_LOAD(_RayDirection, pixCoord.xy).xyz * 2 - 1;
|
||||
float3 PositionWS = H_COMPUTE_POSITION_WS(ProbeCoordNDC.xy, NormalDepth.w, H_MATRIX_I_VP);
|
||||
|
||||
// Calculate biased ray origin and ray directrion in NDC space
|
||||
float3 RayStartPositionNDC, RayDirectionNDC;
|
||||
GetRayOriginAndDirectionNDC(NormalDepth.w, 50, ProbeCoordNDC.xy, PositionWS, RayDirectionWS, NormalDepth.xyz, RayStartPositionNDC, RayDirectionNDC);
|
||||
|
||||
// Raymarch Hi-Z depth buffer
|
||||
float3 HitPositionNDC, LastAboveSurfacePositionNDC;
|
||||
bool HitFound = HierarchicalRaymarch(RayStartPositionNDC, RayDirectionNDC, 55, HitPositionNDC, LastAboveSurfacePositionNDC);
|
||||
|
||||
if (HitFound)
|
||||
{
|
||||
// Center hit coord
|
||||
HitPositionNDC.xy = floor(HitPositionNDC.xy * _ScreenSize.xy) * _ScreenSize.zw + (0.5 * _ScreenSize.zw);
|
||||
|
||||
// Calculate hit position in world space
|
||||
float3 HitPositionWS = HitPositionNDC.z > 1e-7 ? H_COMPUTE_POSITION_WS(HitPositionNDC.xy, HitPositionNDC.z, H_MATRIX_I_VP) : PositionWS;
|
||||
|
||||
// Evaluate occluder thickness
|
||||
float Thickness = AdaptiveThicknessSearch(HitPositionWS, RayDirectionWS);
|
||||
|
||||
// Check if ss ray's end is outside voxel bounds
|
||||
bool IsInsideVoxelBound = IsWorldPositionInBounds(H_GET_ABSOLUTE_POSITION_WS(HitPositionWS));
|
||||
|
||||
float3 HitRadiance = 0;
|
||||
bool HitIsValid = RadianceValidation(pixCoord.xy, HitPositionNDC, RayDirectionWS, HitPositionWS, PositionWS, Thickness, IsInsideVoxelBound, HitRadiance);
|
||||
|
||||
// Calculate hit distance in world space
|
||||
float HitDistanceWS = length(PositionWS - HitPositionWS);
|
||||
|
||||
// If ss ray's end is outside voxel bounds - do not trace ws ray from there, use fallback
|
||||
if (IsInsideVoxelBound == false)
|
||||
{
|
||||
// We use fallback only if ss ray failed
|
||||
if (!HitIsValid)
|
||||
{
|
||||
if (_EnableProbeVolumes)
|
||||
{
|
||||
if (APV_FALLBACK && (PROBE_VOLUMES_L1 || PROBE_VOLUMES_L2))
|
||||
{
|
||||
// Evaluate APV
|
||||
HitRadiance = EvaluateAPV(H_GET_ABSOLUTE_POSITION_WS(PositionWS), NormalDepth.xyz, H_GET_VIEW_DIRECTION_WS(PositionWS), 100);
|
||||
}
|
||||
}
|
||||
|
||||
//Use skybox as fallback and dim it with sky occlusion approximation
|
||||
else if (dot(float3(0,1,0), RayDirectionWS) > _SkyOcclusionCone + 0.05f)
|
||||
{
|
||||
float SkyOcclusion = EvaluateDirectionalShadowOcclusion(H_GET_ABSOLUTE_POSITION_WS(HitPositionWS));
|
||||
HitRadiance = EvaluateSky(RayDirectionWS) * SkyOcclusion;
|
||||
}
|
||||
}
|
||||
|
||||
HitIsValid = true;
|
||||
}
|
||||
|
||||
// Tracing toggles
|
||||
if (DISABLE_SS_TRACING) { HitIsValid = false; HitDistanceWS = 0; }
|
||||
if (DISABLE_WS_TRACING) { HitIsValid = true; }
|
||||
|
||||
// If the ray went outside the frame but travelled a short distance - it may be unreliable (important for probe ao)
|
||||
bool IsOutsideFrame = false;
|
||||
if ((any(HitPositionNDC.xy > 0.99) || any(HitPositionNDC.xy < 0.01)) && HitDistanceWS < _VoxelSize.x)
|
||||
IsOutsideFrame = true;
|
||||
|
||||
_HitRadiance_Output[H_COORD(pixCoord.xy)] = float4(HitRadiance, 1);
|
||||
_HitDistance_Output[H_COORD(pixCoord.xy)] = PackHitDistance(max(HitDistanceWS, 0.001f), IsOutsideFrame, !HitIsValid);
|
||||
|
||||
// _HitRadiance_Output [H_COORD(pixCoord.xy)] = float4(HitRadiance.xyz, 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ------------------------ SCREEN SPACE HIT LIGHTING EVALUATION ------------------------
|
||||
[numthreads(8, 8, 1)]
|
||||
void LightEvaluation(uint3 pixCoord : SV_DispatchThreadID, uint groupIndex : SV_GroupIndex, uint groupID : SV_GroupID)
|
||||
{
|
||||
uint IndirectCoordOffsetVR = _ScreenSize.x * _ScreenSize.y * _IndexXR;
|
||||
uint RayCounterOffsetVR = 10 * _IndexXR;
|
||||
|
||||
uint RayIndex = groupID * 64 + groupIndex;
|
||||
if (RayIndex >= _RayCounter[0 + 4 + RayCounterOffsetVR])
|
||||
return;
|
||||
|
||||
pixCoord.xy = _TracingCoords[RayIndex + IndirectCoordOffsetVR];
|
||||
|
||||
// Load hit coords
|
||||
uint2 HitCoord = asuint(H_LOAD(_HitCoord, pixCoord.xy).xy);
|
||||
float2 HitCoordNDC = (HitCoord + 0.5f) * _ScreenSize.zw;
|
||||
|
||||
// Hit validation in screen tracing shader failed, early out;
|
||||
if (HitCoord.x + HitCoord.y <= 0)
|
||||
return;
|
||||
|
||||
// Compute reprojected hit coords (for those buffers that come from previous frames)
|
||||
float2 HitCoordReprojectedNDC = HitCoordNDC - HBUFFER_MOTION_VECTOR(HitCoordNDC.xy * _ScreenSize.xy);
|
||||
uint2 HitCoordReprojected = HitCoordReprojectedNDC * _ScreenSize.xy;
|
||||
|
||||
// Load gbuffer data at hit point
|
||||
float3 HitNormal = HBUFFER_NORMAL_WS(HitCoord).xyz;
|
||||
float3 HitDiffuse = HBUFFER_DIFFUSE(HitCoord).xyz;
|
||||
|
||||
float3 HitColor = 0;
|
||||
|
||||
// If diffuse is 0 - use color buffer directly instead. TODO: consider metallics
|
||||
if (HitDiffuse.x + HitDiffuse.y + HitDiffuse.z == 0)
|
||||
{
|
||||
// Load color buffer
|
||||
HitColor = H_LOAD(_ColorPyramid_History, HitCoordReprojected).xyz * HGetInverseCurrentExposureMultiplier;
|
||||
|
||||
// Calculate additional gbuffer data at hit point
|
||||
float HitDepth = HBUFFER_DEPTH(HitCoord);
|
||||
float3 HitNormal = H_LOAD(g_GeometryNormal, HitCoord).xyz;
|
||||
float3 HitPosition = H_COMPUTE_POSITION_WS(HitCoordNDC.xy, HitDepth, H_MATRIX_I_VP);
|
||||
float3 HitToCameraDir = -normalize(H_GET_ABSOLUTE_POSITION_WS(HitPosition) - _WorldSpaceCameraPos);
|
||||
|
||||
// Calculate dimming value proprtional to the viewing angle
|
||||
HitColor *= sqrt(sqrt(sqrt(sqrt(dot(HitToCameraDir, HitNormal)))));
|
||||
|
||||
_HitRadiance_Output[H_COORD(pixCoord.xy)] = float4(HitColor, 1);
|
||||
return;
|
||||
}
|
||||
|
||||
// Add directional light contribution
|
||||
|
||||
// Add emissive contribution
|
||||
float3 Emissive = H_LOAD(_GBufferTexture3, HitCoord).xyz;
|
||||
if (any(Emissive.xz != AO_IN_GBUFFER3_TAG.xz))
|
||||
{
|
||||
HitColor = Emissive;
|
||||
bool Unused;
|
||||
uint HitColorPacked = PackVoxelColor(HitColor, true);
|
||||
HitColor = UnpackVoxelColor(HitColorPacked, Unused);
|
||||
|
||||
HitColor *= HGetInverseCurrentExposureMultiplier;
|
||||
}
|
||||
|
||||
// Add indirect lighting contribution (via reprojected screen space radiance cache)
|
||||
HitColor += H_LOAD(_Radiance_History, HitCoordReprojected).xyz * HGetInversePreviousExposureMultiplier * HitDiffuse;
|
||||
|
||||
_HitRadiance_Output[H_COORD(pixCoord.xy)] = float4(HitColor, 1);
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,14 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3bb2f3354bd27ba4796d0f9722c9c4fb
|
||||
ComputeShaderImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 379716
|
||||
packageName: 'HTrace: World Space Global Illumination URP | Beta'
|
||||
packageVersion: 0.9.6
|
||||
assetPath: Assets/HTraceWSGI/Resources/HTraceWSGI/_Shared/Computes/HTracingScreenSpace.compute
|
||||
uploadId: 925118
|
||||
251
Assets/External/HTraceWSGI/Resources/HTraceWSGI/_Shared/Computes/HTracingWorldSpace.compute
vendored
Normal file
251
Assets/External/HTraceWSGI/Resources/HTraceWSGI/_Shared/Computes/HTracingWorldSpace.compute
vendored
Normal file
@ -0,0 +1,251 @@
|
||||
#pragma kernel WorldSpaceTracing
|
||||
#pragma kernel LightEvaluation
|
||||
|
||||
#pragma multi_compile MULTIBOUNCE_OFF MULTIBOUNCE_CACHE MULTIBOUNCE_APV
|
||||
#pragma multi_compile _ EVALUATE_PUNCTUAL_LIGHTS
|
||||
#pragma multi_compile _ _ADDITIONAL_LIGHT_SHADOWS
|
||||
#pragma multi_compile _ PROBE_VOLUMES_L1 PROBE_VOLUMES_L2
|
||||
|
||||
#include "../Includes/Config.hlsl"
|
||||
|
||||
#include "../Includes/VoxelTraversal.hlsl"
|
||||
#include "../Includes/VoxelLightingEvaluation.hlsl"
|
||||
#include "../Includes/SpatialHash.hlsl"
|
||||
#include "../Includes/Reservoir.hlsl"
|
||||
#include "../Includes/ScreenProbesCommon.hlsl"
|
||||
#include "../Includes/FallbackAPV.hlsl"
|
||||
#pragma multi_compile _ _GBUFFER_NORMALS_OCT
|
||||
|
||||
H_TEXTURE3D(float3, _RadianceCacheFiltered);
|
||||
H_TEXTURE(_ProbeNormalDepth);
|
||||
H_TEXTURE(_VoxelPayload);
|
||||
H_TEXTURE(g_GeometryNormal);
|
||||
H_TEXTURE(_RayDirection);
|
||||
H_TEXTURE(_HitDistance);
|
||||
H_TEXTURE(_ProbeSeed);
|
||||
|
||||
H_RW_TEXTURE(uint2, _VoxelPayload_Output);
|
||||
H_RW_TEXTURE(uint, _VoxelBiasOffset_Output);
|
||||
H_RW_TEXTURE(float, _HitDistance_Output);
|
||||
H_RW_TEXTURE(float4, _HitRadiance_Output);
|
||||
|
||||
StructuredBuffer<float2> _PointDistribution;
|
||||
RWStructuredBuffer<uint2> _TracingCoords;
|
||||
RWStructuredBuffer<uint> _RayCounter;
|
||||
|
||||
float _RayLength;
|
||||
|
||||
int _IndexXR;
|
||||
int _HFrameIndex;
|
||||
int _FreezeCache;
|
||||
|
||||
// ------------------------ FUNCTIONS ------------------------
|
||||
|
||||
// ------------------------ WORLD SPACE TRACING -------------------------
|
||||
[numthreads(8, 8, 1)]
|
||||
void WorldSpaceTracing(uint3 pixCoord : SV_DispatchThreadID, uint groupIndex : SV_GroupIndex, uint groupID : SV_GroupID)
|
||||
{
|
||||
uint IndirectCoordOffsetVR = _ScreenSize.x * _ScreenSize.y * _IndexXR;
|
||||
uint RayCounterOffsetVR = 10 * _IndexXR;
|
||||
|
||||
uint RayIndex = groupID * 64 + groupIndex;
|
||||
if (RayIndex >= _RayCounter[0 + 4 + RayCounterOffsetVR])
|
||||
return;
|
||||
|
||||
pixCoord.xy = _TracingCoords[RayIndex + IndirectCoordOffsetVR];
|
||||
|
||||
// Calculate probe coords
|
||||
uint2 ProbeOffset;
|
||||
int2 ProbeCoord = floor(pixCoord.xy / _OctahedralSize);
|
||||
int2 CellCoord = pixCoord.xy - floor(pixCoord.xy / _OctahedralSize) * _OctahedralSize;
|
||||
float4 NormalDepth = UnpackNormalDepth(asuint(H_LOAD(_ProbeNormalDepth, ProbeCoord).xy), ProbeOffset);
|
||||
|
||||
float2 ProbeCoordNDC = (ProbeCoord.xy * float(_ProbeSize) + float2(ProbeOffset) + 0.5f) * _ScreenSize.zw ;
|
||||
|
||||
// Load tracing data
|
||||
float Depth = NormalDepth.w;
|
||||
float3 RayDirectionWS = H_LOAD(_RayDirection, pixCoord.xy).xyz * 2 - 1;
|
||||
float3 PositionWS = H_COMPUTE_POSITION_WS(ProbeCoordNDC, Depth, H_MATRIX_I_VP);
|
||||
|
||||
// Start world space tracing where the screen space part finished
|
||||
bool Unused;
|
||||
uint HitDistancePacked = asuint(H_LOAD(_HitDistance, pixCoord.xy).x);
|
||||
float HitDistanceWS = abs(UnpackHitDistance(HitDistancePacked, Unused, Unused));
|
||||
float3 RayOriginWS = PositionWS + HitDistanceWS * RayDirectionWS;
|
||||
|
||||
// If the ray travelled less than half a voxel - reset it to origin
|
||||
if (HitDistanceWS <= _VoxelSize * 0.5f)
|
||||
{
|
||||
RayOriginWS = PositionWS;
|
||||
HitDistanceWS = 0;
|
||||
}
|
||||
|
||||
// Apply voxel bias
|
||||
VoxelBias(pixCoord.xy, _PointDistribution, Depth, HitDistanceWS, NormalDepth.xyz, RayDirectionWS, RayOriginWS);
|
||||
|
||||
// Initialize voxel ray payload
|
||||
VoxelPayload Payload;
|
||||
InitializePayload(Payload);
|
||||
|
||||
// Calculate ray distance
|
||||
float MaxRayDistance = MaxVoxelRayDistance(H_GET_ABSOLUTE_POSITION_WS(RayOriginWS), RayDirectionWS.xyz);
|
||||
float RayDistance = _RayLength == 0 ? MaxRayDistance : _RayLength;
|
||||
|
||||
// Trace into Voxels
|
||||
bool HitFound = TraceVoxelsDiffuse(H_GET_ABSOLUTE_POSITION_WS(RayOriginWS), RayDirectionWS.xyz, RayDistance, 128, Payload);
|
||||
|
||||
if (!HitFound)
|
||||
Payload.HitDistance = 100; // TODO: check this
|
||||
|
||||
// Total distance travelled by the ray in screen-space + world-space
|
||||
float TotalDistance = HitDistanceWS + Payload.HitDistance;
|
||||
|
||||
// Write total (screen-space + world-space) hit distance
|
||||
_HitDistance_Output[H_COORD(pixCoord.xy)] = max(TotalDistance, 0.001f);
|
||||
|
||||
// Pack voxel payload
|
||||
float3 VoxelHitOffset = VoxelCoordToAbsoluteWorldPosition(Payload.HitCoord) - Payload.HitPosition;
|
||||
_VoxelPayload_Output[H_COORD(pixCoord.xy)] = PackVoxelHitPayload(VoxelHitOffset, TotalDistance, Payload.HitNormal, Payload.HitCoord, HitFound);
|
||||
|
||||
// Add skylight if we missed
|
||||
if (!HitFound && dot(float3(0,1,0), RayDirectionWS) > _SkyOcclusionCone + 0.05f)
|
||||
{
|
||||
// Evaluate sky occlusion
|
||||
float SkyOcclusion = HitFound ? 1 : EvaluateDirectionalShadowOcclusion(H_GET_ABSOLUTE_POSITION_WS(RayOriginWS) + MaxRayDistance * RayDirectionWS);
|
||||
Payload.HitColor += EvaluateSky(RayDirectionWS) * SkyOcclusion;
|
||||
|
||||
// Write evaluated hit radiance
|
||||
_HitRadiance_Output[H_COORD(pixCoord.xy)] = float4(Payload.HitColor.xyz, 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ---------------------- WORLD SPACE HIT LIGHTING EVALUATION -----------------------
|
||||
[numthreads(8, 8, 1)]
|
||||
void LightEvaluation(uint3 pixCoord : SV_DispatchThreadID, uint groupIndex : SV_GroupIndex, uint groupID : SV_GroupID)
|
||||
{
|
||||
uint IndirectCoordOffsetVR = _ScreenSize.x * _ScreenSize.y * _IndexXR;
|
||||
uint RayCounterOffsetVR = 10 * _IndexXR;
|
||||
|
||||
uint RayIndex = groupID * 64 + groupIndex;
|
||||
if (RayIndex >= _RayCounter[0 + 4 + RayCounterOffsetVR])
|
||||
return;
|
||||
|
||||
pixCoord.xy = _TracingCoords[RayIndex + IndirectCoordOffsetVR];
|
||||
|
||||
// Initialize voxel ray payload
|
||||
VoxelPayload Payload;
|
||||
InitializePayload(Payload);
|
||||
|
||||
// Read packed voxel payload
|
||||
uint2 PayloadPacked = asuint(H_LOAD(_VoxelPayload, pixCoord.xy).xy);
|
||||
|
||||
// Unpack voxel payload
|
||||
float3 HitOffset; float TotalRayDistance;
|
||||
bool HitFound = UnpackVoxelHitPayload(PayloadPacked, TotalRayDistance, HitOffset, Payload.HitNormal, Payload.HitCoord);
|
||||
|
||||
// Early-out on the miss with APV evaluation (if available)
|
||||
if (!HitFound)
|
||||
{
|
||||
if (_EnableProbeVolumes)
|
||||
{
|
||||
if (APV_FALLBACK && (PROBE_VOLUMES_L1 || PROBE_VOLUMES_L2))
|
||||
{
|
||||
// Prepare Normal, Depth and PositionWS for APV evaluation
|
||||
uint2 ProbeOffset;
|
||||
float4 NormalDepth = UnpackNormalDepth(asuint(H_LOAD(_ProbeNormalDepth, pixCoord.xy / _OctahedralSize).xy), ProbeOffset);
|
||||
float2 ProbeCoordNDC = (floor(pixCoord.xy / _OctahedralSize) * float(_ProbeSize) + float2(ProbeOffset) + 0.5f) * _ScreenSize.zw ;
|
||||
float3 PositionWS = H_COMPUTE_POSITION_WS(ProbeCoordNDC.xy, NormalDepth.w, H_MATRIX_I_VP);
|
||||
|
||||
// Evaluate APV
|
||||
float3 HitRadiance = EvaluateAPV(H_GET_ABSOLUTE_POSITION_WS(PositionWS), NormalDepth.xyz, H_GET_VIEW_DIRECTION_WS(PositionWS), 100);
|
||||
|
||||
// Output hit radiance and early out
|
||||
_HitRadiance_Output[H_COORD(pixCoord.xy)] = float4(HitRadiance, 1);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Calculate hit position
|
||||
Payload.HitPosition = VoxelCoordToAbsoluteWorldPosition(Payload.HitCoord) + HitOffset;
|
||||
|
||||
// Read & spawn hash entries if it is a hit
|
||||
if (HitFound)
|
||||
{
|
||||
// Evauluate lighting on hit point
|
||||
EvaluateHitLighting(Payload);
|
||||
|
||||
#ifdef MULTIBOUNCE_CACHE
|
||||
{
|
||||
uint3 CacheCoord = ComputeRadianceCacheCoord(Payload.HitCoord);
|
||||
uint HashKey = PackHashKey(CacheCoord, Payload.HitNormal);
|
||||
|
||||
bool IsEmpty;
|
||||
uint HashRank = 2;
|
||||
uint HashProbingIndex, HashLowestRankIndex;
|
||||
uint HashIndex = HashGetIndex(CacheCoord, PackVoxelNormalIndex(Payload.HitNormal));
|
||||
bool HashFound = HashFindAny(HashIndex, HashKey, HashRank, HashLowestRankIndex, HashProbingIndex, IsEmpty);
|
||||
|
||||
int3 VoxelCoordAbsolute = VoxelCoordToAbsoluteVoxelCoord(Payload.HitCoord);
|
||||
float3 VoxelHitOffset = (float3(VoxelCoordAbsolute) * _VoxelSize) - (Payload.HitPosition) ;
|
||||
|
||||
if (HashFound) // If a valid entry was found we reset the decay counter to max value and use cache (it's main purpose)
|
||||
{
|
||||
uint3 HitCachePacked = _HashBuffer_Radiance[HashProbingIndex].xyz;
|
||||
|
||||
float3 RadianceFullRange = UnpackCacheRadianceFull(HitCachePacked.xyz);
|
||||
float3 RadianceNearRange = UnpackCacheRadianceNear(HitCachePacked.xyz);
|
||||
|
||||
// Choose far / near field cache based on the travelled ray distance
|
||||
Payload.HitCache = TotalRayDistance > _VoxelSize.x * 4 ? RadianceFullRange : min(RadianceNearRange, RadianceFullRange);
|
||||
|
||||
// Progressively dim cache at a distance smaller than a voxel size
|
||||
Payload.HitCache *= lerp(0, 1, saturate(TotalRayDistance / 1 / _VoxelSize));
|
||||
|
||||
// Clip cache
|
||||
Payload.HitCache *= HGetCurrentExposureMultiplier;
|
||||
Payload.HitCache = HClipRadiance(Payload.HitCache, 10);
|
||||
Payload.HitCache *= HGetInverseCurrentExposureMultiplier;
|
||||
|
||||
// Add cache to hit radiance
|
||||
Payload.HitColor += Payload.HitCache * Payload.HitDiffuse;
|
||||
|
||||
// Reset decay counter back to 255 as we hit this cache cell - it is useful
|
||||
_HashBuffer_Counter[HashProbingIndex] = 255;
|
||||
}
|
||||
else if (IsEmpty && !FREEZE_CACHE) // If we didn't find a valid entry but found an empty cell, we spawn a new entry
|
||||
{
|
||||
_HashBuffer_Position[HashProbingIndex] = uint4(asuint(VoxelCoordAbsolute.xyz), PackHitOffset(VoxelHitOffset));
|
||||
_HashBuffer_Radiance[HashProbingIndex] = 0;
|
||||
_HashBuffer_Counter[HashProbingIndex] = 255;
|
||||
_HashBuffer_Key[HashProbingIndex] = HashKey | 0x2;
|
||||
}
|
||||
else if (HashRank != 2 && !FREEZE_CACHE) // If neither a valid nor an empty entry was found, we recycle the lowest ranked cell to spawn a new entry
|
||||
{
|
||||
_HashBuffer_Position[HashLowestRankIndex] = uint4(asuint(VoxelCoordAbsolute.xyz), PackHitOffset(VoxelHitOffset));
|
||||
_HashBuffer_Radiance[HashLowestRankIndex] = 0;
|
||||
_HashBuffer_Counter[HashLowestRankIndex] = 255;
|
||||
_HashBuffer_Key[HashLowestRankIndex] = HashKey | 0x2;
|
||||
}
|
||||
}
|
||||
#else
|
||||
if (MULTIBOUNCE_APV)
|
||||
{
|
||||
if (_EnableProbeVolumes)
|
||||
{
|
||||
if (APV_FALLBACK && (PROBE_VOLUMES_L1 || PROBE_VOLUMES_L2))
|
||||
{
|
||||
float3 Unused = 0;
|
||||
Payload.HitCache = EvaluateAPV(Payload.HitPosition, Payload.HitNormal, H_GET_VIEW_DIRECTION_WS(Payload.HitPosition), 100);
|
||||
Payload.HitCache *= smoothstep(0.15f, 1.0f, saturate(TotalRayDistance / 4.0f / _VoxelSize));
|
||||
Payload.HitColor += Payload.HitCache * Payload.HitDiffuse;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
// Write evaluated hit radiance
|
||||
_HitRadiance_Output[H_COORD(pixCoord.xy)] = float4(Payload.HitColor.xyz, 1);
|
||||
}
|
||||
14
Assets/External/HTraceWSGI/Resources/HTraceWSGI/_Shared/Computes/HTracingWorldSpace.compute.meta
vendored
Normal file
14
Assets/External/HTraceWSGI/Resources/HTraceWSGI/_Shared/Computes/HTracingWorldSpace.compute.meta
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
fileFormatVersion: 2
|
||||
guid: af9d6971513146b4ca1294937cf1b8f0
|
||||
ComputeShaderImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 379716
|
||||
packageName: 'HTrace: World Space Global Illumination URP | Beta'
|
||||
packageVersion: 0.9.6
|
||||
assetPath: Assets/HTraceWSGI/Resources/HTraceWSGI/_Shared/Computes/HTracingWorldSpace.compute
|
||||
uploadId: 925118
|
||||
19
Assets/External/HTraceWSGI/Resources/HTraceWSGI/_Shared/Computes/Shadowmap.compute
vendored
Normal file
19
Assets/External/HTraceWSGI/Resources/HTraceWSGI/_Shared/Computes/Shadowmap.compute
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
#pragma kernel ShadowmapMerge
|
||||
|
||||
#include "../Headers/HMain.hlsl"
|
||||
|
||||
Texture2D _Shadowmap;
|
||||
RWTexture2D<float> _Shadowmap_Output;
|
||||
|
||||
float2 _OctantShadowOffset;
|
||||
|
||||
[numthreads(8, 8, 1)]
|
||||
void ShadowmapMerge(uint3 pixCoord : SV_DispatchThreadID, uint3 groupThreadID : SV_GroupThreadID)
|
||||
{
|
||||
int2 ShadowmapSize = int2(2048, 2048);
|
||||
int2 WriteCoord = pixCoord.xy + _OctantShadowOffset.xy;
|
||||
|
||||
float ShadowmapOctant = _Shadowmap.Load(int3(pixCoord.xy, 0)).x; /// LOAD_TEXTURE2D(_Shadowmap, pixCoord.xy).x;
|
||||
|
||||
_Shadowmap_Output[WriteCoord] = ShadowmapOctant;
|
||||
}
|
||||
14
Assets/External/HTraceWSGI/Resources/HTraceWSGI/_Shared/Computes/Shadowmap.compute.meta
vendored
Normal file
14
Assets/External/HTraceWSGI/Resources/HTraceWSGI/_Shared/Computes/Shadowmap.compute.meta
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9c03eda2e389436448aa6be833b4c9cf
|
||||
ComputeShaderImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 379716
|
||||
packageName: 'HTrace: World Space Global Illumination URP | Beta'
|
||||
packageVersion: 0.9.6
|
||||
assetPath: Assets/HTraceWSGI/Resources/HTraceWSGI/_Shared/Computes/Shadowmap.compute
|
||||
uploadId: 925118
|
||||
111
Assets/External/HTraceWSGI/Resources/HTraceWSGI/_Shared/Computes/VoxelVisualization.compute
vendored
Normal file
111
Assets/External/HTraceWSGI/Resources/HTraceWSGI/_Shared/Computes/VoxelVisualization.compute
vendored
Normal file
@ -0,0 +1,111 @@
|
||||
#pragma kernel VisualizeVoxels
|
||||
#pragma once
|
||||
|
||||
|
||||
#include "../Includes/Config.hlsl"
|
||||
|
||||
#include "../Includes/VoxelTraversal.hlsl"
|
||||
#include "../Includes/VoxelLightingEvaluation.hlsl"
|
||||
#include "../Includes/SpatialHash.hlsl"
|
||||
|
||||
#pragma multi_compile_local _ VISUALIZE_LIGHTING
|
||||
#pragma multi_compile _ EVALUATE_PUNCTUAL_LIGHTS
|
||||
#pragma multi_compile _ _ADDITIONAL_LIGHT_SHADOWS
|
||||
#pragma multi_compile _ _GBUFFER_NORMALS_OCT
|
||||
#pragma multi_compile _ PROBE_VOLUMES_L1 PROBE_VOLUMES_L2
|
||||
|
||||
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
||||
#include "../Includes/FallbackAPV.hlsl"
|
||||
|
||||
// Input Buffers
|
||||
H_TEXTURE(_DebugRayDirection);
|
||||
|
||||
// Output Buffers
|
||||
H_RW_TEXTURE(float3, _Visualization_Output);
|
||||
|
||||
int _MultibounceMode;
|
||||
|
||||
[numthreads(8, 8, 1)]
|
||||
void VisualizeVoxels(uint3 pixCoord : SV_DispatchThreadID)
|
||||
{
|
||||
|
||||
// We have deleted "_RTHandleScale" here because when switching from Game to Scene view we got a strecthed and distorted debug image.
|
||||
//float3 RayDirection = H_SAMPLE_LOD(_DebugRayDirection, H_SAMPLER_LINEAR_CLAMP, (pixCoord.xy + 0.5) * _ScreenSize.zw, 0).xyz;
|
||||
|
||||
float2 pixCoordNDC = (pixCoord.xy + 0.5) * _ScreenSize.zw;
|
||||
float4 PositionVS = mul(UNITY_MATRIX_I_P, float4(pixCoordNDC * 2.0 - 1.0, 1.0, 1.0));
|
||||
float3 DirectionVS = normalize(float3(PositionVS.x, -PositionVS.y, PositionVS.z));
|
||||
float3 RayDirection = normalize(mul((float3x3)H_MATRIX_I_V, DirectionVS));
|
||||
|
||||
float3 RayOrigin =
|
||||
GetCameraPositionWS();
|
||||
|
||||
|
||||
// TODO: do we need this?
|
||||
float Depth = HBUFFER_DEPTH(pixCoord.xy);
|
||||
if (Depth >= UNITY_RAW_FAR_CLIP_VALUE)
|
||||
_Visualization_Output[H_COORD(pixCoord.xy)] = 0;
|
||||
|
||||
// Initialize voxel ray payload
|
||||
VoxelPayload Payload;
|
||||
InitializePayload(Payload);
|
||||
|
||||
float DepthLinear = H_LINEAR_01_DEPTH(Depth);
|
||||
DepthLinear *= length(RayDirection);
|
||||
|
||||
DepthLinear = Depth <= UNITY_RAW_FAR_CLIP_VALUE ? _VoxelBounds.x : DepthLinear;
|
||||
RayDirection = normalize(RayDirection);
|
||||
|
||||
// Trace into voxels
|
||||
bool HitFound = TraceVoxelsDiffuse(RayOrigin, RayDirection, MaxVoxelRayDistance(RayOrigin, RayDirection), 1000, Payload);
|
||||
|
||||
if (HitFound)
|
||||
{
|
||||
EvaluateHitLighting(Payload);
|
||||
|
||||
#ifdef VISUALIZE_LIGHTING
|
||||
if (_MultibounceMode == 1)
|
||||
{
|
||||
uint HashIndex = HashGetIndex(ComputeRadianceCacheCoord(Payload.HitCoord), PackVoxelNormalIndex(Payload.HitNormal));
|
||||
|
||||
uint HashIndexFound;
|
||||
uint HashKey = PackHashKey(ComputeRadianceCacheCoord(Payload.HitCoord), Payload.HitNormal);
|
||||
bool HashFound = HashFindValid(HashIndex, HashKey, HashIndexFound);
|
||||
|
||||
if (HashFound)
|
||||
{
|
||||
float3 RadianceCache = UnpackCacheRadianceFull(_HashBuffer_Radiance[HashIndexFound].xyz);
|
||||
Payload.HitCache = RadianceCache;
|
||||
Payload.HitCache *= HGetCurrentExposureMultiplier;
|
||||
}
|
||||
}
|
||||
|
||||
else if (_MultibounceMode == 2)
|
||||
{
|
||||
if (_EnableProbeVolumes)
|
||||
{
|
||||
if (APV_FALLBACK && (PROBE_VOLUMES_L1 || PROBE_VOLUMES_L2))
|
||||
{
|
||||
Payload.HitCache = EvaluateAPV(Payload.HitPosition, Payload.HitNormal.xyz, 0, 100);
|
||||
Payload.HitCache *= HGetCurrentExposureMultiplier;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
float3 payload = Payload.HitColor;
|
||||
|
||||
payload *= HGetCurrentExposureMultiplier;
|
||||
|
||||
_Visualization_Output[H_COORD(pixCoord.xy)] = payload + Payload.HitCache * Payload.HitDiffuse;
|
||||
#else
|
||||
_Visualization_Output[H_COORD(pixCoord.xy)] = Payload.HitDiffuse;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
_Visualization_Output[H_COORD(pixCoord.xy)] = EvaluateSky(RayDirection) * HGetCurrentExposureMultiplier;
|
||||
}
|
||||
|
||||
}
|
||||
14
Assets/External/HTraceWSGI/Resources/HTraceWSGI/_Shared/Computes/VoxelVisualization.compute.meta
vendored
Normal file
14
Assets/External/HTraceWSGI/Resources/HTraceWSGI/_Shared/Computes/VoxelVisualization.compute.meta
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d33f390ebf3831f479f55f9b3b91876c
|
||||
ComputeShaderImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 379716
|
||||
packageName: 'HTrace: World Space Global Illumination URP | Beta'
|
||||
packageVersion: 0.9.6
|
||||
assetPath: Assets/HTraceWSGI/Resources/HTraceWSGI/_Shared/Computes/VoxelVisualization.compute
|
||||
uploadId: 925118
|
||||
193
Assets/External/HTraceWSGI/Resources/HTraceWSGI/_Shared/Computes/Voxelization.compute
vendored
Normal file
193
Assets/External/HTraceWSGI/Resources/HTraceWSGI/_Shared/Computes/Voxelization.compute
vendored
Normal file
@ -0,0 +1,193 @@
|
||||
#pragma kernel GeneratePositionPyramid1
|
||||
#pragma kernel GeneratePositionPyramid2
|
||||
#pragma kernel ClearPositionPyramid
|
||||
#pragma kernel CopyData
|
||||
|
||||
#pragma enable_d3d11_debug_symbols
|
||||
#pragma warning (disable : 3206)
|
||||
|
||||
#include "../Includes/VoxelTraversal.hlsl"
|
||||
|
||||
H_TEXTURE3D(uint, _VoxelPositionIntermediate);
|
||||
|
||||
H_RW_TEXTURE3D(uint, _VoxelData_A);
|
||||
H_RW_TEXTURE3D(uint, _VoxelData_B);
|
||||
H_RW_TEXTURE3D(uint, _VoxelPositionPyramid_MIP0);
|
||||
H_RW_TEXTURE3D(uint, _VoxelPositionPyramid_MIP1);
|
||||
H_RW_TEXTURE3D(uint, _VoxelPositionPyramid_MIP2);
|
||||
H_RW_TEXTURE3D(uint, _VoxelPositionPyramid_MIP3);
|
||||
H_RW_TEXTURE3D(uint, _VoxelPositionPyramid_MIP4);
|
||||
H_RW_TEXTURE3D(uint, _VoxelPositionPyramid_MIP5);
|
||||
H_RW_TEXTURE3D(uint, _VoxelPositionIntermediate_Output);
|
||||
H_RW_TEXTURE3D(uint, _ClearTexture);
|
||||
|
||||
float3 _VoxelOffset;
|
||||
float3 _OctantCopyOffset;
|
||||
|
||||
groupshared bool PositionLDS[4][4][4];
|
||||
|
||||
// ------------------------ SCROLLING DATA COPY -------------------------
|
||||
[numthreads(4,4,4)]
|
||||
void CopyData(uint3 pixCoord : SV_DispatchThreadID, uint3 groupThreadID : SV_GroupThreadID)
|
||||
{
|
||||
pixCoord.xyz *= uint3(2,2,2);
|
||||
|
||||
int3 CopyCoord = pixCoord.xyz + _OctantCopyOffset.xyz;
|
||||
int3 CameraDelta = round((_VoxelOffset) * _VoxelPerMeter);
|
||||
|
||||
int3 TapOffsets[8] = {int3(0,0,0), int3(0,0,1), int3(0,1,0), int3(1,0,0), int3(0,1,1), int3(1,0,1), int3(1,1,0), int3(1,1,1)};
|
||||
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
int3 TapCoord = CopyCoord + TapOffsets[i];
|
||||
|
||||
uint VoxelDataB = _VoxelData_B[TapCoord + CameraDelta];
|
||||
bool IsDynamic = (VoxelDataB >> 23) & 0x1; // Dynamic bit flat (0 - dynamic, 1 - static)
|
||||
|
||||
if (VoxelDataB * IsDynamic != 0u)
|
||||
_VoxelData_A[TapCoord] = VoxelDataB; // Copy and clear dynamic voxels
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------ MIP LEVEL 0-2 GENERATION -------------------------
|
||||
[numthreads(4,4,4)]
|
||||
void GeneratePositionPyramid1(uint3 pixCoord : SV_DispatchThreadID, uint3 groupThreadID : SV_GroupThreadID)
|
||||
{
|
||||
pixCoord.xyz *= uint3(2,2,2);
|
||||
|
||||
int3 TapOffsets[8] = {int3(0,0,0), int3(0,0,1), int3(0,1,0), int3(1,0,0), int3(0,1,1), int3(1,0,1), int3(1,1,0), int3(1,1,1)};
|
||||
|
||||
uint VoxelPositionMIP1 = 0;
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
int3 TapCoord = pixCoord.xyz + TapOffsets[i];
|
||||
uint VoxelPosition = asuint(H_LOAD3D(_VoxelData, TapCoord)) & 0xFF000000;
|
||||
VoxelPosition = VoxelPosition >> 24;
|
||||
|
||||
if (VoxelPosition != 0u)
|
||||
_VoxelPositionPyramid_MIP0[TapCoord] = VoxelPosition;
|
||||
|
||||
VoxelPosition = VoxelPosition > 0 ? 1 : 0;
|
||||
VoxelPositionMIP1 += VoxelPosition;
|
||||
}
|
||||
|
||||
// Kills voxels that are less than half filled (4 out of 8 bricks) by rounding ?
|
||||
// VoxelPosition_MIP1 /= 8.0f;
|
||||
|
||||
PositionLDS[groupThreadID.x][groupThreadID.y][groupThreadID.z] = VoxelPositionMIP1;
|
||||
GroupMemoryBarrierWithGroupSync();
|
||||
|
||||
if (VoxelPositionMIP1 > 0)
|
||||
_VoxelPositionPyramid_MIP1[pixCoord / int3(2, 2, 2)] = VoxelPositionMIP1;
|
||||
|
||||
[branch]
|
||||
if (all((groupThreadID.xyz % int3(2, 2, 2)) == 0))
|
||||
{
|
||||
uint VoxelPositionMIP2 = 0;
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
int3 TapCoord = groupThreadID.xyz + TapOffsets[i];
|
||||
|
||||
uint VoxelPosition = PositionLDS[TapCoord.x][TapCoord.y][TapCoord.z];
|
||||
VoxelPositionMIP2 += VoxelPosition;
|
||||
}
|
||||
|
||||
if (VoxelPositionMIP2 > 0)
|
||||
{
|
||||
_VoxelPositionPyramid_MIP2[pixCoord / int3(4, 4, 4)] = VoxelPositionMIP2;
|
||||
_VoxelPositionIntermediate_Output[pixCoord / int3(4, 4, 4)] = VoxelPositionMIP2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------ MIP LEVEL 3-5 GENERATION -------------------------
|
||||
[numthreads(4,4,4)]
|
||||
void GeneratePositionPyramid2(uint3 pixCoord : SV_DispatchThreadID, uint3 groupThreadID : SV_GroupThreadID)
|
||||
{
|
||||
pixCoord.xyz *= uint3(2,2,2);
|
||||
|
||||
int3 TapOffsets[8] = {int3(0,0,0), int3(0,0,1), int3(0,1,0), int3(1,0,0), int3(0,1,1), int3(1,0,1), int3(1,1,0), int3(1,1,1)};
|
||||
|
||||
uint VoxelPositionMIP3 = 0;
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
int3 TapCoord = pixCoord.xyz + TapOffsets[i];
|
||||
uint VoxelPosition = H_LOAD3D(_VoxelPositionIntermediate, TapCoord); // & 0x000000FF;
|
||||
|
||||
if (VoxelPosition > 0)
|
||||
_VoxelPositionPyramid_MIP3[pixCoord / int3(2, 2, 2)] = VoxelPosition;
|
||||
|
||||
VoxelPositionMIP3 += VoxelPosition;
|
||||
}
|
||||
|
||||
if (VoxelPositionMIP3 > 0)
|
||||
_VoxelPositionPyramid_MIP3[pixCoord / int3(2, 2, 2)] = VoxelPositionMIP3;
|
||||
|
||||
PositionLDS[groupThreadID.x][groupThreadID.y][groupThreadID.z] = VoxelPositionMIP3;
|
||||
GroupMemoryBarrierWithGroupSync();
|
||||
|
||||
[branch]
|
||||
if (all((groupThreadID.xyz % int3(2, 2, 2)) == 0))
|
||||
{
|
||||
uint VoxelPositionMIP4 = 0;
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
int3 TapCoord = groupThreadID.xyz + TapOffsets[i];
|
||||
VoxelPositionMIP4 += PositionLDS[TapCoord.x][TapCoord.y][TapCoord.z];
|
||||
}
|
||||
|
||||
if (VoxelPositionMIP4 > 0)
|
||||
_VoxelPositionPyramid_MIP4[pixCoord / int3(4, 4, 4)] = VoxelPositionMIP4;
|
||||
|
||||
PositionLDS[groupThreadID.x / 2][groupThreadID.y / 2][groupThreadID.z / 2] = VoxelPositionMIP4;
|
||||
}
|
||||
|
||||
GroupMemoryBarrierWithGroupSync();
|
||||
|
||||
[branch]
|
||||
if (all((groupThreadID.xyz % int3(4, 4, 4)) == 0))
|
||||
{
|
||||
uint VoxelPositionMIP5 = 0;
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
int3 TapCoord = groupThreadID.xyz + TapOffsets[i];
|
||||
VoxelPositionMIP5 += PositionLDS[TapCoord.x][TapCoord.y][TapCoord.z];
|
||||
}
|
||||
|
||||
if (VoxelPositionMIP5 > 0)
|
||||
_VoxelPositionPyramid_MIP5[pixCoord / int3(8, 8, 8)] = VoxelPositionMIP5;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ------------------------ MIP CLEAR -------------------------
|
||||
[numthreads(4,4,4)]
|
||||
void ClearPositionPyramid(uint3 pixCoord : SV_DispatchThreadID, uint3 groupThreadID : SV_GroupThreadID)
|
||||
{
|
||||
_VoxelPositionPyramid_MIP1[pixCoord.xyz] = 0;
|
||||
|
||||
[branch]
|
||||
if (all((pixCoord.xyz % int3(2, 2, 2)) == 0))
|
||||
{
|
||||
_VoxelPositionPyramid_MIP2[pixCoord.xyz / 2] = 0;
|
||||
}
|
||||
|
||||
[branch]
|
||||
if (all((pixCoord.xyz % int3(4, 4, 4)) == 0))
|
||||
{
|
||||
_VoxelPositionPyramid_MIP3[pixCoord.xyz / 4] = 0;
|
||||
}
|
||||
|
||||
[branch]
|
||||
if (all((pixCoord.xyz % int3(8, 8, 8)) == 0))
|
||||
{
|
||||
_VoxelPositionPyramid_MIP4[pixCoord.xyz / 8] = 0;
|
||||
}
|
||||
|
||||
[branch]
|
||||
if (all((pixCoord.xyz % int3(16, 16, 16)) == 0))
|
||||
{
|
||||
_VoxelPositionPyramid_MIP5[pixCoord.xyz / 16] = 0;
|
||||
}
|
||||
|
||||
}
|
||||
14
Assets/External/HTraceWSGI/Resources/HTraceWSGI/_Shared/Computes/Voxelization.compute.meta
vendored
Normal file
14
Assets/External/HTraceWSGI/Resources/HTraceWSGI/_Shared/Computes/Voxelization.compute.meta
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3635833b8a6926147b07a731e8e627a9
|
||||
ComputeShaderImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 379716
|
||||
packageName: 'HTrace: World Space Global Illumination URP | Beta'
|
||||
packageVersion: 0.9.6
|
||||
assetPath: Assets/HTraceWSGI/Resources/HTraceWSGI/_Shared/Computes/Voxelization.compute
|
||||
uploadId: 925118
|
||||
3
Assets/External/HTraceWSGI/Resources/HTraceWSGI/_Shared/Headers.meta
vendored
Normal file
3
Assets/External/HTraceWSGI/Resources/HTraceWSGI/_Shared/Headers.meta
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 697435c2517ac764da60b59f984553e9
|
||||
timeCreated: 1659620468
|
||||
3
Assets/External/HTraceWSGI/Resources/HTraceWSGI/_Shared/Headers/Core Files.meta
vendored
Normal file
3
Assets/External/HTraceWSGI/Resources/HTraceWSGI/_Shared/Headers/Core Files.meta
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9ec9ca9ef5c9e8649a6466cb9b34ff5b
|
||||
timeCreated: 1747747307
|
||||
44
Assets/External/HTraceWSGI/Resources/HTraceWSGI/_Shared/Headers/Core Files/CommonCore.hlsl
vendored
Normal file
44
Assets/External/HTraceWSGI/Resources/HTraceWSGI/_Shared/Headers/Core Files/CommonCore.hlsl
vendored
Normal file
@ -0,0 +1,44 @@
|
||||
//Common.hlsl in Core RP
|
||||
#pragma once
|
||||
|
||||
|
||||
// Intrinsic isnan can't be used because it require /Gic to be enabled on fxc that we can't do. So use AnyIsNan instead
|
||||
bool IsNaN(float x)
|
||||
{
|
||||
return (asuint(x) & 0x7FFFFFFF) > 0x7F800000;
|
||||
}
|
||||
|
||||
bool AnyIsNaN(float2 v)
|
||||
{
|
||||
return (IsNaN(v.x) || IsNaN(v.y));
|
||||
}
|
||||
|
||||
bool AnyIsNaN(float3 v)
|
||||
{
|
||||
return (IsNaN(v.x) || IsNaN(v.y) || IsNaN(v.z));
|
||||
}
|
||||
|
||||
bool AnyIsNaN(float4 v)
|
||||
{
|
||||
return (IsNaN(v.x) || IsNaN(v.y) || IsNaN(v.z) || IsNaN(v.w));
|
||||
}
|
||||
|
||||
bool IsInf(float x)
|
||||
{
|
||||
return (asuint(x) & 0x7FFFFFFF) == 0x7F800000;
|
||||
}
|
||||
|
||||
bool AnyIsInf(float2 v)
|
||||
{
|
||||
return (IsInf(v.x) || IsInf(v.y));
|
||||
}
|
||||
|
||||
bool AnyIsInf(float3 v)
|
||||
{
|
||||
return (IsInf(v.x) || IsInf(v.y) || IsInf(v.z));
|
||||
}
|
||||
|
||||
bool AnyIsInf(float4 v)
|
||||
{
|
||||
return (IsInf(v.x) || IsInf(v.y) || IsInf(v.z) || IsInf(v.w));
|
||||
}
|
||||
10
Assets/External/HTraceWSGI/Resources/HTraceWSGI/_Shared/Headers/Core Files/CommonCore.hlsl.meta
vendored
Normal file
10
Assets/External/HTraceWSGI/Resources/HTraceWSGI/_Shared/Headers/Core Files/CommonCore.hlsl.meta
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2ab0191fa0b7a8a4ab5733ad477b7581
|
||||
timeCreated: 1747747319
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 379716
|
||||
packageName: 'HTrace: World Space Global Illumination URP | Beta'
|
||||
packageVersion: 0.9.6
|
||||
assetPath: Assets/HTraceWSGI/Resources/HTraceWSGI/_Shared/Headers/Core Files/CommonCore.hlsl
|
||||
uploadId: 925118
|
||||
3
Assets/External/HTraceWSGI/Resources/HTraceWSGI/_Shared/Headers/HDRP Files.meta
vendored
Normal file
3
Assets/External/HTraceWSGI/Resources/HTraceWSGI/_Shared/Headers/HDRP Files.meta
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a21a67c353591a84aac943a77a445a1f
|
||||
timeCreated: 1747747214
|
||||
21
Assets/External/HTraceWSGI/Resources/HTraceWSGI/_Shared/Headers/HDRP Files/Color.hlsl
vendored
Normal file
21
Assets/External/HTraceWSGI/Resources/HTraceWSGI/_Shared/Headers/HDRP Files/Color.hlsl
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
// Hue, Saturation, Value
|
||||
// Ranges:
|
||||
// Hue [0.0, 1.0]
|
||||
// Sat [0.0, 1.0]
|
||||
// Lum [0.0, HALF_MAX]
|
||||
float3 RgbToHsv(float3 c)
|
||||
{
|
||||
const float4 K = float4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
|
||||
float4 p = lerp(float4(c.bg, K.wz), float4(c.gb, K.xy), step(c.b, c.g));
|
||||
float4 q = lerp(float4(p.xyw, c.r), float4(c.r, p.yzx), step(p.x, c.r));
|
||||
float d = q.x - min(q.w, q.y);
|
||||
const float e = 1.0e-4;
|
||||
return float3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);
|
||||
}
|
||||
|
||||
float3 HsvToRgb(float3 c)
|
||||
{
|
||||
const float4 K = float4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
|
||||
float3 p = abs(frac(c.xxx + K.xyz) * 6.0 - K.www);
|
||||
return c.z * lerp(K.xxx, saturate(p - K.xxx), c.y);
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user