Navigation

    Fuze Arena Logo
    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Popular
    • Users
    • Groups
    • Help
    • Discord

    Questions about renderEffect() and fx_colouradjust.

    Beginners
    5
    11
    446
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • vinicity
      vinicity F last edited by

      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!

      1 Reply Last reply Reply Quote 0
      • pianofire
        pianofire Fuze Team last edited by pianofire

        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.

        1 Reply Last reply Reply Quote 2
        • vinicity
          vinicity F last edited by

          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.

          1 Reply Last reply Reply Quote 0
          • vinicity
            vinicity F last edited by

            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?

            1 Reply Last reply Reply Quote 1
            • pianofire
              pianofire Fuze Team last edited by

              Well I didn't write them - I just did the help files. I will try to get some more information from the actual developers!

              1 Reply Last reply Reply Quote 0
              • Dave
                Dave Fuze Team last edited by

                @vinicity

                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!

                pianofire 1 Reply Last reply Reply Quote 0
                • pianofire
                  pianofire Fuze Team @Dave last edited by

                  @Dave Beat you to it!

                  1 Reply Last reply Reply Quote 1
                  • vinicity
                    vinicity F last edited by

                    Thanks a lot, both of you! I really appreciate you taking the time to answer.

                    1 Reply Last reply Reply Quote 1
                    • Gothon
                      Gothon F last edited by

                      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 the fx_threshold effect with a threshold of 0.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 with drawSprites()

                      vinicity 1 Reply Last reply Reply Quote 4
                      • vinicity
                        vinicity F @Gothon last edited by

                        @Gothon, that’s very interesting findings. I will do some more experimenting myself. Thanks!

                        1 Reply Last reply Reply Quote 0
                        • spikey
                          spikey F last edited by spikey

                          @vinicity ...and there was a post https://fuzearena.com/forum/topic/470/using-multiple-render-effects about combining the effects.

                          1 Reply Last reply Reply Quote 2
                          • First post
                            Last post