From BlenderWiki

Jump to: navigation, search

Results of my GSoC

Here you can find an overview of my work, done during GSoC 2016. I worked on the Cycles render engine and improved its texture system.

Most changes are in master already, and will be part of the upcoming Blender 2.78 release. You can find more details inside the commit logs.

My GIT branch soc-2016-cycles_images can be found here: https://developer.blender.org/diffusion/B/browse/soc-2016-cycles_images/

CUDA Texture Objects

CUDA can now use more textures and different types

Summary: I implemented support for CUDA Texture Objects into Cycles, to increase the maximum amount of textures that can be used on modern GPUs.

Background: In the early days of 2011, when Cycles was announced, the Geforce 4xx/5xx GPUs were the newest ones on the market. They only supported a fixed amount of textures (128 to be precise). With the Geforce 6xx series (Kepler), nvidia increased this limit to 256, but at the same time they added Texture Objects (also known as Bindless Textures), which allows an almost infinite amount of textures. I added support for these, to eliminate this limit artists were experiencing when rendering with their CUDA GPUs. The new limit is 1024 per texture type, but that is just a single value, which can be increased further when needed. The old (fixed amount) way for Fermi cards was kept for compatibility.

Code commit: c9f1ed1e


Single Channel Textures

Less memory usage - Tornado from Cosmos Laundromat

Summary: I lowered the memory usage for single channel (black/white) textures in Cycles, by supporting single channel texture storage.

Background: Cycles stored each texture in a float4 or byte4 buffer before. When using textures which only require 1 channel (e.g. black/white bump maps, or volume density), we therefore wasted quite some memory. I implemented single channel texture support.

This cuts the memory usage for such cases by 3/4, as we only need a single channel. Smoke (density, flame and heat attributes) use this automatically, for image textures, make sure to save the texture as single channel (e.g. in Gimp via Image -> Mode -> Grayscale).

Code commits: 4a4f043b, 3c85e1ca, rB5c0a67b325b2


Half Float Textures

Less memory usage - Comparison by nudelZ

Summary: I implemented half float texture storage, to lower memory usage, when we don't need 32 bit precision.

Background: It's not necessary to save data with full float precision sometimes, that's the reason why there is a half float datatype. I added support for half float textures in Cycles, which is now used to lower the memory usage for Half Float OpenEXR textures (e.g. High Dynamic Range backgrounds).

Code commit: rB6311a9ff234a


Float Storage for OpenCL

Improved dynamic range on OpenCL GPUs

Summary: I implemented float texture storage on OpenCL devices (e.g. AMD GPUs), to properly support High Dynamic Range textures.

Background: When rendering on a OpenCL GPU, Cycles didn't support float textures before, which resulted in a greatly diminished dynamic range, when e.g. lighting the scene with a HDR background.

Code commit: 76481eae


Internal code work

Before working on the bigger targets, I cleaned up some code and re-factored parts of Cycles Image internals to make it easier to add the new features.

  • Move Texture definitions to /util. (9c916b01)
  • Refactor Image Texture limits. Instead of treating Fermi GPU limits as default, and overriding them for other devices, we now nicely set them for each platform. (557544f2)
  • Refactor Cycles ImageManager arrays, to reduce code duplication and make the ImageManager more easily extendable. (36d8a70b)
  • Some variable renaming to distinguish between 4 and 1 channel texture types. (3807bcb3, 9a1e1126)

Work in Progress / ToDo

Memory Statistics

Cycles can output many information about memory usage, but these are a bit hidden from the user (start Blender with a parameter, e.g. ./blender --debug-cycles). We want to have this information inside of Blenders Interface, and therefore I am working on a new Statistics Editor inside of Blender. A design has been discussed here: Cycles Memory statistics in Blenders UI and I started to implement the editor.

WIP Code commits: rBa00890deb70d, rB7e97dd76f8d1

Mipmaps

Unfortunately I didn't start my work on mipmaps yet, due to focusing on university for some weeks, but I am fully committed to implement them later this year.

Half Float Textures

  • Make half float work for OpenCL devices, WIP patch available here.
  • More data can be saved into the half float storage slots, e.g. Volume data or Vertex Normals. I will finish these soon.

Acknowledgements

It's been a great time again and a lot of fun to work on Cycles during this Google Summer of Code. I want to thank

  • Ton, my mentor, for guidance and support.
  • Brecht and Sergey, for code review, code support and generally for being awesome!