Page 1 of 1

[2.1] Updating hlms properties during runtime

Posted: Wed Aug 21, 2019 11:10 am
by gabbsson
Hello!

A while back I created my own implementation for unlit and PBS to add some custom stuff, namely clipping and different polygon modes (wire frame for example). I did this by also creating custom datablocks (which inherit from the unlit and pbs datablocks respectively) and added my own variables for isClipped and polygonMode. This way clipping is done per datablock, so that I can "turn it off and on", even if all clipped objects are clipped the same.

The variables are read in the custom hlms calculateHashForPreCreate and setPropertys are called on the variables.
In other words no data is being sent based on the variables (clipping planes are later sent using a listener).

The issue is if I change the variables of the datablock it does not trigger a new shader to be compiled, which honestly doesn't feel all that surprising after thinking about it. Nothing is really checking if the values are being changed. So I'm assuming there is a way to let the hlms know it needs to create a new shader based on the datablock that now has updated values.
I read the manual for HLMS and still could not find what I am looking for.

So to summarize: The implementation works great if nothing changes during run-time, but I want to be able to change whether or not a datablock should be clipped after creating it.

I've also considered that perhaps this is not the intended way to use datablocks, and that I should instead create datablocks from the start with different values set. A more "everything is created at start, nothing can change during run-time" approach.

Any insight would be appreciated!

Cheers

Re: [2.1] Updating hlms properties during runtime

Posted: Wed Aug 21, 2019 12:37 pm
by xrgo
hi! you have to call flushRenderables();

Re: [2.1] Updating hlms properties during runtime

Posted: Wed Aug 21, 2019 2:05 pm
by gabbsson
xrgo wrote: Wed Aug 21, 2019 12:37 pm hi! you have to call flushRenderables();
Perfect! Thank you!