
previous | next | regular patterns: contents | rmannotes: top

Simple, geometric shapes can be made in the RenderMan Shading Language
using
smoothstep
or
pulse
often with one of two shading language distance functions:
Further, simple geometric shapes can be combined to generate more complex shapes using boolean set operations (union, intersection, difference, and complement).
|
RenderMan Shading Language function
float distance(point p1, p2)
|
Rectangular shapes can be made by intersecting (multiplying) a
vertical
pulse and a horizontal
pulse. (In fact you can
use intersection instead of the
multiplication operator.)
Disks and rings can be generated using
distance and
either smoothstep
(for a disk) or pulse
(for a ring). The idea for disks is simple: if the distance between the
current shading point and the center of the disk is less than the radius
of the disk, then the current shading point is inside the disk. In terms of
a pulse, we have:
where d is the distance between the current shading point and the center of the disk. Note that this pulse is generated by 1 - smoothstep(radius - fuzz, radius, d). The corresponding shader is shown below.
The idea for rings is identical, except that a pulse is used instead of smoothstep.
Lines are generated like disks except that the distance is computed
from the current shading point to the nearest point on the line using
ptlined.
Constructive solid geometry (CSG) is used in solid modeling systems to create complex shapes from the union, intersection, or difference of 2 simpler shapes. These are referred to as "boolean" operations since they operate on only 2 shapes at a time (with the exception of "complement"). While CSG is difficult to do with 3D b-reps, it's trivial to do with procedural shapes in shaders.
|
RManNotes function
float union(float a, b) Boolean operations. Each returns a value between 0 and 1 and requires inputs between 0 and 1. The implementations are from [Perlin89]. |
Below are illustrations of the various boolean operations based on disk and square shapes.
![]() | disk = D | ![]() | square = S |
![]() | union(D,S) | ![]() | intersection(D,S) |
![]() | difference(D,S) | ![]() | difference(S,D) |
![]() | complement(difference(D,S)) | ![]() | union(difference(S,D), difference(D,S)) |
Finally, the disk_ring shader illustrates a masking effect between different shapes repeated at different scales.

previous | next | regular patterns: contents | rmannotes: top

RManNotes is Copyright © 1995, 1996 Stephen F. May
Any comments or suggestions appreciated.
Steve May (smay@pixar.com)Last Modified: 4/15/96