Author Topic: HDR image in TG - possible?  (Read 398 times)

Offline N-drju

  • Member
  • *
  • Posts: 952
  • A ship in port is safe... well, fine by me.
HDR image in TG - possible?
« on: December 19, 2017, 08:43:02 AM »
Morning everyone,

I have a not so simple question - is it possible to create an HDR image in TG that can later be used as a lighting information for other programs? Like DAZ Studio for instance?

Correct me if I'm wrong - I consider .hdr images as a "light chart" of sorts that allows a given renderer to provide more or less automatic light generation in a 3d environment. Is that correct? I know, it's a gross simplification, but in general terms...?

So the first thing that comes to my mind is, of course, a spherical camera. Aaaand... that's it? HDR ready?

It doesn't have to be a pixel-perfect lighting mind you. All I need is a reliable, fairly accurate and nice resource to put some light into my DAZ scene... MY way.

Especially that .hdr files are rarely free of charge. ::)
"Error 404 - pun not found."

Offline digitalguru

  • Member
  • *
  • Posts: 207
Re: HDR image in TG - possible?
« Reply #1 on: December 19, 2017, 09:53:27 AM »
Pretty much, if you save to an .exr format and if you have Terragen 4 you can also render a 32 bit image.

In fact, some commercial providers of HDR environment panoramas use Terragen to generate them.

As to pixel perfect perfect - see this post :
https://www.planetside.co.uk/forums/index.php/topic,21829.msg240240.html#msg240240

first image is a Terragen render
third image is exported Terrain in Maya rendered with a spherical render from Terragen to create an HDR to use as lighting

pretty close!


Offline N-drju

  • Member
  • *
  • Posts: 952
  • A ship in port is safe... well, fine by me.
Re: HDR image in TG - possible?
« Reply #2 on: December 19, 2017, 10:04:07 AM »
Hm, that's cool. I thought it may get more complicated. But do I need to convert .exr to .hdr somehow, and if yes is Photoshop enough?

I am not sure how familiar are you with DS, do you think it reads .exr files for environment maps?
"Error 404 - pun not found."

Offline digitalguru

  • Member
  • *
  • Posts: 207
Re: HDR image in TG - possible?
« Reply #3 on: December 19, 2017, 10:27:40 AM »
Sorry, I don't know Daz studio, but if it can, use the spherical render (.exr) directly from Terragen.

You could load it into Photoshop and convert it to HDR, but you will need to ensure you don't add any exposure or gamma correction in the process that might de-linearize the image. Images to be used as image based lighting shouldn't have any gamma applied.
« Last Edit: December 19, 2017, 10:50:53 AM by digitalguru »

Offline N-drju

  • Member
  • *
  • Posts: 952
  • A ship in port is safe... well, fine by me.
Re: HDR image in TG - possible?
« Reply #4 on: December 19, 2017, 11:02:35 AM »
Hm, that's an interesting bit though...

.exr images from TG turn outrageously bright... Are you sure I should just leave it as is?
"Error 404 - pun not found."

Offline pokoy

  • Member
  • *
  • Posts: 156
    • mswee.net
Re: HDR image in TG - possible?
« Reply #5 on: December 19, 2017, 12:06:01 PM »
Hm, that's an interesting bit though...

.exr images from TG turn outrageously bright... Are you sure I should just leave it as is?

That's because EXR and HDR (high dynamic range formats) are not tone mapped - unlike the frame buffer and low dynamic range formats such as TIF, BMP or PNG. Internally, all low dynamic range output is derived from the high dynamic image data and then tone compressed so it looks like what you would expect from a camera. In fact, all camera software does exactly the same, albeit their dynamic range is way lower than what's possible in the digital world.

If your HDR image is too bright, simply tone down exposure of that map (or in post-processing options if available) in the software you use for rendering.

Offline N-drju

  • Member
  • *
  • Posts: 952
  • A ship in port is safe... well, fine by me.
Re: HDR image in TG - possible?
« Reply #6 on: December 19, 2017, 12:41:50 PM »
Luckily DS has many options (including exposure) to control this. :)

Then I guess, I'll give it a go with a non-modified environment map first (other than convert it to .hdr) and then change light power from within the software if necessary.
"Error 404 - pun not found."

Offline digitalguru

  • Member
  • *
  • Posts: 207
Re: HDR image in TG - possible?
« Reply #7 on: December 19, 2017, 12:48:00 PM »
hmmm in theory it shouldn't be - for instance, the images in the reference post are rendered in Maya/Arnold  - the exr is loaded into a dome light and rendered - nothing changed except to rotate the map to match the light direction in Terragen.

However if you look at the your HDR image in something like Photoshop and do a 32 bit sample of the values you'll probably see that sampling the centre of the sun produces values that are many thousands times brighter than any other part of your image. There may be something to adjust in Daz that might fix this - you'd need to get on the forums perhaps for some tips.

However in most professional studios a common workflow is to use two versions of the HDR (or EXR) map. One will have the sun painted out and the other with just the sun extracted, and two separate lights in the scene to use the modified maps. That way the main keylight coming from the sun can be adjusted in relation to overall ambient light (for example the light from the sky and the ground).  Usually these separate lights can be left at default intensities and they will approximate the scene the HDR was taken from, but in your case it could adjust the sun (key) light down to a more manageable level.

Before renderers like Arnold had a clamp facility, I used to clamp the output of dome light to prevent "fireflies" - these were bright pixels in an image that were often produced by having a light source with very high values ( like 20, 000 +) in an image - in most cases clamping the max value of the HDR to something as low as 100 didn't change the overall look of the render but prevented the firelflies.

You might want to experiment with clamping your HDR to a similar value - either in Photoshop or on the fly in Daz if such a feature exists

