Three.js: What Is The Exact Difference Between Lambert and Phong?

后端 未结 4 1444
孤街浪徒
孤街浪徒 2020-12-03 10:19

I understand the difference between Lambert and Phong in general computer graphics. I also understand how we can change and create our own materials using three.js. But I ca

4条回答
  •  孤城傲影
    2020-12-03 11:03

    If you know a little GLSL, I think the best thing for you to do is to look at the vertex/fragment shaders generated in both cases and look for the differences. You can use http://benvanik.github.com/WebGL-Inspector/ to get the code of the programs, or put a console.log() at the right place in three js sources (look for buildProgram, you should output prefix_fragment + fragmentShader and prefix_vertex + vertexShader to see the program code).

    Also, you can have a look to the building blocks used to create both shaders:

    Lambert: https://github.com/mrdoob/three.js/blob/master/src/renderers/WebGLShaders.js#L2036 Phong: https://github.com/mrdoob/three.js/blob/master/src/renderers/WebGLShaders.js#L2157

    It may be more readable than to look at the source program code.

提交回复
热议问题