X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=world_gen.c;h=04d6131ec51e52da759a0ddf27b57a8592327576;hb=304647a7672165dd35ffe54884ed9aedcc9bf363;hp=bc9b2222dc7dda30952b9fca25eb60e6fbccf0cf;hpb=14851c4c820eb07a0db0ec0366a70bdd6518c331;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/world_gen.c b/world_gen.c index bc9b222..04d6131 100644 --- a/world_gen.c +++ b/world_gen.c @@ -9,6 +9,7 @@ #include "world_load.h" #include "world_volumes.h" #include "world_gate.h" +#include /* * Add all triangles from the model, which match the material ID @@ -722,10 +723,12 @@ void world_gen_load_surfaces( world_instance *world ) vg_align8(sizeof(GLuint)*world->texture_count) ); world->textures[0] = vg.tex_missing; - for( u32 i=0; imeta.textures); i++ ){ + for( u32 i=0; imeta.textures); i++ ) + { mdl_texture *tex = mdl_arritm( &world->meta.textures, i ); - if( !tex->file.pack_size ){ + if( !tex->file.pack_size ) + { vg_fatal_error( "World models must have packed textures!" ); } @@ -749,9 +752,25 @@ void world_gen_load_surfaces( world_instance *world ) struct world_surface *errmat = &world->surfaces[0]; memset( errmat, 0, sizeof(struct world_surface) ); - for( u32 i=0; imeta.materials); i++ ){ + for( u32 i=0; imeta.materials); i++ ) + { struct world_surface *surf = &world->surfaces[i+1]; surf->info = *(mdl_material *)mdl_arritm( &world->meta.materials, i ); surf->flags = 0; + + if( surf->info.shader == k_shader_water ) + { + struct shader_props_water *props = surf->info.props.compiled; + world->ub_lighting.g_water_fog = props->fog_scale; + } + + if( surf->info.shader == k_shader_standard_cutout || + surf->info.shader == k_shader_foliage ) + { + struct shader_props_standard *props = surf->info.props.compiled; + surf->alpha_tex = props->tex_diffuse; + } + else + surf->alpha_tex = 0; } }