File Exchange

image thumbnail

Patch Software Render

version (56.8 KB) by Dirk-Jan Kroon
Patch Software Render with Phong-shading, shadows and textures


Updated 25 Mar 2010

View License

These files features a complete software render pipeline from Triangulated Mesh to Fragments. Like the OpenGL software renderer, but without using any external libraries, and far less code. The renderer renders to a Matlab image, instead of the computer screen.

The render pipeline is written in c++ code, and supports, Phong shading, Color interpolation, Textures.

Also there is c++ code for calculation of Shadow Volumes, which can be used for self shadowing, and other real shadow effects.

The pipeline and all commandos are like in OpenGL, thus you can use the OpenGL documentation for things like your blending function and modelmatrix.

This is "version 0", thus there are only a few examples, only limited help available, and probably some bugs.

You need a c++ compiler to compile the code, before running the example. Compile code:
mex renderpatch.cpp -v
mex patchshadowvolume.cpp -v
mex patchnormals_double.c -v

Cite As

Dirk-Jan Kroon (2020). Patch Software Render (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (4)

When trying out this, to make it compile there were some changes that had to be made. The examples then looked good
In patchshadowvolume.cpp I had to:
Comment out/remove line 34 (// typedef long long int int64_t ;)
Change the line:
int Vout_ndims=2; int Vout_dims[2]; Vout_dims[0]=idn; Vout_dims[1]=3;
mwSize Vout_ndims=2; mwSize Vout_dims[2]; Vout_dims[0]=idn; Vout_dims[1]=3;

And in renderpatch.cpp I had to change the line:
double *Iin; const mwSize *Iin_dimsc; int Iin_dims[3]; int Iin_ndims=0;
double *Iin; const mwSize *Iin_dimsc; mwSize Iin_dims[3]; mwSize Iin_ndims=0;

Note, in this version is the following bug
Line 34 in renderpatch_shading.cpp:
Is a bug, must be:

Very impressive piece of code.

Tal Darom

Great work.
I have only one comment - I think depth check should be true by default

MATLAB Release Compatibility
Created with R2010a
Compatible with any release
Platform Compatibility
Windows macOS Linux