ComfyUI Node

Sine

Sine is a tone curve, not a wave — the FuncAsTexture node that teaches you NumPy

By CoiiChan·Created about a year ago·Updated about a year ago· 2
Sine
  • imga
  • IMAGE
formularesult = np.sin(imga)

The name promises a waveform, and the reality is both more useful and more boring: Sine runs np.sin(imga) on every pixel and hands you an image. No API calls, no model files, no VAE swap - just math. It's one of the "derived nodes" in CoiiChan's ComfyUI-FuncAsTexture-CoiiNode pack, which is a fancier way of saying it's a pre-baked formula sitting on top of the pack's real workhorse, the CustomScript-NumPy node.

That main node is the whole reason the pack exists. The author built it as a ComfyUI take on the Custom node in Unreal Engine's Material Editor: instead of fiddling with blend-mode sliders and hoping, you write a multi-line NumPy formula and it runs against your images. Every other node in the pack - Sine, Subtraction, Max, HueShift, all of them - is just a saved formula with the inputs you don't need hidden away. Once you get that, Sine stops being a magic box.

What it actually does

Your image arrives as a float tensor in [B,H,W,C] shape with values from 0 to 1. The node converts it to a NumPy array, drops it in a namespace that already has np imported plus per-channel copies like imga_r, imga_g, imga_b and a makergb(r,g,b) helper, then exec()s the formula. Whatever you assign to result is the output, converted back to a tensor.

So result = np.sin(imga) applies sine to every pixel value. Here's the part that surprises people: over the 0–1 range, sin is monotonic and lands between 0 and about 0.84. It's a smooth nonlinear curve - a gentle grade that pulls the highlights down and keeps shadows near black. It is not the zigzag wave you picture when you hear "sine." To make actual ripples you'd feed coordinates into the main node, not this one. Sin of a pixel value is a tone curve.

The inputs that matter

There are exactly two, and one is optional:

  • formula (required): a multi-line text box, default result = np.sin(imga). Fully editable - this is the teaching bit.
  • imga (optional IMAGE): the image. Its size sets the output resolution.

The single output is an IMAGE in the same [B,H,W,C] space, ready to wire into a preview, a VAE decode, or another FuncAsTexture node.

When you'd actually reach for it

Honest answer: rarely as a standalone. Sine's real value is as a worked example. Because the formula field is live, you can open the node, swap np.sin(imga) for np.sqrt(imga) or np.clip(imga*1.2, 0, 1) and watch a whole family of tone curves in seconds - a poor-man's curves adjustment with zero extra nodes. If you're learning NumPy, this is the friendliest sandbox in ComfyUI. If you just want a rounded, less harsh brightening, sine does a decent imitation of a subtle S-curve on its own.

Installing it

No dependencies beyond what ComfyUI already ships (NumPy, PyTorch, PIL - there's no requirements.txt in the repo), and no model downloads. ComfyUI Manager is the easy path: search ComfyUI-FuncAsTexture-CoiiNode and install. Or do it by hand:

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

Restart ComfyUI and you'll find Sine under the FunctionAsTexture category.

Where you'll trip

Three things, all from reading the source. First, if you forget to assign result, the node silently returns a copy of your input - no error, just confusion. Second, unplug imga and you get a 512×512 array of zeros, and sin(0) is 0, so you get a black canvas. Feed it an image. Third, values outside 0–1 are legal for NumPy but the preview will clamp them, so if your formula makes things brighter than 1.0 the display won't show you what you computed. Sine itself stays in range, which is part of why it's a safe first formula to edit.

CategoryFunctionAsTexture

Inputs (2)

NameTypeDefaultDescription
formulaSTRINGresult = np.sin(imga)
imgaoptIMAGEOptional ,Reference size ,Default =(1,512,512,3)

Outputs (1)

NameTypeDescription
IMAGEIMAGE