# HG changeset patch # User John Tsiombikas # Date 1355877440 -7200 # Node ID 2f4406cc341eb4fd8552c6bec92ffad9c5c4f6aa # Parent 9021a906c5d33700e3f1d370e3948aa0af3fc6fa meh diff -r 9021a906c5d3 -r 2f4406cc341e sdr/bloboray.p.glsl --- a/sdr/bloboray.p.glsl Tue Dec 18 06:13:09 2012 +0200 +++ b/sdr/bloboray.p.glsl Wed Dec 19 02:37:20 2012 +0200 @@ -27,7 +27,7 @@ vec3 get_blob(int i); #define BLOB_THRESHOLD 0.5 -#define BLOB_SCALE (1.0 / 4.0) +#define BLOB_SCALE 0.1 #define MAX_ITER 1 #define RAY_STEP (0.75 / volsize.z) @@ -184,8 +184,11 @@ float val = 0.0; for(int i=0; icollision(b->pos, npos, &npos, &normal)) { - b->velocity = b->velocity.reflection(normal); + printf("%d: COLLISION (%.2f %.2f %.2f)\n", (int)i, npos.x, npos.y, npos.z); + b->velocity = b->velocity.reflection(normal) * DAMPING; } + b->pos = npos; } + rend->prepare(); } void game_render() diff -r 9021a906c5d3 -r 2f4406cc341e src/level.cc --- a/src/level.cc Tue Dec 18 06:13:09 2012 +0200 +++ b/src/level.cc Wed Dec 19 02:37:20 2012 +0200 @@ -73,7 +73,8 @@ // generate some blobs for(int i=0; icreate(vol->get_size(0), vol->get_size(1), vol->get_size(2)); blobtex = new Texture1D; + blobtex->set_pixel_format(GL_RGBA16F); // floating point textures blobtex->create(level->blobs.size()); blobtex->set_filtering(GL_NEAREST); @@ -59,11 +60,14 @@ static void draw_cube(const Vector3 &pos, float sz); +void Renderer::prepare() +{ + leveltex->update((float*)level->terrain->get_data_ptr()); + update_blobtex(); +} + void Renderer::render() const { - leveltex->update((float*)level->terrain->get_data_ptr()); - ((Renderer*)this)->update_blobtex(); - bind_texture(leveltex, 0); bind_texture(blobtex, 1); @@ -73,6 +77,8 @@ level->terrain->get_size(1), level->terrain->get_size(2)); set_uniform_float4(sdrprog, "camprop", fov, aspect, 0, 0); + set_uniform_int(sdrprog, "num_blobs", (int)level->blobs.size()); + set_uniform_int(sdrprog, "voltex", 0); set_uniform_int(sdrprog, "blobtex", 1); bind_program(sdrprog); diff -r 9021a906c5d3 -r 2f4406cc341e src/renderer.h --- a/src/renderer.h Tue Dec 18 06:13:09 2012 +0200 +++ b/src/renderer.h Wed Dec 19 02:37:20 2012 +0200 @@ -25,6 +25,7 @@ void set_fov(float fov); void set_aspect(float aspect); + void prepare(); void render() const; }; diff -r 9021a906c5d3 -r 2f4406cc341e src/texture.cc --- a/src/texture.cc Tue Dec 18 06:13:09 2012 +0200 +++ b/src/texture.cc Wed Dec 19 02:37:20 2012 +0200 @@ -25,6 +25,7 @@ Texture::Texture() { type = 0; + intfmt = GL_RGBA; size[0] = size[1] = size[2] = 0; @@ -38,6 +39,11 @@ } } +void Texture::set_pixel_format(unsigned int fmt) +{ + intfmt = fmt; +} + void Texture::set_filtering(unsigned int min_filter, unsigned int mag_filter) { if(mag_filter == 0) { @@ -74,7 +80,7 @@ void Texture1D::create(int sz, float *data) { glBindTexture(type, tex); - glTexImage1D(type, 0, GL_RGBA, sz, 0, GL_RGBA, GL_FLOAT, data); + glTexImage1D(type, 0, intfmt, sz, 0, GL_RGBA, GL_FLOAT, data); size[0] = sz; } @@ -97,7 +103,7 @@ void Texture2D::create(int xsz, int ysz, float *data) { glBindTexture(type, tex); - glTexImage2D(type, 0, GL_RGBA, xsz, ysz, 0, GL_RGBA, GL_FLOAT, data); + glTexImage2D(type, 0, intfmt, xsz, ysz, 0, GL_RGBA, GL_FLOAT, data); size[0] = xsz; size[1] = ysz; @@ -124,7 +130,7 @@ void Texture3D::create(int xsz, int ysz, int zsz, float *data) { glBindTexture(type, tex); - glTexImage3D(type, 0, GL_RGBA, xsz, ysz, zsz, 0, GL_RGBA, GL_FLOAT, data); + glTexImage3D(type, 0, intfmt, xsz, ysz, zsz, 0, GL_RGBA, GL_FLOAT, data); size[0] = xsz; size[1] = ysz; diff -r 9021a906c5d3 -r 2f4406cc341e src/texture.h --- a/src/texture.h Tue Dec 18 06:13:09 2012 +0200 +++ b/src/texture.h Wed Dec 19 02:37:20 2012 +0200 @@ -5,6 +5,7 @@ protected: unsigned int type; unsigned int tex; + unsigned int intfmt; int size[3]; @@ -12,6 +13,8 @@ Texture(); virtual ~Texture(); + virtual void set_pixel_format(unsigned int fmt); + virtual void set_filtering(unsigned int min_filter, unsigned int mag_filter = 0); virtual void set_wrapping(unsigned int wrap);