Whenever I'm working on a custom shader in THREE.js and encounter an error, the console provides me with a helpful error message containing the compiled GLSL code. This includes my own code along with additional lines automatically added by Three.js:
https://i.sstatic.net/lsWX3.png
Query:
Is there a method to retrieve the compiled vertexShader
and fragmentShader
of a predefined material? Specifically, I am utilizing THREE.MeshLambertMaterial
in my current project and would like to analyze the underlying GLSL code for better insight into how it functions. While I am aware that I can access the library's \src\renderers\shaders\ShaderLib\meshlambert_frag.glsl, it contains numerous #include
lines and does not include all the additional attributes/uniforms appended by THREE.js.
I have attempted to log the material's properties after the initial render but have been unsuccessful in locating the compiled GLSL code:
var firstRender = true;
function update(){
renderer.render(scene, camera);
if(firstRender === true){
// Where can I find the stored GLSL code in myMaterial?
console.log(myMaterial.program.vertexShader);
firstRender = false;
}
}