This file is indexed.

/usr/share/k3d/shaders/k3d_material.h is in k3d-data 0.8.0.3-3build1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
/************************************************************************
 * material.h - Functions which compute the light response of materials.
 *
 * Author: Larry Gritz (gritzl@acm.org)
 *
 * Reference:
 *   _Advanced RenderMan: Creating CGI for Motion Picture_, 
 *   by Anthony A. Apodaca and Larry Gritz, Morgan Kaufmann, 1999.
 *
 * $Revision: 1.1 $    $Date: 2004/05/19 18:15:19 $
 *
 ************************************************************************/

#ifndef MATERIAL_H
#define MATERIAL_H


#include "k3d_locillum.h"
#include "k3d_reflections.h"



/* Compute the color of the surface using a simple plastic-like BRDF.
 * Typical values are Ka=1, Kd=0.8, Ks=0.5, roughness=0.1.
 */
color MaterialPlastic (normal Nf;  color basecolor;
                       float Ka, Kd, Ks, roughness;)
{
    extern vector I;
    return basecolor * (Ka*ambient() + Kd*diffuse(Nf))
           + Ks*specular(Nf,-normalize(I),roughness);
}


/* Compute the color of the surface using a simple Lambertian BRDF. */
color MaterialMatte (normal Nf;  color basecolor;  float Ka, Kd;)
{
    return basecolor * (Ka*ambient() + Kd*diffuse(Nf));
}


/* Compute the color of the surface using a simple metal-like BRDF.  To
 * give a metallic appearance, both diffuse and specular components are 
 * scaled by the color of the metal.  It is recommended that Kd < 0.1,
 * Ks > 0.5, and roughness > 0.15 to give a believable metallic appearance.
 */
color MaterialRoughMetal (normal Nf;  color basecolor;
                          float Ka, Kd, Ks, roughness;)
{
    extern vector I;
    return basecolor * (Ka*ambient() + Kd*diffuse(Nf) +
                        Ks*specular(Nf,-normalize(I),roughness));
}


/* Compute the color of the surface using a simple thin plastic-like BRDF.
 * We call it _thin_ because it includes a transmisison component to allow 
 * light from the _back_ of the surface to affect the appearance.  Typical
 * values are Ka=1, Kd=0.8, Kt = 0.2, Ks=0.5, roughness=0.1.
 */
color MaterialThinPlastic (normal Nf;  vector V;  color basecolor; 
                           float Ka, Kd, Kt, Ks, roughness;)
{
    return basecolor * (Ka*ambient() + Kd*diffuse(Nf) + Kt*diffuse(-Nf))
           + Ks*specular(Nf,V,roughness);
}



/* Compute the color of the surface using a simple plastic-like BRDF, with
 * fresnel-attenuated coherent reflections.
 * If twosided is nonzero, both sides are shiny, but if you know that
 * the object has N facing outward, twosided==0 is a good optimization
 * (especially when using the ray server).
 */
color
MaterialShinyPlastic (normal Nf; color basecolor;
                      float Ka, Kd, Ks, roughness, Kr, blur, ior;
		      uniform float twosided;
                      DECLARE_ENVPARAMS; )
{
    extern vector I;
    extern point P;
    extern normal N;
    vector IN = normalize(I), V = -IN;
    float fkr, fkt;  vector R, T;
    fresnel (IN, Nf, 1/ior, fkr, fkt, R, T);
    fkt = 1-fkr;
    if (twosided == 0 && N.I > 0)
	fkr = 0;
    return  fkt * basecolor * (Ka*ambient() + Kd*diffuse(Nf))
          + (Ks) * specular(Nf,V,roughness)
	  + SampleEnvironment (P, R, fkr*Kr, blur, ENVPARAMS);
}



/* Compute the color of the surface using a simple metal-like BRDF.  To
 * give a metallic appearance, both diffuse and specular components are 
 * scaled by the color of the metal.  It is recommended that Kd < 0.1,
 * Ks > 0.5, and roughness > 0.15 to give a believable metallic appearance.
 * If twosided is nonzero, both sides are shiny, but if you know that
 * the object has N facing outward, twosided==0 is a good optimization
 * (especially when using the ray server).
 */
