# coding: utf-8 # original alg from https://github.com/assimp/assimp/issues/4573 # Copyright (C) 2023 Ilia Kurochkin # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. __version__ = '0.1' import math def shiny_to_rough(shininess): ''' convert shiny to roughness ''' a, b = -1.0, 2.0 c = (shininess / 100.0) - 1.0 D = math.pow(b, 2) - (4 * a * c) roughness = (-b + math.sqrt(D)) / (2 * a) return max(roughness, 0)