©Anton Podvalny

Table of Contents

This chapter contains some troubleshooting tips for V-Ray and the AppSDK.

Error logging


Always watch out for is V-Ray's errors and warnings by implementing the LogMessage callback. In the following example we show how this is done, along with the interpretation of the different log levels:

def logMessage(renderer, message, level, instant):
	if level == vray.LOGLEVEL_ERROR:
		print("[ERROR]", message)
	elif level == vray.LOGLEVEL_WARNING:
		print("[Warning]", message)
	elif level == vray.LOGLEVEL_INFO:
		print("[info]", message)
	# Uncomment for testing, but you might want to ignore these in real code
	#else: print("[debug]", message)

# It's recommended to always have a console log
renderer.setOnLogMessage(logMessage)
# Returns the last error that occurred when a method was called. Use this to understand why a method returned false.
err = renderer.lastError
void logMessage(VRay::VRayRenderer &renderer, const char* message, VRay::MessageLevel level, double instant, void* userData) {
	switch (level) {
	case VRay::MessageError:
		printf("[ERROR] %s\n", message);
		break;
	case VRay::MessageWarning:
		printf("[Warning] %s\n", message);
		break;
	case VRay::MessageInfo:
		printf("[info] %s\n", message);
		break;
	case VRay::MessageDebug:
		// Uncomment for testing, but you might want to ignore these in real code
		//printf("[debug] %s\n", message);
		break;
	}
}

// It's recommended to always have a console log
renderer.setOnLogMessage(logMessage);
// Returns the last error that occurred when a method was called. Use this to understand why a method returned false.
VRayRenderer::Error err = renderer.getLastError();
// It's recommended to always have a console log
renderer.LogMessage += new EventHandler<MessageEventArgs>((source, e) =>
{
	// You can remove the if for testing, but you might want to ignore Debug in real code
	if (e.LogLevel != LogLevelType.Debug)
	{
		Console.WriteLine(String.Format("[{0}] {1}", e.LogLevel.ToString(), e.Message));
	}
});

// Returns the last error that occurred when a method was called. Use this to understand why a method returned false.
Error err = renderer.LastError;
// It's recommended to always have a console log
renderer.on('logMessage', function (message, level, instant) {
	if (level == vray.LOGLEVEL_ERROR)
		console.log("[ERROR] ", message);
	else if (level == vray.LOGLEVEL_WARNING)
		console.log("[Warning] ", message);
	else if (level == vray.LOGLEVEL_INFO)
		console.log("[info] ", message);
	// Uncomment for testing, but you might want to ignore these in real code
	//else console.log("[debug] ", message);
});
// Returns the last error that occurred when a method was called. Use this to understand why a method returned false.
var err = renderer.lastError;

Error checking


Most methods that can fail have at least a boolean return value, so make sure you've checked this when you encounter problems.

Plugin parameters


A very useful tool for basic parameter information is plgparams.exe included in the binary folder of the SDK. It lists all parameters for the specified plugin (or all plugins with -list) and their types, default values and text comments. Similar information can be obtained using the plugin and parameter meta-info API discussed in the Fundamentals section. The ListAllPluginsAndProperties example in the C++ folder (or equivalent code for another language) uses this API.

Parameter information is also available in the comments for the C++ and .Net concrete Plugin classes (as a tooltip in the IDE).

Additional documentation


Apart from documentation included with the AppSDK and this self-training program, the help pages for 3dsMax and Maya on docs.chaosgroup.com are a good source of parameter information and examples, although they use names of types and parameters as they are in the UI of the respective application - these are usually similar but different from the underlying V-Ray plugins.

Save scene file for inspection


It is often useful to save out your scene to a file to inspect if you did everything properly. For example you may have failed to set some parameter properly and you will see this in the file as a missing or incorrect value, although you can also check the result of the set operation in your code (when using setValue). You can try to pinpoint problems by deleting parts of the scene file (parameters or whole plugins) and re-rendering.

It can be very helpful if you have a V-Ray for 3dsMax or Maya and use it to export vrscene files to see what plugins and parameters are written out. The exporters for 3dsMax and Maya can be considered "ground truth" (even though they may have an occasional bug or missing feature).

Coordinate system


If you're getting a black render make sure your camera is positioned and oriented properly and not inside an object. Keep in mind the default up-axis is Z, but it can be set to something else, usually Y. You might also get invisible or black objects if something is wrong with the attached material. In this case you can still see the object in the alpha channel if there is nothing behind it - the environment has 0 alpha.

Also keep in mind that V-Ray uses column-major matrices (like OpenGL, but unlike DirectX).

  • No labels