X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=water.h;h=81d709e47956e56e992110f2eb8c945c51ee601a;hb=4fccea589f00c06c570cc4ea3e7a69d191328ffb;hp=94c7b34d0a332c782e58b581f46bca735367e9a7;hpb=1f1d636056450dcd23cce55c0795ec6276272531;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/water.h b/water.h index 94c7b34..81d709e 100644 --- a/water.h +++ b/water.h @@ -7,6 +7,7 @@ #include "model.h" #include "render.h" #include "shaders/water.h" +#include "scene.h" vg_tex2d tex_water_surf = { .path = "textures/water_surf.qoi" }; @@ -15,6 +16,10 @@ static struct GLuint fb, rgb, rb; glmesh mdl; + GLuint depthmap; + boxf depthbounds; + int depth_computed; + float height; } wrender; @@ -24,9 +29,67 @@ static void water_register(void) shader_water_register(); } -static void water_init( void (*newfb)(GLuint*,GLuint*,GLuint*)) +static void water_init(void) +{ + create_renderbuffer_std( &wrender.fb, &wrender.rgb, &wrender.rb ); +} + +static int ray_world( v3f pos, v3f dir, ray_hit *hit ); +static void water_compute_depth( boxf bounds ) { - newfb( &wrender.fb, &wrender.rgb, &wrender.rb ); +#ifdef VG_RELEASE + int const kres = 512; +#else + int const kres = 64; +#endif + + vg_info( "Computing depth map\n" ); + u8 *img = malloc( kres*kres ); + + v3f volume; + v3_sub( bounds[1], bounds[0], volume ); + box_copy( bounds, wrender.depthbounds ); + + for( int y=0; y