|
Revision 6871
(checked in by robert, 2 years ago)
|
Checked in first cut of new SVN for OpenSceneGraph-Data
|
| Line | |
|---|
| 1 |
|
|---|
| 2 |
// |
|---|
| 3 |
// marble.frag: Fragment shader for producing a marble effect |
|---|
| 4 |
// |
|---|
| 5 |
// author: Randi Rost |
|---|
| 6 |
// |
|---|
| 7 |
// Copyright (c) 2002: 3Dlabs, Inc. |
|---|
| 8 |
// |
|---|
| 9 |
|
|---|
| 10 |
// Mike Weiblen 2003-09-19 : derived from ogl2demo in the 3Dlabs OpenGL2 SDK, |
|---|
| 11 |
// available from http://www.3dlabs.com/opengl2/ |
|---|
| 12 |
|
|---|
| 13 |
varying float LightIntensity; |
|---|
| 14 |
varying vec3 MCposition; |
|---|
| 15 |
|
|---|
| 16 |
const vec3 MarbleColor = vec3( 0.7, 0.7, 0.7 ); |
|---|
| 17 |
const vec3 VeinColor = vec3( 0.0, 0.15, 0.0 ); |
|---|
| 18 |
|
|---|
| 19 |
uniform sampler3D NoiseTex; |
|---|
| 20 |
uniform sampler1D SineTex; |
|---|
| 21 |
uniform vec3 Offset; |
|---|
| 22 |
|
|---|
| 23 |
void main (void) |
|---|
| 24 |
{ |
|---|
| 25 |
vec4 noisevec = texture3D(NoiseTex, MCposition + Offset.yzx); |
|---|
| 26 |
|
|---|
| 27 |
float intensity = abs(noisevec[0] - 0.25) + |
|---|
| 28 |
abs(noisevec[1] - 0.125) + |
|---|
| 29 |
abs(noisevec[2] - 0.0625) + |
|---|
| 30 |
abs(noisevec[3] - 0.03125); |
|---|
| 31 |
|
|---|
| 32 |
vec4 unswiz = texture1D(SineTex, MCposition.z + intensity * 2.0); |
|---|
| 33 |
float sineval = unswiz.s; |
|---|
| 34 |
vec3 color = mix(VeinColor, MarbleColor, sineval); |
|---|
| 35 |
color *= LightIntensity; |
|---|
| 36 |
color = clamp(color, 0.0, 1.0); |
|---|
| 37 |
gl_FragColor = vec4 (color, 1.0); |
|---|
| 38 |
} |
|---|