home *** CD-ROM | disk | FTP | other *** search
- You've now rendered your first picture but it is somewhat boring. Let's
- add some fancy features to the texture.
-
-
- Surface Finishes:
-
- One of the main features of a ray tracer is its ability to do interesting
- things with surface finishes such as highlights and reflection. Let's add a
- nice little phong highlight (shiny spot) to the sphere. To do this you need
- a 'finish' parameter. Change the definition of the sphere to this:
- sphere {
- <0, 1, 2>, 2
- texture {
- pigment { color Yellow } // Yellow is predefined in
- finish { phong 1 } // COLORS.INC
- }
- }
-
- Now render this the same way you did before. The phong keyword adds a
- highlight the same color of the light shining on the object. It adds a lot
- of credibility to the picture and makes the object look smooth and shiny.
- Lower values of phong will make the highlight less bright. Phong can be
- between 0 and 1.
-
-
- Adding Bumpiness:
-
- The highlight you've added illustrates how much of our perception depends
- on the reflective properties of an object. Ray tracing can exploit this by
- playing tricks on our perception to make us see complex details that aren't
- really there.
-
- Suppose you wanted a very bumpy surface on the object. It would be very
- difficult to mathematically model lots of bumps. We can however simulate
- the way bumps look by altering the way light reflects off of the surface.
- Reflection calculations depend on a vector called a 'surface normal' vector.
- This is a vector which points away from the surface and is perpendicular to
- it. By artificially modifying (or perturbing) this normal vector you can
- simulate bumps. Change the scene to read as follows and render it:
- sphere {
- <0, 1, 2>, 2
- texture {
- pigment { color Yellow }
- normal { bumps 0.4 scale 0.2 }
- finish { phong 1 }
- }
- }
-
- This tells POV-Ray to use a bump pattern to modify the surface normal.
- The value 0.4 controls the apparent depth of the bumps. Usually the bumps
- are about 1 unit wide which doesn't work very well with a sphere of radius
- 2. The scale makes the bumps 1/5th as wide but does not affect their depth.
-
-
- Creating Color Patterns:
-
- You can do more than assign a solid color to an object. You can create
- complex patterns in the pigment block. Consider this example:
- sphere {
- <0, 1, 2>, 2
- texture {
- pigment {
- wood
- color_map {
- [0.0 color DarkTan]
- [0.9 color DarkBrown]
- [1.0 color VeryDarkBrown]
- }
- turbulence 0.05
- scale <0.2, 0.3, 1>
- }
- finish { phong 1 }
- }
- }
-
- The keyword 'wood' specifies a pigment pattern of concentric rings like
- rings in wood. The color_map specifies that the color of the wood should
- blend from DarkTan to DarkBrown over the first 90% of the vein and from
- DarkBrown to VeryDarkBrown over the remaining 10%. The turbulence slightly
- stirs up the pattern so the veins aren't perfect circles and the scale fac-
- tor adjusts the size of the pattern.
-
- The most of the patterns are set up by default to give you one 'feature'
- across a sphere of radius 1.0. A 'feature' is very roughly defined as a co-
- lor transition. For example, a wood texture would have one band on a sphere
- of radius 1.0. In this example we scale the pattern using the 'scale' key-
- word followed by a vector. In this case we scaled 0.2 in the x direction,
- 0.3 in the y direction an the z direction is scaled by 1, which leaves it
- unchanged. Scale values larger than 1 will stretch an element. Scale va-
- lues smaller than one will squish an element. And scale value 1 will leave
- an element unchanged.
-
-
- Predefined Textures:
-
- POV-Ray has some very sophisticated textures predefined in the standard
- include files 'textures.inc' and 'stones.inc'. Some are entire textures
- with pigment, normal and/or finish parameters already defined. Some are
- just pigments or just finishes. Change the definition of our sphere to the
- following and then re-render it:
- sphere {
- <0, 1, 2>, 2
- texture {
- pigment {
- DMFWood4 // Predefined from textures.inc
- scale 4 // Scale by 4 in all directions
- }
- finish { Shiny } // This finish defined in textures.inc
- }
- }
-
- The pigment identifier DMFWood4 has already been scaled down quite small
- when it was defined. For this example we want to scale the pattern larger.
- Because we want to scale it uniformly we can put a single value after the
- scale keyword rather than a vector of x,y,z scale factors.
-
- Look through the file TEXTURES.INC to see what pigments and finishes are
- defined and try them out. Just insert the name of the new pigment where
- DMFWood1 is now or try a different finish in place of Shiny and re-render
- your file.
-
- Here is an example of using a complete texture identifier rather than
- just the pieces:
- sphere {
- <0, 1, 2>, 2
- texture { PinkAlabaster }
- }
-