Rendering HDR files in 3ds Max

Hi,
I am struggling to render HDR data to my HDR images in max. I am rendering a cube map by playing a small cube in the scene and using the reflect/refract map to render my cubic map files to 6 HDR image files. Max is rendering the files correctly but the files are not containing any HDR data - i would expect highlights to stay when i reduce exposure in Photoshop extended.

Main question is how do I set up to render to HDR and do I have to set up the lights in any way to see the highlights preserved at low exposure?

Thanks

Gareth

This is a bit of a shot in the dark as I haven’t really messed with HDR in 3DS Max, but… Certain HDR techniques require high precision textures, more than 8-bits per channel. As such, depending upon your implementation, you might need to render your light intensity to a floating point texture in order to get the effect you’re after.

Thanks for the reply eevans.

I have been testing using Frame Buffer type: Floating Point (32 bits per channel) and saving to a .HDR file but no luck, I think I am still missing something.

Gareth

Out of the box the only thing I can think of is that the reflect/refract map is clipping hdr values… dunno, why are you using that map in the first place?

Also, have you tried exporting to EXR and see if you have the same clamped results?

I ended up writing a script to do this but I can’t remember if I had similar issues with the reflect/refract map.

See how you go with the script below. I wrote it to automate cube cross rendering and processing with ATI’s CubeMapGen but you may find it usefull.

To get started just modify (outputFolder=@“C: emp”) to the location you want to save to (don’t forget the final backslash!). It’s currently configured to output an HDR cube cross image from the location of the currently selected object but this can easily be changed.

Also, I’ve disabled the CubeMapGen stuff but to enable it just modify the “cubeMapGenPath” variable if needed and set (processWithCubeMapGen=false) to true.

Hope it helps, post if it gives you any grief :slight_smile:


-- Script to generate cube cross images from within max.
-- by Stefan Kamoda 2011
-- This script is freeware.
-- Tested using mental ray but may require the "force 2 sided" option in order to work with the default scanline renderer
	
Global RUST_CubeMapTools

