-
Hi! I want to bind some uniforms manually, either from a world parameter or with an arbitrary value. I think I need UBOs for that, but I didn't find the correct path in the code. Do you know how to do it ? Something like the code here: def __init__(self, plugins=[]):
# [...]
self.parameters.world['ParamGlobal'] = Parameter(0, Type.FLOAT)
def do_render(self, resolution, scene, is_final_render, is_new_frame):
#CustomMaterial.shader['MAIN_PASS'].uniforms['paramLocal'] = 5.0
#CustomMaterial.shader['MAIN_PASS'].uniforms['paramGlobal'] = self.parameters.world['ParamGlobal']
self.draw_screen_pass(CustomMaterial.shader['MAIN_PASS'], self.renderTarget) As an additional related question, do you know how to get the current value of a parameter ? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
You can do: CustomMaterial.shader['MAIN_PASS'].uniforms['paramLocal'].set_value(5.0) If you modify the value after binding the material you would have to call GLUniform.bind too: CustomMaterial.shader['MAIN_PASS'].uniforms['paramLocal'].bind() Here's the GLUniform class: For an example on how to use UBOs, you can check the CommonBuffer: |
Beta Was this translation helpful? Give feedback.
You can do:
If you modify the value after binding the material you would have to call GLUniform.bind too:
Here's the GLUniform class:
https://github.com/bnpr/Malt/blob/Development/Malt/GL/Shader.py#L77
For an example on how to use UBOs, you can check the CommonBuffer:
https://github.com/bnpr/Malt/blob/Development/Malt/Render/Common.py