User-defined Surfaces, BSDF and Materials
FRED has a very large assortment of predefined surface types. They range from “ordinary” optical surfaces such as planes, conics, and rotationally symmetric aspherics to surfaces typically found in CAD software such as NURBS, splines, and surfaces created from extruded curves. For most users, this palette of surfaces covers most of the common applications.

When we were planning
FRED, we knew that users would occasionally require a surface type that we had not yet programmed. To address this need, we implemented user-defined surfaces, BSDF and materials through FRED's built-in BASIC compiler. The advantages are many:
Compiled surfaces, BSDF and materials raytrace extremely quickly because they’re compiled just once
The underlying BASIC code is part of the FRED document and so when the FRED document is shared, the user-defined code goes with it
Changes to the user-defined code can be made and tested quickly
No additional compilers or associated software (with the associated costs) are required

Rippled surface as a BASIC script


(Left) Dispersive MgF2 as scripted material
(Right) Warped cylinder as a BASIC scripted surface

In many other optical software, a user faced with this problem would be required to program the new surface in a DLL. This requires an appropriate compiler and some experience with code development; these are significant drawbacks for most users. Perhaps the most inconvenient aspect of the DLL, though, is portability: in order to run the file containing the user-defined surface, the user must also have the DLL present as well. This makes file sharing difficult.

Other software deal with the problem of a user-defined surface by implemented a scripted surface that is interpreted during execution. While this avoids the need for a compiler to create a DLL, interpreted code is always slow, a drawback for many applications.

© Photon Engineering LLC. All Rights Reserved.