1vpSetMaterial(3) Library Functions Manual vpSetMaterial(3)
2
3
4
6 vpSetMaterial - set material properties
7
9 #include <volpack.h>
10
11 vpResult
12 vpSetMaterial(vpc, material, property, surface_side, r, g, b)
13 vpContext *vpc;
14 int material;
15 int property;
16 int surface_side;
17 double r, g, b;
18
20 vpc VolPack context from vpCreateContext.
21
22 material
23 A constant specifying a particular material number (VP_MATE‐
24 RIAL0, VP_MATERIAL1, ..., VP_MATERIAL5).
25
26 property
27 A constant specifying one material property (VP_AMBIENT, VP_DIF‐
28 FUSE, VP_SPECULAR or VP_SHINYNESS).
29
30 surface_side
31 A constant specifying which side of the material surface the
32 properties apply to (VP_EXTERIOR, VP_INTERIOR or VP_BOTH_SIDES).
33
34 r, g, b
35 RGB components of the color associated with the property. For
36 VP_SHINYNESS, g and b are not used.
37
39 vpSetMaterial is used to set the properties of a material type. Each
40 voxel may be composed of a mixture of several different material types,
41 as described in vpSetLookupShader(3). Each material type has its own
42 color and light reflection properties. The properties are used as
43 parameters to the Phong shading equation for computing the color of the
44 material given a set of light sources and a viewing direction (see
45 vpShadeTable(3)).
46
47 To initialize the material parameters, call vpSetMaterial for each
48 property of each material type to be used. The total number of materi‐
49 als is specified as an argument to vpSetLookupShader. The first mate‐
50 rial is specified by the constant VP_MATERIAL0, the second is VP_MATE‐
51 RIAL1, and so on.
52
53 The VP_AMBIENT property specifies the RGB ambient light coefficients of
54 the material. This term represents the intensity of background light
55 reflected by the material. Each of the RGB components specifies the
56 coefficient for the corresponding light basis function. The values of
57 the coefficients should be in the range 0.0-1.0. Default: 0.1
58
59 The VP_DIFFUSE property specifies the RGB diffuse light coefficients of
60 the material. This term represents the fraction of incident light
61 intensity that is reflected diffusely (with a dull, matte appearance).
62 The values of the coefficients should be in the range 0.0-1.0.
63 Default: 0.4
64
65 The VP_SPECULAR property specifies the RGB specular light coefficients
66 of the material. This term represents the fraction of incident light
67 intensity that is reflected specularly (with a shiny, mirror-like
68 appearance). The values of the coefficients should be in the range
69 0.0-1.0. Default: 0.5
70
71 The VP_SHINYNESS property specifies a single exponent that modifies the
72 spread of specular highlights. The higher the number, the smaller and
73 more intense the specular highlights. The exponent is specified with
74 the r argument and can have any value; the generally-useful range is
75 1.0 to 100.0. The g and b arguments are ignored for this property.
76 Default: 10.0
77
78 The surface_side argument specifies which side of the material surface
79 the properties apply to. By default, the "interior" side of a voxel is
80 the side in the direction of the surface normal. During rendering, if
81 the normal points closer to the direction of the viewer than the oppo‐
82 site of the normal then the viewer is looking at the exterior side of
83 the voxel rather than the interior. Different material parameters can
84 be applied to the two surface sides by calling vpSetMaterial separately
85 for each side. The option VP_BOTH_SIDES allows the same property to be
86 set for both sides with only one function call. It is possible to
87 reverse the definition of interior and exterior sides by calling vpEn‐
88 able with the VP_REVERSE_SURFACE_SIDES option.
89
90 Voxels are shaded using the following equation: I = A + L * (D *
91 n_dot_l + S * pow(n_dot_h, E))
92
93 I intensity for one color channel
94 A ambient intensity coefficient
95 D diffuse reflection coefficient
96 S specular reflection coefficient
97 E shinyness
98 L light intensity
99 n_dot_l dot product of normal and light vectors
100 n_dot_h dot product of normal and highlight vectors This equation
101 is evaluated separately for each color channel. If multiple light
102 sources are enabled an additional term identical to the second term
103 above is added for each light source (with different values for L,
104 n_dot_l and n_dot_h corresponding to the particular light source).
105
107 Information about the current material properties can be retrieved with
108 the following state variable codes (see vpGeti(3)): VP_MATERIAL_COUNT,
109 VP_REVERSE_SURFACE_SIDES
110
112 The normal return value is VP_OK. The following error return values
113 are possible:
114
115 VPERROR_BAD_VALUE
116 Either the material number or the RGB components are invalid.
117
118 VPERROR_BAD_OPTION
119 Either the surface_side or property arguments are invalid.
120
122 VolPack(3), vpCreateContext(3), vpSetLookupShader(3), vpShadeTable(3),
123 vpGetMaterial(3)
124
125
126
127VolPack vpSetMaterial(3)