changed: gcc8 base update
[opensg.git] / Examples / CSM / Shader / Simple / scene.osg
blob04309544a4a8ea89ad233bcf2ac0913374d25ea8
1 #OSG V1.0 
3 Node
5   core MaterialGroup
6   {
7     material ChunkMaterial
8     {
9       chunks
10       [
11         SimpleSHLChunk
12         {
13           variables ShaderProgramVariables
14           {
15             variables
16             [
17               ShaderVariableReal
18               {
19                 name "ColR"
20                 value 1.0
21               }
22               ShaderVariableReal
23               {
24                 name "ColG"
25                 value 0.6
26               }
27               ShaderVariableReal
28               {
29                 name "ColB"
30                 value 0.6
31               }
32               ShaderVariableReal
33               {
34                 name "ColB"
35                 value 0.0
36               }
37             ]
38           }
40           vertexShader 
41           [
42             ShaderProgram
43             {
44               shaderType GL_VERTEX_SHADER
46               program "
48                 varying float Diffuse; 
50                 void main(void)
51                 {
52                   // calculate vertex position in eye coordinates
53                   vec4 ecPosition = -normalize(gl_ModelViewMatrix * gl_Vertex);
55                   // compute the transformed normal
56                   vec3 tnorm      = normalize(gl_NormalMatrix * gl_Normal);
58                   // Calculate a diffuse light intensity
59                   Diffuse             = dot(ecPosition.xyz, 
60                                             tnorm     );
62                   // output final vertex information
63                   gl_Position     = gl_ModelViewProjectionMatrix * gl_Vertex;
64                 }
65               "
66             }
67           ]
69           fragmentShader 
70           [
71             ShaderProgram
72             {
73               shaderType GL_FRAGMENT_SHADER
75               program "
76                 varying float Diffuse; 
77                 uniform float ColR;
78                 uniform float ColG;
79                 uniform float ColB;
81                 void main (void)
82                 {
83                   gl_FragColor = vec4(ColR * Diffuse, 
84                                       ColG * Diffuse, 
85                                       ColB * Diffuse, 
86                                       1.);
87                 }
88               "
89             }
90           ]
91         }
92       ]
93     }
94   }
96   children
97   [
98     Node
99     {
100       core Inline
101       {
102         url "../../SimpleTeapot/object.wrl"
103       }
104     }
105   ]