wowserhq / wowser

World of Warcraft in the browser using JavaScript and WebGL
MIT License
238 stars 63 forks source link

Excessive CPU time spent on WebGLRenderer.setProgram #153

Open fallenoak opened 8 years ago

fallenoak commented 8 years ago

Even when a scene has fully loaded and the camera is stationary, uniform uploads seem to be burning a rather large amount of CPU time. What's happening?

fallenoak commented 8 years ago

I might be mistaken on this... it looks like the flag goes away once the group is rendered once. However, something is clearly burning cycles on uniform updating...

fallenoak commented 8 years ago

The biggest culprit might be context switches between different textures (ie calls to bindTexture and activeTexture). In particular, probably because of layering, terrain tends to cause a lot more of these calls than, say, a few WMOs or doodads.

Not sure what the best way to reduce these context switches would be.

fallenoak commented 8 years ago

It would appear that objects with transparent materials are sorted by depth, whereas opaque objects are sorted by material. We're overusing transparent materials for M2s: the no-backface-culling flag and blending mode 1 both cause transparent flagging, even though neither case ought to necessitate it.