-
Notifications
You must be signed in to change notification settings - Fork 6
Add R11G11B10FloatToBGRA32 #17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
ds5678
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A lot to unpack with this, despite the small line count.
- The
RBAConverter.{format name}ToBGRA32methods are legacy code and scheduled to be removed at some point. This is partially my fault; I should have added obsolete attributes to signal my intent. These methods have been replaced with structs in theFormatsnamespace. Your current method can stay for use in unit tests, ie RGBTests and NewRGBTests. - I'm concerned about the use of
Halfandfloat. Given that the significand forHalfuses 10 bits not including the sign bit (reference 1, reference 2), this is actually just an integer. The single exponent bit for R and G could only double the significand, the same as normal integer types. It should be more efficient to useushortdirectly (similar to RGB16). You should verify all this with unit tests and document accordingly. Assuming my thoughts are correct, I want this to beRGB32 : IColor<ushort>, otherwiseRGB32Half : IColor<Half>. - You should add a line here and run automated test generation for the new color struct.
|
f16 still has 5 exponent bits, i.e. 0x3401 is 0.2503~ there's no neat conversion to a UNORM value (0x4013 as U16, or 0x3F as U8) without doing what Half does anyway. |
ds5678
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Much closer this time. I would appreciate a test file, but that's not strictly necessary. I verified that this is a format used by Unity, albeit only for render textures.
|
Rebased the code and fixed the comments/remarks. |
ds5678
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One small change and then I think this is good, assuming the continuous integration succeeds.
|
Alright, added the test case using RGB24's sample file. I should probably dump the r11g11b10 texture i was using and provide that but this works too. |
If licensing is not an issue, I would greatly appreciate this. |
|
Unsure on licensing. I'll probably make a new one someday and PR it with the updated test case. |
|
Sounds good! |
|
@yretenai I think there may be bugs in this color. I had to disable the unit tests for it in the above commit. It is the only color with failing unit tests. |
|
If you're not willing to fix the bugs, I would like to remove this color from the codebase, for quality control. This would not impact your ability to use the library. I specifically designed it to be easy for someone to declare their own custom structs inheriting from |
Feel free to remove it in this case, I'll add it to my own use cases. |
|
Thank you for understanding. |
Known in Unity as
GraphicsFormat.B10G11R11_UFloatPack32, usually used for lightmap and HDR data.MS Reference code: https://github.com/microsoft/DirectX-Graphics-Samples/blob/e5ea2ac7430ce39e6f6d619fd85ae32581931589/MiniEngine/Core/Shaders/PixelPacking_R11G11B10.hlsli#L31-L37