jerome Posted May 16, 2016 Share Posted May 16, 2016 Hi, This is a naive question because I didn't try so far to code any shader, but I read the docs, in particular the one about the ShaderMaterial : https://www.eternalcoding.com/?p=113 Well, I'm wondering if there's a way to define a custom vertex shader and still use, say, the BJS StandardMaterial. Something like : var mesh = BABYLON.Mesh.CreateXXX(); mesh.material = new BABYLON.StandardMaterial('sm', scene); (???) => mesh.vertexShader = new BABYLON.VertexShader("vs", scene, {attibute, uniform} ); Or do we have to use the ShaderMaterial, then code our custom vertex shader within and finally copy or reference (from where ?) the current standard material (or PBR) shader code ? Quote Link to comment Share on other sites More sharing options...
NasimiAsl Posted May 16, 2016 Share Posted May 16, 2016 i think need overwirte standard material a little but without that you can change BABYLON.Effect.ShaderStore["defaultVertexShader"] = " " ; it change all standard mesh defaults you can use new Uniform for control that for special mesh but it is not recomended way jerome 1 Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted May 16, 2016 Share Posted May 16, 2016 @NasimiAsl is correct. The first option would be to override the BABYLON.Effect.ShaderStore["defaultVertexShader"] Other option: Create a ShaderMaterial and define the fragment shader to use to "default" jerome and NasimiAsl 2 Quote Link to comment Share on other sites More sharing options...
jerome Posted May 16, 2016 Author Share Posted May 16, 2016 ok, the second option seems cleaner then "default" is the name to set in the place of the DOM element or file in the ShaderMaterial constructor call ? not sure I understand well how to reference a custom vertex shader (say, in a DOM element) and the default fragment shader in the same time ... Quote Link to comment Share on other sites More sharing options...
NasimiAsl Posted May 17, 2016 Share Posted May 17, 2016 i agree second is clear but you need fill all uniforms you need in shaderMaterial same standard material Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted May 17, 2016 Share Posted May 17, 2016 Here is an example of ShaderMaterial: http://www.babylonjs-playground.com/#12AWCR#4 Here is to change it: var shaderMaterial = new BABYLON.ShaderMaterial("shader", scene, { vertex: "custom", fragment: "default", }, { ... }); jerome and NasimiAsl 2 Quote Link to comment Share on other sites More sharing options...
jerome Posted May 17, 2016 Author Share Posted May 17, 2016 capice ! thank you Quote Link to comment Share on other sites More sharing options...
Norbz Posted February 5, 2018 Share Posted February 5, 2018 Hello there. Following this old thread instruction, I tried to apply a custom vertex shader on top of the PBR material. Here is what I tried using the "wave" shader from CYOS, and reusing the PBR shader from the Shader Store : https://playground.babylonjs.com/#QRD69S I get the following error on my conole : babylon.js:1 Uncaught (in promise) TypeError: Cannot read property 'maxSimultaneousLights' of undefined I get the same thing if I try the standard material. Im pretty new to babylonJS so maybe this is a dumb question, but I would appreciate if someone can help me find my mistake. Thanks folks. Quote Link to comment Share on other sites More sharing options...
NasimiAsl Posted February 6, 2018 Share Posted February 6, 2018 you cant use different shader name for one shaderMaterial shaderFragment and shaderVertex depend in varying and uniforms Quote Link to comment Share on other sites More sharing options...
Norbz Posted February 6, 2018 Share Posted February 6, 2018 Hello there, Thanks for answering me. OK I lurked into the pbr vertex shader and I understand what you are saying. I'm not exposing all the varying needed What would be the right way to apply a material on a mesh with a custom vertex shader to morph the shape on GPU ? Sorry if this seems dumb, I'm pretty new to this thing Thanks again Quote Link to comment Share on other sites More sharing options...
NasimiAsl Posted February 6, 2018 Share Posted February 6, 2018 i try make it Norbz 1 Quote Link to comment Share on other sites More sharing options...
NasimiAsl Posted February 6, 2018 Share Posted February 6, 2018 with some hack https://www.babylonjs-playground.com/#LCA0Q4#1 @Norbz jerome, BitOfGold and Norbz 1 2 Quote Link to comment Share on other sites More sharing options...
Norbz Posted February 7, 2018 Share Posted February 7, 2018 Wow, thanks ! I'm digging into it this afternoon. Thank you so much for putting some efforts into it ! NasimiAsl 1 Quote Link to comment Share on other sites More sharing options...
NasimiAsl Posted February 7, 2018 Share Posted February 7, 2018 i try find a way to set uniform (need some time) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.