Simple PBR Node Generator

Started by aokcub, May 30, 2020, 01:43:04 PM

Previous topic - Next topic

aokcub

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


Nodes will be built based on the Matt's instruction.
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.

sboerner

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.

WAS

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.

aokcub

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.

WAS

#4
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/

aokcub

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)

WAS

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?

aokcub

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.

WAS

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

Dune

Cool! This might come in handy. Thanks for developing it.

aokcub

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.


WAS

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

bobbystahr

Cool stuff, thanks very much.
something borrowed,
something Blue.
Ring out the Old.
Bring in the New
Bobby Stahr, Paracosmologist

mhall

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.