Jump to content

Custom PBR material


Converge
 Share

Recommended Posts

Hello everyone,

I've encountered a situation where I need to mix two normal maps for my PBR material. One map is the main texture while the second one is tiled detail texture. Much like Unity does with its standard material. What would be the best way to extend the functionality of the current PBR material (https://doc.babylonjs.com/classes/3.0/pbrmetallicroughnessmaterial or at least its PBRBaseSimpleMaterial parent). Amending shader itself and passing a second texture sampler is not a problem for me. I understand I should utilize material library and compile a new material. But should I use existing custom standard material as a basis or there are better ways of doing it? I would love to keep entire PBR shader code in local .fx files instead of replacing custom parts though. I bet many artists working with BJS have encountered similar issue where they'd need to tweak existing material and meddle with the shader code but the process of creating anything custom isn't that clear or intuitive. Any tips would be very helpful!

Many thanks in advance.

PS readme file for custom standard mat states that it would only work with BJS 3.0.0 and I'm using the latest stable one. 

Link to comment
Share on other sites

https://www.babylonjs-playground.com/#7AIII8#20

https://www.babylonjs-playground.com/#7AIII8#25

that is Simple PBR From CustomShader

u can make any channel for you pbr

 

** 

reflectPart = function( sampler Ref, nrm , scale ,   RefractiveParameter  , direction x , direction y , direction z , bias)

part1 : https://www.babylonjs-playground.com/#7AIII8#22

 new SB()

        .Map({path:'https://i.imgur.com/5b9To6N.jpg'}) 
         
         .InLine( reflectPart(
            'txtRef_0','nrm'
            ,0.005 ,-1,-1.,-1.,-1.,0.))
          

        .BuildMaterial(scene);

you can use shader string  for manage any parameter

reflective mix

https://www.babylonjs-playground.com/#7AIII8#23

normal mix

https://www.babylonjs-playground.com/#7AIII8#24

 

play  anything you want and ask me if you have any question about this

http://www.babylonjs-playground.com/#7AIII8#11

Link to comment
Share on other sites

The long term version is either to use the custom material as shown by Nasimi or do as you mentioned: inherit from PBRBaseMaterial and create an entry in the material library (this way it will be maintained in the core repo)

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