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 CSS | What 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: hiddencombined withborder-radiusclips child elements (including images and progress fills) cleanly to rounded corners. - Blurred box shadows:
box-shadowrenders 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 = Trueandscale = 4.0render 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 = Trueautomatically reads Blender's UI scale (OS DPI × Resolution Scale) viaBlenderTheme.get_ui_scale()and passes it to RmlUi asdp_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, andflex: 1are fully supported.display: gridis not supported. - Border shorthand omits
solid: Writeborder: 1px var(--bl-border-subtle);instead ofborder: 1px solid .... - Alpha in
rgba()is0–255: RmlUi expectsrgba(255, 255, 255, 128)(0–255 alpha) or 8-digit hex#ffffff80. - SVG tinting uses
image-color: Style inline<svg>icons withimage-color: var(--bl-accent);rather thanfillorcolor. - No JavaScript: All interactivity lives in Python (
on_click,@blendcss.on,bind_*, anddraw()/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.