color MaterialShinyMetal (normal Nf;  color basecolor;
                          float Ka, Kd, Ks, roughness, Kr, blur;
			  uniform float twosided;
                          DECLARE_ENVPARAMS;)
{
    extern point P;
    extern vector I;
    extern normal N;
    float kr = Kr;
    if (twosided == 0 && N.I > 0)
	kr = 0;
    vector IN = normalize(I), V = -IN;
    vector R = reflect (IN, Nf);
    return basecolor * (Ka*ambient() + Kd*diffuse(Nf) +
                        Ks*specular(Nf,V,roughness) + 
                        SampleEnvironment (P, R, kr, blur, ENVPARAMS));
}



/* Compute the color of the surface of a very rough, totally nonspecular
 * material like clay.  Use an Oren/Nayar BRDF for the diffuse term.
 */
color MaterialClay (normal Nf;  color basecolor;
                    float Ka, Kd, roughness;)
{
    extern vector I;
    return basecolor * (Ka*ambient() + 
			Kd*LocIllumOrenNayar(Nf,-normalize(I),roughness));
}


/* Compute the color of the surface using an anisotropic BRDF.  To
 * give a metallic appearance, both diffuse and specular components are 
 * scaled by the color of the metal.  It is recommended that Kd < 0.1,
 * Ks > 0.5, and roughness > 0.15 to give a believable metallic appearance.
 */
color MaterialBrushedMetal (normal Nf;  color basecolor;
                            float Ka, Kd, Ks;
                            vector xdir;  float uroughness, vroughness;)
{
    extern vector I;
    color spec = LocIllumWardAnisotropic (Nf, -normalize(I), 
					  xdir, uroughness, vroughness);
    return basecolor * (Ka*ambient() + Kd*diffuse(Nf) + Ks*spec);
}


/* Compute the color of a ceramic object.  Like plastic, but use a
 * "glossy" specular term.
 */
color MaterialCeramic (normal Nf;  color basecolor;
                       float Ka, Kd, Ks, roughness, specsharpness;)
{
    extern vector I;
    vector V = -normalize(I);
    return basecolor * (Ka*ambient() + Kd*diffuse(Nf))
              + Ks * LocIllumGlossy (Nf, V, roughness/10, specsharpness);
}



/* Compute the color of a glass-like surface with coherent reflections
 * and refractions.
 */
color MaterialGlass (normal Nf;  color basecolor;
                     float Ka, Kd, Ks, roughness, Kr, reflblur;
		     float Kt, refrblur, eta;
		     color transmitcolor;
		     uniform float refrrayjitter, refrraysamples;
		     DECLARE_ENVPARAMS;)
{
    extern point P;
    extern vector I;
    extern normal N;

    vector IN = normalize (I);

    /* Compute the reflection & refraction directions and amounts */
    vector Rfldir, Rfrdir;   /* Smooth reflection/refraction directions */
    float kr, kt;
    fresnel (IN, Nf, (I.N < 0) ? 1.0/eta : eta, kr, kt, Rfldir, Rfrdir);
    kt = 1-kr;   /* Physically incorrect, but portable */
    kr *= Kr;
    kt *= Kt;
#if (defined(BMRT) || defined(RAYSERVER_H))
    /* Speedup -- at deep ray levels, reflection is unimportant */
    if (raylevel() > 0)
	kr = 0;
#endif
#ifndef BMRT
    /* Speedup for PRMan -- don't shade back sides, but you HAVE to be sure
     * that normals correctly face outward.
     */
    if (N.I > 0)
	kr = kt = 0;
#endif

    /* Calculate the reflection & refraction color */
    color Crefl = SampleEnvironment (P, normalize(Rfldir), kr, reflblur,
				     ENVPARAMS);
    color Crefr = SampleEnvironment (P, normalize(Rfrdir), kt, refrblur,
				     envname, envspace, envrad, 
				     refrrayjitter, refrraysamples);
    return (basecolor * (Ka*ambient() + Kd*diffuse(Nf)) +
	    (Crefl + Ks*LocIllumGlossy(Nf,-IN,roughness,0.5)) +
	    transmitcolor * Crefr);
}



#endif /* defined(MATERIAL_H) */