Offline N-drju

  • Member
  • *
  • Posts: 952
  • A ship in port is safe... well, fine by me.
Re: HDR image in TG - possible?
« Reply #8 on: December 19, 2017, 01:01:27 PM »
nothing changed except to rotate the map to match the light direction in Terragen.

By the way, do you have any idea on how to make this adjustment easy? I know rotating the enviro map may be a problem, especially when you don't know what was the sun position in the original photo. You end up with sun shining from beneath the ground then. :D Is, for instance, setting a sun rotation to 0 (north) and 45 degree of elevation helpful in any way?

Actually, I am usually lighting DAZ people and later just post them back into TG renders. So as you can see I don't really need too much complexity. I just need an alpha channel. Which, luckily, DAZ also renders by default. :D I hope there should be no surprises and no fireflies then.
"Error 404 - pun not found."

Offline digitalguru

  • Member
  • *
  • Posts: 207
Re: HDR image in TG - possible?
« Reply #9 on: December 19, 2017, 01:16:31 PM »
If you are inserting Daz characters into a Terragen render you should assume that the elevation of the sun position that gets rendered to the spherical map is correct (so the height of the sun is the same)

The only variable that may occur is the rotation of the spherical map around its vertical axis ( the Y coord in Terragen)

Depending on the 3d app your are rendering in, this might have to be adjusted. For instance, if I load the map into Maya and render with Arnold, I know i have to rotate the map 180 degrees in Y for the lighting to match, this might be the same or a different value in Daz, but I would imagine all you'd have to do is rotate the hdr light in 90 degree increments (around the vertical axis) till it looks right.
« Last Edit: December 19, 2017, 01:28:06 PM by digitalguru »

Offline N-drju

  • Member
  • *
  • Posts: 952
  • A ship in port is safe... well, fine by me.
Re: HDR image in TG - possible?
« Reply #10 on: December 19, 2017, 06:23:08 PM »
Okay, an update...

First of, of course! Your explanation makes perfect sense. The thing is that I was once using a completely alien .hdr and had no idea where the sun is. So I had a tough time figuring out what rotation is the correct one. ;) This somehow planted a notion in my mind that it is tricky hence the question.

I tried the crude, fresh-out-of-TG .exr file first... and failed miserably... :-\ The lighting and shading is screwed up. I guess it's because of bit depth. What's the default .exr output in TG?

Then came another surprise - my version of Photoshop does not read .exr's. As a matter of fact, I cannot even convert files to 32 bits!! >:( The only choices I get in PS is 8 bits/channel and 16 bits/channel which outputs either 24 or 48 bit images... Needless to say, DAZ Studio does not produce any lighting with these images except for a general brightness and a small speck of shadow on the ground for the person/object.

It's a bit exotic... but I'll try to duplicate the blue channel, thus, producing a 32bit image. Not sure if I can fool DS this way though... :P Or add the extra alpha channel that TG can additionally produce.

On a positive note - DAZ Studio Iray renderer has a firefly filter of its own. ;)
"Error 404 - pun not found."

Offline paq

  • Member
  • *
  • Posts: 190
Re: HDR image in TG - possible?
« Reply #11 on: December 20, 2017, 03:56:00 AM »
Hi N-drju,

You can use  http://www.hdrlabs.com/picturenaut/index.html to convert .exr to .hdr

Beside I would slightly increase the angular diameter of the Sun disc (Lighting option), to avoid out of range pixels that might appends when converting file format.
(otherwise you might get black or pink sun)

Something like 0.55 - 0.6 should be fine.
Gameloft

Offline N-drju

  • Member
  • *
  • Posts: 952
  • A ship in port is safe... well, fine by me.
Re: HDR image in TG - possible?
« Reply #12 on: December 20, 2017, 06:51:50 AM »
paq, thank you for this link so much! Looks like a very reliable program. :) I only hope that DAZ Studio considers the output valid. ::)

It is complicated, because DS does not have such a comprehensible documentation as TG does. It is hard to anticipate or pinpoint what file formats and properties are supported or not.

I'll check tonight whether Picturenaut can handle the situation.
"Error 404 - pun not found."

Offline digitalguru

  • Member
  • *
  • Posts: 207
Re: HDR image in TG - possible?
« Reply #13 on: December 20, 2017, 11:25:40 AM »
Quote
What's the default .exr output in TG?

If you can save to EXR in your version of TG it will be 16bit float. If you have TG4 you can also select 32bit float.

As far as I know (not having Photoshop in front of me at work) Photoshop treats 16 float as 16 bit integer (you lose floating point precision) so I would save to 32 bit float if u can.

I'd forgotten about PictureNaut, it's a good free program - bypass Photoshop altogether and use that, much simpler.
« Last Edit: December 20, 2017, 11:29:52 AM by digitalguru »

Offline N-drju

  • Member
  • *
  • Posts: 952
  • A ship in port is safe... well, fine by me.
Re: HDR image in TG - possible?
« Reply #14 on: December 20, 2017, 03:59:13 PM »
Okay, I have downloaded Picturenaut but I'm stuck again... Obviously, I can't create .hdr from a single image... Something I, as an HDR newbie, naively hoped I could do. On the other hand, when I include several pictures, the final .hdr turns out either completely black, or completely grey. What am I doing wrong? Do I have to prepare TG render in any particular way to make it work? I don't know... divide it into several images? :-\



Edit:

GAWD!! How stupeeed I am! I should have noticed there is a SAVE AS option in the file menu. ;D I am a fucking genius, really... ;D
« Last Edit: December 20, 2017, 04:10:12 PM by N-drju »
"Error 404 - pun not found."