change shader properties to be vg_msg based
[carveJwlIkooP6JGAAIwe30JlM.git] / world_gen.c
index bc9b2222dc7dda30952b9fca25eb60e6fbccf0cf..3d88ecd72f87312d9f6e2ef389005c73b444675f 100644 (file)
@@ -9,6 +9,7 @@
 #include "world_load.h"
 #include "world_volumes.h"
 #include "world_gate.h"
+#include <string.h>
 
 /*
  * 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; i<mdl_arrcount(&world->meta.textures); i++ ){
+   for( u32 i=0; i<mdl_arrcount(&world->meta.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,19 @@ 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; i<mdl_arrcount(&world->meta.materials); i++ ){
+   for( u32 i=0; i<mdl_arrcount(&world->meta.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_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;
    }
 }