-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlenin.html
More file actions
340 lines (265 loc) · 10.4 KB
/
lenin.html
File metadata and controls
340 lines (265 loc) · 10.4 KB
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
328
329
330
331
332
333
334
335
336
337
338
339
<!DOCTYPE html>
<HTML>
<HEAD>
<title>Vladimir Ilyich - Alexandr Poltavsky, software developer</title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
<meta http-equiv="Pragma" content="no-cache" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" type="text/css" href="css/common.css" />
<link rel="stylesheet" href="highlight/styles/hybrid.css">
</HEAD>
<BODY>
<div id="wrap">
<!-- header part -->
<div id="header">
<a href="/color-throne.html"><img class="ad" src="images/color-throne-logo-promo.png" title="Color Throne Game"/></a>
<div class="avatar">
<a href="/">
<img class="avatar" width="160" src="images/alexandr-poltavsky-avatar.jpeg" title="Alexandr Poltavsky" align="left"/>
</a>
</div>
<div class="text">
<span class="bio">
Alexandr Poltavsky <br/>
Software Developer <br/>
Location: Russia, Moscow <br/>
<span class="email">
<a href="mailto:poltavsky.alexandr@gmail.com">poltavsky.alexandr@gmail.com</a><br/>
</span>
</span>
<div class="break"></div>
<span class="links">
<a href="/">Blog</a>
<a href="https://github.com/alexpolt/">Github</a>
<a href="https://www.shadertoy.com/user/alexpolt">Shadertoy</a>
<a href="https://twitter.com/poltavsky_alex">Twitter</a>
</span>
</div>
</div>
<div id="content" style="clear: left">
<!-- here goes the main content -->
<div id="main-menu">
<a id="main-menu-0" href="index.html">Programming</a>
<a id="main-menu-1" href="index-gfx.html">Graphics</a>
<a id="main-menu-2" href="index-off.html">Off-topic</a>
</div>
<h2>Vladimir Ilyich</h2>
<p>Vladimir Ilyich is often used in Russia to refer to <a href="https://en.wikipedia.org/wiki/Vladimir_Lenin" title="Vladimir Lenin">Vladimir Lenin</a>, a great russian
revolutionary, who had an immense impact on the course of history. Today <a href="https://en.wikipedia.org/wiki/Communism" title="Communism">communism</a> is
mostly viewed in negative light, but, truth to be told, it is the socialists (<a href="https://en.wikipedia.org/wiki/Bolsheviks" title="Bolsheviks">bolsheviks</a>)
in the previous century (and others before, but not on the global scale) who raised the
questions of equality and social justice that later developed into <a href="https://en.wikipedia.org/wiki/Human_rights" title="Human Rights">human rights</a> movement.</p>
<p>I was doing a <a href="http://alexpolt.github.io/shader.html#lights" title="Lighting using gl_PrimitiveID">lights demo</a> and as a result made a WebGL rotating statue of Vladimir Lenin.
Best viewed in fullscreen.</p>
<div class="webgl" webgl_version="1" webgl_div="shader0" init="load_demo">
<img class="link" src="images/lenin-bronze.png" title="Click to show WebGL demo" alt="WebGL demo"/><br/>
<span>Click to show WebGL demo</span>
</div>
<div class="shader hidden" id="shader0" js="" fn="">
<ul class="close">
<li title="Info" class="help">?</li>
<li title="Close Demo" class="close">Close</li>
</ul>
<ul class="menu">
<li title="WebGL Canvas" class="canvas">Canvas</li>
<li title="Vertex Shader" class="vs">VS</li>
<li title="Pixel Shader" class="ps">PS</li>
</ul>
<div class="canvas">
<canvas hide class="canvas"></canvas>
<textarea hide class="vs hidden" spellcheck="false">//<!--
attribute vec3 v_in;
attribute vec3 vn_in;
varying vec3 vn;
uniform mat3 cam;
uniform vec3 campos;
uniform float t;
uniform vec2 screen;
void main() {
vec3 ar = vec3(1);
if( screen.x > screen.y )
ar = vec3(screen.y/screen.x,1,1);
else
ar = vec3(1,screen.x/screen.y,1);
float a = t/16., c = cos(-a), s = sin(-a);
mat3 m = mat3( vec3(c, 0, s), vec3(0, 1, 0), vec3(-s, 0, c) );
vn = cam*m*vn_in;
vec3 p = cam*m*v_in+campos;
float far = 10000.0;
float near = 1.0;
float z = p.z;
p = ar * p;
p.z = far*(p.z-near)/(far-near);
gl_Position = vec4(p,z);
}
//-->
</textarea>
<textarea hide class="ps hidden" spellcheck="false">//<!--
precision highp float;
varying vec3 vn;
uniform float t;
const float pi = 3.14159265;
void main() {
vec3 c = vec3(227,103,0)/255.;
vec3 light0 = normalize(vec3(0,5,-10));
vec3 cam = vec3(0,0,-1);
vec3 norm = normalize(vn);
float kd = clamp( .0, .25, dot( light0, norm ));
float ks = clamp( .0, 1., dot( .5*(cam+light0), norm ));
ks = pow( ks, 6. );
gl_FragColor = vec4( c*ks+c*kd, 1);
}
//-->
</textarea>
<div hide class="help hidden"></div>
</div>
<div class="buttons">
<button title="Reload Shaders" class="reload">Reload</button>
<button title="Output WebGL Info in Console" class="log">Log</button>
<button title="Pause Rendering" class="pause">Pause</button>
<button title="Go Fullscreen" class="fscreen">FS</button>
</div>
</div>
<div class="clear">
</div>
<div>
<script src="js/common.js"></script>
<script src="js/loader.js"></script>
<script src="js/math.js"></script>
<script src="js/camera.js"></script>
<script src="js/webgl-quad.js"></script>
<script src="js/webgl.js"></script>
<script>
var r;
function load_demo (cb) {
var span = this.querySelector("span");
var div = this;
if( !r || r.failed || !r.loaded )
r = load_resources( ["webgl/lenin2dec2.obj"], {} );
r.delay = 500;
var fn = function(){
if( r.failed )
alert("Loading " + r.failed_src + " failed. Try realoading the page.");
else if( ! r.loaded )
alert("Resources not loaded. Check console output (ctrl+shift+j or F12) and try reloading the page.");
else {
div.load_animation = true;
lenin.call ( div, cb );
}
};
if( ! this.load_animation )
load_animation (r, span, fn);
else fn ();
}
function lenin (cb) {
var b = load_buffers();
var div = this.getAttribute("webgl_div");
var divc = document.querySelector( "div#"+div+" div.canvas" );
var cam = camera_create( { element: divc, nobind: false, personal: false, pos: vec3(0,0,450), speed: 10 } );
var opts = {
bgcolor: [.95, .95, .95, 1],
buffers: {v_in: b[0], vn_in: b[1]},
draw_size: b[0].length/3,
uniforms: { cam: function(){ return cam.get_m(); }, campos: function(){ return cam.get_pos(); } },
onreload: function() { cam.reset_m(); },
onclose: function() { camera_remove(cam); },
onpause: function(s) { cam.pause(s); },
};
opts.uniforms.cam.matrix_size = 3;
cb (opts);
}
function load_buffers() {
var m, v=[], vn=[], f=[];
var reg = /^v\s+([-.\d]+)\s+([-.\d]+)\s+([-.\d]+)/gm;
while( (m = reg.exec( r.data[0])) !== null ) v.push( m[1], m[2], m[3] );
reg = /^vn\s+([-.\d]+)\s+([-.\d]+)\s+([-.\d]+)/gm;
while( (m = reg.exec( r.data[0])) !== null ) vn.push( m[1], m[2], m[3] );
reg = /^f\s+(\d+)\/\/\d+\s+(\d+)\/\/\d+\s+(\d+)\/\/\d+/gm;
while( (m = reg.exec( r.data[0])) !== null ) f.push( m[1], m[2], m[3] );
var b0 = new Float32Array( f.length*3 ), b1 = new Float32Array( f.length*3 );
for(var i=0; i<f.length; i++) {
for(var t=0; t<3; t++) {
b0[i*3+t] = v[ (f[i]-1)*3+t ];
b1[i*3+t] = vn[ (f[i]-1)*3+t ];
}
}
return [b0,b1];
}
</script>
</div>
<script>
document.addEventListener( "DOMContentLoaded", function() {
if( /iPhone|iPad|iPod|Android|Windows Phone/i.test(navigator.userAgent) ) {
document.getElementById("wrap").classList.add("mobile");
}
} );
</script>
<script src="highlight/highlight.pack.js"></script>
<script>
//hljs.configure({languages: ["C++"]});
hljs.initHighlightingOnLoad();
</script>
<div id="disqus_comments"><a href="javascript: run_disqus()">read and write commentaries</a></div>
<div id="disqus_thread"></div>
<script>
/**
* RECOMMENDED CONFIGURATION VARIABLES: EDIT AND UNCOMMENT THE SECTION BELOW TO INSERT DYNAMIC VALUES FROM YOUR PLATFORM OR CMS.
* LEARN WHY DEFINING THESE VARIABLES IS IMPORTANT: https://disqus.com/admin/universalcode/#configuration-variables
*/
/*
var disqus_config = function () {
this.page.url = PAGE_URL; // Replace PAGE_URL with your page's canonical URL variable
this.page.identifier = PAGE_IDENTIFIER; // Replace PAGE_IDENTIFIER with your page's unique identifier variable
};
*/
function run_disqus() { // DON'T EDIT BELOW THIS LINE
var d = document, s = d.createElement('script');
s.src = '//alexpolt-github-io.disqus.com/embed.js';
s.setAttribute('data-timestamp', +new Date());
(d.head || d.body).appendChild(s);
d.getElementById("disqus_comments").innerHTML = ""; // alexpolt
return undefined;
};
if( location.hash.indexOf("comment") != -1 ) run_disqus();
</script>
<!--noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript" rel="nofollow">comments
powered by Disqus.</a></noscript-->
</div> <!-- end content -->
</div> <!-- end wrap -->
<!-- Google Analytics -->
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-75341409-1', 'auto');
ga('send', 'pageview');
</script>
<!-- Yandex.Metrika counter -->
<script type="text/javascript">
(function (d, w, c) {
(w[c] = w[c] || []).push(function() {
try {
w.yaCounter43425229 = new Ya.Metrika({
id:43425229,
clickmap:true,
trackLinks:true,
accurateTrackBounce:true
});
} catch(e) { }
});
var n = d.getElementsByTagName("script")[0],
s = d.createElement("script"),
f = function () { n.parentNode.insertBefore(s, n); };
s.type = "text/javascript";
s.async = true;
s.src = "https://mc.yandex.ru/metrika/watch.js";
if (w.opera == "[object Opera]") {
d.addEventListener("DOMContentLoaded", f, false);
} else { f(); }
})(document, window, "yandex_metrika_callbacks");
</script>
<noscript><div><img src="https://mc.yandex.ru/watch/43425229" style="position:absolute; left:-9999px;" alt="" /></div></noscript>
<!-- /Yandex.Metrika counter -->
</BODY>