V-Ray for 3ds max supports compiling and rendering OSL shaders,
And also offers some handy shaders for download on the V-Ray documentation website. Note: OSL shaders are supported only in V-Ray Advanced and not in V-Ray GPU.
To load an external OSL shader:
For a material (color closure) shader, create a: Materials > V-Ray > VRayOSLMtl
For a texture shader create a: Maps > V-Ray > VRayOSLTex
In the VRayOSLMtl or VRayOSLTex‘s General properties,
Click the Shader File slot-button to locate and load the *.osl file.
Provided that the shader has loaded and compiled successfully,
You will now be able to set it’s custom parameters in its Parameters section:
If compile errors will be found you’l be able to read the error messages in the V-Ray messages window:
To write an OSL shader:
To write a material shader (color closure) create a: Materials > V-Ray > VRayOSLMtl
To write a texture shader create a: Maps > V-Ray > VRayOSLTex
Expend the Quick Shader section of the node’s properties,
And check the Enable option.
Write you’r OSL code, and press Compile.
Provided that the shader compiled successfully,
You will now be able to set it’s custom parameters in its Parameters section:
If compile errors will be found you’l be able to read the error messages in the V-Ray messages window.
Software: 3ds max 2020 | V-Ray Next | Unreal Engine 4.25
This post details basic steps and tips for exporting models from 3ds max & V-Ray to Unreal Engine using the Datasmith plugin.
The Datasmith plugin from Epic Games is revolutionary in the relatively painless workflow it enables for exporting 3ds max & V-Ray architectural scenes into Unreal Engine.
Bear in mind however, that Datasmith‘s streamlined workflow can’t always free us from the need to meticulously prepare models as game assets by the book (UV unwrapping, texture baking, mesh and material unifying etc.) (especially if we need very high game performance).
That being said, the Datasmith plugin has definitely revolutionized the process of importing assets into Unreal, making it mush more convenient and accessible.
Make sure all materials are VRayMtl type (these get interpreted relatively accurately by Datasmith)
Make sure all material textures are properly located so the Datasmith exporter ill be able to export them properly.
In Rendering > Exposure Control:
Make sure Exposure control is disabled. Explanation:
If the Exposure Control will be active it will be exported to the Datasmith file, and when imported to Your Unreal Level/Map a “Global_Exposure” actor will be created with the same exposure settings. Sounds good, right? So what’s the problem?
The problem with this is that these exposure setting will usually be compatible with photo-metric light sources like a VRaySun for example, but when imported to Unreal, the VRaySun does not keep its photo-metric intensity. (in my tests it got 10lx intensity on import). the result is that the imported exposure settings cause the level to be displayed completely dark.
Of-course you can simply delete the “Global_Exposure” actor after import, but honestly, I always forget its there, and start looking for a reason why would everything be black for no apparent reason…
* If your familiar with photo-metric units, you can set the VRaySun to its correct intensity of about 100000lx, and also adjust other light sources intensity to be compatible with the exposure setting.
Select all of the models objects intended for export,
And File > Export > Export Selected:
* If you choose File > Export > Export you’l still have an option to export only selected objects..
In the File Export window,
Select the export location, name the exported file,
And in the File type drop-down select Unreal Datasmith:
In the Datasmith Export Options dialog,
Set export options, and click OK.
* Here you select whether to export only selected object or all objects (again)
Depending on the way you prepared your model,
You may get warning messages after the export has finished: Explanation:
Traditionally, models intended for use in a game engine should be very carefully prepared with completely unwrapped texture UV coordinates and no overlapping or redundant geometry UV space.
Data-smith allows for a significantly forgiving and streamlined (and friendly) workflow but still warns for problem it locates.
In many cases these warnings will not have an actual effect (especially if Lightmap UV’s are generated by Unreal on import), but take into account that if you do encounter material/lighting issues down the road, these warnings may be related.
Note that the Datasmith exporter created both a Datasmith (*.udatasmith) file, and a corresponding folder containing assets.
It’s important to keep both these items in their relative locations:
In Unreal Editor:
Go to Edit > Plugins to open the Plugins Manager:
In the Plugins Manager search field, type “Datasmith” to find the Datasmith Importer plugin in the list, and make sure Enabled checked for it.
* Depending on the project template you started with, it may already be enabled.
* If the plugin wasn’t enabled, the Unreal Editor will prompt you to restart it.
In the Unreal project Content, create a folder to which the now assets will be imported:
* You can also do this later in the import stage
In the main toolbar, Click the Datasmith button to import your model:
Locate the the *.udatasmith file you exported earlier, double click it or select it and press Open:
In the Choose Location… dialog that opens,
Select the folder to which you want to import the assets:
* If you didn’t create a folder prior to this stage you can right click and create one now.
The Datasmith Import Options dialog lets you set import options:
* This can be a good time to raise the Lightmap resolution for the models if needed.
Wait for the new imported shaders (materials) to compile..
The new assets will automatically be placed into the active Map\Level in the Editor.
All of the imported actors will be automatically parented to an empty actor names the same as the imported Datasmith file.
In the Outliner window, locate the imported parent actor, and transform it in-order to transform all of the imported assets together:
* If your map’s display turns completely dark or otherwise weird on import, locate the “Global_Exposure” actor that was imported and delete (you can of-course set new exposure setting or adjust the light settings to be compatible)
Continuing this example,
If you need to select objects (nodes) of a certain type i.e. lights, cameras etc.
You can use the INode class’s GetObject() method to get a reference to the node’s object, or “modified object” in 3ds max terms, and use the object’s GetSuperClassID() method to get the integer id representing the object’s superclass.
An example of a script that selects all light objects in the scene:
from MaxPlus import SuperClassIds
from MaxPlus import SelectionManager
list = 
for c in node.Children:
list = list + list_children(c)
for o in scene_objects():
obj = o.GetObject()
if obj.GetSuperClassID() == SuperClassIds.Light:
* note that when copying and pasting a script from this example, the indentation may not be pasted correctly.
tyFlow is a new advanced event driven particle / dynamics system plugin for 3ds max that can somewhat be described as the “next generation of Particle Flow*“.
An ‘event driven particle system‘ is a particle system in which the behavior of the particles is defined in ‘events‘. each event contains a collection of ‘operators‘ that control the different aspects of the particle behavior, like their shape, their speed, direction etc. special ‘test operators‘ are used to check if the particles should switch to a different event and so change their behavior.
Setting up an event driven particle system in 3ds max is done through a node based visual interface, in which the nodes in the flow graph are the particle events, each event is a collection of operators and their parameters.
This tutorial demonstrates some fundamental concepts of event driven particles and tyFlow:
Using Property Test operators to switch between different motions and shapes.
Using the PhysX Shape and PhysX Switch operators to switch between physical and non-physical particle behavior.
Spawning new particles and deleting them.
> Note that while understanding the logic of this example is relatively easy, tweaking all the parameters to get it right takes a lot of tests and fine tuning. Download the example file and playing with the system parameters to get to know how the different operators affect the particles.
> To create a tyFlow particle system:
In Command Panel > Create > Standard Primitives,
Click tyFlow, and then click and drag in the viewport to create a tyFlow object.
When the tyFlow object is selected, in the Modify panel press the Open Editor button to open the tyFlow editor. Drag operators from the library below to the work space in order to create a new event containing them, or drag them into existing events.
> Note that almost all of the system’s events contain a Display operator set to Geometry mode so that the particle’s actual animated shapes will be displayed in the viewport, and also a Mesh operator needed for particles to be exported to a render engine for final rendering.
Particles are initially created in event: ‘Birth’ using a Birth Objects Operator, and are immediately sent to the next event: ‘Physical Falling’ by the Send Out operator.
> The Birth Objects operator is used to initialize particles directly from scene objects.
Initial setup of the spheres as sources of particles for the Birth Objects operator:
The event titled ‘Physical Falling’ is the only event in the system in which the particles behave as PhysX objects who’s motion is governed by physical simulation i.e they fall and collide with the slide model (named Box001).
The PhysX Shape operator turns the particles into physical simulation objects, and the PhysX Collision operator adds the slide model as a collision object to the simulation.
A Property Test operator checks if the falling balls fell below -35 in the Z axis, and if so sends them to the event titled ‘Rocket Upward’. > Note that in the PhysX Collision operator, the Hull Type of the slide model is set to Mesh rather than Convex to allow the sphere particles to slide inside the slide (a convex hull type would behaves as if it’s filled making the balls fall to the sides)
> Note that in the tyFlow PhysX settings, the default ground collider has been disabled to allow the balls to fall freely below the 0.0 Z axis position.
> The (standard) Shape Operator and Speed operators are in this event in order to reset the shape and speed of particles in case they entered this event after already having different shapes ans speeds.
The event titled ‘Rocket Upwards’ uses a PhysX Switch operator to deactivate the particles participation in physical simulation, assigns them a new (rocket shape),
A Force operator referring to a tyWind object causes the particles to accelerate upwards, and a Spawn operator to have each original particle spawn new particles as the rocket trail.
A Property Test operator checks if the particles have reach a height of 200 and if so sends them to the event titled ‘Chopper back to start’. > Note that the Slow, and Rotation operators are in this event to force the particles back to default orientation so the rockets will be aimed upwards. > The Spawn operator creates new particles and at the original particle location and sends them to the event titled ‘Rocket flare’.
The event titled ‘Chopper back to start’ assigns the particles a new ‘little chopper’ animated shape, and uses a Force operator to make them affected by the tyWind object pointing back to the start.
> Note that the Shape operator has the Animated Geometry option checked, and set to sync by particle age. the animation speed is played back 3 times faster than the original animation. > A Property Test operator checks if the particles Y position higher than -150 and if so sends the particles to the event titled ‘find drop location’.
The event titled ‘find drop location’ uses a Find Target test operator to make the particles move to the Point Helper object located above the slide and when they have reached it send them back to the event titled ‘Physical falling’ where they start their journey all over again.
> Note that the Slow operator slows the particles velocity that was inherited for the previous event so they wont overshoot and ‘fly’ further beyond the point helper.
The event titled ‘Rocket flare’ defines the shape, speed and direction of the spawned rocket trail particles and uses a Time Test operator to check if the trail particles have existed more than 3 frames and if so send them to the event titles ‘Delete Flare’
The event titles ‘Delete Flare’ uses a Delete operator to delete the trail particles.
System setup with the tyWind objects responsible for moving the particles in the non-physical events of the system, and a Point helper object that serves as a ‘find target’ for the particles to get back to the initial location above the slide:
Particle shapes for the ‘Rocket Upward’, ‘Chopper back to start’ and ‘find drop location’ events.
Note that the shape pivots are consistently at the center of the ball for the shape switching to work well, and that the ‘chopper’ animation is done at the mesh level using Poly Select and XForm:
* Particle Flow is a powerful event driven particle system that was originally developed by ThinkBox software, ans later bacame 3ds max’s built in particle system.
The Lock/Bond Particle Flow test can be used to have particle movement restricted to a surface.
This example shows a simple setup in which the particle teapots have a Speed operator set to Random 3D mode that causes them to move in random directions,
While at the same time the Lock/Bond test forces them to ‘stick’ to the surface: