Planetside Software Forums

General => Terragen Discussion => Topic started by: aokcub on May 30, 2020, 01:43:04 PM

Title: Simple PBR Node Generator
Post by: aokcub on May 30, 2020, 01:43:04 PM
Inspired by recent Jordan's works, I wrote a small app to import PBR textures into Terragen 4.
I was originally writing this as command-line Perl script for my own but I re-wrote as GUI application.

The app can read a JSON attached in the MEGASCAN assets and extract texture paths, and then export node network (save as tgc or copy to clipboard) as shown in the attached pictures.
Of course you can choose texture manually as you want.

Refer to the following page for the detail and download.
https://incscenes.hateblo.jp/entry/2020/05/31/021209 (https://incscenes.hateblo.jp/entry/2020/05/31/021209)


Nodes will be built based on the Matt's instruction.
https://planetside.co.uk/forums/index.php/topic,26658.msg265834.html#msg265834 (https://planetside.co.uk/forums/index.php/topic,26658.msg265834.html#msg265834)


Note that this is still prototype, and welcome your comment to improve!
I have a plan to support metalness workflow when TG4.5 is released.
Title: Re: Simple PBR Node Generator
Post by: sboerner on May 30, 2020, 01:49:41 PM
Cool idea. I used to mess around with Perl, it's fun. Way too rusty now to attempt anything like this. This suggests all kinds of possibilities.
Title: Re: Simple PBR Node Generator
Post by: WAS on May 30, 2020, 01:56:51 PM
This is a pretty cool start, especially reading the MEGASCAN JSON config. That's serious effort for TG in this age.

One thing I would suggest is having the Default Shader be part of the editor to adjust per-material. Fore example you use diffuse of 1 (white), which actually doesn't work for a lot of PBR materials because of TG's color space. You get white-washed very bright textures.

As it is right now, the MEGASCAN bit is really nice, and setting the image settings, but in TG, one image map settings usually translate across all maps, so it's not too hard to simply duplicate the image shader and simply swap file name or load new image. The actually "customization" for me, at least, comes in the Default Shader.
Title: Re: Simple PBR Node Generator
Post by: aokcub on May 30, 2020, 02:09:06 PM
Thank you for suggestion. I see...

Well, actually it's good to add some fields to tweak values in the Default Shader for each map, e.g., diffuse color for albedo, amplitude for displacement, ...
I put in my plan.
Title: Re: Simple PBR Node Generator
Post by: WAS on May 30, 2020, 02:28:13 PM
That would be awesome. Great work on this. The GUI looks clean, and sharp too. :)

I wanted to make GUI's for my tools, but but with C, it looked like a lot of dependencies just to get the functionality I wanted, like reading XML data, and I'm not well versed anymore (hardly written in it for like 10 years +). And Java, I know well, but it's such overkill and heavy. Web tools most anyone can access seemed next best option.

PS; I hope you don't mind, I added your tool to the resource section, and made a post over at NWDA:

https://nwdastore.com/boards/topic/terragen-4-pbr-node-generator/
https://nwdastore.com/resources/
Title: Re: Simple PBR Node Generator
Post by: aokcub on May 30, 2020, 02:59:48 PM
Quote from: WAS on May 30, 2020, 02:28:13 PMPS; I hope you don't mind, I added your tool to the resource section, and made a post over at NWDA:
Happy to hear that! I have a plan to move the page to GitHub when I open the source code, so I'll inform you then.


The app is written in JavaScript (Electron and Vue.js).
I've been writing C++/Perl (mainly CUI), but I recently started learning JS to write GUI app simply (and to support cross-platform)
Title: Re: Simple PBR Node Generator
Post by: WAS on May 30, 2020, 03:12:00 PM
Quote from: aokcub on May 30, 2020, 02:59:48 PMThe app is written in JavaScript (Electron and Vue.js).
I've been writing C++/Perl (mainly CUI), but I recently started learning JS to write GUI app simply (and to support cross-platform)

You know I've heard about this and read a article awhile back but have never given it a try. I know JavaScript pretty well too. Is it pretty straight-forward? Can you use other libraries with the approach? Like Mootools or something?
Title: Re: Simple PBR Node Generator
Post by: aokcub on May 30, 2020, 07:53:53 PM
Honestly I'm not sure about JS library as I have just started learning. Used xml-js conversion library.
But, for me, it was easy to get started.
Title: Re: Simple PBR Node Generator
Post by: WAS on May 30, 2020, 09:39:39 PM
Oh that's interesting. Why are you serializing to JSON? To store something or was it just easier to manage? I'm not sure if you're aware but JavaScript has its own DOM parser, which can handle XML.

See this basic example: https://www.w3schools.com/xml/dom_intro.asp
Title: Re: Simple PBR Node Generator
Post by: Dune on May 31, 2020, 01:41:21 AM
Cool! This might come in handy. Thanks for developing it.
Title: Re: Simple PBR Node Generator
Post by: aokcub on May 31, 2020, 02:42:20 AM
Quote from: WAS on May 30, 2020, 09:39:39 PMWhy are you serializing to JSON?
Ah, it was bad wording, sorry. I meant that using the library to convert JavaScript Object (not JSON) into XML.
https://www.npmjs.com/package/xml-js

Internally texture paths and parameters are managed by JS Object and converted to XML at exporting.


Quote from: Dune on May 31, 2020, 01:41:21 AMCool! This might come in handy. Thanks for developing it.
If you have any questions/comments, please feel free to let me know.
Title: Re: Simple PBR Node Generator
Post by: Kadri on May 31, 2020, 05:20:59 AM
Thank you.
Title: Re: Simple PBR Node Generator
Post by: WAS on May 31, 2020, 01:35:07 PM
Quote from: aokcub on May 31, 2020, 02:42:20 AM
Quote from: WAS on May 30, 2020, 09:39:39 PMWhy are you serializing to JSON?
Ah, it was bad wording, sorry. I meant that using the library to convert JavaScript Object (not JSON) into XML.
https://www.npmjs.com/package/xml-js

