Jump to content

Custom Vertex Shader + Legacy Material ?


jerome
 Share

Recommended Posts

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 ?

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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 ...

Link to comment
Share on other sites

  • 1 year later...

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...