Planetside Software Forums

General => Terragen Discussion => Topic started by: N-drju on December 19, 2017, 04:43:02 AM

Title: HDR image in TG - possible?
Post by: N-drju on December 19, 2017, 04: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. ::)
Title: Re: HDR image in TG - possible?
Post by: digitalguru on December 19, 2017, 05: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!

Title: Re: HDR image in TG - possible?
Post by: N-drju on December 19, 2017, 06: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?
Title: Re: HDR image in TG - possible?
Post by: digitalguru on December 19, 2017, 06: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.
Title: Re: HDR image in TG - possible?
Post by: N-drju on December 19, 2017, 07: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?
Title: Re: HDR image in TG - possible?
Post by: pokoy on December 19, 2017, 08:06:01 AM
Quote from: N-drju on December 19, 2017, 07: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?

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.
Title: Re: HDR image in TG - possible?
Post by: N-drju on December 19, 2017, 08:41:50 AM
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.
Title: Re: HDR image in TG - possible?
Post by: digitalguru on December 19, 2017, 08:48:00 AM
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
Title: Re: HDR image in TG - possible?
Post by: N-drju on December 19, 2017, 09:01:27 AM
Quote from: digitalguru on December 19, 2017, 08:48:00 AM
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.
Title: Re: HDR image in TG - possible?
Post by: digitalguru on December 19, 2017, 09:16:31 AM
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.
Title: Re: HDR image in TG - possible?
Post by: N-drju on December 19, 2017, 02: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. ;)
Title: Re: HDR image in TG - possible?
Post by: paq on December 19, 2017, 11:56:00 PM
Hi N-drju,

You can use  http://www.hdrlabs.com/picturenaut/index.html (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.
Title: Re: HDR image in TG - possible?
Post by: N-drju on December 20, 2017, 02: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.
Title: Re: HDR image in TG - possible?
Post by: digitalguru on December 20, 2017, 07:25:40 AM
QuoteWhat'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.
Title: Re: HDR image in TG - possible?
Post by: N-drju on December 20, 2017, 11:59:13 AM
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
Title: Re: HDR image in TG - possible?
Post by: digitalguru on December 21, 2017, 06:25:36 AM
You got it - you would only use Picturenaut to load the image in one format, then save it in another, no processing required.

Picturenaut can assemble an HDR image form a series of photographs (from the "real" world) at different exposures, but that would be a different workflow entirely.

The exr output from Terragen is high dynamic range by default, you would never need to create a series of exposures to assemble an HDR image.