Internally texture paths and parameters are managed by JS Object and converted to XML at exporting.


Quote from: Dune on May 31, 2020, 01:41:21 AMCool! This might come in handy. Thanks for developing it.
If you have any questions/comments, please feel free to let me know.
Ohh duuh, that makes sense. I immediately was drawn to the xmltostring stuff.

Wanted to try the vue.js myself but having issues installing npm. When doing the autoscripts portion it just hangs at "Installing 64-Bit Python...". Been about an hour now. :\ Hope this is a common issue. Asked over at the reddit.
Title: Re: Simple PBR Node Generator
Post by: bobbystahr on May 31, 2020, 11:46:00 PM
Cool stuff, thanks very much.
Title: Re: Simple PBR Node Generator
Post by: mhall on June 01, 2020, 01:16:39 AM
Quote from: WAS on May 30, 2020, 03:12:00 PMI know JavaScript pretty well too. Is it pretty straight-forward? Can you use other libraries with the approach? Like Mootools or something?
Electron is just a "wrapper" around the Chrome browser, and the Node execution environment. It provides them both for you and when the run the Electron program, runs a node and Chrome instance for that app (also giving you access to the local file system and network). You don't have to make a ton of changes to the way you are used to working with Javascript in the browser. You should be able to use any frontend or backend library and framework you are used to working with.


Applications like Microsoft's VSCode, which is huge in the programming space these days, are actually Electron applications. So are things like the Skype desktop client.

I haven't written an Electron application myself, but have been considering what it would take to migrate a project I've been working on to it, so I've been reading a bit and watching some videos.
Title: Re: Simple PBR Node Generator
Post by: WAS on June 01, 2020, 01:34:30 AM
Quote from: mhall on June 01, 2020, 01:16:39 AM
Quote from: WAS on May 30, 2020, 03:12:00 PMI know JavaScript pretty well too. Is it pretty straight-forward? Can you use other libraries with the approach? Like Mootools or something?
Electron is just a "wrapper" around the Chrome browser, and the Node execution environment. It provides them both for you and when the run the Electron program, runs a node and Chrome instance for that app (also giving you access to the local file system and network). You don't have to make a ton of changes to the way you are used to working with Javascript in the browser. You should be able to use any frontend or backend library and framework you are used to working with.


Applications like Microsoft's VSCode, which is huge in the programming space these days, are actually Electron applications. So are things like the Skype desktop client.

I haven't written an Electron application myself, but have been considering what it would take to migrate a project I've been working on to it, so I've been reading a bit and watching some videos.

Yes that's definitely true, Discord and Epic Launcher to name some others. 

It is really interesting. Totally different from web design and a kid where we were always told JavaScript was a tool and never to rely on it. Haha. Now everything is running JavaScript.  But really that's not a bad thing. I'd rather this than Flash.. there was a time they thought Java Applets and Flash and ActionScript was going to be the future of the web. Glad that didn't happen. 

Learned some pretty cool stuff today. But I feel for my apps, considering the scope of electron, while it is cool it may be much less effort to just distribute them with PHP Desktop, a chrome instance with PHP support. Since I already wrote them in PHP 😂 never know though, I like the idea of desktop apps. Even contributed to a compiler for PHP for a couple years ages ago.
Title: Re: Simple PBR Node Generator
Post by: mhall on June 01, 2020, 02:00:35 AM
Yeah, JS is everywhere these days!

Electron applications are criticized for being bloated - and it's hard to argue they aren't. An entirely separate instance of Chrome spins up for every application (and Chrome itself is known to be bloated) and it will run a number of different processes. I'm running two visible instances of VSCode right now, with 9 open files (was many more before) and it has 26 processes I can recognize in my process list and is using somewhere north of 2GB of memory. Granted, it's an extreme example. Some of the files I have open have 5,000+ lines in them that it's parsing, highlighting, linting, analyzing syntax on, providing hints/tips, etc. So, I'm not particularly taking it easy on it. But that's a lot of processes and a lot of memory all the same!

As for your recent cool TG related projects - unless you want to do it just to learn it, or can find some clear benefit in functionality - probably best to distribute them in a way you already know.

Sorry for de-railing the thread!
Title: Re: Simple PBR Node Generator
Post by: JoeB on June 02, 2020, 03:03:23 PM
Hi aokcub, Thanks so much for all your work with this. I'm trying to download the Mac version but the link from your download site is giving me the "403 Forbidden" error. I'd love to get the Mac version and try it out.
Title: Re: Simple PBR Node Generator
Post by: aokcub on June 03, 2020, 09:57:52 AM
Oops, sorry, I fixed the file permission!
Due to the security policy, the app cannot be opened by double-click.
Please right-click and click "Open".
Title: Re: Simple PBR Node Generator
Post by: aokcub on June 03, 2020, 10:05:54 AM
Updated to v0.3.0.

v0.3.0 added a new mode "Basic - Mixed", generating default shaders for both Non-metalic and metalic, and mixes them by the merge shader.

mix.pngmix2.png

https://incscenes.hateblo.jp/entry/2020/05/31/021209
Title: Re: Simple PBR Node Generator
Post by: Balletdude on July 16, 2021, 03:54:30 AM
the .mtl tab seems to be greyed out. I wanted to import the MTL file for a model I created in Blender, but can't see how to do it properly?
Title: Re: Simple PBR Node Generator
Post by: aokcub on July 18, 2021, 07:34:45 AM
Importing mtl is not implemented yet, sorry.