Nodes/ComfyUI-Leputen-Utils/Normal Map Format Converter
ComfyUI Node

Normal Map Format Converter

The DirectX vs OpenGL normal map flip

By lilquail·Created 9 months ago·Updated 9 months ago· 1
Normal Map Format Converter
  • image
  • IMAGE
flip_xfalse
flip_ytrue

Here's the single most annoying fact of normal map life: the green channel's Y axis points up in OpenGL convention (Y+) and down in DirectX convention (Y−). Plug a map made for one convention into an engine that expects the other, and your lighting goes "inside out" - bumps look like dents, the sun appears to come from below, and nothing you tweak in the material fixes it. Normal Map Format Converter is a two-toggle fix: it flips the green channel, and optionally red, converting your map between DirectX (Y−) and OpenGL (Y+) with zero quality loss, because it's just a channel inversion.

You'll reach for this constantly if you work across tools. DeepBump generates in one convention, Unity HDRP wants another, Unreal another still, and the pack's own README calls it out: if your shadows look wrong, flip the Y channel before touching anything else.

How it works

The conversion is a simple per-channel inversion: channel = 1 - channel. Flip Y and your green channel inverts, converting between the two conventions. That's the entire mechanism, which is exactly what you want from a converter - no resampling, no math that could introduce error.

Two booleans, and they're both self-explanatory:

  • flip_y - inverts green. This is the one that matters: it's the DirectX/OpenGL switch. Note the default is on, so the node converts by default rather than passing through.
  • flip_x - inverts red. The tooltip is honest about this: rarely needed, only for engines with non-standard X conventions. Leave it off unless you specifically know your target is weird.

One IMAGE in, one IMAGE out.

The trap: flip_y defaults to true

This is worth saying plainly because it's the #1 way people get tripped up. If you drop this node into an existing workflow just to "convert," the default state will flip your green channel - so a map that was already correct comes out backwards. If you actually want a pass-through, uncheck flip_y. Conversely, if you did want the conversion and skip it because you assumed defaults were a no-op, you'll be chasing the exact inside-out lighting bug you were trying to fix.

How to know which way you're going

There's no reliable label on most files, so the practical test is fast: convert, render, compare. The wrong convention produces that unmistakable dented look; the right one doesn't. Once you know what your engine wants, the flip becomes a muscle-memory step. If you're generating normal maps with this pack's DeepBump nodes, the README flags that they and your target engine may disagree - run the converter between them and settle it in one render.

Install

Leputen Utils is lilquail's Windows-oriented texture toolkit. Install with ComfyUI Manager (search "ComfyUI-Leputen-Utils") or:

cd ComfyUI/custom_nodes
git clone https://github.com/lilquail/ComfyUI-Leputen-Utils

Restart ComfyUI. This node is a channel operation on tensors - no DeepBump, DDS, or ONNX dependencies involved, so it works even if the pack's heavier siblings fail to set up on your machine.

CategoryLeputen-Utils/NormalMap

Inputs (3)

NameTypeDefaultDescription
imageIMAGEThe normal map image to convert.
flip_xBOOLEANfalseInvert the Red (X) channel. Rarely needed - only for engines with non-standard X conventions.
flip_yBOOLEANtrueInvert the Green (Y) channel. Enable to convert between DirectX (Y-) and OpenGL (Y+) formats.

Outputs (1)

NameTypeDescription
IMAGEIMAGE