天天看点

OpenGL Shading Language Third Edition——Non-photorealistic Shaders

a significant amount of computer graphics research has been aimed at achieving more and more realistic renditions 表演 of synthetic 人造的 scenes. a long time goal has been to render a scene so perfectly that it is indistinguishable from a photograph of the real scene, a goal called PHOTOREALISM.写实主义. with the latest graphics hardware, some photorealistic effects are becoming possible in real-time rendering.

this quest for realism is also reflected in graphics APIs such as opengl. the opengl specification defines specific formulas for calculatinig effects such as illumination from light sources, material properties, and fog. these formulas attemp to define effects as realistically as possible while remaining relatively easy to implement in hardware, and they have duly 适当的 been cast into silicon 硅 by intrepid 勇敢的 graphics hardware designers.

but the collection of human art and literature shows us that photorealism is not the only important style for creating images. the availability of low-cost programmable graphics hardware has sparked the growth of an area called NON-PHOTOREALISTIC RENDERING, or NPR. researchers and practitioners 从业人员 in this filed are attempting to use computer graphics to produce a wide range of artistic effects other than photorealism. in this chapter, we look at a few examples of shaders whose main focus is something other than generating results that are as realistic as possible.

18.1 hatching example 孵化

bert freddenberg of the university of Magdeburg in germany 马格德堡大学 was one of the first people outside of 3Dlabs to come up with a unique opengl shader. his area of research has been to use programmable hardware to produce real-time NPR effects such as hatching and half-toning. he experimented with a prototype implementation of the opengl shading language in the summer of 2002 and produced a hatching shader that he agreed to share with us for this book.

this shader has a few unique features, and the steps involved in designing this shader are described in Bert’s ph.d. thesis, real-time stroke-based half toning(2003). bert’s hatching shader is based on a woodblock printing shader by scott johnston that is discussed in advanced renderman: creating cgi for motion pictures by anthony a. apodaca an larry gritz (1999).

the goal in a hatching shader is to render an object in a way that makes it look hand-drawn, for instance with strokes that look like they may have been drawn with pen and ink. 墨水. each stroke contributes to the viewer’s ability to comprehend the tone, texture, and shape of the object being viewed. the effect being sought 寻求 in this shader is that of a woodcut print 木刻. in a woodcut, a wooden block carved with small grooves 沟槽 is covered with ink and pressed onto a surface. the image left on the surface

继续阅读