diff --git a/Prefabs/CBIRP Manager.prefab b/Prefabs/CBIRP Manager.prefab index 3021495..2ef490e 100644 --- a/Prefabs/CBIRP Manager.prefab +++ b/Prefabs/CBIRP Manager.prefab @@ -137,7 +137,7 @@ Camera: far clip plane: 2000 field of view: 60 orthographic: 1 - orthographic size: 2000 + orthographic size: 256000 m_Depth: 0 m_CullingMask: serializedVersion: 2 @@ -207,7 +207,7 @@ MonoBehaviour: AllowCollisionOwnershipTransfer: 0 Reliable: 0 _syncMethod: 1 - serializedProgramAsset: {fileID: 11400000, guid: 26380f5940f05bd48bba8b948e65f4be, + serializedProgramAsset: {fileID: 11400000, guid: 97f666214d09bce4eaface49713984a4, type: 2} programSource: {fileID: 11400000, guid: cc0a5ac8e4930034fb55412459c61ee0, type: 2} serializedPublicVariablesBytesString: Ai8AAAAAATIAAABWAFIAQwAuAFUAZABvAG4ALgBDAG8AbQBtAG8AbgAuAFUAZABvAG4AVgBhAHIAaQBhAGIAbABlAFQAYQBiAGwAZQAsACAAVgBSAEMALgBVAGQAbwBuAC4AQwBvAG0AbQBvAG4AAAAAAAYBAAAAAAAAACcBBAAAAHQAeQBwAGUAAWgAAABTAHkAcwB0AGUAbQAuAEMAbwBsAGwAZQBjAHQAaQBvAG4AcwAuAEcAZQBuAGUAcgBpAGMALgBMAGkAcwB0AGAAMQBbAFsAVgBSAEMALgBVAGQAbwBuAC4AQwBvAG0AbQBvAG4ALgBJAG4AdABlAHIAZgBhAGMAZQBzAC4ASQBVAGQAbwBuAFYAYQByAGkAYQBiAGwAZQAsACAAVgBSAEMALgBVAGQAbwBuAC4AQwBvAG0AbQBvAG4AXQBdACwAIABtAHMAYwBvAHIAbABpAGIAAQEJAAAAVgBhAHIAaQBhAGIAbABlAHMALwEAAAABaAAAAFMAeQBzAHQAZQBtAC4AQwBvAGwAbABlAGMAdABpAG8AbgBzAC4ARwBlAG4AZQByAGkAYwAuAEwAaQBzAHQAYAAxAFsAWwBWAFIAQwAuAFUAZABvAG4ALgBDAG8AbQBtAG8AbgAuAEkAbgB0AGUAcgBmAGEAYwBlAHMALgBJAFUAZABvAG4AVgBhAHIAaQBhAGIAbABlACwAIABWAFIAQwAuAFUAZABvAG4ALgBDAG8AbQBtAG8AbgBdAF0ALAAgAG0AcwBjAG8AcgBsAGkAYgABAAAABgEAAAAAAAAAAi8CAAAAAUkAAABWAFIAQwAuAFUAZABvAG4ALgBDAG8AbQBtAG8AbgAuAFUAZABvAG4AVgBhAHIAaQBhAGIAbABlAGAAMQBbAFsAUwB5AHMAdABlAG0ALgBJAG4AdAAzADIALAAgAG0AcwBjAG8AcgBsAGkAYgBdAF0ALAAgAFYAUgBDAC4AVQBkAG8AbgAuAEMAbwBtAG0AbwBuAAIAAAAGAgAAAAAAAAAnAQQAAAB0AHkAcABlAAEXAAAAUwB5AHMAdABlAG0ALgBTAHQAcgBpAG4AZwAsACAAbQBzAGMAbwByAGwAaQBiACcBCgAAAFMAeQBtAGIAbwBsAE4AYQBtAGUAAR8AAABfAF8AXwBVAGQAbwBuAFMAaABhAHIAcABCAGUAaABhAHYAaQBvAHUAcgBWAGUAcgBzAGkAbwBuAF8AXwBfACcBBAAAAHQAeQBwAGUAARYAAABTAHkAcwB0AGUAbQAuAEkAbgB0ADMAMgAsACAAbQBzAGMAbwByAGwAaQBiABcBBQAAAFYAYQBsAHUAZQACAAAABwUHBQcF @@ -243,4 +243,4 @@ MonoBehaviour: _trackingCamera: {fileID: 1582084508120223640} _dynamicUpdates: 1 probeBounces: 1 - probeResolution: 128 + probeResolution: 64 diff --git a/Runtime/CBIRPLight.asset b/Runtime/CBIRPLight.asset index dcd1d5a..2e4d3a7 100644 --- a/Runtime/CBIRPLight.asset +++ b/Runtime/CBIRPLight.asset @@ -12,7 +12,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: c333ccfdd0cbdbc4ca30cef2dd6e6b9b, type: 3} m_Name: CBIRPLight m_EditorClassIdentifier: - serializedUdonProgramAsset: {fileID: 11400000, guid: 43a3e7496e111fb4cbf2abc3487f26e1, + serializedUdonProgramAsset: {fileID: 11400000, guid: dcaf1c08714cfe747acd9d9d7aec871b, type: 2} udonAssembly: assemblyError: diff --git a/Runtime/CBIRPManager.asset b/Runtime/CBIRPManager.asset index ef48e0d..0a43f16 100644 --- a/Runtime/CBIRPManager.asset +++ b/Runtime/CBIRPManager.asset @@ -12,7 +12,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: c333ccfdd0cbdbc4ca30cef2dd6e6b9b, type: 3} m_Name: CBIRPManager m_EditorClassIdentifier: - serializedUdonProgramAsset: {fileID: 11400000, guid: 97f666214d09bce4eaface49713984a4, + serializedUdonProgramAsset: {fileID: 11400000, guid: 26380f5940f05bd48bba8b948e65f4be, type: 2} udonAssembly: assemblyError: diff --git a/Runtime/CBIRPReflectionProbe.asset b/Runtime/CBIRPReflectionProbe.asset index 91f277f..dcb8946 100644 --- a/Runtime/CBIRPReflectionProbe.asset +++ b/Runtime/CBIRPReflectionProbe.asset @@ -12,7 +12,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: c333ccfdd0cbdbc4ca30cef2dd6e6b9b, type: 3} m_Name: CBIRPReflectionProbe m_EditorClassIdentifier: - serializedUdonProgramAsset: {fileID: 11400000, guid: 2cb8794cf72572042bf76e67a2d3e34a, + serializedUdonProgramAsset: {fileID: 11400000, guid: 47beab666ce76aa47aaca52d948634cf, type: 2} udonAssembly: assemblyError: diff --git a/Runtime/rt/CBIRP_Uniforms.mat b/Runtime/rt/CBIRP_Uniforms.mat index 2dbb791..8ce5490 100644 --- a/Runtime/rt/CBIRP_Uniforms.mat +++ b/Runtime/rt/CBIRP_Uniforms.mat @@ -24,5 +24,5 @@ Material: m_Scale: {x: 1, y: 1} m_Offset: {x: 0, y: 0} m_Floats: - - _Far: 150 + - _Far: 100 m_Colors: [] diff --git a/Shaders/Clustering.shader b/Shaders/Clustering.shader index d79c3ae..b68405d 100644 --- a/Shaders/Clustering.shader +++ b/Shaders/Clustering.shader @@ -42,7 +42,6 @@ float positionMax = position; uint flags[4] = { 0, 0, 0, 0 }; - uint4 writeMask = uint4(1,0,0,0); [loop] for (uint index = 1; index < CBIRP_MAX_LIGHTS; index++) diff --git a/Shaders/cbirp.hlsl b/Shaders/cbirp.hlsl index 4a3d219..4b8bf0c 100644 --- a/Shaders/cbirp.hlsl +++ b/Shaders/cbirp.hlsl @@ -15,15 +15,17 @@ Texture2D _Udon_CBIRP_ShadowMask; #define CBIRP_TYPE_LIGHT 0 #define CBIRP_TYPE_PROBE 1 -#define CBIRP_CLUSTER_START_LIGHT(cluster) \ - uint4 flags4x = _Udon_CBIRP_Clusters[uint2(0, cluster.x)]; \ - uint4 flags4y = _Udon_CBIRP_Clusters[uint2(1, cluster.y)]; \ - uint4 flags4z = _Udon_CBIRP_Clusters[uint2(2, cluster.z)]; \ +#define CBIRP_CLUSTER_START(cluster, type) \ + bool isLight = type == CBIRP_TYPE_LIGHT; \ + uint4 flags4x = _Udon_CBIRP_Clusters[uint2(isLight ? 0 : 3, cluster.x)]; \ + uint4 flags4y = _Udon_CBIRP_Clusters[uint2(isLight ? 1 : 4, cluster.y)]; \ + uint4 flags4z = _Udon_CBIRP_Clusters[uint2(isLight ? 2 : 5, cluster.z)]; \ uint4 flags4 = flags4x & flags4y & flags4z; \ uint flags = flags4.x; \ uint offset = 0; \ + uint maxOffset = isLight ? 128 : 32; \ [loop] while (true) { \ - [branch] if (offset == 128) break; \ + [branch] if (offset == maxOffset) break; \ [branch] if (flags == 0) { \ offset += 32; \ flags = offset == 32 ? flags4.y : (offset == 64 ? flags4.z : flags4.w); \ @@ -32,21 +34,7 @@ Texture2D _Udon_CBIRP_ShadowMask; flags ^= 0x1 << index; \ index += offset; \ -#define CBIRP_CLUSTER_END_LIGHT \ - }} \ - -#define CBIRP_CLUSTER_START_PROBE(cluster) \ - uint4 flags4x = _Udon_CBIRP_Clusters[uint2(3, cluster.x)]; \ - uint4 flags4y = _Udon_CBIRP_Clusters[uint2(4, cluster.y)]; \ - uint4 flags4z = _Udon_CBIRP_Clusters[uint2(5, cluster.z)]; \ - uint flags = flags4x.x & flags4y.x & flags4z.x; \ - [loop] while (true) { \ - [branch] if (flags == 0) break; \ - else { \ - uint index = firstbitlow(flags); \ - flags ^= 0x1 << index; \ - -#define CBIRP_CLUSTER_END_PROBE \ +#define CBIRP_CLUSTER_END \ }} \ // uniform float _Udon_CBIRP_CullFar; @@ -207,7 +195,7 @@ namespace CBIRP half clampedRoughness = max(roughness * roughness, 0.002); half debug = 0; - CBIRP_CLUSTER_START_LIGHT(cluster) + CBIRP_CLUSTER_START(cluster, CBIRP_TYPE_LIGHT) debug+=1; Light light = Light::DecodeLight(index); @@ -267,7 +255,7 @@ debug+=1; } } - CBIRP_CLUSTER_END_LIGHT + CBIRP_CLUSTER_END #ifdef _CBIRP_DEBUG // diffuse = Heatmap((debug) / 16.); @@ -350,7 +338,7 @@ debug+=1; half4 decodeInstructions = 0; - CBIRP_CLUSTER_START_PROBE(cluster) + CBIRP_CLUSTER_START(cluster, CBIRP_TYPE_PROBE) ReflectionProbe probe = ReflectionProbe::DecodeReflectionProbe(index); debug += 1; @@ -367,7 +355,7 @@ debug+=1; irradiance += weight * DecodeHDREnvironment(encodedIrradiance, half4(probe.intensity, decodeInstructions.yzw)); } - CBIRP_CLUSTER_END_PROBE + CBIRP_CLUSTER_END #ifdef CBIRP_SKYPROBE UNITY_BRANCH