root/OpenSceneGraph-Data/trunk/shaders/eroded.frag

Revision 6871 (checked in by robert, 2 years ago)

Checked in first cut of new SVN for OpenSceneGraph-Data

Line 
1
2 //
3 // eroded.frag: Fragment shader for erosion effect
4 //
5 // author: Randi Rost
6 //
7 // Copyright (c) 2002: 3Dlabs, Inc.
8 //
9
10 varying float lightIntensity;
11 varying vec3 Position;
12
13 uniform vec3 Offset;
14 uniform sampler3D sampler3d; // value of sampler3d = 6
15
16 void main (void)
17 {
18     vec4 noisevec;
19     vec3 color;
20     float intensity;
21
22     noisevec = texture3D(sampler3d, 1.2 * (vec3 (0.5) + Position));
23
24     intensity = 0.75 * (noisevec.x + noisevec.y + noisevec.z + noisevec.w);
25
26     intensity = 1.95 * abs(2.0 * intensity - 1.0);
27     intensity = clamp(intensity, 0.0, 1.0);
28
29     if (intensity < fract(0.5-Offset.x-Offset.y-Offset.z)) discard;
30
31     color = mix(vec3 (0.2, 0.1, 0.0), vec3(0.8, 0.8, 0.8), intensity);
32    
33     color *= lightIntensity;
34     color = clamp(color, 0.0, 1.0);
35
36     gl_FragColor = vec4 (color, 1.0);
37    
38 }
Note: See TracBrowser for help on using the browser.