Skip to content

Commit

Permalink
set sorting order to prevent flicker while moving
Browse files Browse the repository at this point in the history
  • Loading branch information
z3y committed Oct 23, 2023
1 parent c36f59e commit df90963
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 2 deletions.
1 change: 1 addition & 0 deletions Prefabs/CBIRP Light.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ MonoBehaviour:
shadowMask: 0
specularOnlyShadowmask: 0
meshRenderer: {fileID: 219479547}
_shadowMaskID: -1
--- !u!33 &219479546
MeshFilter:
m_ObjectHideFlags: 0
Expand Down
4 changes: 2 additions & 2 deletions Prefabs/CBIRP Probe.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@ MonoBehaviour:
PrefabModifications: []
SerializationNodes: []
_udonSharpBackingUdonBehaviour: {fileID: 2169391047014929947}
probe: {fileID: 5018727802146543098}
destroyComponent: 1
blendDistance: 0.1
cubeArrayIndex: 0
meshRenderer: {fileID: 3192795575258911616}
probe: {fileID: 5018727802146543098}
--- !u!215 &5018727802146543098
ReflectionProbe:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -159,7 +159,7 @@ MeshRenderer:
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
m_SortingOrder: 127
--- !u!33 &7892692966851333613
MeshFilter:
m_ObjectHideFlags: 0
Expand Down
8 changes: 8 additions & 0 deletions Runtime/CBIRPManagerEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,20 @@ public void OnProcessScene(Scene scene, BuildReport report)
{
var objects = scene.GetRootGameObjects();
var probes = objects.SelectMany(x => x.GetComponentsInChildren<CBIRPReflectionProbe>(false));
var lights = objects.SelectMany(x => x.GetComponentsInChildren<CBIRPLight>(true));

foreach (var probe in probes)
{
probe.probe.bakedTexture = null;
probe.enabled = false;
}

int order = 10000;
foreach (var light in lights)
{
light.meshRenderer.sortingOrder = order;
order++;
}
}

public static void PackProbes(CBIRPManager target)
Expand Down
2 changes: 2 additions & 0 deletions Runtime/CBIRPReflectionProbe.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ void Start()

public void UpdateProbe()
{
meshRenderer.sortingOrder = 128 - probe.importance;

_propertyBlock = new MaterialPropertyBlock();

//float intensity = probe.textureHDRDecodeValues.x;
Expand Down

0 comments on commit df90963

Please sign in to comment.