A game about forced loneliness, made by TACStudios
1#pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch webgpu gles3
2//#pragma enable_d3d11_debug_symbols
3
4#pragma kernel BlendScenarios
5
6#pragma multi_compile _ PROBE_VOLUMES_L2
7#pragma multi_compile _ USE_APV_PROBE_OCCLUSION
8
9#include "Packages/com.unity.render-pipelines.core/Runtime/Lighting/ProbeVolume/ProbeVolumeBlendStates.hlsl"
10
11Texture3D<float4> _State0_L0_L1Rx;
12Texture3D<float4> _State0_L1G_L1Ry;
13Texture3D<float4> _State0_L1B_L1Rz;
14
15Texture3D<float4> _State1_L0_L1Rx;
16Texture3D<float4> _State1_L1G_L1Ry;
17Texture3D<float4> _State1_L1B_L1Rz;
18
19RWTexture3D<float4> _Out_L0_L1Rx;
20RWTexture3D<float4> _Out_L1G_L1Ry;
21RWTexture3D<float4> _Out_L1B_L1Rz;
22
23#ifdef PROBE_VOLUMES_L2
24Texture3D<float4> _State0_L2_0;
25Texture3D<float4> _State0_L2_1;
26Texture3D<float4> _State0_L2_2;
27Texture3D<float4> _State0_L2_3;
28
29Texture3D<float4> _State1_L2_0;
30Texture3D<float4> _State1_L2_1;
31Texture3D<float4> _State1_L2_2;
32Texture3D<float4> _State1_L2_3;
33
34RWTexture3D<float4> _Out_L2_0;
35RWTexture3D<float4> _Out_L2_1;
36RWTexture3D<float4> _Out_L2_2;
37RWTexture3D<float4> _Out_L2_3;
38#endif
39
40#ifdef USE_APV_PROBE_OCCLUSION
41Texture3D<float4> _State0_ProbeOcclusion;
42Texture3D<float4> _State1_ProbeOcclusion;
43RWTexture3D<float4> _Out_ProbeOcclusion;
44#endif
45
46float4 _ChunkList[1000];
47
48float4 _PoolDim_LerpFactor;
49#define _DstPoolDim _PoolDim_LerpFactor.xy
50#define _LerpFactor _PoolDim_LerpFactor.z
51
52uint3 IndexToChunk(uint index, float2 poolSize)
53{
54 uint coordZ = index / (poolSize.x*poolSize.y);
55 uint offsetXY = index - coordZ * (poolSize.x*poolSize.y);
56 return uint3(offsetXY % poolSize.x, offsetXY / poolSize.x, coordZ);
57}
58
59[numthreads(4, 4, 4)]
60void BlendScenarios(uint3 probe : SV_DispatchThreadID, uint3 brick : SV_GroupID)
61{
62 uint chunkIndex = brick.z;
63 probe.z -= 4 * chunkIndex;
64
65 // Load
66 APVResources resources0, resources1;
67 LOAD_APV_RES(resources0, _State0);
68 LOAD_APV_RES(resources1, _State1);
69
70 uint3 srcChunk = _ChunkList[chunkIndex].xyz;
71 APVSample state0 = LoadAndDecodeAPV(resources0, probe + srcChunk);
72 APVSample state1 = LoadAndDecodeAPV(resources1, probe + srcChunk);
73
74 // Blend
75 state0 = BlendAPVSamples(state0, state1, half(_LerpFactor));
76
77 // Store
78 APVResourcesRW output;
79 LOAD_APV_RES(output, _Out);
80
81 uint3 dstChunk = IndexToChunk(_ChunkList[chunkIndex].w, _DstPoolDim);
82 EncodeAndStoreAPV(output, state0, probe + dstChunk);
83}