3D Surface Plotter

This package contains a .NET C# Standard 2.0 class library called Surface3DLib.dll, which can be used to create 3D surface plots in the Unity game engine for any math function that describes a simple 3D surface.


The full and well-maintained Documentation contains detailed explanation and demos on how to use this library to create 3D surface plot in your Unity projects.


If you have any issues, questions, or requests, please feel free to contact Email Support.



Package Overview


This library implements a colormap class that can be used to create colormap data for the vertex colors of the Mesh object in Unity. It also includes a colormap enumeration that defines over 60 colormaps with familiar names such as jet, hsv, hot, earth, cool, etc. The library also exposes a ColormapReverse field that can be used to reverse the order of colors defined in the colormap. This means that the library provides over 120 colormaps (61 predefined colormaps + 61 reversed colormaps). You can use these colormaps to easily set colors for your 3D surface plots.


This library also contains a MathFunc class that implements four built-in math functions, including Sinc, Peaks, ExpFunc, and SinCos. These built-in math functions can be used to test the capability and features of this library. The MathFunc class also defines four animation methods that can be used to animate the parameters used in these built-in functions.


The key part of this library is the SurfaceData class, which exposes various public fields used to define 3D surfaces. This class also contains two public methods: CreateData and GetBuiltinData. The CreateData method generates data of vertices, colormaps, UV coordinates, and triangles (or indices) for a simple 3D surface described by any math function. The GetBuiltinData method is used to generate the same set of data using the built-in math function with default parameters. This method lets you use the MathFunctionEnum to select the built-in math function.


The simple 3D surfaces are usually open surfaces, indicating that in order to see both sides of the surface, we need to apply the lighting and colormap to both the front face and back face of the surface. Here, for demonstration of our library, we use Unity's built-in render pipeline and define a material called Surface3DMaterial using the Unity's built-in Particles/Standard Surface shader, because it supports the vertex color and two-side lighting. The Surface3DLib library should also work for other piplelines, including URP and HDRP, as long as you create a shader that supports the vertex color and two-sided lighting. 


Since our library also creates the UV coordinate data, we define a TextureMaterial using the standard shader. This material can be used to add texture mapping onto our 3D surface plots.


The online User Guide or the PDF manual in the Documentation folder included with this package provides the detailed description on how to use this library.



What this Package Includes


Mathematically, a surface draws a y function for each x- and z-value pair in a region of interest. For each x and z value pair, a simple 3D surface can have at most one y value. Note that this package cannot be used to plot parametric 3D surfaces that can have multiple y values at some x and z value pairs.

This package includes:

  • A .NET Standard 2.0 class library: Surface3DLib.dll, which implements a Colormap class with over 120 colormaps with farmiliar names such as jet, hsv, cool, etc.; a MathFunc class that contains four built-in math functions; and a SurfaceData class that exposes two public methods: CreateData and GetSurfaceData, which can be used to generate data for vertices, colormaps, UV coords, and triangles (or indices).
  • Custom material: Surface3DMaterial and TextureMaterial. Since most built-in shaders do not display the vertex colors with colormaps, we need to use a material that supports the vertex colors. Here, we create a material named Surface3DMaterial that uses the built-in "particles/standard surface" shader with the "Two Sided" property enabled becuase 3D surfaces are usually open surfaces and we want to render both the front and back faces of the surface. Since our library also generates teh UV coord data, the TextureMaterial can be used to map texture images onto 3D surfaces.
  • Eight Demos created using different Scenes. The BuiltinFunctions demo shows surfaces created using four built-in math functions that can be selected from Inspector. The four animation demos for built-in math functions illustrate how to animate parameters used in defining these functions. The UserColormap demo shows how to create a custom colormap and how to apply it to the surface plot. The TexturePeaks demo explains how to add texture mapping to the built-in Peaks surface. The true power of package is its ability to create 3D surface plots using custom math functions provided by the user. The UserFunction demo shows how to define a custom math functions and how to use it to create a 3D surface plot.

The Reference Manual contains the detailed description about the classes, methods, and members, etc. used in our library.