Example use of gridpattern()
Example use of gridpattern()
gridpattern()
is a shading language function which returns
a one or zero for each (varying) shading point on a shading grid
according to a specified
pattern.
Here is an example in which gridpattern is used to create a sort of poor-man's wireframe rendering. As noted in the gridpattern description, the precise size and shape of shading grids depends on many interacting factors, so specific resulting images will differ.
surface gridframe (float width=1;) { varying float ctx = 0; varying float g = 0; uniform float w; for (w=0; w < width; w += 1) { g += gridpattern("concentric", ctx); } Ci = g + (1-g) * Cs * 0.8; Ci *= Os; Oi = Os; /* or less for see-thru "wireframe" */ } |
##RenderMan RIB FrameBegin 1 Display "gridframe.tif" "tiff" "rgba" Format 256 192 1 # note: シェーディングRate and gridsize greatly affect # the density and size of grids, of course. シェーディングRate 2 Option "limits" "gridsize" [1000] シェーディングInterpolation "constant" Projection "perspective" "fov" [30] Translate 0 0 4 WorldBegin Surface "gridframe" "float width" [1] AttributeBegin Translate -20 -20 10 Scale 40 40 40 カラー .2 .2 .4 Patch "bilinear" "P" [0 1 0 1 1 0 0 0 0 1 0 0] AttributeEnd AttributeBegin Translate -0.75 -.35 -1 Rotate -30 0 1 0 カラー .6 .6 .2 Patch "bilinear" "P" [0 1 0 1 1 0 0 0 0 1 0 0] AttributeEnd AttributeBegin Translate .5 -.5 -1 Rotate 80 0 1 0 Translate 0 -.1 0 カラー 0 0 1 Patch "bilinear" "P" [0 1 0 1 1 0 0 0 0 1 0 0] AttributeEnd WorldEnd FrameEnd |