A game about forced loneliness, made by TACStudios
1#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
2#include "Packages/com.unity.render-pipelines.core/Runtime/Lighting/ProbeVolume/ProbeVolume.hlsl"
3#include "Packages/com.unity.render-pipelines.core/Runtime/Lighting/ProbeVolume/ProbeReferenceVolume.Streaming.cs.hlsl"
4
5ByteAddressBuffer _ScratchBuffer;
6
7float4 UintToFloat4(uint input)
8{
9 float4 result;
10 result.x = (input & 0x000000FF) / 255.0f;
11 result.y = ((input >> 8) & 0x000000FF) / 255.0f;
12 result.z = ((input >> 16) & 0x000000FF) / 255.0f;
13 result.w = ((input >> 24) & 0x000000FF) / 255.0f;
14
15 return result;
16}
17
18// Extract two FP16 rgba values encoded in an uint4
19void ExtractFP16(uint4 input, out float4 value0, out float4 value1)
20{
21 float4 temp0 = f16tof32(input);
22 float4 temp1 = f16tof32(input >> 16);
23
24 value0.xz = temp0.xy;
25 value0.yw = temp1.xy;
26 value1.xz = temp0.zw;
27 value1.yw = temp1.zw;
28}
29
30void ExtractByte(uint4 input, out float4 value0, out float4 value1, out float4 value2, out float4 value3)
31{
32 value0 = UintToFloat4(input.x);
33 value1 = UintToFloat4(input.y);
34 value2 = UintToFloat4(input.z);
35 value3 = UintToFloat4(input.w);
36}
37
38void ExtractByte(uint input, out float4 value)
39{
40 value = UintToFloat4(input);
41}
42
43void getProbeLocationAndOffsets(uint chunkIndex, uint chunkProbeIndex, out float3 baseProbe, out float3 loc, out float3 probe1Offset, out float3 probe2Offset, out float3 probe3Offset)
44{
45 baseProbe.z = chunkProbeIndex / _ProbeCountInChunkSlice;
46 uint indexInSlice = chunkProbeIndex - baseProbe.z * _ProbeCountInChunkSlice;
47 baseProbe.y = indexInSlice / _ProbeCountInChunkLine;
48 baseProbe.x = indexInSlice - baseProbe.y * _ProbeCountInChunkLine;
49
50 uint3 dstChunk = _ScratchBuffer.Load4(chunkIndex * 16).xyz; // *16 because 4 int per chunk.
51 loc = dstChunk + baseProbe;
52 probe1Offset = uint3(1, 0, 0);
53 probe2Offset = uint3(2, 0, 0);
54 probe3Offset = uint3(3, 0, 0);
55}