Skip to content

Instantly share code, notes, and snippets.

View andsve's full-sized avatar
🍎
Coding

Sven Andersson andsve

🍎
Coding
View GitHub Profile
--[[
http://people.ee.ethz.ch/~pascmu/documents/procedural_modeling_of_cities__siggraph2001.pdf
]]
--[[
from: http://www.newton64.ca/blog/?p=747#7472
@andsve
andsve / Makefile
Created October 8, 2014 08:44
Ogre 1.10.x Test for Emscripten
emsc:
em++ ogre_test.cpp -I/usr/ogre/OgreMain/include/ -I/usr/ogre/build/include/ -I/usr/ogre/RenderSystems/GLES2/include/ -I/usr/ogre/PlugIns/OctreeSceneManager/include/ -I/usr/ogre/Components/RTShaderSystem/include/ -o ogre_test.bc -Werror
em++ ogre_test.bc /usr/ogre/build_static/lib/libRenderSystem_GLES2Static.a /usr/ogre/build_static/lib/libPlugin_OctreeSceneManagerStatic.a /usr/ogre/build_static/lib/libOgreRTShaderSystemStatic.a /usr/ogre/build_static/lib/libOgreMainStatic.a -o ogre.html --preload-file assets/plugins.cfg --preload-file assets/media/models/ogrehead.mesh --preload-file assets/media/materials/scripts/Ogre.material --preload-file assets/media/materials/scripts/cool.frag --preload-file assets/media/materials/scripts/cool.vs
native:
g++ -L/usr/lib/x86_64-linux-gnu/ -lfreeimage -lpthread -lX11 -lXt -lXmu -lXaw -lm -lGL -lGLU -lXrandr ogre_test.cpp -I/usr/ogre/OgreMain/include/ -I/usr/ogre/build/include/ -I/usr/ogre/RenderSystems/GL/include/ -I/usr/ogre/PlugIns/OctreeSceneManager/include/ -I
@andsve
andsve / gist:03ef7c2f911d3b061c55
Last active August 29, 2015 14:08
Faking a JavaScript "local" context + exporting predefined specific functions.
function FakeContext( src ) {
return (Function( '"use strict";' +
"if (this != window) {" +
" for (var __i in this) {" +
" eval( 'var ' + __i + ' = this[ __i ];' );" +
" }" +
"}" +
src +
"\n" +
"if (typeof(initialize) != 'undefined') { this.initialize = initialize; };" +
float control_points[7*7*3];
for (int i = 0; i < (n->numpoints); i++) {
for (int a = 0; a < 7; a+=1) {
float angle = (float)a/7.0f * 2 * PI;
control_points[i*7*7+a*3] = n->p[i+1].x*cos(angle);
control_points[i*7*7+a*3+1] = n->p[i+1].y;
control_points[i*7*7+a*3+2] = n->p[i+1].x*sin(angle);
}
}
float control_points[7*7*3];
for (int i = 0; i < n->numpoints; i++) {
for (int a = 0; a < 7; a+=1) {
float angle = (float)a/7.0f * 2 * PI;
control_points[i*7*7+a*3] = n->p[i+1].x*cos(angle);
control_points[i*7*7+a*3+1] = n->p[i+1].y;
control_points[i*7*7+a*3+2] = n->p[i+1].x*sin(angle));
}
}
R T G M P D F A L H B U I X K O J S Z W N Y Q
-------------------------------------------------------------------------
R | 2 1 3 5 1 4 1 2 1 1 1 1 1 1
T | 4 1 2 8 2 2 1 2 1
G | 2 4 1 3 1 1 8 2 1 1
M | 1 3 1 1 7 1 1 1 2
P | 4 2 1 2 1 1 1 1 1 1 1 1 1
D | 4 1 3 1 1 3 1 1 1 1
F | 2 2 4 2 1 1 2 1
A | 5 2 2 2 1
# >> ones i ni eo a e idsorsah e totristhria nats idaseahehrndotaorth ids thei rnid nrt es et eotsaota th theoat neti oes e si ids ise th esrnar id a e idsi h t aserreona ehineotrartihth t nrth iherne ah se idr a esah ri a iah r ts e rneihed thrneirnes trnods stoth e restr
# >> iser o so ei a e o rinrah e titnorthnoa satr o areahehns itainth o r theo nso snt er et eitraita th theiat seto ier e ro o r ore th ernsan o a e o ro h t arenneisa ehoseitnantohth t snth ohense ah re o n a erah no a oah n tr e nseohe thnseonser tnsi r rtith e nertn
Task 2A:
X = 12
x = 9
Since: 18^9 % 23 = 12
Task 2B:
m = 16
X = 12
k = 5
void main (void)
{
float depth = texture2D(tex_depth, gl_TexCoord[0].st).r * 2.0 - 1.0;
vec3 norm = texture2D(tex_norm, gl_TexCoord[0].st).xyz * 2.0 - 1.0;
//norm = normalize(norm); // no need?
vec4 ambient = texture2D(tex_motion, gl_TexCoord[0].st); // currently holds ambient colors
// will be used for velocity in future
// Viewport position at this pixel in the range -1 to 1.
vec4 projection_pos = vec4(gl_TexCoord[0].st * 2.0 - 1.0, depth, 1.0);