getShaderParameter use too much time!

shaders

#1

I use chrome dev tool to profile my game, and found the function getshaderParameter function use too much time, this makes my game slow。

This is the picture from chrome dev tool, https://imgur.com/IAkvkIJ
and the call trace:
https://imgur.com/T4cbaPS

Obviously, this is related to render stuff, but I would like to know more about this function, why it takes so long time to execute, which exactly object in my scene cause this problem? which shader ?
Maybe related to show some more other object ? cause right after the timeline, the game about show another object.

I would like to hear from you guys


#2

WebGLRenderingContext.getShaderParameter() is only called when a shader program is compiled. This normally happens when a material is used for the first time. three.js uses getShaderParameter() to verify the compilation status of shaders. If it was not successful, an error message is logged.


#3

If you’re seeing it called frequently (e.g. after the scene has started rendering), are you setting material.needsUpdate = true or creating materials during the render loop? Try to avoid both of those.


#4

Yes, it is. so I make my preload object render once, so it will not consume much time when it shows again.
It will be great if the FBXLoader has the feature to preload material


#5

WebGLRenderer.compile() might be the method you are looking for.