You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've been checking out the Blender Hydra/MaterialX support, and believe to have stumbled upon a bug in the MDL implementation of the HSV to RGB color space transformation logic.
The following images show shading networks parametrized with different Hue values in (1) Blender's Cycles, (2) Storm (via Hydra) using the MaterialX GLSL backend, (3) Gatling (via Hydra) using the MaterialX MDL backend and (4) Gatling, with the correct logic.
Discrepancies between the MaterialX GLSL and MDL backends can only be seen for high hue values (0.9, 1.0) and stem from a differing line of code in their mx_hsvtorgb functions. For GLSL, the hue is first floored and then brought into the range 0-6:
I've been checking out the Blender Hydra/MaterialX support, and believe to have stumbled upon a bug in the MDL implementation of the HSV to RGB color space transformation logic.
The following images show shading networks parametrized with different Hue values in (1) Blender's Cycles, (2) Storm (via Hydra) using the MaterialX GLSL backend, (3) Gatling (via Hydra) using the MaterialX MDL backend and (4) Gatling, with the correct logic.
![Storm GLSL](https://private-user-images.githubusercontent.com/3663466/278297636-2ce2e54d-44b4-4013-b3ff-dbe6ada2c844.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkyODI0MDUsIm5iZiI6MTczOTI4MjEwNSwicGF0aCI6Ii8zNjYzNDY2LzI3ODI5NzYzNi0yY2UyZTU0ZC00NGI0LTQwMTMtYjNmZi1kYmU2YWRhMmM4NDQucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI1MDIxMSUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTAyMTFUMTM1NTA1WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9MWI5M2I2OWViMmExYzY1YzYwNmMwY2Y0NmVlNzNiNzA5YjNmYjI5YjRmZjg2MmNhNGZlMmMyMDU4NWUwM2U0ZiZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.2s-I0PVJByTOTFXJvDdbCRrFd0MGmQbdqIOrVVvY7n4)
![Gatling MDL (new)](https://private-user-images.githubusercontent.com/3663466/278297746-6158806d-5093-49a2-9a1d-cdb5963ff01b.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkyODI0MDUsIm5iZiI6MTczOTI4MjEwNSwicGF0aCI6Ii8zNjYzNDY2LzI3ODI5Nzc0Ni02MTU4ODA2ZC01MDkzLTQ5YTItOWExZC1jZGI1OTYzZmYwMWIucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI1MDIxMSUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTAyMTFUMTM1NTA1WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9OGJlMDNiOGNkYTRjYWFkNTdmOWNkOWEwZDAxMGE0YzFlZWMzZGUzYWIyZTU5YmY3Y2Y5YzI1YWFkMDc0Y2MxYyZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.lf-m3InPNenRZUnjcj_1Q7lUXxbLooesVvaAvP9Nt2c)
Discrepancies between the MaterialX GLSL and MDL backends can only be seen for high hue values (0.9, 1.0) and stem from a differing line of code in their
mx_hsvtorgb
functions. For GLSL, the hue is first floored and then brought into the range 0-6:MaterialX/libraries/stdlib/genglsl/lib/mx_hsv.glsl
Lines 47 to 49 in 926ac27
whereas for MDL, the value is first brought into the range 0-6 and is then floored:
MaterialX/source/MaterialXGenMdl/mdl/materialx/hsv.mdl
Lines 29 to 31 in 926ac27
I can't tell whether this is an implementation mistake or an error in the referenced literature (Reinhard et al.), as the book is not openly available. However, the GLSL logic also matches OpenColorIO:
https://github.com/AcademySoftwareFoundation/OpenColorIO/blob/8add374dade5a7e3ee802269b71e1c0b75f8b8f0/src/OpenColorIO/ops/fixedfunction/FixedFunctionOpGPU.cpp#L413
cc @krohmerNV
The text was updated successfully, but these errors were encountered: