gum-raylib-rendering

Diagnoses blend-mode and render-target alpha issues in RaylibGum's rendering pipeline.

614|78|Updated Mar 11, 2015
One-click install
npx skills add https://github.com/vchelaru/Gum --skill gum-raylib-rendering
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: gum-raylib-rendering
Source: https://github.com/vchelaru/Gum/tree/main/.claude/skills/gum-raylib-rendering
Command: npx skills add https://github.com/vchelaru/Gum --skill gum-raylib-rendering

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Translucent Gum content rendered through the raylib backend can appear darker in-game than in the Gum tool, and developers struggle to trace whether the fault lies in their own compositing code or in the renderer's blend-mode handling.

Core Features & Use Cases

  • Pipeline Architecture Map: Explains how Renderer.Draw routes scissor, blend, and shader state changes through BatchDrawCallCounter, and why per-element renderables wrap draws in BeginBlendMode/EndBlendMode.
  • Known Gap Documentation: Details how Blend.Normal and Additive bypass the render-target premultiply pass in BeginRenderTargetBlend, tracked in issue #4204.
  • Alpha-Channel Gotcha Analysis: Explains why raylib's canned BlendMode.Alpha produces incorrect destination alpha, causing darkening when a render target is composited a second time.
  • Use Case: A host application bakes Gum's draw output into its own RenderTexture2D and blits it to the window; translucent regions look darker than in the Gum tool, and this Skill identifies the double-alpha multiplication as the cause and prescribes a replace-copy composite.

Quick Start

Explain why my translucent Gum UI looks darker in my raylib game than in the Gum tool and how to fix the compositing pass.

Frequently Asked Questions about gum-raylib-rendering

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
Why does translucent Gum content look darker in my raylib game than in the Gum tool?

Raylib's BlendMode.Alpha applies the same SrcAlpha/OneMinusSrcAlpha factors to the alpha channel, leaving the render target's alpha below 255. When your game composites that target a second time weighted by its alpha, translucent regions darken. Use a straight replace-copy or flatten the alpha first.

How does RaylibGum handle blend modes during rendering?

Renderer.Draw routes all blend state changes through BatchDrawCallCounter, and per-element renderables like Sprite, NineSlice, and Text call BeginBlendMode/EndBlendMode whenever Blend.HasValue. Since StandardElementsManager assigns Blend.Normal by default, this path fires for virtually all content.

Does the raylib backend share rendering code with the MonoGame backend?

No, raylib uses its own renderer with BatchDrawCallCounter and BlendModeExtensions, while MonoGame, KNI, and FNA go through a different renderer entirely. The MonoGame render-target gotcha is documented in docs/code/rendering/gumbatch.md, but raylib has no equivalent documentation yet.

What is the known limitation of BeginRenderTargetBlend in RaylibGum?

BeginBlendMode calls TryGetSimpleRaylibBlendMode first, which maps Blend.Normal and Additive directly to canned raylib blend modes without checking _renderTargetBlendActive. Only Replace, ReplaceAlpha, SubtractAlpha, and MinAlpha reach the premultiply-aware path, so the protection never engages for ordinary translucent content. Tracked in issue #4204.

When does the raylib alpha-channel bug not occur?

Single-pass compositing is unaffected because the color channels are still computed correctly. The Gum tool and gumcli screenshot --backend raylib never re-consume the leftover alpha, so the darkening only appears when a host application composites the render target a second time.