From 23bf255d09a0811f83f051b7565b193d918e5c8e Mon Sep 17 00:00:00 2001 From: Matias Lavik Date: Thu, 26 Jan 2023 20:11:47 +0100 Subject: [PATCH] Handle linear colour space + Unity EULA compatilble third party license notice (#155) * Unity EULA-compatible third party notices * Handle linear colour space * Perform gamma correction in TF palette shader, since Graphics.DrawTexture doesn't. --- ACKNOWLEDGEMENTS.txt | 40 ------------------- .../TransferFunction/TransferFunction.cs | 2 +- .../TransferFunctionPaletteShader.shader | 4 ++ Third-Party Notices.txt | 31 ++++++++++++++ scripts/ExportUnityPackage.py | 10 ++++- 5 files changed, 44 insertions(+), 43 deletions(-) delete mode 100644 ACKNOWLEDGEMENTS.txt create mode 100644 Third-Party Notices.txt diff --git a/ACKNOWLEDGEMENTS.txt b/ACKNOWLEDGEMENTS.txt deleted file mode 100644 index 39f62e54..00000000 --- a/ACKNOWLEDGEMENTS.txt +++ /dev/null @@ -1,40 +0,0 @@ -This project uses the following libraries: - -openDICOM.net -released under LGPL Version 2.1. -http://opendicom.sourceforge.net/index.html - -Copyright (C) 2006-2007 Albert Gnandt - -(a modified version of openDICOM.net is included in this repository) - - -nifti.NET -released under MIT. -https://github.com/plwp/Nifti.NET - -Copyright (c) 2019 Patrick Prendergast - -(a modified version of nifti.NET is included in this repository) - - -SimpleITK -released under Apache License 2.0 -https://github.com/SimpleITK/SimpleITK/blob/master/LICENSE - -Copyright 2010-2019 Insight Software Consortium -Copyright 2020 NumFOCUS - -SimpleITK is not included in this repository, but will optionally be downloaded if the user chooser enable it. -The license file will be stored together with the library in the Assets/3rdparty/SimpleITK directory. - - -CUDA Cubic B-Spline Interpolation shader. -Original source: https://github.com/DannyRuijters/CubicInterpolationCUDA/blob/master/examples/glCubicRayCast/tricubic.shader -Released under a revised BSD style license. - -Copyright (c) 2008-2009, Danny Ruijters. All rights reserved. -http://www.dannyruijters.nl/cubicinterpolation/ -This file is part of CUDA Cubic B-Spline Interpolation (CI). - -See full license i TricubicSampling.cginc diff --git a/Assets/Scripts/TransferFunction/TransferFunction.cs b/Assets/Scripts/TransferFunction/TransferFunction.cs index be83fadd..7435959f 100644 --- a/Assets/Scripts/TransferFunction/TransferFunction.cs +++ b/Assets/Scripts/TransferFunction/TransferFunction.cs @@ -89,7 +89,7 @@ public void GenerateTexture() for (int iY = 0; iY < TEXTURE_HEIGHT; iY++) { - tfCols[iX + iY * TEXTURE_WIDTH] = pixCol; + tfCols[iX + iY * TEXTURE_WIDTH] = QualitySettings.activeColorSpace == ColorSpace.Linear ? pixCol.linear : pixCol; } } diff --git a/Assets/Shaders/TransferFunctionPaletteShader.shader b/Assets/Shaders/TransferFunctionPaletteShader.shader index 930ca240..32cf022e 100644 --- a/Assets/Shaders/TransferFunctionPaletteShader.shader +++ b/Assets/Shaders/TransferFunctionPaletteShader.shader @@ -48,6 +48,10 @@ { float4 col = tex2D(_TFTex, float2(i.uv.x, 0.0f)); col.a = 1.0f; +#if !UNITY_COLORSPACE_GAMMA +#define INVERSA_GAMMA 0.4545454 + col.rgb = pow(col.rgb, float3(INVERSA_GAMMA, INVERSA_GAMMA, INVERSA_GAMMA)); +#endif return col; } diff --git a/Third-Party Notices.txt b/Third-Party Notices.txt new file mode 100644 index 00000000..2f9a5439 --- /dev/null +++ b/Third-Party Notices.txt @@ -0,0 +1,31 @@ +A. openDICOM.net +LGPL Version 2.1. +Copyright (C) 2006-2007 Albert Gnandt +See full LGPL license in subfolder: Assets/3rdparty/openDicom/LGPL + +B: VisMale.raw (Visible Human Project) +UNNAMED LICENSE. +Courtesy of the U.S. National Library of Medicine +Disclaimer: This version of the Visible Human Dataset does not reflect the most current/accurate data available from NLM. +See full license in subfolder DataFiles/VisMale-license.txt + +C. SimpleITK +Apache License 2.0 +Copyright 2010-2019 Insight Software Consortium +Copyright 2020 NumFOCUS +This library is automatically downloaded when requested by user. +See full license in subfolder: Assets/3rdparty/SimpleITK-[VERSION]/LICENSE + +D. nifti.NET +MIT License. +Copyright (c) 2019 Patrick Prendergast +See full license in subfolder: Assets/3rdparty/Nifti.NET/LICENSE +(Note: a modified version of nifti.NET is included in this repository) + +E. CUDA Cubic B-Spline Interpolation shader. +Released under a revised BSD style license. +Copyright (c) 2008-2009, Danny Ruijters. All rights reserved. +http://www.dannyruijters.nl/cubicinterpolation/ +This file is part of CUDA Cubic B-Spline Interpolation (CI). + +See full license i Assets/Shaders/TricubicSampling.cginc diff --git a/scripts/ExportUnityPackage.py b/scripts/ExportUnityPackage.py index 4d3f2373..bd56cd36 100644 --- a/scripts/ExportUnityPackage.py +++ b/scripts/ExportUnityPackage.py @@ -29,9 +29,15 @@ def copy_filedir(src, dst): os.system("pandoc README.md -o MANUAL.pdf") if assetstore_package: - assets = ["Assets", "DataFiles", "ACKNOWLEDGEMENTS.txt", "MANUAL.pdf"] + with open('Third-Party Notices.txt', 'r') as original: + third_party_contents = original.read() + with open('Third-Party Notices.txt', 'w') as modified: + modified.write("This asset is governed by the Asset Store EULA; however, the following components are governed by the licenses indicated below:\n" + third_party_contents) + +if assetstore_package: + assets = ["Assets", "DataFiles", "Third-Party Notices.txt", "MANUAL.pdf"] else: - assets = ["Assets", "DataFiles", "ACKNOWLEDGEMENTS.txt", "CREDITS.md", "LICENSE", "README.md"] + assets = ["Assets", "DataFiles", "Third-Party Notices.txt", "CREDITS.md", "LICENSE", "README.md"] for asset in assets: dest_asset = os.path.join(export_project_path, "Assets", plugin_folder_name, asset)