Author Topic: how to select uniform in renderhook  (Read 285 times)

Offline MichaelJPCT

  • long
  • ***
  • Posts: 215
    • View Profile
how to select uniform in renderhook
« on: January 13, 2020, 07:39:23 am »
Hi Egon,
if multiple objects share a shader, i must set a renderhook to apply a uniform to an object. the question is ,how to select the correct uniform to an object?
i have an array of objects and an array of uniforms.
i need an ID for each object right?
currently i use object3d.set/get transparency like an id to select uniforms. it works, but i dont think this is the formal way.
i see object3d.getid, but this id is different from the id in my array. should i map these 2 types of id's? is it the formal way to select uniforms?

thanks for your support.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12081
    • View Profile
    • http://www.jpct.net
Re: how to select uniform in renderhook
« Reply #1 on: January 14, 2020, 09:20:07 am »
There's no formal way. You could extend Object3D and add your uniform to it, or you could use http://www.jpct.net/jpct-ae/doc/com/threed/jpct/Object3D.html#setUserObject(java.lang.Object) to add some context instance to your object. That's a little bit dodgy, but it might do the trick.

Offline MichaelJPCT

  • long
  • ***
  • Posts: 215
    • View Profile
Re: how to select uniform in renderhook
« Reply #2 on: January 15, 2020, 06:31:57 am »
thanks, i think these ways can all work.