DiffBMP: Differentiable Rendering with Bitmap Primitives

Seongmin Hong, Junghun James Kim, Daehyeop Kim, Insoo Chung, Se Young Chun

TL;DR

DiffBMP is a highly parallelized, scalable differentiable rendering engine designed specifically for bitmap (raster) images rather than vector graphics. By leveraging custom half-precision CUDA kernels, it can optimize the position, scale, rotation, color, and opacity of thousands of bitmap primitives in under a minute on a consumer GPU, opening up new creative workflows like automated graphic mosaics and text-to-image generation using raster assets.

What Problem Does This Paper Address?

Differentiable rendering has revolutionized inverse graphics by allowing gradients to flow from a rendered output image back to scene parameters (like 3D meshes, voxels, or 2D vector paths). However, a critical gap remains in the 2D domain: existing popular frameworks like DiffVG are strictly constrained to vector graphics (SVGs).

The vast majority of real-world visual assets are bitmaps (discrete arrays of pixels like PNGs or JPEGs). Trying to use vector renderers for bitmap assets requires complex vectorization that causes performance to tank. Directly optimizing bitmap transformations is historically difficult because bitmaps are discrete and high-dimensional, imposing massive memory overheads and suffering from severe gradient sparsity (gradients only exist at the exact boundaries of the image). DiffBMP addresses this scalability and optimization bottleneck.

Figure 1. Explore the new creative horizons opened by DiffBMP. Essentially, DiffBMP makes the position, rotation, scale, color, and opacity of arbitrary bitmap images differentiable (e.g., a fingerprint or the ‘Seurat’ autograph in a). This capability extends operations previously limited to vector graphics to any bitmap primitive (e.g., b: intrinsic-preserving graphic assemblage of Marilyn Monroe using numerous brand logos). DiffBMP is highly flexible and expandable, so that it can process videos, spatially constrained images, or both simultaneously, as shown in c(3, 4). Moreover, DiffBMP outputs 2D layers in an editable format (.psd), enabling diverse post-processing creation, as the blooming effect in c(1-3). The various image/video creations, including c, can be viewed in the supplementary video. GPU VRAM usage and runtimes were measured on an NVIDIA RTX 3090. Note that c’s runtime excludes post-processing.

Methods

The authors introduce an end-to-end differentiable module tailored for raster primitives, structured around several key innovations:

  • Custom Tile-and-Bin CUDA Pipeline: To handle thousands of primitives efficiently, DiffBMP partitions the image plane into $T \times T$ tiles. Primitives are assigned to tiles via a CPU bounding-box check, and a GPU thread block is launched per tile to cooperatively stage parameters and perform front-to-back alpha compositing.
  • Half-Precision (FP16) Arithmetic: The backward pass utilizes packed half2 buffers and atomic operations (half2 atomicAdd) to drastically reduce VRAM footprint and memory bandwidth requirements.
  • Soft Rasterization (Blurring): To counteract gradient sparsity caused by standard bilinear pixel sampling, DiffBMP applies a Gaussian blur to primitives before optimization. This enriches and broadens the spatial gradient paths.
  • Structure-Aware Initialization: Instead of random placement, primitives are initialized based on the local variance of the target image. High-variance (highly detailed) regions receive smaller, denser primitives, while smooth regions get larger, sparser ones.
  • Noisy Canvas: To prevent primitives from avoiding regions that match a solid background color, the system can blend a uniform noise background during training, forcing primitives to fill out the entire canvas.
Figure 2. An illustration of the algorithm flow of DiffBMP. Our core contribution is the renderer for bitmap images, introduced in Sec. 3.1, which enables scalable and efficient differentiable rendering using a custom CUDA kernel. Additionally, we employ soft raster- ization (Sec. 3.2.1) for improved gradient propagation and an initialization technique (Sec. 3.2.2) for better target approximation. After optimization, a native, layered file is generated, which enables diverse post-processing creation.

Datasets

As an optimization-based rendering framework rather than a deep learning model, DiffBMP does not require a traditional training dataset. For evaluation and creative demonstrations, the authors utilized:

  • Standard target images (e.g., paintings by Georges Seurat, photographs of Marilyn Monroe).
  • A public Kaggle Brand Logos Dataset (Khandekar, 2021) containing 300 brand logos used as the bitmap primitives for graphic assemblages.
  • Short video sequences to test the dynamic/sequential video optimization heuristics.

Key Insights and Ideas

  • Vector Renderers Fail at Raster Complexity: Even if you vectorize a bitmap into complex SVG curves to use a tool like DiffVG, the analytical gradient calculations become a massive computational bottleneck, leading to poor image fidelity (low PSNR) and slow runtimes. Treating primitives purely as rasters maintains consistent performance regardless of internal asset complexity.
  • Gradient Sparsity is the Enemy: In bitmap optimization, gradients typically only appear at object boundaries because the internal pixels of a primitive often have uniform or smoothly interpolating values. Pre-blurring the assets provides a continuous gradient ramp that guides the optimization smoothly from a distance.
  • Workflow Integration Matters: Differentiable renderers shouldn't just exist in a vacuum. DiffBMP includes a dedicated export kernel that bypasses the backward pass to output the final optimized composition directly into a native, layered .psd file, allowing artists to immediately post-process the layers in tools like Photoshop.

Key Results

  • Speed and Memory Efficiency: Compared to a naive PyTorch baseline, DiffBMP's custom CUDA-16bit implementation achieves massive speedups. For a $2048 \times 2048$ image resolution, the PyTorch baseline takes over 5.4 seconds for a forward pass and 9.4 seconds for a backward pass, consuming 9.0 GB of VRAM. DiffBMP handles the same workload in 9.0 ms (forward) and 6.4 ms (backward) while using only 3.8 GB of VRAM.
  • Fidelity vs. Vector Renderers: When reconstructing complex graphics, DiffVG achieved a PSNR of only 14.35 dB after 477 seconds. DiffBMP achieved 23.35 dB in just 115 seconds.
  • Text-to-Raster Art: By coupling DiffBMP with CLIP losses, the framework successfully generates complex compositions from text prompts (e.g., "A witch flying on a broomstick") using arbitrary bitmap primitives.

Limitations and Future Work

  • Strict GPU Requirement: Unlike vector renderers that can fall back to CPUs, DiffBMP's architecture is fundamentally tied to custom CUDA kernels due to the high memory and parallel processing demands of raster data structures.
  • Hyperparameter Sensitivity: The optimization process can be sensitive to initialization and hyperparameter choices, occasionally getting trapped in local minima. Automating hyperparameter selection based on the target image and primitive types is a key area for future research.
  • Autoregressive/RL Drawing: The authors suggest that DiffBMP provides a critical foundation for future work applying reinforcement learning or first-order optimization to autoregressive drawing and painting agents.

Summary updated

BibTeX
@inproceedings{hong2026diffbmp,
  author = {Seongmin Hong and Junghun James Kim and Daehyeop Kim and Insoo Chung and Se Young Chun},
  title = {{DiffBMP: Differentiable Rendering with Bitmap Primitives}},
  booktitle = {IEEE/CVF Conference on Computer Vision and Pattern Recognition},
  year = {2026},
  url = {https://openreview.net/forum?id=efo2tb2CGf},
}
Figure