Questions about renderEffect() and fx_colouradjust.
-
Hi!
I am back with a new question:
I was thinking of trying to change the colour of a sprite using the renderEffect function, and using the fx_coloradjust effect.
First of all, it would be nice to know what the parameters actually do. The Help page lists the parameters as
fx_colourAdjust [ biasR, biasG, biasB, unused, gainR, gainG, gainB, unused, curveR, curveG, curveB, saturation ]
But I can not find any place that describes what each parameter actually does? What is the difference between for example biasR, gainR, and curveR? Which values do they accept? If I only want to change one colour, I need the default values as well (that I could supply to make sure I do not change the other colours values).
Actually, I found this example in the forum, which changes the image to grey-scale by changing the saturation to 0:
renderEffect(image, framebuffer, fx_colouradjust, [ 0.5, 0.5, 0.5, 0, 0.5, 0.5, 0.5, 0, 5, 5, 5, 0 ])
...and I guess that I can use that as some sort of starting point.
And for my second question, I tried doing something like this:
shipImage = loadImage("Untied Games/Enemy small top C", false) newShipImage = createImage(imageSize(shipImage).x, imageSize(shipImage).y, false, image_rgba) renderEffect(shipImage, newShipImage, fx_colouradjust, [ 0.5, 0.5, 0.5, 0, 0.5, 0.5, 0.5, 0, 5, 5, 5, 1 ]) r = createSprite() setSpriteImage(r, newShipImage)
And this kind of works, as I get a new sprite r that has its colour adjusted. However, the new Sprite no longer has a transparent background, instead it has a solid colour behind it. Is there a way to do this that keeps the transparency from the original image?
And thirdly, I love that you have insisted on using British spelling for the colour commands. It's a nice touch!
-
Sorry that no one has replied to this yet. I wanted to try it for myself first. I don't think that anyone has tried using renderEffect on a sprite before (correct me if I am wrong people)
OK firstly the documentation on the renderEffect options needs expanding as there is very little detail on what all of the options do.
I did a bit of research on colo(u)r correction and I found this: https://www.sidefx.com/docs/houdini/nodes/vop/colorcorrection.html which I think covers the gain, bias and saturation but I am not sure about the "curve"
I also found this: "Gain affects color in the bright parts of the picture and Bias affects color in the dark parts of the picture"
Anyway it seems like this is not respecting the image transparency as you have noticed. I will raise an issue for this.
As for the British spelling, well we are British! Actually there are US spelling aliases for a lot of the built in colour functions though not it seems for the renderEffect constants.
-
Thanks!
Yeah, the loss of transparency feels a lot like a bug... I hope it gets fixed, even though I do understand that it might not have top priority.
-
Just out of curiosity, what is the basis of these RenderEffect functions? Are they built into the hardware or something?
Since you guys don’t seem to have 100% grasp on parameters and stuff, I am guessing you did not originally write them?
-
Well I didn't write them - I just did the help files. I will try to get some more information from the actual developers!
-
Bias - A value added to the given colour channel
Gain - A multiplier on the given colour channel, applied in order that it appears in the parameters, so this takes into account the bias
Curve - Gamma curve, increases or decreases the perceived contrast, applied separately to each colour channel. As if each colour channel were greyscale. 0 - inf
I hope this helps. Experimentation will likely lead to the best understanding of these parameters. Thanks for pointing out the transparency, and this post also highlights the fact that we need a better explanation of the individual parameters in the help that simply the names. I will raise an issue for this!
-
@Dave Beat you to it!
-
Thanks a lot, both of you! I really appreciate you taking the time to answer.
-
I too, am curious about the
renderEffect()
function and it's parameters. I have been playing with your example and have found that it is possible to restore the transparency using thefx_threshold
effect with a threshold of0.035
. This value I determined experimentally.newShipImage2 = createImage(imageSize(shipImage).x, imageSize(shipImage).y, false, image_rgba) renderEffect(newShipImage, newShipImage2, fx_threshold, [ 0.035 ])
It is also possible to generate a mask image from a source image to represent transparent regions. Applying a mask requires some extra work changing blend modes (with the
setBlend()
function) while drawing the image however, so it may not be compatible withdrawSprites()
-
@Gothon, that’s very interesting findings. I will do some more experimenting myself. Thanks!
-
@vinicity ...and there was a post https://fuzearena.com/forum/topic/470/using-multiple-render-effects about combining the effects.