Skip to content

Commit

Permalink
fix probe issue
Browse files Browse the repository at this point in the history
  • Loading branch information
z3y committed Nov 1, 2023
1 parent 6c1a5b6 commit d34c7e3
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 32 deletions.
6 changes: 3 additions & 3 deletions Prefabs/CBIRP Manager.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -243,4 +243,4 @@ MonoBehaviour:
_trackingCamera: {fileID: 1582084508120223640}
_dynamicUpdates: 1
probeBounces: 1
probeResolution: 128
probeResolution: 64
2 changes: 1 addition & 1 deletion Runtime/CBIRPLight.asset
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion Runtime/CBIRPManager.asset
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion Runtime/CBIRPReflectionProbe.asset
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion Runtime/rt/CBIRP_Uniforms.mat
Original file line number Diff line number Diff line change
Expand Up @@ -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: []
1 change: 0 additions & 1 deletion Shaders/Clustering.shader
Original file line number Diff line number Diff line change
Expand Up @@ -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++)
Expand Down
36 changes: 12 additions & 24 deletions Shaders/cbirp.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -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); \
Expand All @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -267,7 +255,7 @@ debug+=1;
}

}
CBIRP_CLUSTER_END_LIGHT
CBIRP_CLUSTER_END

#ifdef _CBIRP_DEBUG
// diffuse = Heatmap((debug) / 16.);
Expand Down Expand Up @@ -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;

Expand All @@ -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
Expand Down

0 comments on commit d34c7e3

Please sign in to comment.