Need help creating/converting a Shader Forge shader from Unity

Hi everyone,

First post here for me :slight_smile:

I’m trying to port a Unity project to BabylonJS.
So far, I’ve been able to handle the “coding part” pretty well (thanks in part to the great documentation, examples and some posts on this forum) but I’m facing problems with the conversion of a shader (that is, I humbly admit, not usually my area of expertise).

It was done using the “old” Shader Forge plugin (if you’re familiar with it) but I can’t replicate it with the NME.Here’s what it looks like in Unity :

This is just an extract of it, the entire shader is kind of a Triplanar mapping (imported 3D models on which it is applied don’t have UVs) but it also includes reflection, normal and AO maps.

So if anyone can help me with that conversion, that would be awesome. Alternatively, if there is a more native option in Babylon to combine all these options, I’m all ears (like I said, I’m not really a shader programmer)

Thanks a lot for your help.

Welcome aboard!

We do have a TriPlanar block in the NME, as well as a PBRMetallicRoughness block that let’s you implement a PBR material with reflection, AO, etc:

However, if your shader uses custom code in Unity, you may have to replicate it in the NME, which may not be easy, as Unity uses a number of macros and helper functions, that you would also have to convert. Another important thing is that, I think, Unity is not using the same coordinate axis for camera space (+Z is into the screen for Babylon, whereas it is -Z for Unity - not totally sure of this), that’s something to take into account when converting the code.


Thanks for your (quick) reply.
Before attempting to convert my current shader, I’ve been trying the Triplanar and PBR shaders through code (with “new BABYLON.PBRMaterial() or new BABYLON.TriplanarMaterial()” commands).
“Individually” they work great, but I would indeed need to create my own node material that “combines” them (because the 3D models imported don’t have UVs).
I’ll try to do that today and I’ll also add options to invert axis just in case.