Jump to content

PBR Texture Generator


klepto2
 Share

Recommended Posts

Here it is a first release of my PBR Texture generator made with UltraEngine:

UltraPBRTextureGen.zip

[New-Version with real hdr and Exposure]

UltraPBRTextureGen_v0_8.zip

Features:

  • Standalone UI-App with preview and settings
    • Allows single import of panorama (*.hdr) and cubemap (*dds and *.tex) files
    • Adjustments for samples / lodbias and resolutions
    • Saving is limited (it currently saves only to appdir and the names are fixed to sky_diffuse/sky_specular
  • CLI 
    • Allows batch and single operations on folders or single files
    • Full set of parameters here:
Usage:
  UltraPBRTextureGen.exe [OPTION...]

  -b, --batch        Batch operations
  -c, --cubemap      Convert cubemaps (dds, tex)
  -p, --panorama     Convert panoramas (hdr)
  -d, --dir arg      path to search the files (only used with batch option)
  -o, --out arg      output folder
  -f, --file arg     file to convert (only when not used with batch option)
  -s, --samples arg  Samples to be used (default: 1024)
      --lb arg       LodBias to be used (default: 0.0)
      --dr arg       Resolution for the diffuse map (default: 128)
      --sr arg       Resolution for the specular map (default: 1024)
  -h, --help         Show help

In the folder cli-samples is a subfolder for HDRI images, for the sample commands to work you first need to download one or more HDR images from a source like https://polyhaven.com/hdris

Screenshot:

image.thumb.png.5a425f9cf88c2788cb04b266a233ac25.png

the generated files can directly be used in the UltraEngine Editor under MAP/Environment/(Background/Specular/Diffuse) to provide proper PBR lighting. 

Planned Features:

  • Fix save behaviour in the GUI-App
  • Add more image formats
  • Add Exposure control for generation like here: https://matheowis.github.io/HDRI-to-CubeMap/
  • provide a small cpp lib to enable on the fly (realtime) generation of these textures.
Edited by klepto2
Updated download
  • Like 2
  • Thanks 2
  • Upvote 1
  • Windows 10 Pro 64-Bit-Version
  • NVIDIA Geforce 1080 TI
Link to comment
Share on other sites

UltraPBRTextureGen_v0_8.zip

New Version with exposure added to the import of hdr images.

Changes: 

  • HDR files are now loaded as real HDR images and not converted to LDR before processing
  • Exposure parameter added (default 4.0) 
  • Gui:
    • Added Exposure controls and rebuild panorama button
    • When you import a panorama or cubemap, the initial build is triggered.
  • Like 1
  • Windows 10 Pro 64-Bit-Version
  • NVIDIA Geforce 1080 TI
Link to comment
Share on other sites

Wow, this is so so good. Can it convert a folder of panoramas to environment maps?

This will convert a whole folder of HDRIs. This saves so much time:

UltraPBRTextureGen.exe -b -p -d ./hdris

FYI, with big textures and a 1024 sample count, some graphics cards can time out on that IBL shader and produce the VK_DEVICE_LOST error:
https://github.com/KhronosGroup/glTF-IBL-Sampler/issues/8

I remember setting some OS setting or reg key to allow a longer timeout with the Vulkan driver, when I was using the Khronos app.

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

14 hours ago, Josh said:

Wow, this is so so good. Can it convert a folder of panoramas to environment maps?

This will convert a whole folder of HDRIs. This saves so much time:

UltraPBRTextureGen.exe -b -p -d ./hdris

FYI, with big textures and a 1024 sample count, some graphics cards can time out on that IBL shader and produce the VK_DEVICE_LOST error:
https://github.com/KhronosGroup/glTF-IBL-Sampler/issues/8

I remember setting some OS setting or reg key to allow a longer timeout with the Vulkan driver, when I was using the Khronos app.

yes i noticed this as well, in an early version it was as soon as I created a cubemap > 512px. Unlike the method of the IBL Sampler from Khronos I am using a compute pipeline for this, which means i could reduce the errors by maximizing the Workgroup sizes to the allowed maximum. I have multiple compute shaders with different Local sizes and choose the correct one based on the current MipMapsize. 

It still happens with textures > 1024 (not everytime but from time to time) as i currently have just added 2 shaders one with a localSize of 1 and one with a local size of 32. But i will try to optimize it. Some suggestions to speed it up are not included in the IBL sampler code (e.g: precalculations of some values).

  • Windows 10 Pro 64-Bit-Version
  • NVIDIA Geforce 1080 TI
Link to comment
Share on other sites

I am currently working through this nice gem: https://placeholderart.wordpress.com/2015/07/28/implementation-notes-runtime-environment-map-filtering-for-image-based-lighting/

and i just made one small adjustment to the ibl shader pipeline (i simply reduce the samples based on the roughness, roughness = 0 --> samples = 32, roughness = 1.0 --> samples = maxSamples(default 1024)) and with this i was able to generate even 4k cubemaps without the lost device error and nearly the same quality. of course this has be altered to be used only, when x mipmaps are available. But maybe i can integrate some other ideas from this blog as well.

  • Windows 10 Pro 64-Bit-Version
  • NVIDIA Geforce 1080 TI
Link to comment
Share on other sites

Was playing with this. This truly makes it super easy to get skyboxes into Ultra Engine! 

If you place the extension within the Engine's Tool Directory, you can use this script to launch the application right from the editor which is much more convenient.

--[[
    This extention is intended to be used with Klepto2's PBR Texture Generator
    https://www.ultraengine.com/community/topic/62344-pbr-texture-generator/
]]--
local extension = {}
extension.toolpath = "/Tools/PBRTextureGen/UltraPBRTextureGen.exe"

function extension.hook(event, extension)
    if event.id == EVENT_WIDGETACTION then
        RunFile(AppDir()..extension.toolpath)
    end
end

--------------------------------------------------------------------
-- Add menu item
--------------------------------------------------------------------

local menu = program.menu:FindChild("Scripting", false)
if menu == nil then
    Print("Error: Could not find \"Scripting\" menu.")
    return
end

if menu ~= nil then
    local submenu = menu:FindChild("Generate", false)
    if submenu == nil then
        submenu = CreateMenu("Generate", menu)
    end
    extension.menuitem = CreateMenu("PBR Texture Generator", submenu)
end

ListenEvent(EVENT_WIDGETACTION, extension.menuitem, extension.hook, extension)

 

  • Like 3

Cyclone - Ultra Game System - Component PreprocessorTex2TGA - Darkness Awaits Template (Leadwerks)

If you like my work, consider supporting me on Patreon!

Link to comment
Share on other sites

  • 4 months later...

Hello.
I tried the tool using the GUI and through command prompt. In the GUI it will crash and using the command prompt it will be stuck at Importing Cubemap.
image.thumb.png.aba47f206e3f1a4beba210980f63423d.png
 

The gui will load, but crash on importing either panorama or other import option, or canceling the import.

I used this cubemap at 1k resolution (.hdr) https://polyhaven.com/a/symmetrical_garden_02
Windows 11 updated graphics drivers rtx 4090

 

Link to comment
Share on other sites

We saw the same thing with the Unity Vulkan builds of our benchmarks. It seems like Vulkan code only works temporarily before some update breaks it.

  • Sad 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

18 hours ago, Slastraf said:

Hello.
I tried the tool using the GUI and through command prompt. In the GUI it will crash and using the command prompt it will be stuck at Importing Cubemap.
image.thumb.png.aba47f206e3f1a4beba210980f63423d.png
 

The gui will load, but crash on importing either panorama or other import option, or canceling the import.

I used this cubemap at 1k resolution (.hdr) https://polyhaven.com/a/symmetrical_garden_02
Windows 11 updated graphics drivers rtx 4090

I will rebuild and refactor it as soon as the new Ultra Engine version is out, as I think there will be some kind of refactoring needed. I think most work will go into the actual Compute-Pipeline. For my current Environment (atmosphere and ocean) WIP I already have optimized a lot which might cause issues in this build, but I need time to polish it further and make it more future prove and stable.

  • Like 2
  • Windows 10 Pro 64-Bit-Version
  • NVIDIA Geforce 1080 TI
Link to comment
Share on other sites

  • 2 months later...

A basic implementation of HDRI to PBR is now available in the editor, without using Vulkan. See Scripts > Utilities > Hdri to PBR in the main menu.

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