Hartha Posted July 18, 2018 Share Posted July 18, 2018 Hi, How I can color the mesh backface only, the mesh maybe has a texture or not. Thanks in advance. Quote Link to comment Share on other sites More sharing options...
JohnK Posted July 18, 2018 Share Posted July 18, 2018 Something like this http://doc.babylonjs.com/how_to/frontandbackuv ? Hartha 1 Quote Link to comment Share on other sites More sharing options...
Hartha Posted July 18, 2018 Author Share Posted July 18, 2018 Thanks @JohnK for reply. yes I saw this tutorial, But the application I build will receive many models from the users so I can't modify the texture, I just need to color the backface with a color not applying texture to it. Quote Link to comment Share on other sites More sharing options...
Guest Posted July 18, 2018 Share Posted July 18, 2018 This will be trickier because the mesh has only one material. So you cannot not apply a texture on some faces. One option would be to duplicate the mesh, create a new material with the color you want and invert the backFace culling Hartha 1 Quote Link to comment Share on other sites More sharing options...
sable Posted July 19, 2018 Share Posted July 19, 2018 If you're ok using BABYLON.CustomMaterial, you can do this like so: http://www.babylonjs-playground.com/#PMVQPJ#3 It's probably a bit faster doing the dot product in the vertex shader though: http://www.babylonjs-playground.com/#PMVQPJ#4 You would probably want to pass in the desired color as a uniform instead of hard coding it. brianzinn and Hartha 2 Quote Link to comment Share on other sites More sharing options...
brianzinn Posted July 19, 2018 Share Posted July 19, 2018 Here is the PG from sable with the color as uniform. that onBindObservable() is called infinitely! http://www.babylonjs-playground.com/#PMVQPJ#5 Hartha 1 Quote Link to comment Share on other sites More sharing options...
Hartha Posted July 19, 2018 Author Share Posted July 19, 2018 doubling the mesh works for me but it cost in some cases, I will try to use CustomMaterial as @sable mention. Thank you guys for help. 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.