Jump to content

Unable to transform mesh instance using shader material


projectcs
 Share

Recommended Posts

I was unable to transform mesh instance if the original mesh had a shader material. Is this a bug?

 

I have created a playground example using box mesh. If you open the debug -> mesh panel, you realize there are 6 meshes, but only 5 are displayed. This is because one of the instances in the second row was not transformed properly. On the other hand, clones of meshes with shader material can be transformed properly.

https://playground.babylonjs.com/#B2NZ1M#1

Link to comment
Share on other sites

Thank you @Deltakosh, you solved my problem but explained it wrong. It's actually not because I was using a different material than the original mesh, but rather I did not know that in order to render transformed mesh instance with custom shader:

1. You need to use #include<instanceDeclaration> and #include<instanceVertex> in the custom shader.

2. You need to use ”viewprojection” and ”finalworld” instead of ”worldviewprojection” in the custom shader. 

However the above variables are not documented in the custom shader session. Wondering if there is any more hidden variables that we need to know when working with custom shader?

Anyway thanks a lot for your solution!

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