Nodes/ComfyUI-FuncAsTexture-CoiiNode/UV Coordinate Generator
ComfyUI Node

UV Coordinate Generator

A gradient you can tile — the humble node behind ComfyUI texture mapping

By CoiiChan·Created about a year ago·Updated about a year ago· 2
UV Coordinate Generator
    • IMAGE
    width256
    height256
    scale1.00

    This node doesn't look like much - feed it a width and height and it gives you back a smooth gradient. But that gradient is a UV map, and in the texture-mapping world it's the foundation everything else stands on. It's the first node in the pack's texture chain, and once you see the pattern, you'll reach for it constantly.

    The idea, borrowed straight from 3D material editors: encode a coordinate in the red and green channels. Red ramps 0→1 left to right (that's U), green ramps 0→1 top to bottom (that's V), blue stays at 0. Any image that looks like a smooth color ramp is secretly a map of positions, and a node like the pack's Texture Sampler can then use it to rearrange other images.

    How it works

    The source builds a meshgrid over torch.linspace(0, 1) in both axes, then applies a scale factor with a modulo - u = torch.fmod(x * scale, 1). That fmod is the whole trick: at scale = 1 you get one clean gradient across the image, but at scale = 2 the gradient wraps twice, so you get two full cycles of U and V. That's what makes the map tileable - scale is really "how many times the pattern repeats," which is how you'd drive a repeating texture.

    The inputs that matter

    Only three, all required, all obvious:

    • width / height - output resolution, 1–16384. The UV map doesn't need to be huge; it's data, not a picture. 256×256 is plenty for most work and keeps downstream nodes fast.
    • scale - 0–10, default 1.0. The tiling multiplier described above. At 0 you get a constant map, which is occasionally exactly what you want.

    Output is a single IMAGE. Wire it into the uvmap input of Texture Sampler, or into Inverse UV Map Generator if you're going down that road.

    Where it fits

    The pattern that makes this pack click: generate a UV map → distort it with math (Panner, Rotator, or a formula in CustomScript-NumPy) → sample your actual image through it with Texture Sampler. The gradient by itself is boring; the gradient distorted and used as a lookup table is how you get panning textures, radial effects, and warped projections without touching a 3D program.

    Install

    ComfyUI Manager → search "FuncAsTexture", or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/CoiiChan/ComfyUI-FuncAsTexture-CoiiNode
    # restart ComfyUI
    

    No models, no requirements.txt, no downloads. It lives under the FunctionAsTexture category.

    Gotchas

    • The map is channel-last and 0–1 by design. Don't be surprised that the preview looks like a flat gradient - that's the feature. If you preview it as an image it'll look washed out, because the blue channel is zero.
    • scale doesn't rescale the image, it multiplies the gradient before wrapping. Setting it above 1 gives repeats, not zoom.
    • Nothing downstream checks the resolution you chose. If you feed a 256×256 UV into a sampler working on a 1024×1024 texture, the sampler handles resizing on its own (Texture Sampler explicitly does). Just be aware the coordinate density changes.

    It's the pack's quietest node, but it's the one you'll actually use in every texture workflow - every time you start from "give me a coordinate field," this is where you begin.

    CategoryFunctionAsTexture

    Inputs (3)

    NameTypeDefaultDescription
    widthINT2561–16384
    heightINT2561–16384
    scaleFLOAT1.000–10

    Outputs (1)

    NameTypeDescription
    IMAGEIMAGE