使用常识Compute only things that you need; anything that is not actually needed can be eliminated. For example, supporting per-material color is nice to make a shader more flexible, but if you always leave that color set to white then it's useless computations performed for each vertex or pixel rendered on screen.仅仅计算你所需要的部分,消除任何实际上不必要的部分。例如,支持逐材质着色是一件非常好的事情,并且这样做可以让着色器更加灵活易用,但是如果你总是将颜色设置为白色,那么逐顶点或逐像素的计算将是无用的。Another thing to keep in mind is frequency of computations. Usually there are many more pixels rendered (hence their pixel shaders ***cuted) than there are vertices (vertex shader ***cutions); and more vertices than objects being rendered. So generally if you can, move computations out of pixel shader into the vertex shader; or out of shaders completely and set the values once from a script.还有一件需要注意的事情是计算频率。通常地说,所需要渲染的像素(像素着色器执行)个数要比所需要渲染的顶点(顶点着色器执行)个数要多,同时,所需要渲染的顶点个数也要比模型的个数要多。所以,一般来说,尽可能地将计算量从像素着色器移到顶点着色器中,或者完全从着色器中移除并从脚本中来赋值。| 欢迎光临 纳金网 (http://go.narkii.com/club/) | Powered by Discuz! X2.5 |