I clear you doubts line by line might be helpful:
What is the difference between using MeshPhongMaterial and ShaderMaterial with THREE.ShaderLib.phong.
MeshPhongMaterial is the Namespace provided you end user by library to make the development faster more easy for those who are from graphics ( dev/designer background )
So Internally if you check library src/renderers/shaders/ShaderLib.js
THREE.ShaderLib['phong'] is mapped to shaderIDs line 29574 three 75 version.
So they are same.
Will Three js internally use the shaders for all materials ?
Answer: OpenGLES 2.0 and above all are shader based technology compare to fixed pipeline to draw stuff on the surface created using EGL.
Will using ShaderMaterial improve performance ?
Answer: Depends what you are looking into three.js shaders are mature enough you could get a peanut if you don't want light vector calculation into fragment shader ( by providing direct vec3 instead of uniform) but this might not be first point to shoot for performance they are many like LOD, Object Pooling etc etc. ( different people might have different opinion about same )
I have a piece of code which uses MeshPhongMaterial and how do i convert to ShaderMaterial with THREE.ShaderLib.phong.
Answer: You can manually Called
var phongShader = THREE.ShaderLib[ 'phong' ]
var shaderMaterial = new THREE.ShaderMaterial( {
uniform: phongShader.uniform,
vertexShader: phongShader.vertexShader,
fragmentShader: phongShader.fragmentShader
});
But you can use extend shader by calling your custom glsl file using the THREE.ShaderChunk too.
How do I specify combine, reflectivity and other properties in ShaderMaterial
Answer: Create your own uniform (the one one which you mention are already supported in material) and then call
THREE.UniformsUtils.merge( [
phongShader.uniform,
{
//to do custom uniform
}
vertexShader:vertexShader,
fragmentShader:fragmentShader
)]
var vertexShader = [
//so on add the shaderChunk Required
].join( '\n' )
var fragmentShader = [
THREE.ShaderChunk[ "common" ],
//so on add the shaderChunk Required
//call your custom uniform which you have supplied into the final gl_FragColor
].join( '\n' )
Seeing your problem IMHO you won't need to change in the vertexShader you can edit the fragmentShader directly using your custom paramters.