struct RUST_CubeMapTools_Struct
(	
	--Location of Cube Map Gen exe.
	cubeMapGenPath = "C:\\Program Files (x86)\\ATI Research Inc\\CubeMapGen v1.1\\CubeMapGen.exe",
	
fn fnPasteBitmap src dest destPos =
(
	srcWidth = src.width
	srcHeight = src.height
	pastePos = destPos

		for y = 0 to (srcHeight-1) do
		(
			pixelRow = getPixels src [0,y] srcWidth
			setPixels dest [pastePos.x,pastePos.y] pixelRow
			pastePos += [0,1]
		)
),
	
	
fn fnCreateCubeMap setBasePath setBaseName setFormat setPos setGamma setCubeSize setCubeBlurFactor saveCubeCross processWithCubeMapGen=
(

--Cube map renderer
basePath = setBasePath 
baseName = setBaseName
imageFormat = setFormat 
tempCubeCrossPath = setBasePath + setBaseName + "_cubecross" + imageFormat
cubeCamera = freeCamera()
cubeCamera.scale.controller = scale_script()
cubeCamera.scale.controller.script = "[-1,1,1]" 
cubeCamera.fov = 90

cubeSize = setCubeSize
renderFaces = true
cameraPos = setPos-- altering the rotation changes the position! So fix it manually.

	
cubeFaces = #(
	#((quat 0.707107 0 0 0.707107),"forward"),
	#((quat 0.5 -0.5 -0.5 0.5),"right"),
	#((quat -0.707107 0 0 0.707107),"back"),
	#((quat -0.5 -0.5 -0.5 -0.5),"left"),
	#((quat -1 0 0 0),"top"), 
	#((quat 0 0 0 1),"bottom") 
)
bitmaps = #()
if renderFaces then
(
	index = 1
for face in cubeFaces do
	(
		cubeCamera.pos = cameraPos
		cubeCamera.rotation = face[1]
		cubeCamera.pos = cameraPos
		
		redrawViews()
		bitmaps[index] = bitmap cubeSize cubeSize HDR:true
		
		--/*
		render \
		camera:cubeCamera \
		gamma:setGamma \
		vfb:true \
		outputHDRbitmap:true \
		to:bitmaps[index] 
		
		undisplay bitmaps[index]
		index += 1
		--sliderTime += 1
	)
)
deleteFile tempCubeCrossPath

cubeCross = undefined
cubeCross = bitmap (cubeSize * 3) (cubeSize * 4) \
filename:tempCubeCrossPath \
gamma:setGamma \ -- 2.2 = 0.454545
HDR:true \
Color:(color 245 0 0 0) \
PixelAspect:1 --\


freeSceneBitmaps()

--'Paste' source images into cube cross format
--top
fnPasteBitmap bitmaps[5] cubeCross [cubeSize,0] 

--Left
fnPasteBitmap bitmaps[2] cubeCross [0,cubeSize] 


--Front
fnPasteBitmap bitmaps[1] cubeCross [cubeSize,cubeSize]


--Right
fnPasteBitmap bitmaps[4] cubeCross [cubeSize*2,cubeSize]


--bottom
fnPasteBitmap bitmaps[6] cubeCross [cubeSize,cubeSize*2]


--back
fnPasteBitmap bitmaps[3] cubeCross [cubeSize,cubeSize*3] 

display cubeCross

--Targa.setColorDepth 32
--portable_network_graphics.setType #true48

	if (saveCubeCross) then 
	(
		save cubeCross 
	)

	if (processWithCubeMapGen) then
	(
		--cube map gen options, see cube map gen documentation for more information.
		cmdString = cubeCross.filename
		cmdString += " -filterTech:AngularGaussian"
		cmdString += " -numFilterThreads:2"
		cmdString += " -baseFilterAngle:" + (setCubeBlurFactor as string)
		cmdString += " -exportFilename:" + (setBasePath + setBaseName + ".DDS")
		cmdString += " -exportPixelFormat:A16B16G16R16" 
		cmdString += " -exportCubeDDS"
		cmdString += " -exit"
		
		shellLaunch cubeMapGenPath cmdString
	)
--Remove the cube map camera
delete cubeCamera
)
)


RUST_CubeMapTools = RUST_CubeMapTools_Struct()

--Notes on calling the function:
--Don't forget trailing backslash when setting outputFolder!
--Don't forget to include the '.' when setting cubeMapFormat!

RUST_CubeMapTools.fnCreateCubeMap (outputFolder=@"C:	emp\") (cubeMapName="cubemap") (cubeMapFormat=".HDR") (cubeMapPosition=$.pos) (cubeMapGamma=1) (cubeMapFaceSize=128) (cubeBlurFactor=90) (saveResult=true) (processWithCubeMapGen=false)

Thanks for the script. The script works well for creating the Cube maps, but the refract/reflect does this well already.

Both methods (the script and refract/reflect) seem to not be exporting a HDR data. The file format is HDR but when I alter the exposure there is no HDR data.

If anyone has created a HDR image from a max scene could you possibly send me the HDR image to see that HDR data is possible from Max?

Thanks again for the replys

Gareth

Since I’m not into the gaming stuff, I ask again, why are you using reflect/refract? Like I’ve said before, those kind of maps, clamp HDR values, just like having an hdr with a composite or color correct, it immediatly looses it’s HDR information.

Thanks Kameleon! It is the reflect/refract map. I was using it to create my cube map but as you pointed out it is clamping the image.

I have done some test renders using the 6 camera and the images are now containing HDR data. I am using Photometric lights and it is worth noting the intensity needs to be increased until the real-pixel values are above 1.

Thanks

Gareth

Glad to help!

Glad to hear the script works. It won’t clamp output values so as long as there are bright light sources in the scene you’ll get values over 1 :slight_smile: