Cycles: Adding native support for UINT16 textures.
ClosedPublic

Authored by Stefan Werner (swerner) on Thu, Jul 5, 10:50 AM.

Details

Summary

Textures in 16 bit integer format are sometimes used for displacement, bump and normal maps and can be exported by tools like Substance Painter. Without this patch, Cycles would promote those textures to single precision floating point, causing them to take up twice as much memory as needed.

Diff Detail

Branch
cycles_uint16_textures
Build Status
Buildable 1802
Build 1802: arc lint + arc unit
Stefan Werner (swerner) edited the summary of this revision. (Show Details)Thu, Jul 5, 10:52 AM
Stefan Werner (swerner) added a reviewer: Cycles.
Stefan Werner (swerner) set the repository for this revision to rB Blender.
Stefan Werner (swerner) added a subscriber: Cycles.

Nice Work, gread to see this being implemented, I was missing that in my 2016 GSoC, when I added half float support.

Quickly scanning through the code, I couldn't find obvious errors. :)

This revision is now accepted and ready to land.Thu, Jul 5, 11:15 AM
Sergey Sharybin (sergey) added inline comments.
intern/cycles/kernel/kernels/cpu/kernel_cpu_image.h
66–76

Why to add spaces around operators few functions above and not add them in the new code?

intern/cycles/kernel/kernels/opencl/kernel_opencl_image.h
58–72

Inconsistent spaces around operator in new code.

intern/cycles/render/image.cpp
34–46

Why this functions are returning false?

intern/cycles/util/util_half.h
43

Single argument constructors are to be marked as explicit.

intern/cycles/util/util_image_impl.h
92

Space around operators.

intern/cycles/util/util_types_ushort4.h
3

It is 2018.

Sergey Sharybin (sergey) requested changes to this revision.Thu, Jul 5, 11:19 AM
This revision now requires changes to proceed.Thu, Jul 5, 11:19 AM
intern/cycles/kernel/kernels/cpu/kernel_cpu_image.h
66–76

Text editors trying to be smart...

intern/cycles/render/image.cpp
34–46

Good question. I just did the same for uint16_t that you did for uchar and half: https://developer.blender.org/rC69b50f6f8405bf008040bf51de9173d9638328e6

I guess uchar and uint16_t should always return true, as they have no representation for infinite. I'd handle that in a separate commit though. Should this change cause problems, it'll make finding it via git bisect much easier.

  • Addressed Sergey's comments regarding code style
Stefan Werner (swerner) marked 5 inline comments as done.Thu, Jul 5, 12:36 PM
  • Removed whitespace change in unrelated code - let's keep this patch to the point.
Stefan Werner (swerner) marked 2 inline comments as done.Thu, Jul 5, 12:39 PM

The finite thing totally makes sense to do as a separate commit.

This revision is now accepted and ready to land.Thu, Jul 5, 12:41 PM
This revision was automatically updated to reflect the committed changes.