-#ifndef LIGHTING_H
-#define LIGHTING_H
-
-#include "common.h"
-#include "scene.h"
-
-static int ray_world( v3f pos, v3f dir, ray_hit *hit );
-
-typedef struct voxel_gi voxel_gi;
-
-struct voxel_gi
-{
- GLuint hw_texture,
- pt_texture;
-
- v3i pt_dims; /* Page table dimentions */
- i32 page_size;
-
- v3f origin;
-};
-
-static void voxel_gi_setup( voxel_gi *gi, scene *sc,
- i32 page_size, float voxel_res )
-{
- v3_copy( sc->bbx[0], gi->origin );
- gi->page_size = page_size;
-
- v3f extent;
- v3_sub( sc->bbx[1], sc->bbx[0], extent );
-
- float fpage_size = voxel_res * (float)page_size;
-
- for( int i=0; i<3; i++ )
- {
- i32 voxel_count = extent[i] / voxel_res;
- gi->pt_dims[i] = (voxel_count+page_size-1) / page_size;
- }
-
- i32 pt_capacity = gi->pt_dims[0]*gi->pt_dims[1]*gi->pt_dims[2];
- vg_info( "Page table size: %dkb\n", (pt_capacity*2*2)/1024 );
-
- u16 *page_table = malloc( pt_capacity*sizeof(u16)*3 );
-
-
- u32 active_count = 0;
-
- for( int z=0; z<gi->pt_dims[2]; z++ )
- {
- for( int y=0; y<gi->pt_dims[1]; y++ )
- {
- for( int x=0; x<gi->pt_dims[0]; x++ )
- {
- v3f base = {x,y,z},
- end = {x+1,y+1,z+1};
-
- boxf page_region;
-
- v3_muladds( sc->bbx[0], base, ((float)page_size)*voxel_res, base );
- v3_muladds( sc->bbx[0], end, ((float)page_size)*voxel_res, end );
- v3_copy( base, page_region[0] );
- v3_copy( end, page_region[1] );
-
- u32 nothing[2];
- if( bh_select( &sc->bhtris, page_region, nothing, 2 ))
- {
- active_count ++;
-
- /* Calculate lighting */
- }
- }
- }
- }
-
- /* Calculate physical storage size */
- vg_info( "Hardware texture required size: %dmb\n",
- ((active_count*page_size*page_size*page_size*1)/1024)/1024 );
- vg_info( "Required physical blocks: %d\n", active_count );
-
- free( page_table );
-}
-
-static void compute_lighting_vertex( scene *sc )
-{
- v3f light_dir = { 0.2f, 1.0f, 1.0f };
- v3_normalize( light_dir );
-
- for( int i=0; i<sc->vertex_count; i++ )
- {
- model_vert *mv = &sc->verts[i];
-
- ray_hit hit;
- hit.dist = 100.0f;
-
- ray_world( mv->co, light_dir, &hit );
- float amt = hit.dist / 100.0f;
-
- mv->colour[0] = amt;
- mv->colour[1] = amt;
- mv->colour[2] = amt;
- mv->colour[3] = 1.0f;
- }
-}
-
-#endif /* LIGHTING_H */