How do I know which variables are built into PBRCustomMaterial?

How do I know which variables are built into PBRCustomMaterial?

For example, when I need to use uv, normal, the document can not give me a good help, only through the source code or error to find?
I also didn’t know there was a built-in variable in the source code called vPositionW!!!


I also didn’t know I had to use a texture when I needed uv!!!

Is there anything I can do to help?

1 Like

Here is the clickable link to the PG you mentioned - https://playground.babylonjs.com/debug.html#6T8SBT#18
(it is easier to help when there is clickable link in question instead of link screenshot :slight_smile: )
Could you make you question more specific and understandable?

1 Like

The OP wants to know the variable names used in shaders.

I believe that now you already know :crazy_face:

I have to admit that the first time I had a hard time too to find out all the variables availabe in different material shaders when I was writing my first MaterialPlugin. Those should be added to the docs and well maintained so we don’t need to look at the shader source codes when trying to inject our code into the shaders. The docs should also clearly describe the different built-in define variables we can use.

@Deltakosh

1 Like

Such a document is really needed, otherwise PBRCustomMaterial is difficult to use.

I searched the entire forum, but I seem to be the only one with this complaint

1 Like

I can give you a suggestion:

Open PG: https://playground.babylonjs.com/#GC63G5#90 (stay in WebGL)

Make an error in the shader on purpose:

Run the PG

Have a look at the shader code in the console. Now you can observe the variables (local/in/out).

Works similarly with the custom materials.

1 Like

I have a bookmark just for bjs shaders. :stuck_out_tongue:

1 Like

Thank you,I’ll try !!!
I look forward to having a document in the near future

1 Like

There are only two I use most often: default.vertex.fx + default.fragment.fx. Virtually all my plugins revolve around fragment.fx and I’m currently sitting at 20ish custom shaders. Plus if you run into any problems, the community here is super responsive. Never fear!

The amount of work involved in looking at the source code is enormous!
And viewing the source code is a bit complicated for a novice!

thank you all the same!!!

Yes, that’s one of the biggest reasons I love babylonjs

Someone kind enough to catalog the entry point and do a documentation update?