-
Posts
853 -
Joined
-
Last visited
Content Type
Blogs
Forums
Store
Gallery
Videos
Posts posted by klepto2
-
-
Not an important one, but some stricter compilers or parsers will break on line 258 in Math_.h
inline unsigned int Rgba(const unsigned char r, unsigned const char g, unsigned const char b, unsigned const char a = 255) { return Clamp(r, 0, 255) | (Clamp(g, 0, 255) << 8) | (Clamp(b, 0, 255) << 16) | (Clamp(a, 0, 255) << 24);; }
should be:
inline unsigned int Rgba(const unsigned char r, const unsigned char g, const unsigned char b, const unsigned char a = 255) { return Clamp(r, 0, 255) | (Clamp(g, 0, 255) << 8) | (Clamp(b, 0, 255) << 16) | (Clamp(a, 0, 255) << 24);; }
the const keyword is aligned wrong for the parameters g,b and a.
- 1
-
33 minutes ago, diedir said:
- Textures on terrain: no UV Tiling ?
You can change the tiling via the scale setting for each layer. in theory (which looks very ugly) you can assign a colormap covering the whole terrain.
-
I have tried some approaches, but none of them is satisfying. I have an approach where i share the world between windows, but only create standalone ui_worlds. This is still laggy and i guess as Josh stated comes from the culling thread. For plane ui rendering it should be possible to disable culling on a camera or world at all. This would resolve this issue i think.
-
Do you need multiple worlds? or is one world, but rendered on multiple windows (with different cameras) enough?
-
instead of a panel you could maybe use a simple sprite and an orthographic camera.
-
The editor does it, so it should be possible. Do you need different worlds?
with one world I would create multiple cameras and rendertargets. And draw a panel in each window with the correct texture applied to it.
i will come back with a sample in a few minutes.
- 1
-
Open the project manager and click on the warning icon at your project (if there is one) this should trigger the project update.
-
Just a sidenote: One thing that highly improves the editing (at least in my case) is to switch to single viewport while editing the terrain. Which makes absolutely sense, as only one viewport needs to handle the costly wireframe selection rendering.
-
Here is a first version of the Polyhaven-extension polyhaven_browser.zip:
This is an early release, but nearly everything should be working.
Screenshot:
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:
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.
- 5
- 1
-
I am currently working on the settings dialog for my Polyhaven browser. At first i wanted to use the defualt options dialog provided by the Editor itself, but for now this lacks some features and is not that easy to access.
While you already can add your own options to the options dialog, you have no detailed enough control where these settings are stored.
Lets take an example:
I have a few settings for my extension and i want to have them stored this way:
program.settings.extensions.polyhaven.model.folder = "Models/Polyhaven" program.settings.extensions.polyhaven.material.folder = "Materials/Polyhaven" program.settings.extensions.polyhaven.hdri.folder = "Materials/Environment/Polyhaven" program.settings.extensions.polyhaven.material.downloadSize = "2k" program.settings.extensions.polyhaven.model.downloadSize = "4k" program.settings.extensions.polyhaven.hdri.downloadSize = "4k" program.settings.extensions.polyhaven.material.displacement = true program.settings.extensions.polyhaven.material.displacement_settings = {} program.settings.extensions.polyhaven.material.displacement_settings[1] = 0.025 program.settings.extensions.polyhaven.material.displacement_settings[2] = -0.0125
this works nicely, and the editor correctly saves and load them correctly. But they are of course not visible in the options dialog of the editor itself.
with this small piece you can add options to the editors options dialog:
local opt = program.optionsdialog opt:AddSetting("extensions", "Displacement", PROPERTY_BOOLEAN)
but this will just use "program.settings.extensions.displacement" in the settings.json instead of the original intended path.
So what are my requirements for a good settings dialog:
-
it should be as generic as possible
- this means it should be easy to extend functionality.
- eg: add a specific settings behaviour when it is not included already.
- each option should represent a path in the settings file
- it should be possible to have groups of settings
- it should still using the editors own settings.json
This is what i have so far:
First some sample code i use in my polyhaven extension:
--Setups the settingsdialog or returns the already created one --the setting is more or less a simple singleton shared via the global table local assetsettings = require("assetsettings") --Now we define the settings layout and register settings --the option groups are created by the path and the order they are added --you can have multiple sub nodes local hdrnode = assetsettings.registerOptionGroup("Polyhaven/Hdri") assetsettings.addSettingFolder(hdrnode,"Storage-Path", "Materials/Environment/Polyhaven", "extensions.polyhaven.hdri.folder") assetsettings.addSettingCombobox(hdrnode,"Download-Size", "2k","1k;2k;4k;8k", "extensions.polyhaven.hdri.downloadSize") local material_node = assetsettings.registerOptionGroup("Polyhaven/Material") assetsettings.addSettingFolder(material_node,"Storage-Path", "Materials/Polyhaven", "extensions.polyhaven.material.folder") assetsettings.addSettingCombobox(material_node,"Download-Size", "2k","1k;2k;4k;8k", "extensions.polyhaven.material.downloadSize") assetsettings.addSettingCheckbox(material_node,"Displacement", true, "extensions.polyhaven.material.displacement") local model_node = assetsettings.registerOptionGroup("Polyhaven/Model") assetsettings.addSettingFolder(model_node,"Storage-Path", "Models/Polyhaven", "extensions.polyhaven.model.folder") assetsettings.addSettingCombobox(model_node,"Download-Size", "2k","1k;2k;4k;8k", "extensions.polyhaven.model.downloadSize")
and this is how it looks like:
you can even select toplevel nodes and then you get this:
So if you want, you can get all settings in one place, or get a cleaner one by selecting the subgroup directly.
Each addSettings...() method is responsable for its own to create the required widgets and to update the values which should be saved.
sample implementation of the combox setting:
function assetsettings.addSettingCombobox(node, description, defaultvalue, possibleValues, settingspath) assetsettings.addSetting(node, description, defaultvalue, settingspath, function(x,y, labelwidth, item, parent) local width = parent:ClientSize().x - 10 CreateLabel(item.description..":", x ,y + 5,labelwidth,25, parent) local combobox = CreateComboBox(x + labelwidth,y, width -labelwidth-5, 25, parent) local n = possibleValues:split(";") for i = 1, #n do combobox:AddItem(n[i], n[i] == item.valuetosave) end ListenEvent(EVENT_WIDGETSELECT, combobox, function() local w_item = combobox.items[combobox:GetSelectedItem()] item.valuetosave = w_item.text end, assetsettings) return combobox end ) end
the underlying addsettings function already sets up all required properties to handle the updating and saving behaviour.
If you close and save the dialog, the item.valuetosave is the applied to the correct parogram.settings path and stored as soon as the engine saves the settings.json.
- 2
-
it should be as generic as possible
-
If you drop a model from the assetbrowser into a viewport, the rotation is set to a weird value depending on the viewport you drop the model.
Perspective: -90,0,0
Top : 90,0,0
Left : 0,90,0
Back : -90,0,0I would expect that the initial orientation is always 0,0,0.
- 2
-
that works.
I noticed, that sometimes when using CreateDir in the script, the assetbrowser is not updating the folder structure. Could you add a method which refreshes the nodes, or something like assetbrowser:RefreshFolder(folder) ?
-
Yeah i also noticed that and also filed a bug report:
An idea for @Josh: Maybe just render a simple plane with the terrain matrix applied to the selection buffer. This will not be optimal as the outline is just flat, but will hopefully solve the bottleneck. Or there must be some other indicator for terrain selection.
- 1
-
Hi,
I have tried various JSON parsers for lua. And they are all slow as hell (at least if the json string is a larger one). In my API -Module for Polyhaven i have integrated a function which converts the nlohman:json object into a lua table and this is magnitudes faster than any lua json library. Also the usage is very easy and lua like.
void jsonToLua(const nlohmann::json& json, lua_State* L) { switch (json.type()) { case nlohmann::json::value_t::null: lua_pushnil(L); break; case nlohmann::json::value_t::boolean: lua_pushboolean(L, json.get<bool>()); break; case nlohmann::json::value_t::number_integer: lua_pushinteger(L, json.get<int>()); break; case nlohmann::json::value_t::number_unsigned: lua_pushinteger(L, json.get<unsigned>()); break; case nlohmann::json::value_t::number_float: lua_pushnumber(L, json.get<double>()); break; case nlohmann::json::value_t::string: lua_pushstring(L, json.get<std::string>().c_str()); break; case nlohmann::json::value_t::array: lua_newtable(L); for (size_t i = 0; i < json.size(); ++i) { lua_pushinteger(L, i + 1); // Lua arrays are 1-indexed jsonToLua(json[i], L); lua_settable(L, -3); } break; case nlohmann::json::value_t::object: lua_newtable(L); for (auto it = json.begin(); it != json.end(); ++it) { lua_pushstring(L, it.key().c_str()); jsonToLua(it.value(), L); lua_settable(L, -3); } break; default: // Handle other types if needed break; } } int lua_JsonToLua(lua_State* L) { std::string jsonString; if (lua_isstring(L, -1)) { jsonString = lua_tostring(L, -1); } auto json = nlohmann::json::parse(jsonString); jsonToLua(json, L); return 1; } extern "C" { __declspec(dllexport) int luaopen_PolyHavenApiClient(lua_State* L) { // Load the DLL and create an instance of PolyHavenApiClient lua_newtable(L); int sz = lua_gettop(L); lua_pushcfunction(L, lua_JsonToLua); lua_setfield(L, -2, "JsonToLua"); lua_settop(L, sz); return 1; } }
With this you can do something like this:
local assets = extension.api.getAssets(type,cat) --just a sample api call i use to retrieve the json data local assetTable = extension.json.JsonToLua(assets) -- convert json string to lua table Print(assetTable.bark_brown_01.name) --or iterating sorted by keys function pairsByKeys (t, f) local a = {} for n in pairs(t) do table.insert(a, n) end table.sort(a, f) local i = 0 -- iterator variable local iter = function () -- iterator function i = i + 1 if a[i] == nil then return nil else return a[i], t[a[i]] end end return iter end for key,data in pairsByKeys(extension.currentAssets ) do Print(key.." Displayname: "..data.name) --Prints in this case eg: "bark_brown_01 Displayname: Bark Brown 01 end
- 1
-
currently i only find LoadTable functions for a path or a stream, it would be nice to have a method to load the table structure by providing just a json string (eg: When Fetching a url request)
In general this can be done by using the Stream method, but the stream override is not available in lua and might be a bit complicated to use.
- 1
-
11 hours ago, Josh said:
How else would it work? Multiple asset windows can be opened, and they are never empty.
The Model.base member is a class that is an asset, though I am not sure if it is exposed to Lua. I don't see it in the documentation...
This is exactly what i meant. I guessed it should be only this one.
Is the model.base already exposed in the editor? I can't access it after the latest update.
This is what i have tried so far:
model.base (not available)
model:GetBase() (not available)
Asset(model) or Asset(model.base) (not working)
-
I have reported that originally here:
But i would like to bring this up again. I have now working a lot with the polyhaven api and their textures to generate materials out of them. The textures or better the metadata of the PBR materials have a property called wideness, which for some is 1m and for others eg: 15m. Polyhaven itself use this in their blender plugin to fix the texturesize on brushes by scaling the uvs according to this wide parameter. This would be nice to have in UltraEngine itself, not only for imported materials, but also for tiling on planes etc.
-
@Josh I have found some additional things (I know the api is still in development)
- program:OpenAsset is the only method to open the AssetEditor
- no Asset(model) / Asset(entity) is available --> currently it is not possible (at least no way i know about) to open a model file in the AssetEditor via lua.
-
consider to make the Options in optionswindow a treeview to reflect the actual json layout of the settings.
-
Maybe an addition to the AddSettings where you can specify the node where this is stored in the settings.json.
- eg: I have this: program.settings.extensions.polyhaven.material.downloadSize = "1k"
- now i want a method like opt:AddSettings("Polyhaven", "Material DownloadSize", PROPERTY_STRING, { "1k,"2k",4k",8k" }, "program.settings.extensions.polyhaven.material.downloadSize")
-
a settings property with multiple combo values would be nice as well. eg: PROPERTY_STRING and a array of Strings as possible values
- In my case i have a setting where you can choose between (1k,2,4k and 8k) resolutions
- I can add my own settings dialog, but it would be nice to have the ability to let plugins have its configuration at the same place as the other options.
-
Maybe an addition to the AddSettings where you can specify the node where this is stored in the settings.json.
In general it would by nice if you could expose more Editor-Scripting possibilities for lua in the near future. This would increase the power of the editor by magnitudes (IMHO)
- 1
-
Unfortunaltly it still doesn't work as expected. Here is a smaple material, one working and the other one not.
-
If a material is saved via code, then the thumbnails not get generated correctly.
when you create a Material in code, Load a texture and assign it to a slot.
The following is saved using Material:Save:
"texture0": "Materials/XXX/textures/brown_brick_02_diffuse.dds"
where it should be :
"texture0": "./textures/brown_brick_02_diffuse.dds"
the above code leads to thumbnails with just a white ball. The later one displays correctly.
-
The first case is solved, the second case is still bugged and can be reproduced like it is shown in the gif.
- 1
-
-
There are some issues with the updating the folder hierarchy whithin the editor.
- When you add a folder to the project structure in windows explorer, the folder is visible within the editor, but selecting it doesn't update the Assetbrowser (also when you copy files into the folder they will only appear after an editor restart)
- if you copy a more complex folder structure in the windows explorer or extract a zip file with multiple folders in the project directory, some directories are added multiple times and when you select one of the duplicates the selection goes to the first original entry.
- 1
-
As the title says, generate a Material and change some values / texture later. The thumbnail is not updated.
Polyhaven Browser Extension
in Extensions & Plugins
Posted
I will try the curl approach later. you can also add a refferer to curl.exe which could be used to fully support some api licenses.