Skip to content

CSS & GPU Rendering ​

This page explains how blendcss translates standard CSS into hardware-accelerated Blender GPU rendering, how HiDPI and anti-aliasing work, and where RmlUi CSS differs from web browsers.

RmlUi 6.4 + blendcss CSS preprocessor ​

Under the hood, blendcss uses RmlUi 6.4 (a lightweight C++ HTML/CSS engine) paired with a Python CSS preprocessor inside UICssDocument. The preprocessor bridges common web CSS habits so you can write familiar stylesheets:

What you write in CSSWhat blendcss does for you
padding: 12px; font-size: 11px;Converts px to dp (density-independent pixels) when hi_dpi = True so UI scales cleanly with Blender's UI Scale
:root { --my-color: #fff; }Translates :root to RmlUi's root selector automatically
background: linear-gradient(...)Rewrites linear-gradient, radial-gradient, conic-gradient, and repeating-* variants into RmlUi shader/decorator syntax
font-weight: semibold;Maps named keywords (thin, light, medium, semibold, extrabold, black) to numeric weights (100–900)
@font-face { ... }Extracts and registers the font file with FreeType automatically
cursor: pointer;Maps 25+ CSS cursors to Blender's native window cursors (HAND_POINT, SCROLL_X, TEXT, STOP, etc.)

Visual effects rendered by custom GPU shaders ​

Beyond RmlUi's built-in geometry, blendcss runs custom Blender GLSL shaders (css_shaders.py) for modern UI effects:

  • Rounded overflow clipping: overflow: hidden combined with border-radius clips child elements (including images and progress fills) cleanly to rounded corners.
  • Blurred box shadows: box-shadow renders smooth soft shadows.
  • Backdrop blur: backdrop-filter: blur(...) blurs content behind translucent surfaces.
  • Gradients & text shadows: Hardware-accelerated gradients and text-shadow.

Anti-aliasing (SSAA) and crisp HiDPI typography ​

Drawing thin 1px borders and rounded corners directly onto a 2D viewport can look jagged. blendcss uses single-pass SSAA (supersampling anti-aliasing) by default:

  • anti_aliasing = True and scale = 4.0 render shapes cleanly onto an offscreen buffer and box-resolve them to the N-Panel.
  • Text is rasterized by FreeType at 1:1 physical pixel alignment so small 10px–12px Blender UI labels stay sharp instead of blurry.
  • hi_dpi = True automatically reads Blender's UI scale (OS DPI × Resolution Scale) via BlenderTheme.get_ui_scale() and passes it to RmlUi as dp_ratio.

If you have a very tall or animation-heavy panel and want lower GPU fill cost, you can lower scale (for example scale = 2.0) or set anti_aliasing = False on your Panel subclass.

Key differences from browser CSS ​

Because RmlUi is a focused UI engine rather than a full browser, keep these differences in mind:

  • Use Flexbox, not CSS Grid: display: flex, flex-direction, flex-wrap, justify-content, align-items, gap, and flex: 1 are fully supported. display: grid is not supported.
  • Border shorthand omits solid: Write border: 1px var(--bl-border-subtle); instead of border: 1px solid ....
  • Alpha in rgba() is 0–255: RmlUi expects rgba(255, 255, 255, 128) (0–255 alpha) or 8-digit hex #ffffff80.
  • SVG tinting uses image-color: Style inline <svg> icons with image-color: var(--bl-accent); rather than fill or color.
  • No JavaScript: All interactivity lives in Python (on_click, @blendcss.on, bind_*, and draw() / on_sync()).

Live Blender theme synchronization ​

When sync_theme = True (the default), BlenderTheme.read_live_theme() inspects Blender's active theme (supporting both Blender 4.x panelcolors and Blender 5.x user_interface.panel_* APIs). On each frame, UICssDocument.sync_theme() performs an O(1) signature check and only updates CSS variables and @media (theme: dark | light) rules when the user actually changes their Blender theme.

Released under the GNU GPL v3.0 License.