Skip to content

Commit

Permalink
use else instead of continue
Browse files Browse the repository at this point in the history
why is this so much faster wtf
  • Loading branch information
z3y committed Nov 1, 2023
1 parent 6a8d344 commit 469dd4a
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 9 deletions.
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
15 changes: 9 additions & 6 deletions Shaders/cbirp.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,16 @@ Texture2D _Udon_CBIRP_ShadowMask;
uint4 flags4 = flags4x & flags4y & flags4z; \
uint flags = flags4.x; \
uint component = 0; \
while (component < 3) { \
[branch] if (flags == 0) { flags = component == 0 ? flags4.y : (component == 1 ? flags4.z : flags4.w); component++; continue; } \
while (true) { \
[branch] if (component >= 3) break; \
[branch] if (flags == 0) { flags = component == 0 ? flags4.y : (component == 1 ? flags4.z : flags4.w); component++;} \
else { \
uint index = firstbitlow(flags); \
flags ^= 0x1 << index; \
index += 32 * component; \

#define CBIRP_CLUSTER_END \
} \
}} \

// uniform float _Udon_CBIRP_CullFar;
// uniform float4 _Udon_CBIRP_PlayerCamera;
Expand Down Expand Up @@ -219,12 +221,13 @@ debug+=1;
}
#endif

attenuation *= NoL;
debug += attenuation > 0;

UNITY_BRANCH
if (attenuation > 0 && NoL > 0)
if (attenuation > 0)
{
half3 currentDiffuse = attenuation * light.color * NoL;
half3 currentDiffuse = attenuation * light.color;

float3 halfVector = CBIRP::SafeNormalize(L + viewDirectionWS);
half LoH = saturate(dot(L, halfVector));
Expand Down

0 comments on commit 469dd4a

Please sign in to comment.