HDR Image converted to lights

Post Reply
User avatar
clintonman
Captain
Posts: 5432
Joined: 21 May 2009, 21:08
Type the number ten into the box: 0
Location: California
Contact:

HDR Image converted to lights

Post by clintonman »

HDRIcar.jpg
image shows script result using 32 spotlights to recreate the lighting environment in the D3D view

HDRI to Lights script

This script will read an HDR image and convert it to a collection of lights and a preview sphere. Works with panorama(latitude/longitude) type images. This was adpated from the original python script for Houdini created by Steve Twist and found in the 3D World issue number 134. His script in turn is based off of the work of Paul Debevec and his 2005 Siggraph presentation of his Median Cut technique for getting lighting information from an image.

The 3DBuzz HDRI Shader Development for Mantra module starts with an introduction video to the subject of hdri images.
https://archive.org/download/3dbuzz-arc ... v-part-01/
HDRIcontrols.jpg
HDRI to Lights script and the resulting HDRILightsGroup object

Usage:

FileName - Press the "..." button to choose an image file
Reduce Factor - shrinks the size of the image for processing. Max is about 1024 pixels wide. Anything above that may eat all the memory and crash trueSpace
Divisions controls the number of lights created
Radius - the size of the preview sphere and lights
Intensity Multiplier - initial brightness control of the lights
Create Lights - press to create a preview sphere and spot lights group

There may be a delay between the script returning and trueSpace becoming responsive again.
The preview sphere will use the full resolution image.

The script has a number of dependencies so we'll just say that the Unofficial Updates is required to use it.
Panorama images for the 2 trueSpace cube map hdr images can be found here:
https://web.archive.org/web/20090203184 ... ection.htm

HDRILightsGroup is created by the HDRI to Lights script

Radius - change the size of the preview sphere and lights
Cone Angle - decrease the spotlight cone angle for higher quality shadows and increase for more light coverage
Intensity - control the brightness of the spot lights
Gamma - control the contrast of the image
Show Image Sphere
Hide Image Sphere - trueSpace primitive creation has a bug where they don't work properly if the view is engulfed by a mesh, this hides the mesh so it does not interfere
Shadow - enable shadows for the spot lights
Depth Bias - smaller numbers give better shadows up to a point
Shadow Threshold - used to limit the number of lights that cast shadows. The Luminance Low and High show the range of light values. Any light below this value will not cast shadows.
Set Shadows - applies the shadow options to the spot lights


One thing I discovered while working on this is that trueSpace will store colors outside of the 0 to 255 integer range. The color picker has the limit but the colors can be stored with HDR values and maybe can even have negative number values.

The script has a number of dependencies so we'll just say that the Unofficial updates are required to use it.
Attachments
HDRI to Lights.RsObj
(396.48 KiB) Downloaded 26 times
Clinton Reese

http://clintons3d.com
User avatar
clintonman
Captain
Posts: 5432
Joined: 21 May 2009, 21:08
Type the number ten into the box: 0
Location: California
Contact:

Re: HDR Image converted to lights

Post by clintonman »

HDRItoLights.jpg
New support for probe images and creating only the preview sphere without lights.
Probe or Angular images look like mirrored balls.

The probe conversion requires Hugin installation.

https://hugin.sourceforge.io/download/

New Controls:

Probe - when checked the image will be run through Hugin to convert it to the latitude/longitude format for the preview and light generation.
Background Image Only - when checked lights will not be created

If Hugin is not installed then no conversion will occur.
Attachments
HDRI to Lights.RsObj
(406.04 KiB) Downloaded 20 times
Clinton Reese

http://clintons3d.com
User avatar
clintonman
Captain
Posts: 5432
Joined: 21 May 2009, 21:08
Type the number ten into the box: 0
Location: California
Contact:

Re: HDR Image converted to lights

Post by clintonman »

EdgeKeepAnyway.jpg

It looks like if you download using the Edge browser you will have to tell it to keep it, "Keep anyway"
If you don't trust it then don't use the script with probe/mirror ball images.
Clinton Reese

http://clintons3d.com
User avatar
trueBlue
Captain
Posts: 5216
Joined: 06 Jul 2009, 22:50
Type the number ten into the box: 10

Re: HDR Image converted to lights

Post by trueBlue »

Try this modified HDRILightsGroup with a Transparent Plane
It does not have the Primitive Tool(S) issue
It is Uneditable and UnSelectable
Plane trick.png
Edit: Updated the Grid Plane material's color to black
This eliminates the banding shown in the image on the bottom of the objects
Grid set to None.png
.
Added benefit, it receives Shadows
update.png
Removed due to update
User avatar
clintonman
Captain
Posts: 5432
Joined: 21 May 2009, 21:08
Type the number ten into the box: 0
Location: California
Contact:

