Jorgeromeu / blender-3D-debugger

A simple, extensible blender script for debugging 3D related code such as ray tracers, specifically designed for working with the PBRT-v3 renderer can be used with almost any 3D application

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

3D-debugger

A simple, extensible blender script for debugging 3D related code such as ray tracers, specifically designed for working with the pbrt renderer but can theoretically be used with any renderer.

Example

Visualizing directions of camera rays in an example scene:

window

Usage

To use the script, you first need to produce a traces file containing all of the shapes you want to visualize. The simplest way to do this is to write this data to the log file of your renderer. For example, with the pbrt renderer, you can just do:

Visualizing points

// p is a Point3f or Vector3f
LOG(INFO) << "DBG POINT:" << p;

// optionally pass a name
LOG(INFO) << "DBG POINT:" << p << ";" << "pointName";

Visualizing lines

// a is the start point, b is the end point
LOG(INFO) << "DBG LINE:" << a << ";" << b;

// optionally pass a name
LOG(INFO) << "DBG LINE:" << a << ";" << b << ";" << "lineName";

Visualizing directions

// p is the start point, d is a (normalized) direction
LOG(INFO) << "DBG DIR:" << p << ";" << d;

// optionally pass a name
LOG(INFO) << "DBG DIR:" << p << ";" << d << ";" <<"directionName;

Loading the traces file into blender

In blender, switch to the scripting tab, or open a text editor area and open blendebug.py. Then set LOGFILE to be the absolute path to your traces file.

Now simply run the script and the debug traces will be created and placed in the DEBUG collection so you can conveniently hide or select all of the debug traces.

image

Things to watch out for:

If you re-run the renderer, and re-run the script in blender, the existing traces will be deleted first, so there is no need to do this manually.

Often times traces you are debugging dont all need to be placed (for instance if you are visualizing sampled points on a light source). In such cases, you can set the MAX_OBJS field in SETTINGS and then set LIMIT_POINTS so that the amount of points is bounded. Then it will only place a random subset of the points you provided. This way you dont need to change resolution or spp settings and can instead work with the entire dataset.

TODO:

  • Support colors
  • UI within blender

About

A simple, extensible blender script for debugging 3D related code such as ray tracers, specifically designed for working with the PBRT-v3 renderer can be used with almost any 3D application


Languages

Language:Python 100.0%