Jump to content

Polyhaven Browser Extension


klepto2
 Share

Recommended Posts

Here is a first version of the Polyhaven-extension polyhaven_browser.zip:

This is an early release, but nearly everything should be working.

Screenshot:

image.thumb.png.3a1b448b5b32a0204722f6a8515d9d9e.png

Some notes:

There might be some errors while converting some materials. this is due the fact that some materials have multiple diffuse files configured and i am currently assuming a "Diffuse" slot and not the other configured maps. This will be fixed and adressed in a later release.

The settings dialog is a proof of concept extension which i plan to release as a standalone extension later and which might be a replacement for the current options dialog in the tools section.

The scripts still have some garbage included which i will get rid of in a future release.

 

Download:

polyhaven_browser.zip

Installation:

Extract the content of the zip into your UltraEngine installation folder. The file structure in zip reflects the needed structure to get it working.

 

  • Like 5
  • Thanks 1
  • Intel® Core™ i7-8550U @ 1.80 Ghz 
  • 16GB RAM 
  • INTEL UHD Graphics 620
  • Windows 10 Pro 64-Bit-Version
Link to comment
Share on other sites

For Steam users, placing libcurl.dll in the program folder will cause the Steamworks library to crash:
https://steamcommunity.com/groups/steamworks/discussions/0/6699728899096777474/

There are two ways around this.

  1. Recompile libcurl to use a different DLL name. I used a precompiled binary because I could not figure out how to compile libcurl with SSL.
  2. Before loading the OpenAI module, copy libcurl.dll to the program directory, then load the OpenAI module, then immediately remove the DLL. Not sure if this will work if the DLL is loaded.

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

  • 2 weeks later...

I came across something else when looking at the OpenAI API. It appears that the executable curl does work with authorization maybe:

curl https://api.openai.com/v1/images/edits \
  -H "Authorization: Bearer $OPENAI_API_KEY" \
  -F image="@sunlit_lounge.png" \
  -F mask="@mask.png" \
  -F model="dall-e-2" \
  -F prompt="A sunlit indoor lounge area with a pool containing a flamingo" \
  -F n=1 \
  -F size="1024x1024"

Curl comes standard on win10 and 11 now.

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

Yeah, if you look in OpenAI.lua there are two different calls that use two different approaches. One is using the default content type, and then the other is using JSON. The only tricky part was figuring out how to encode JSON in a command line and then encode that in a Lua file. So, for every quotation mark you have to replace it with \\\"

If you use curl instead of curl.exe, it will make the script cross-platform compatible, I think.

Interesting stuff, anyways.

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

4 hours ago, Alienhead said:

Also the 'settings' option under neath the Poly Haven option on the drop down is of very small scale. Unlike other pop up windows throughout the editor.

This is probably because it does not use DPI scaling, but this extension is not part of the editor so this should be reported to the author.

I will take a look at the stack size error.

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

The settings are more or less a prototype done shortly before the beta release. I have not used any dpi scaling in the plugin but i plan to include it in a refactored version.  the stacksize error is new for me. Looks like a stack error with lua. could probably be a problem with either the dll for fetching the polyhaven api or the small json to lua extension i have added. 

I will investigate both.

Also as Josh said the polyhaven is not an official plugin, so bug reports should be added here: 

or you could send me a PM.

  • Like 1
  • Intel® Core™ i7-8550U @ 1.80 Ghz 
  • 16GB RAM 
  • INTEL UHD Graphics 620
  • Windows 10 Pro 64-Bit-Version
Link to comment
Share on other sites

10 hours ago, SpiderPig said:

Hi Klepto, just letting you know that I'm getting the "stack size error" as well.  I haven't done anything other than install and launch the extension.

Hi, is it possible to debug the Editor for you? if you have installed VSCode you can go to the Ultraengine directory and run the Open with VSCode.bat and then Run -> Start Debugging.

Also does the error occur just by opening the  window (Polyhaven) or after selecting a node?

  • Intel® Core™ i7-8550U @ 1.80 Ghz 
  • 16GB RAM 
  • INTEL UHD Graphics 620
  • Windows 10 Pro 64-Bit-Version
Link to comment
Share on other sites

Ok, you might need to allow access to some specific files. 

 

image.png.fb82edd1b02d2961ebcac62230ec14ee.png

these are the files:

in main directory: libcurl.dll

then Modules/PolyHavenApiClient.dll

and finally: Tools/pbr.exe and all dlls under plugins.

Hopefully this will solve the issue. Otherwise i look forward for the debugging results.

  • Thanks 1
  • Intel® Core™ i7-8550U @ 1.80 Ghz 
  • 16GB RAM 
  • INTEL UHD Graphics 620
  • Windows 10 Pro 64-Bit-Version
Link to comment
Share on other sites

9 hours ago, klepto2 said:

in main directory: libcurl.dll

then Modules/PolyHavenApiClient.dll

and finally: Tools/pbr.exe and all dlls under plugins.

These were blocked, unblocking them didn't help though.  All the plugins are unblocked already.

Interestingly debugging through VSCode gave no errors.  It took about 5 seconds to actually load anything but there was no error.  Very odd. :unsure:

Link to comment
Share on other sites

So you was able to browse the items while debugging it? or was there just no error but still no treeview available?

I am currently rewriting some internals to not rely on dlls that much. I will provide a small test later which rewrites the first step (treeview populating) using curl and Command an LoadTable instead of the custom dll for accessing the api. If that solves the problems i will rewrite the other api calls as well and remove all dll dependecies execept the pbr exe (this is needed for converting the HDR images and should not cause problems).

  • Intel® Core™ i7-8550U @ 1.80 Ghz 
  • 16GB RAM 
  • INTEL UHD Graphics 620
  • Windows 10 Pro 64-Bit-Version
Link to comment
Share on other sites

Polyhaven.lua

In this file i have changed the loading for the types and catagories to use curl and the inernal Command and LoadTable functions instead of the custom api dll. 

Replace this file in the Scripts\Start\Extensions folder. Hopefully this will resolve the initial problems. I will continue to replace the api calls with native curl requests to get rid of the external dll requirements.

Let me know if this resolves some of the issues.

  • Intel® Core™ i7-8550U @ 1.80 Ghz 
  • 16GB RAM 
  • INTEL UHD Graphics 620
  • Windows 10 Pro 64-Bit-Version
Link to comment
Share on other sites

42 minutes ago, klepto2 said:

So you was able to browse the items while debugging it? or was there just no error but still no treeview available?

Everything appeared to work when debugging.  The treeview populated and I could browse the assets.

15 minutes ago, klepto2 said:

In this file i have changed the loading for the types and catagories to use curl and the inernal Command and LoadTable functions instead of the custom api dll. 

I don't get the error now and the treeview populates but there are no assets showing and "Unknown exception" is printed in the editors console whenever I click a treeview item.

Like before, debugging everything works as it should.

Link to comment
Share on other sites

Ok, that inidcates that i need to remove the custom module usage. I will continue with it and upload a modfied version in a few minutes (maybe a bit longer ;) ). 

  • Thanks 1
  • Intel® Core™ i7-8550U @ 1.80 Ghz 
  • 16GB RAM 
  • INTEL UHD Graphics 620
  • Windows 10 Pro 64-Bit-Version
Link to comment
Share on other sites

  • Josh changed the title to Polyhaven Browser Extension

In the future, there is going to be an AsyncCommand() function that will call _wsystem on a separate thread, so all your curl calls can be made asynchronous, even in Lua.

  • Like 1

My job is to make tools you love, with the features you want, and performance you can't live without.

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.

 Share

×
×
  • Create New...