Re: HDR Image converted to lights

Post by clintonman »

HDRItoLightsNewControls.jpg

image shows new Rotation control for the HDRILightsGroup, new Reduce label and status display on the HDRI to Lights
far left shows the background panel of YafaRay4tS and the preview controls in the process of moving to the bottom of the panel

Update:

not required to run from inside the scene
yafaray compatibility - new YafaRay4tS in the works
auto crash protection from large images
tested - 8k image takes a long time to just load into tS, 16k image crash
color indicator red=image too small, yellow=reduce value was overridden to avoid crashes
new control for yaw rotation
regular widget locked - removed Matrix conn so cannot transform the group
test that the probe image is squarish shape
rewritten with undo friendly code - no need to delete all undos
question to remove temp files when converting probe images
asks to first remove old hdrilightsgroup if it already exists
questions and alerts - change to globalfs form to avoid opening underneath the tS window
open panel in stack view at end instead of select to show in stack view
auto clear input image after run - clear out memory usage
manual clear input image
Attachments
HDRI to Lights.RsObj
(525 KiB) Downloaded 14 times
Clinton Reese

http://clintons3d.com
User avatar
clintonman
Captain
Posts: 5432
Joined: 21 May 2009, 21:08
Type the number ten into the box: 0
Location: California
Contact:

Re: HDR Image converted to lights

Post by clintonman »

HDRItoLights_VRay.jpg

Got around to testing VRay render. For VRay the rotation value needs to be set at 180 degrees. I also changed the Gamma to 1 and Saturation to 2 to match the render after the fact. An important thing to remember is that the HDRLightsGroup does not render in VRay. In this case it is only for previewing. The preview sphere has to be hidden or removed before the render. In this case I also set VRay Env. lighting only, otherwise the preview lights would be in the final render.

Screenshot also shows the new Threshold slider control. Typing in the Shadow Threshold was wildly unintuitive to use. The graph shows the relative brightness of the lights as horizontal lines. The brightest light at the top and the dimmest at the bottom. Slider at 0 means all lights will cast shadows and as you move the control to the right the dimmer lights at the bottom will not cast shadows.

The next release will be an installer so it can be used with upcoming YafaRay4tS changes.
Clinton Reese

http://clintons3d.com
User avatar
clintonman
Captain
Posts: 5432
Joined: 21 May 2009, 21:08
Type the number ten into the box: 0
Location: California
Contact:

Re: HDR Image converted to lights

Post by clintonman »

Feb 17 2024
Publish first installer version

The only major change is it uses it's own internal spotlight instead of loading one in from tS and there were changes for yafaray background previews.

http://clintons3d.com/plugins/truespace ... ights.html
Clinton Reese

http://clintons3d.com
User avatar
clintonman
Captain
Posts: 5432
Joined: 21 May 2009, 21:08
Type the number ten into the box: 0
Location: California
Contact:

Re: HDR Image converted to lights

Post by clintonman »

Feb 24 2024

New release, mostly improvements to shadows and bug fixes

Nothing further is planned for this tool in the future.

Changes:

add filtering quality, filter size and sample count controls for shadows
separate light distance control
show/hide lights
fixed bugs probe and shadows and clear image from dialog
updates and fixes for yafaray bg(new yafaray4ts release coming up)
shadow map size control


EDIT:
One more small change coming. Testing with yafaray showed that the scale of the mesh and lights needed a small adjustment. The sphere will be created with a radius of 500 and the light distance will default to 50, 1/10 the sphere size.
Clinton Reese

http://clintons3d.com
User avatar
clintonman
Captain
Posts: 5432
Joined: 21 May 2009, 21:08
Type the number ten into the box: 0
Location: California
Contact:

Re: HDR Image converted to lights

Post by clintonman »

March 10 2024
Update

some changes mostly based on trueBlue changes

panel opens in a floating window - solves the need to change selection to clear the panel image
check for yafaray preview background nodes and ask before proceeding
fast hdrilightsgroup remove button which asks permission because there is no undo for fast delete

the new yafaray background check is setup to work with new not yet released sunsky background
Clinton Reese

http://clintons3d.com
User avatar
trueBlue
Captain
Posts: 5216
Joined: 06 Jul 2009, 22:50
Type the number ten into the box: 10

Re: HDR Image converted to lights

Post by trueBlue »

Awesome HDRI and EXR
For trueSpace and Clinton's HDR 2 Lights, recommend 2K or 1K
https://polyhaven.com/hdris
https://polyhaven.com/map
Square Probes
https://www.pauldebevec.com/Probes/
Post Reply