gr7.76 Posted December 21, 2020 Share Posted December 21, 2020 Hello I apologize, this has problaby been asked before, buit I cannot find anything in the forum or in the docs. Which variant is faster "void Material::setState ( int num, int value )" or "void Material::setState ( const char * name, int value )"? And in case it's the first one, where do I find the values for the variable "num"? I looked for it in UnigineMaterial.h, but did not find anything. Link to comment
andrey-kozlov Posted December 21, 2020 Share Posted December 21, 2020 Hello @gr7.76, String version does int id = findState(name); if (id != -1) setState(id, value); So you may cache this id and reuse it latter. Although the main performance considiration about setState is that it leads to shader recompilation which may cause spikes. So it's usually recommended to change states only at moments when spikes are acceptable (e.g. when rendering settings are changed) Link to comment
Recommended Posts