private void UpdateMaaterialProperties() { bool useGradientTexture = tfRenderMode == TFRenderMode.TF2D || renderMode == RenderMode.IsosurfaceRendering || lightingEnabled; meshRenderer.sharedMaterial.SetTexture("_GradientTex", useGradientTexture ? dataset.GetGradientTexture() : null); if (tfRenderMode == TFRenderMode.TF2D) { meshRenderer.sharedMaterial.SetTexture("_TFTex", transferFunction2D.GetTexture()); meshRenderer.sharedMaterial.EnableKeyword("TF2D_ON"); } else { meshRenderer.sharedMaterial.SetTexture("_TFTex", transferFunction.GetTexture()); meshRenderer.sharedMaterial.DisableKeyword("TF2D_ON"); } if (lightingEnabled) { meshRenderer.sharedMaterial.EnableKeyword("LIGHTING_ON"); } else { meshRenderer.sharedMaterial.DisableKeyword("LIGHTING_ON"); } switch (renderMode) { case RenderMode.DirectVolumeRendering: { meshRenderer.sharedMaterial.EnableKeyword("MODE_DVR"); meshRenderer.sharedMaterial.DisableKeyword("MODE_MIP"); meshRenderer.sharedMaterial.DisableKeyword("MODE_SURF"); break; } case RenderMode.MaximumIntensityProjectipon: { meshRenderer.sharedMaterial.DisableKeyword("MODE_DVR"); meshRenderer.sharedMaterial.EnableKeyword("MODE_MIP"); meshRenderer.sharedMaterial.DisableKeyword("MODE_SURF"); break; } case RenderMode.IsosurfaceRendering: { meshRenderer.sharedMaterial.DisableKeyword("MODE_DVR"); meshRenderer.sharedMaterial.DisableKeyword("MODE_MIP"); meshRenderer.sharedMaterial.EnableKeyword("MODE_SURF"); break; } } meshRenderer.sharedMaterial.SetFloat("_MinVal", visibilityWindow.x); meshRenderer.sharedMaterial.SetFloat("_MaxVal", visibilityWindow.y); }
private void UpdateMaaterialProperties() { MeshRenderer meshRenderer = GetComponent <MeshRenderer>(); bool useGradientTexture = tfRenderMode == TFRenderMode.TF2D || renderMode == RenderMode.IsosurfaceRendering; meshRenderer.sharedMaterial.SetTexture("_GradientTex", useGradientTexture ? dataset.GetGradientTexture() : null); if (tfRenderMode == TFRenderMode.TF2D) { meshRenderer.sharedMaterial.SetTexture("_TFTex", transferFunction2D.GetTexture()); meshRenderer.sharedMaterial.EnableKeyword("TF2D_ON"); } else { meshRenderer.sharedMaterial.SetTexture("_TFTex", transferFunction.GetTexture()); meshRenderer.sharedMaterial.DisableKeyword("TF2D_ON"); } switch (renderMode) { case RenderMode.DirectVolumeRendering: { meshRenderer.sharedMaterial.EnableKeyword("MODE_DVR"); meshRenderer.sharedMaterial.DisableKeyword("MODE_MIP"); meshRenderer.sharedMaterial.DisableKeyword("MODE_SURF"); break; } case RenderMode.MaximumIntensityProjectipon: { meshRenderer.sharedMaterial.DisableKeyword("MODE_DVR"); meshRenderer.sharedMaterial.EnableKeyword("MODE_MIP"); meshRenderer.sharedMaterial.DisableKeyword("MODE_SURF"); break; } case RenderMode.IsosurfaceRendering: { meshRenderer.sharedMaterial.DisableKeyword("MODE_DVR"); meshRenderer.sharedMaterial.DisableKeyword("MODE_MIP"); meshRenderer.sharedMaterial.EnableKeyword("MODE_SURF"); break; } } }