Learn how to use the VRED Core out-of-the-box features.
Video Captions: Hello and welcome to this video on our tutorial series for VRED Core. My name is Christopher and today I will show you how you can use the main features of VRED Core, like streaming or batch rendering or data preparation. In simple terms, VRED Core offers most of the functionality as VRED Pro, as it uses the same raytracing engine and tools. It's just missing the graphical user interface to manipulate data in your scene. This makes it perfect for automated tasks, where you input data at one end and output process data at the other end.
In this video, I will talk about how you can use VRED Core to achieve your goals and how you utilize its features.
And VRED Core itself, might not have a graphical user interface, but it comes with a streaming app that is great for presentations or design reviews. It can be accessed in a browser, even on the same device or over a network connection on multiple different devices at the same time. This means that multiple users can connect to the same instance of VRED Core, with for example a tablet or smartphone or a PC.
With the streaming app, you can navigate freely in your scene or jump between viewpoints. This works just like in VRED Pro when navigating with a mouse. You also have a menu where you can select variant sets that are already defined in the scene, playing animation, changing material, or switching geometry.
In the Settings menu, it's possible to adjust the framerate, the resolution, and render settings like antialiasing or raytracing.
The streaming app also offers a Python terminal, where it's possible to run simple Python commands or more complex scripts to manipulate your scene in other ways. When you open the streaming app, there's already a small script that will load a new scene with a cube in it.
In order to use the streaming app, you have to enable the web interface in VRED Core's preferences. Here you can define a port number, the allowed hosts, and even set up an authentication system. The default setting should be fine when you are testing streaming for the first time. When you are finished your setup, you can access the streaming app by entering localhost:
and your selected port number in your browser, while VRED Core is running in the background.
Because there's no user interface to interact with your scenes, you'll mostly interact with them using Python scripts. With Python scripts, you can basically change and manipulate every aspect of your scene. We have a whole video series about Python scripting, where it explains all available Python interfaces in VRED Pro. As I won't go into details too much in this tutorial, but for every concept I mention here, you'll find a more in-depth explanation in the Python scripting tutorials.
Most of the Python concepts and use cases are usable with VRED Core, because under the hood, it's basically the same engine and offers the same Python API.
Okay, let's have a quick look at the Python interfaces that are available in VRED Core. At first, we'll talk about the -pre
and -post
Python command line parameter. They are available when you start VRED Core from the command line and can execute Python before or right after the scene is loaded. When we test this with a simple print command, we can see how the scripts are executed in the command line window.
For most of the automated tasks, like rendering or data conversion, you will probably use either -pre
or -post
Python to start the task. And, in post cases, -post
Python is the correct parameter for you because it is executed after your scene has finished loading.
In both of these parameters, you can call multiple Python commands by separating them with a semicolon. This is great for up to 3 or 4 Python commands, but I guess you can see the problem when you want to execute a longer script with this method. It's just not possible, because Python heavily relies on whitespace to provide a logical structure to the code. But the Autodesk engineers included a convenient way to fix this. It's possible to encode long Python scripts in a base64 string that can be passed as a parameter. This way, you can execute arbitrarily long Python scripts.
Here I just use an online service to take out a simple Python script that is then executed when VRED is started. Adding the script line-by-line would not be possible because Python heavily relies on whitespace's structure, which the semicolon method cannot recreate.
We will skip this technique for now, but we will use it in the next video, where we will show you how you can further customize the VRED pipelines with more complex scripts.
Of course, there are other ways to added Python scripts to your scene. For example, we have the scripts that are embedded in VRED's VPB files. In VRED Pro, you would find them in the Script Editor of your scene. Depending on your scene preferences, the script will automatically be executed. For example, you could implement a virtual room with interactive buttons in the 3D environment, where users in VR can change materials, activate tools like the turntable, and so on. Such scripts would only be available for this particular scene, so this method is great when you have functionality that is specific for a scene.
In my opinion, it is not a good solution when you want to implement automatic rendering or data preparation because you first would have to copy the script to every file you want to render. In most cases, this is not a really efficient.
For frequently used tasks that require the same code over and over again, you can use Python modules. A Python module contains classes, functions, and variables that belong to the same functionality or concept. For example, a rendering module could include functions that set specific render settings or automate rendering with variant sets or using other data sources.
All functions and classes that are defined in such modules are available with the Python interfaces, such as the Python terminal and the streaming app or can be called with the -pre
or -post
Python command line parameter.
Modules can be added to VRED Core by copying the module files in VRED Core's module directory, which is located in the VRED Core installation directory.
In this example, I can add a simple watermark by calling the watermark function in the module. With a simple Python call with -post
Python, I can add this watermark to a streaming session or rendering. You can see that we first have to import the function for the module name space before we can us it.
Let's give you a few simple examples what you can achieve with VRED Core and some Python scripting. VRED Core is a great tools to perform automatic data translation. That means loading a file in one format, and exporting the file in another format. This is very easy because you just have to load a file with a certain file format and save it with a different name. All the hard work is handled by VRED Core.
After the file is saved, you can close the software with the terminate VRED command and you are finished.
We can just use the -post
Python command that we learned about earlier in this video and this task only requires 3 separate Python commands.
Here, all Python commands are listed line-by-line, so you can see them better. You will also have to escape the quote characters with a backslash so that the file paths are recognized correctly.
Rendering a scene is a little more complex and requires a few more Python commands to work. Again, we are using the -post
Python command to start the render process. There are actually 2 ways to render a scene. First, we can use the createSnapshot
function that just needs a file name and resolution as parameters. This will use specific render settings or automate rendering with variant sets or using other data sources.
The model approach is to use the functions from the VR Render Settings module to render the scene. But here, we need even more commands to do this, as we first have to set the resolution and the filename of the rendering. But, this way, we could in theory change any render setting we like.
A more efficient way, however, is to use render presets that you can define in your render preferences. You can load them with the applyPreset
function and only have to set the filename of the rendering.
When you want to use VRED Core for data preparation, you can use its internal functions to optimize geometry and transformations. Unfortunately, this is a bit more sophisticated and requires us to use the base64 encoding that I talked about earlier in this video, because we need some more Python code to pull this off. And that is why I will talk about data preparation and optimization in our next video, where we will also show you a few more ways to automate and customize your VRED pipeline. We will also write scripts to fully automate the data translation rendering examples that we just saw, so stay tuned.
Okay, that's it for today. I really hope you enjoyed this video about VRED Core's main features. Thanks for watching and see you next time.
Before using VRED Core, ensure you have followed these steps:
localhost:8888
in the address field to open the streaming app to interact with a scene.For additional information and help, see the Python Tutorials, and VRED Core documentation.
This is the accompanying example Python scripts for the Tutorial 3: How to Use the VRED Core Out-of-the-Box Features video.
To download these files zipped, click here.
cmd-data-conversion
is used for converting a file into another format.
./VREDCore.exe -postpython="load(\"C:/VRED_Examples/vpb/Example.vpb\"); save(\"C:/VRED_Examples/fbx/Example.fbx\"); terminateVred()"
load(\"C:/VRED_Examples/Example.vpb\")
save(\"C:/VRED_Examples/Example.fbx\")
terminateVred()
cmd-rendering
is used for specifying render settings or automating rendering with variant sets or using other data sources.
# Start batch rendering with different quality settings
# With createScreenshot
./VREDCore.exe -postpython="load(\"C:/VRED_Examples/Example.vpb\"); createSnapshot(\"C:/VRED_Examples/rendering/screenshot_3.jpg\", 1920, 1080); terminateVred()"
load(\"C:/VRED_Examples/Example.vpb\");
createSnapshot("C:/VRED_Examples/rendering/screenshot_3.jpg", 1920, 1080);
terminateVred()
# With Rendersettings
./VREDCore.exe -postpython="load(\"C:/VRED_Examples/Example.vpb\"); setRenderPixelResolution(1920, 1080, 300); setRenderFilename(\"C:/VRED_Examples/rendering/screenshot_2.jpg\"); startRenderToFile(False); terminateVred()"
load(\"C:/VRED_Examples/Example.vpb\")
setRenderPixelResolution(1920, 1080, 300)
setRenderFilename(\"C:/VRED_Examples/screenshot.jpg\")
startRenderToFile(False)
terminateVred()
# With Rendersettings and Preset
./VREDCore.exe -postpython="load(\"C:/VRED_Examples/Example.vpb\"); applyPreset(\"Production_Quality\"); setRenderFilename(\"C:/VRED_Examples/rendering/screenshot_1.jpg\"); startRenderToFile(False); terminateVred()"
load(\"C:/VRED_Examples/Example.vpb\")
applyPreset(\"Production_Quality\")
setRenderFilename(\"C:/VRED_Examples/screenshot.jpg\")
startRenderToFile(False)
terminateVred()
cmd-watermark
is used for adding a watermark to a streaming session or rendering.
# Start batch rendering with different quality settings
# With createScreenshot
./VREDCore.exe -postpython="load(\"C:/VRED_Examples/Example.vpb\"); createSnapshot(\"C:/VRED_Examples/rendering/screenshot_3.jpg\", 1920, 1080); terminateVred()"
load(\"C:/VRED_Examples/Example.vpb\");
createSnapshot("C:/VRED_Examples/rendering/screenshot_3.jpg", 1920, 1080);
terminateVred()
# With Rendersettings
./VREDCore.exe -postpython="load(\"C:/VRED_Examples/Example.vpb\"); setRenderPixelResolution(1920, 1080, 300); setRenderFilename(\"C:/VRED_Examples/rendering/screenshot_2.jpg\"); startRenderToFile(False); terminateVred()"
load(\"C:/VRED_Examples/Example.vpb\")
setRenderPixelResolution(1920, 1080, 300)
setRenderFilename(\"C:/VRED_Examples/screenshot.jpg\")
startRenderToFile(False)
terminateVred()
# With Rendersettings and Preset
./VREDCore.exe -postpython="load(\"C:/VRED_Examples/Example.vpb\"); applyPreset(\"Production_Quality\"); setRenderFilename(\"C:/VRED_Examples/rendering/screenshot_1.jpg\"); startRenderToFile(False); terminateVred()"
load(\"C:/VRED_Examples/Example.vpb\")
applyPreset(\"Production_Quality\")
setRenderFilename(\"C:/VRED_Examples/screenshot.jpg\")
startRenderToFile(False)
terminateVred()
# global interpolator and slider for turntable
turntableInterpolator = None
turntableSlide = None
# Function to initialize and active the turntable
def turntableToolEnabled():
print("Enable Turntable Tool")
global turntableInterpolator
global turntableSlide
turntable = vrNodeService.findNode("*tool_turntable", wildcard=True)
toNode(turntable.getObjectId()).makeTransform()
turntableInterpolator = vrInterpolator()
turntableSlide = vrRotationSlide(turntable, 0, 0, 0, 0, 0, 359, 15.0)
turntableInterpolator.add(turntableSlide)
turntableInterpolator.setActive(True)
# Function to disable the turntable and clear the scene
def turntableToolDisabled():
print("Disable Turntable Tool")
global originalRotation
global turntableInterpolator
if turntableInterpolator:
turntableInterpolator.setActive(False)
turntableInterpolator = None
turntableToolEnabled()
from vrKernelServices import vrSceneplateTypes
from vrKernelServices import vrdSceneplateNode
# Get reference to sceneplate types
NodeType = vrSceneplateTypes.NodeType
ContentType = vrSceneplateTypes.ContentType
PositionType = vrSceneplateTypes.Position
def addWatermark(text):
'''
Add a watermark with a text to your scene
'''
print("Create Watermark")
sceneplateRoot = vrSceneplateService.getRootNode()
watermarkNode = vrSceneplateService.createNode(sceneplateRoot, NodeType.Frontplate, "Watermark")
watermark = vrdSceneplateNode(watermarkNode)
watermark.setContentType(ContentType.Text)
watermark.setText(text)
watermark.setFontColor(QVector3D(0.7, 0.7, 0.7))
watermark.setPosition(PositionType.Center)