Call UpdateMaaterialProperties after enabling/disabling lighting. SetVisibilityWindow: Don't call UpdateMaaterialProperties of value didn't change.

This commit is contained in:
Matias Lavik 2022-02-12 20:19:56 +01:00
Родитель 698117d3ca
Коммит b196f0ffdb
1 изменённых файлов: 16 добавлений и 9 удалений

Просмотреть файл

@ -76,9 +76,13 @@ namespace UnityVolumeRendering
return lightingEnabled;
}
public void SetLightingEnabled(bool enable)
{
lightingEnabled = enable;
public void SetLightingEnabled(bool enable)
{
if (enable != lightingEnabled)
{
lightingEnabled = enable;
UpdateMaaterialProperties();
}
}
public void SetVisibilityWindow(float min, float max)
@ -88,8 +92,11 @@ namespace UnityVolumeRendering
public void SetVisibilityWindow(Vector2 window)
{
visibilityWindow = window;
UpdateMaaterialProperties();
if (window != visibilityWindow)
{
visibilityWindow = window;
UpdateMaaterialProperties();
}
}
public Vector2 GetVisibilityWindow()
@ -113,11 +120,11 @@ namespace UnityVolumeRendering
meshRenderer.sharedMaterial.DisableKeyword("TF2D_ON");
}
if(lightingEnabled)
meshRenderer.sharedMaterial.EnableKeyword("LIGHTING_ON");
if(lightingEnabled)
meshRenderer.sharedMaterial.EnableKeyword("LIGHTING_ON");
else
meshRenderer.sharedMaterial.DisableKeyword("LIGHTING_ON");
meshRenderer.sharedMaterial.DisableKeyword("LIGHTING_ON");
switch (renderMode)
{
case RenderMode.DirectVolumeRendering: