-2

How to pass an uniform value into vertex and fragment shaders?

I know that something like that is possible in QMaterial:

self.colorParameter = Qt3DRender.QParameter("color", color)
self.addParameter(self.colorParameter)

Is there any other way?

My goal is to pass some uniform values and change them from time to time.

Matphy
  • 1,086
  • 13
  • 21

1 Answers1

1

As @Florian Blume suggested, I am posting my answer:

class MyMaterial(Qt3DRender.QMaterial):
    def __init__(self, parent):
        super().__init__(parent)
        # some code ...

        self.parameter_position = Qt3DRender.QParameter("position", QVector3D(0, 0, 0))
        self.addParameter(self.parameter_position)

    def update_position(self, position):
        self.removeParameter(self.parameter_position)
        self.parameter_position.setValue(position)
        self.addParameter(self.parameter_position)
Matphy
  • 1,086
  • 13
  • 21