X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=water.h;h=1de2554abf8e459175a30438cb6146e0f24b09a3;hb=4a883ac1b2506032f9dddab342712de46f2ca734;hp=c2a7122c2244c1774e9f49f428803ad6afb85ec1;hpb=cb16ccb05a796178c879ea8d5091663d215a5217;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/water.h b/water.h index c2a7122..1de2554 100644 --- a/water.h +++ b/water.h @@ -4,7 +4,6 @@ static void water_register(void); static void water_init(void); static void water_fb_resize(void); -static void water_compute_depth( boxf bounds ); static void water_set_surface( glmesh *surf, float height ); static float water_height(void); @@ -23,16 +22,16 @@ static struct struct framebuffer fbreflect, fbdepth; glmesh mdl; - GLuint depthmap; boxf depthbounds; int depth_computed; float height; int enabled; + v4f plane; } wrender = { - .fbreflect = { .format = GL_RGB, .div = 4 }, + .fbreflect = { .format = GL_RGB, .div = 3 }, .fbdepth = { .format = GL_RGBA, .div = 4 } }; @@ -64,6 +63,7 @@ static void water_fb_resize(void) fb_resize( &wrender.fbdepth ); } +#if 0 static void water_compute_depth( boxf bounds ) { if( !wrender.enabled ) @@ -72,38 +72,43 @@ static void water_compute_depth( boxf bounds ) #ifdef VG_RELEASE int const kres = 512; #else - int const kres = 64; + int const kres = 1024; #endif vg_info( "Computing depth map\n" ); - u8 *img = malloc( kres*kres ); + float *img = malloc( kres*kres*sizeof(float) ); + + boxf interior; + v3_add(bounds[0],(v3f){1.0f,1.0f,1.0f},interior[0]); + v3_sub(bounds[1],(v3f){1.0f,1.0f,1.0f},interior[1]); v3f volume; - v3_sub( bounds[1], bounds[0], volume ); - box_copy( bounds, wrender.depthbounds ); + v3_sub( interior[1], interior[0], volume ); + box_copy( interior, wrender.depthbounds ); for( int y=0; y