Important: Please read the Qt Code of Conduct -

Qt5 Scene Graph custom geometry and gradients

  • Hi,

    Is there any other way to apply gradients to custom geometries in scene graph than creating custom material and own shader programs? Is their some material similar to QSGFlatColorMaterial with a gradient property that can be set?


  • Hi,
    As far as I know there isn't such class in Qt. However depending on the gradient you want to achieve it shouldn't be too hard to write your own material and shader program.

  • Thanks unai_i! Do you have any example on how this could work? Maybe this kind of general stuff could be already implemented in the ready made materials in the future?

  • I don't really have an example as the code will highly depend on the kind of shape and gradient you are trying to achieve. The easiest way is to use QSGGeometry::ColoredPoint2D for your vertices data and to adjust their color and placement in such way that when color is interpolated between vertices in fragment shader you get your desired gradient. I don't know if this will be implemented in ready made materials in the future.

Log in to reply