This is a MAXScript I’ve been working on recently. It exports an SC-file for use in Sunflow, an open source rendering system written in Java, which is freely available from http://sunflow.sourceforge.net
What’s new in Version 0.25?
– adds support for renderable splines
– adds basic support for the Arch & Design material, turning them into diffuse shaders using the diffuse color (or texture map if one is used)
– adds support for bump maps on mental ray Arch & Design materials
– any material that isn’t a Standard / Raytrace / Shellac / Arch & Design material is now defined as a diffuse shader using the objects wire colour
– adds support for Free_Point lights (the power setting may need adjusting, it uses the candela value divided by 1500, and then multiplied by the multiplier value)
– fixes a bug where objects with a multi/sub-object material and no UVs were missing the “face_shaders” parameter
– changes the way of setting bump map strength, it now uses the the ‘Bump Amount’ value from the maps’ Output settings
What was new in Version 0.24?
– adds support for Hair and Fur modifiers
– adds support for the Amb-Occ shader
– fixes a bug where exporting a scene more than once resulted in the bump modifiers being left out
– fixes a problem with naming bump modifiers
– finally fixes the “center” value for IBL (to get this to work properly, you will need to set the “U Tiling” value in Max to -1)
What was new in Version 0.23?
– adds support for Multi/Sub-Object materials
– adds a “Skip geometry” checkbox. Useful if you’ve already exported your geometry, and just want to fiddle with the materials or sunflow settings.
– bumpmaps now work in Uber shaders
– fixes bumpmaps on instanced objects being missed
– fixes a bug in the way that camera transforms are exported
What was new in Version 0.22?
– adds the “Enable Jitter” option to the Sampling settings
– adds support for spherical cameras (the old exporter only had support for the fisheye camera)
– adds an option for importance sampling to the IBL settings
– adds a setting for SunSky turbidity
– fixes a bug with filenames for separate geometry files
– planes are now only infinite if the render scale is greater than 1
– changes the way of getting blur strength for Phong shaders again (now uses Max softness setting x 1000)
– fixes a bug with GI settings in the INI file not being loaded properly
– changed the layout of the Camera section to avoid confusion with the different settings for different camera types
– adds an option to reverse the bucket order
– fixes a bug where the exporter would crash if the camera was deleted before exporting the scene
– fixes a bug that was causing problems in Max if the script aborted during export
What was new in Version 0.21a?
– fixes automatic rendering after export
– changes the encryption of the script so that it works with older versions of Max again
What was new in Version 0.21?
– fixes a bug with incorrect scaling of instances
– fixes a bug with instanced materials not always being recognized
– changes the way of getting blur strength for Phong shaders (now uses Max softness setting x 100)
– adds an INI file so that settings from the previous session get loaded when you start the script
– changes the way of outputting camera transforms, which means that roll angles now get exported properly
– adds support for the debug shaders (GI, photons and caustics)
– the script is now a macroscript, and can be started from a toolbar
– adds support for the Uber shader
– adds the option to start rendering the scene after exporting it (the first time you do this you need to set up the paths first)
What was new in Version 0.20?
– adds settings for light samples
– removes the image / animations settings from the rollout (now uses Render Scene settings)
– adds meshlights
– adds object instancing and material instancing
– fixes a bug in animation export
What was new in Version 0.19?
– fixes a problem with German-language Max not finding cameras
– fixes a problem with mental ray shaders stopping export
– fixes a bug where the exporter tried to export UVs that didn’t exist
– fixes a bug with negative scale values
– the script no longer exports multiple duplicated materials
– groups now get exported properly
– fixes some shaders being exported twice
– adds image-based lighting
What was new in Version 0.18?
– the script now checks the screen resolution, and makes the rollout shorter for lower resolutions
– legacy particle systems only export the particles visible in the viewport (doesn’t apply to PFlow)
– adds camera motion blur
– adds diffuse texture map export
– adds bump map export
– adds UV export for meshes
– fixes a bug when exporting Strauss materials
What was new in Version 0.17?
– updated the script to work with SunFlow v0.07.2
– fixed a bug in particle export
– adds camera settings for lens sides and rotation
– shaders now use the material name if a material has been assigned
– changed the file extension of particle files form *.bin to *.part.sc
– adds an option to export geometry to a separate file with the extension *.geo.sc
– the exporter no longer needs the plugin ‘Endian.dlx’
What was new in Version 0.16?
– adds shader support
– generally faster (more than 50% faster when exporting lots of particles)
– tidied up my code, because it was a complete mess…
What was new in Version 0.15?
– fixes a bug with particle systems
– adds photon settings
– adds support for IES_Sun, mr_Sun and Daylight systems
What was new in Version 0.14?
– adds support for PFlow particle systems
– adds all of the GI options for Sunflow
What was new in Version 0.13?
– fixes another transform problem if objects are created in Edge mode instead of Center mode
What was new in Version 0.12?
– transforms were going wrong for some objects – fixed
– tidied up a few functions
What was new in Version 0.11?
– added particle export
What was new in Version 0.1?
– first release
All camera types
– If you enable DOF, you can use the cameras ‘Far Range’ to focus.
– Also with DOF, if the ‘Lens Sides’ setting is less than 3, a circular lens will be used.
– Point (omni) and directional lights (free / target spotlights / directlights)
– IES_Sun, mr_Sun and Daylight systems
– IBL (image-based lighting) is automatic if an HDR or EXR image is used as an environment map (and is turned on). To get the same view of your HDR in SunFlow as in Max, you will need to set the U Tiling value to -1
– Meshlights: the object MUST have a name beginning with “meshlight”, and a standard material with an output map in the diffuse channel. The diffuse color is multiplied by the output amount to get the radiance amount.
– Primitives: sphere, torus, teapot, plane (if the planes render scale is greater than 1 it gets converted to an infinite ground-plane)
– Standard particle systems and PFlow systems
– Hair and Fur modifiers: the width setting is taken from the ‘Root Thick’ setting in the modifier, the amount from the ‘Hair Count’ setting, and the shader just uses the the ‘Root Color’ setting to create a diffuse shader
– Renderable splines
– Everything else gets turned into a generic mesh (including UVs and Material IDs)
– Object instances get exported as SunFlow instances
– All objects with no material assigned get a diffuse shader with the object colour
– All objects with a material type not covered by the other shaders get a diffuse shader with the object colour
– Standard and raytrace materials with shader type OrenNayerBlinn get exported as a diffuse shader using the diffuse colour
– Any materials with a self-illumination value of more than 0 get exported as a constant shader
– Any materials with a self-illumination / luminosity colour more than 0,0,0 get exported as a constant shader
– Any materials with an opacity of less than 100 are exported as a glass shader using the diffuse colour and IOR set in Max
– Raytrace materials with a reflection colour more than 0,0,0 get exported as a mirror shader using the reflect colour as the mirror colour
– Raytrace materials with a reflection amount of more than 0 get exported as a mirror shader using the reflect amount to set a greyscale for the mirror colour
– Standard and raytrace materials with shader type Blinn or Phong get exported as a phong shader using the diffuse and specular colours in Max
– Blur strength is calculated using the Softness setting in Max x 1000 (so if you want a blur strength of 2, you need to set Softness to 0.002)
– Standard and raytrace materials with shader type Anisotropic or Multi-Layer get exported as a ward shader using the diffuse and specular colours in Max.
– X and Y roughness is calculated using the glossiness setting (0 = very blurry, 100 = sharp) and the anisotropy setting (0 = X and Y equal, 50 = Y half the width of X, etc.)
– Standard and raytrace materials with shader type Metal or Strauss get exported as a shiny shader using the diffuse colour
– Shininess is set using the glossiness amount
– Any Shellac material exports the Base Material as an Uber shader
– Diffuse color and texture are set using the Diffuse color and map slot in Max
– Specular color and texture are set using the Specular color and map slot in Max
– Diffuse and specular blend amounts are set using the Map Amount settings for the Diffuse and Specular maps divided by 100
– Samples are set using the Specular Level amount in Max
– Glossiness is set using the Soften amount in Max (I couldn’t use the Glossiness setting in Max because it only handles integers)
– Any Standard material with a Falloff map in the Diffuse slot exports as an amb-occ shader
– The Falloff front colour is used for the SunFlow bright colour
– The Falloff back colour is used for the SunFlow dark colour
– At the moment, the ‘samples’ and ‘dist’ values are fixed at 32 and 10. If I can think of a good way of setting them in Max, I’ll change this
IMPORTANT – shaders always get assigned in the following order:
1. Any standard material with a falloff map in the diffuse slot gets an amb-occ shader
2. Any material with self-illumination gets a constant shader
3. Any material with transparency gets a glass shader
4. Any raytrace material with reflection gets a mirror shader
5. After that the different shader types get assigned according to the material types listed above.
– bitmaps in the Diffuse map channel get exported as part of the shader
– bitmaps in the Bump map channel get exported as bump modifiers
– Support for single frames and animations: uses the Render Scene Dialog to get the image size and still / animation / range settings
– Animations get written to multiple files (test0000.sc, test0001.sc, etc.)
– Particle systems get written to an extra .bin file which has the same filename as the .sc file.
– Particle systems get written to an extra *.part.sc file which has the same filename as the .sc file
– If the ‘Separate geometry file’ checkbox is checked, all geometry is exported to an extra file with the ending *.geo.sc
– There is also a ‘Skip’ checkbox which is only active if the ‘Separate geometry file’ is checked. This is useful if you’ve already exported everything once, and just need to tweak materials and render settings. When this is on, the exporter will export everything except the geometry.
– If the ‘Start Sunflow after exporting’ checkbox is checked, the exported scene is automatically rendered (the first time you do this you need to set the paths to Sunflow and Java by clicking on the ‘Set Paths’ button)
What’s not done yet:
– It looks like just about everything is in there now…
Click here for the script. (71.6 Kb)
The main script (max2sunflow024.mse) goes in the main Scripts folder
(usually C:\Program Files\Autodesk\3ds Max 9\Scripts)
The macroscript (max2sunflow.mcr) goes in the macroscripts folder:
C:\Program Files\Autodesk\3ds Max 9\ui\macroscripts
The 4 icons (*.bmp) go in the icons folder:
C:\Program Files\Autodesk\3ds Max 9\ui\Icons
Now start Max, go to Customize -> Customize User Interface… and add the macroscript to a toolbar or menu of your choice
(I always use the ‘Extras’ toolbar for my bits and pieces)
If you are going to be exporting a lot of particles, or very heavy scenes, it night be an idea to increase the memory allocation for MAXScript. You can do this by going into the ‘Customize -> Preferences… -> MAXScript’ settings, and increasing the ‘Initial heap allocation’ setting. I’ve got mine set to 64MB.
If you find any bugs, just send me a mail
As far as I know, this script won’t do any damage to you, your computer, or your Max installation, but I can’t guarantee anything. If something should go wrong, I’m sorry, but I’m not liable. It’s free, after all!
Script last updated: 07.04.2008