-
Notifications
You must be signed in to change notification settings - Fork 80
/
glsl_julia.osgt
416 lines (414 loc) · 9.4 KB
/
glsl_julia.osgt
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
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
#Ascii Scene
#Version 78
#Generator OpenSceneGraph 2.9.17
osg::Geode {
UniqueID 1
Name "glsl_julia.osg"
DataVariance DYNAMIC
StateSet TRUE {
osg::StateSet {
UniqueID 2
DataVariance STATIC
AttributeList 1 {
osg::Program {
UniqueID 3
DataVariance STATIC
Shaders 2 {
osg::Shader {
UniqueID 4
DataVariance DYNAMIC
Type VERTEX
ShaderSource 35 {
"//"
"// Vertex shader for drawing Julia sets"
"//"
"// Authors: Dave Baldwin, Steve Koren, Randi Rost"
"// based on a shader by Michael Rivero"
"//"
"// Copyright (c) 2002-2004: 3Dlabs, Inc."
"//"
"// See 3Dlabs-License.txt for license information"
"//"
""
"uniform vec3 LightPosition;"
"uniform float SpecularContribution;"
"uniform float DiffuseContribution;"
"uniform float Shininess;"
""
"varying float LightIntensity;"
"varying vec3 Position;"
""
"void main(void)"
"{"
" vec3 ecPosition = vec3 (gl_ModelViewMatrix * gl_Vertex);"
" vec3 tnorm = normalize(gl_NormalMatrix * gl_Normal);"
" vec3 lightVec = normalize(LightPosition - ecPosition);"
" vec3 reflectVec = reflect(-lightVec, tnorm);"
" vec3 viewVec = normalize(-ecPosition);"
" float spec = max(dot(reflectVec, viewVec), 0.0);"
" spec = pow(spec, Shininess);"
" LightIntensity = DiffuseContribution * "
" max(dot(lightVec, tnorm), 0.0) +"
" SpecularContribution * spec;"
" Position = vec3(gl_MultiTexCoord0 - 0.5) * 5.0;"
" gl_Position = ftransform();"
""
"}"
}
}
osg::Shader {
UniqueID 5
DataVariance DYNAMIC
Type FRAGMENT
ShaderSource 56 {
"//"
"// Fragment shader for drawing Julia sets"
"//"
"// Authors: Dave Baldwin, Steve Koren, Randi Rost"
"// based on a shader by Michael Rivero"
"//"
"// Copyright (c) 2002-2004: 3Dlabs, Inc."
"//"
"// See 3Dlabs-License.txt for license information"
"//"
""
"varying vec3 Position;"
"varying float LightIntensity;"
""
"uniform float MaxIterations;"
"uniform float Zoom;"
"uniform float Xcenter;"
"uniform float Ycenter;"
"uniform vec3 InnerColor;"
"uniform vec3 OuterColor1;"
"uniform vec3 OuterColor2;"
"uniform float Creal;"
"uniform float Cimag;"
""
"void main(void)"
"{"
" float real = Position.x * Zoom + Xcenter;"
" float imag = Position.y * Zoom + Ycenter;"
" //float Creal = real; // Change this line..."
" //float Cimag = imag; // ...and this one to get a Julia set"
""
" float r2 = 0.0;"
" float iter;"
""
" for (iter = 0.0; iter < MaxIterations && r2 < 4.0; ++iter)"
" {"
" float tempreal = real;"
""
" real = (tempreal * tempreal) - (imag * imag) + Creal;"
" imag = 2.0 * tempreal * imag + Cimag;"
" r2 = (real * real) + (imag * imag);"
" }"
""
" // Base the color on the number of iterations"
""
" vec3 color;"
""
" if (r2 < 4.0)"
" color = InnerColor;"
" else"
" color = mix(OuterColor1, OuterColor2, fract(iter * 0.05));"
""
" color *= LightIntensity;"
""
" gl_FragColor = vec4 (color, 1.0);"
"}"
}
}
}
GeometryVerticesOut GL_GEOMETRY_VERTICES_OUT_EXT 1
GeometryInputType GL_GEOMETRY_INPUT_TYPE_EXT 4
GeometryOutputType GL_GEOMETRY_OUTPUT_TYPE_EXT 5
}
Value OFF
}
UniformList 13 {
osg::Uniform {
UniqueID 6
Name "Cimag"
DataVariance DYNAMIC
Type FLOAT
NumElements 1
Elements TRUE ArrayID 1 FloatArray 1 {
0.11
}
}
Value OFF
osg::Uniform {
UniqueID 7
Name "Creal"
DataVariance DYNAMIC
Type FLOAT
NumElements 1
Elements TRUE ArrayID 2 FloatArray 1 {
-0.765
}
}
Value OFF
osg::Uniform {
UniqueID 8
Name "DiffuseContribution"
DataVariance DYNAMIC
Type FLOAT
NumElements 1
Elements TRUE ArrayID 3 FloatArray 1 {
0.8
}
}
Value OFF
osg::Uniform {
UniqueID 9
Name "InnerColor"
DataVariance DYNAMIC
Type FLOAT_VEC3
NumElements 1
Elements TRUE ArrayID 4 FloatArray 3 {
0 0 0
}
}
Value OFF
osg::Uniform {
UniqueID 10
Name "LightPosition"
DataVariance DYNAMIC
Type FLOAT_VEC3
NumElements 1
Elements TRUE ArrayID 5 FloatArray 3 {
0 0 1
}
}
Value OFF
osg::Uniform {
UniqueID 11
Name "MaxIterations"
DataVariance DYNAMIC
Type FLOAT
NumElements 1
Elements TRUE ArrayID 6 FloatArray 1 {
100
}
}
Value OFF
osg::Uniform {
UniqueID 12
Name "OuterColor1"
DataVariance DYNAMIC
Type FLOAT_VEC3
NumElements 1
Elements TRUE ArrayID 7 FloatArray 3 {
1 1 0
}
}
Value OFF
osg::Uniform {
UniqueID 13
Name "OuterColor2"
DataVariance DYNAMIC
Type FLOAT_VEC3
NumElements 1
Elements TRUE ArrayID 8 FloatArray 3 {
1 0 0
}
}
Value OFF
osg::Uniform {
UniqueID 14
Name "Shininess"
DataVariance DYNAMIC
Type FLOAT
NumElements 1
Elements TRUE ArrayID 9 FloatArray 1 {
0.3
}
}
Value OFF
osg::Uniform {
UniqueID 15
Name "SpecularContribution"
DataVariance DYNAMIC
Type FLOAT
NumElements 1
Elements TRUE ArrayID 10 FloatArray 1 {
0.2
}
}
Value OFF
osg::Uniform {
UniqueID 16
Name "Xcenter"
DataVariance DYNAMIC
Type FLOAT
NumElements 1
Elements TRUE ArrayID 11 FloatArray 1 {
0
}
}
Value OFF
osg::Uniform {
UniqueID 17
Name "Ycenter"
DataVariance DYNAMIC
Type FLOAT
NumElements 1
Elements TRUE ArrayID 12 FloatArray 1 {
0
}
}
Value OFF
osg::Uniform {
UniqueID 18
Name "Zoom"
DataVariance DYNAMIC
Type FLOAT
NumElements 1
Elements TRUE ArrayID 13 FloatArray 1 {
0.7
}
}
Value OFF
}
}
}
Drawables 1 {
osg::Geometry {
UniqueID 19
DataVariance DYNAMIC
PrimitiveSetList 1 {
DrawArrays GL_QUADS 0 4
}
VertexData {
Array TRUE ArrayID 14 Vec3fArray 4 {
0 0 1
0 0 0
1 0 0
1 0 1
}
Indices FALSE
Binding BIND_PER_VERTEX
Normalize 0
}
NormalData {
Array TRUE ArrayID 15 Vec3fArray 1 {
0 -1 0
}
Indices FALSE
Binding BIND_OVERALL
Normalize 0
}
ColorData {
Array TRUE ArrayID 16 Vec4fArray 1 {
1 1 1 1
}
Indices FALSE
Binding BIND_OVERALL
Normalize 0
}
TexCoordData 1 {
Data {
Array TRUE ArrayID 17 Vec2fArray 4 {
0 1
0 0
1 0
1 1
}
Indices FALSE
Binding BIND_PER_VERTEX
Normalize 0
}
}
}
}
}