Introduction
The Neutral File Format is a minimal scene description by Eric Haines, drafted in 1988; version 3.9 dates from 4 December 1996. It was designed to test rendering algorithms and acceleration schemes, and is the output of the Standard Procedural Databases (SPD), a set of scene generators. It describes a view, a background, lights, surface properties and a few primitives, and is meant to be easy to translate into other formats.
A different format with the same name and extension was used by Sense8’s
WorldToolKit; its files begin with the word
nff.
Structure
A file is lines of text. The first field of an entity gives its type, and the rest of that line and sometimes further lines give its values. There is no header or signature. The view and all lights must come before any object, so that a renderer can draw objects as it reads them.
| Type | Entity |
|---|---|
v | Viewing vectors and angles |
b | Background colour |
l | Positional light |
f | Surface properties |
c | Cylinder or cone |
s | Sphere |
p | Polygon |
pp | Polygonal patch |
# | Comment: the rest of the line |
v: view
v
from Fx Fy Fz
at Ax Ay Az
up Ux Uy Uz
angle degrees
hither distance
resolution xres yres
| Keyword | Meaning |
|---|---|
from | Position of the eye |
at | Point at the centre of the image, in world coordinates |
up | Up direction |
angle | Field of view in degrees, measured from the centre of the top pixel row to that of the bottom row, and from the left column to the right |
hither | Distance of the near clipping plane from the eye, if any |
resolution | Image size in pixels |
Nothing need be normalised, and the vectors need not be perpendicular. The far plane is at infinity and the aspect ratio is 1.0.
b: background
b R G B
Colour components run from 0 to 1. Without this entity the background is 0 0 0.
l: light
l X Y Z [R G B]
A point light at X Y Z with an optional colour. Its intensity is not specified; the program chooses a useful one.
f: surface properties
f red green blue Kd Ks Shine T index_of_refraction
| Value | Meaning |
|---|---|
red green blue | Colour, 0 to 1 |
Kd | Diffuse component, usually 0 to 1 |
Ks | Specular component, usually 0 to 1; Kd + Ks need not be 1 |
Shine | Phong cosine power of highlights |
T | Transmittance, the share contributed by the transmitted ray. Objects with T above 0 count as two-sided where that matters |
index_of_refraction | Index of refraction |
The properties apply to every following object until the next f.
Objects
Objects are one-sided, with the outside visible, unless transmittance requires the second side.
c: cylinder or cone
c
base.x base.y base.z base_radius
apex.x apex.y apex.z apex_radius
The two points define the axis and the end circles; a cone has different radii, with the apex radius the smaller. There are no end caps. If both radii are negative, only the inside is visible. Base and apex must not coincide.
s: sphere
s center.x center.y center.z radius
With a negative radius only the inside is visible.
p: polygon
p total_vertices
x y z
…
One line per vertex. The vertices are coplanar and run counterclockwise seen from the front, in a right-handed system. The first two edges must form a non-zero convex angle, so that the normal follows from the first three vertices.
pp: polygonal patch
pp total_vertices
x y z nx ny nz
…
A polygon with a normal at each vertex, under the same rules.
Worked example
A red triangle and a sphere, with one light:
# view and lights come first
v
from 0 0 8
at 0 0 0
up 0 1 0
angle 45
hither 1
resolution 512 512
b 0.1 0.1 0.2
l 5 5 5
f 1 0 0 0.8 0.2 20 0 1
p 3
-1 -1 0
1 -1 0
0 1 0
s 2 0 0 0.5
Divergence from the specification
- The SPD package’s own reader,
readnff.c, reads only the three coordinates of a light, not the optional colour, and treats aShinebelow 1 as 1. - Assimp reads
las position, intensity and colour; treats the number afterindex_of_refraction, if any, as an ambient value and otherwise a word there as a texture file name; ignoresShineandT; and does not require thevline beforefromand the other view keywords. - Assimp also accepts additions of its own and of files found in the wild:
shader filefor a texture;tess nfor tessellation;tpp, a patch whose vertex lines end with texture coordinates u v; and the solidsdod,oct,tetandhex, written likeswith a centre and one radius or three. It reportspb(Bézier patch) andpn,pnn(NURBS) as unsupported.
In the explorer
A dropped .nff file in this format shows every entity and word in the
byte tree. All polygons, patches, cylinders, cones, spheres and the additional
solids are drawn in 3D in their fill colours, and the file’s viewpoint, when it
has one, is offered as a camera. Round surfaces are divided into 48 segments, or
fewer when the file holds very many of them; a tess line is shown and
does not change this. A very large model is drawn in parts of three million
triangles.
Tables list the entities, polygon vertices, solids, surfaces, lights and texture files. Texture files are separate: their names are shown and they are not applied. Files up to 256 MB are read.
Also used for
- WorldToolKit Neutral File Format – Sense8’s polygonal text geometry for WorldToolKit.
Links
Software
- Standard Procedural Databases – generators that write NFF, with readers and converters (C)
- Assimp – 3D import library that reads both NFF formats (C++)
Reference
- NFF.TXT – Eric Haines’s description, version 3.9
- readnff.c – the SPD reader
- Neutral File Format – Paul Bourke’s copy of the description
- NFFLoader.cpp – Assimp’s reader