Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
replicating grain extract in blender using nodes
I tried to use the Formula in the manual but the results are similar to when I use Subtract and Addition Modes in Gimp when using MixRGB Nodes in Blender.
 I tried separating the RGB channels and did a straight up calculation on each channel and the results look to washed out. 

I looked in the code at github and is says:

[blendModeKeys.GRAIN_EXTRACT]: (i, m) => (
i - m + 0.5

I attached a pic of the Node Setup and the results and what it should look like.
Anybody know what the problem is?

Attached Files Thumbnail(s)
Are you working in "Linear space" or in "Perceptual"?

Originally, Gimp worked in a gamma-corrected perceptual space: The 255 available values per channel do not represent the level directly, but are  a function of it (about a square root: but 1/2.24instead of 2). This gives more level points to distinguish the darks (the middle gray, is around 180 instead of 128). And all computations were done directly on these values.

When you use a [0.0 ... 1.0] scale, you are using floating point and are not limited  by the number of distinct value points, so your values can represent the level directly.

The I-M+0.5 formula was applied directly on the gamma corrected values

gamma( R ) = gamma( I ) - gamma( M ) + 0.5

But in linear space you do:
gamma( R ) = gamma( I - M + 0.5 )

(in the second case the gamma isn't applied on the stored values, but applied when passing the data to the display (or exporting to JPEG/PNG)

 There is a way to tell if this is your problem: in Gimp 2.10 the "legacy" blend modes(*) are applied on the linear values as if they were gamma corrected, so if the legacy Grain Extract produces the same result as your Blender computation, you are doing the computation on lianear values.

(*) this is the small selector at the end of the blend mode selector in the Layers list, Wilber's head switching the modes to "legacy". You also get a (l)  in the mode name: [Image: ecca5fV.png]
Big Grin 
Yep Gamma was the issue!!  You need to set the Image Texture Nodes from sRGB to Linear, Raw, or Non-Color, and after the equation, stick a Gamma Node at the end of it and set it to 2.2 to 2.5. You don't even need Math Nodes it works for MixRGB as well.

Forum Jump: