+ /* create scene lighting buffer */
+
+ u32 size = VG_MAX(world->light_count,1) * sizeof(float)*12;
+
+ vg_info( "Upload %ubytes (lighting)\n", size );
+
+ glGenBuffers( 1, &world->tbo_light_entities );
+ glBindBuffer( GL_TEXTURE_BUFFER, world->tbo_light_entities );
+ glBufferData( GL_TEXTURE_BUFFER, size, NULL, GL_DYNAMIC_DRAW );
+
+ /* buffer layout
+ *
+ * colour position direction (spots)
+ * | . . . . | . . . . | . . . . |
+ * | Re Ge Be Night | Xco Yco Zco | Dx Dy Dz Da |
+ *
+ */
+
+ v4f *light_dst = glMapBuffer( GL_TEXTURE_BUFFER, GL_WRITE_ONLY );
+
+ for( int i=0; i<world->light_count; i++ )
+ {
+ struct world_light *light = &world->lights[i];
+ struct classtype_world_light *inf = light->inf;
+
+ /* colour + night */
+ v3_muls( inf->colour, inf->colour[3] * 2.0f, light_dst[i*3+0] );
+ light_dst[i*3+0][3] = 0.0f;
+
+ if( (inf->type == k_light_type_spot_nighttime_only) ||
+ (inf->type == k_light_type_point_nighttime_only ) )
+ {
+ u32 hash = (i * 29986577) & 0xff;
+ float switch_on = hash;
+ switch_on *= (1.0f/255.0f);
+
+ light_dst[i*3+0][3] = 0.44f + switch_on * 0.015f;
+ }
+
+ /* position + nothing */
+ v3_copy( light->node->co, light_dst[i*3+1] );
+
+ /* direction + angle */
+ q_mulv( light->node->q, (v3f){0.0f,-1.0f,0.0f}, light_dst[i*3+2]);
+ light_dst[i*3+2][3] = inf->angle;
+ }
+
+ glUnmapBuffer( GL_TEXTURE_BUFFER );
+
+ glGenTextures( 1, &world->tex_light_entities );
+ glBindTexture( GL_TEXTURE_BUFFER, world->tex_light_entities );
+ glTexBuffer( GL_TEXTURE_BUFFER, GL_RGBA32F, world->tbo_light_entities );
+
+