ScriptSpot

Forum topic · General Scripting

Writing EXR HDR values with bitmap IO functions

By thegoodwar · 2014-12-12

Description

Hi,
I'm attempting to store hdr values in a EXR file. When opened in photoshop, the values clamp between 0-1. Does anyone know how to store a signed 16 bit exr files via maxscript? I tried colors, float3s and float4s. It doesn't seem to affect the outcome.

Any tips would be greatly appreciated


	global ImageArray=#()
	tempArray=#()
	for j=0 to 15 do (
		append tempArray ([700, 100, 0, 15])--(color 153 228 184)
	)
	for i =0 to 15 do (
		append ImageArray tempArray
	)
			
	fopenexr.SetCompression 0 -- uncompressed
	fopenexr.setLayerOutputType 0 1 -- set layer 0  main layer to RGB
	fopenexr.setLayerOutputFormat 0 1 -- sets main layer to float 16 via 1. other options are 0 float 32, 2 int 32 
	
	TextureName = getSaveFileName types:"EXR (*.EXR)|*.EXR"
	FinalTexture = bitmap (ImageArray.count) (ImageArray.count) filename:TextureName;
	for i=0 to (ImageArray.count-1) do (
		setPixels FinalTexture [0, i] ImageArray[i+1]
		print ImageArray[i+1]
	)
	
	save FinalTexture
	close FinalTexture
Comments (1)

thegoodwar · 2015-01-27

The issue was that

FinalTexture = bitmap (ImageArray.count) (ImageArray.count) filename:TextureName;

did not include "hdr:true"