checkin
authorhgn <hgodden00@gmail.com>
Thu, 2 Mar 2023 22:28:04 +0000 (22:28 +0000)
committerhgn <hgodden00@gmail.com>
Thu, 2 Mar 2023 22:28:04 +0000 (22:28 +0000)
19 files changed:
blender_export.py
common.h
maps_src/mp_mtzero.mdl
model.h
shaders/common_scene.glsl
shaders/common_world.glsl
shaders/model_character_view.h
shaders/model_sky.h
shaders/scene_depth.h
shaders/scene_position.h
shaders/scene_route.h
shaders/scene_standard.h
shaders/scene_standard_alphatest.h
shaders/scene_terrain.h
shaders/scene_vertex_blend.h
shaders/scene_water.h
shaders/scene_water_fast.h
world.h
world_gen.h

index b60b2e02fc8cf14550c3f2ace276c11545c48bec..6117ff871b80bbd0ead49466cec553776ac0176b 100644 (file)
@@ -837,6 +837,9 @@ class classtype_world_light( Structure ):
          _.type = 1
          _.angle = math.cos(data.spot_size*0.5)
       #}
+
+      if data.cv_data.bp0:
+         _.type += 2
    #}
 
    @staticmethod
@@ -1340,7 +1343,7 @@ def encoder_build_scene_graph( collection ):
 
    for obj in collection.all_objects:
    #{
-      if obj.parent: continue
+      #if obj.parent: continue
 
       def _extend( p, n, d ):
       #{
@@ -1915,7 +1918,7 @@ def encoder_process_definition( node_def ):
    #{
       obj      = node_def['obj']
       obj_type = obj.type
-      obj_co   = obj.location
+      obj_co   = obj.matrix_world @ Vector((0,0,0))
 
       if obj_type == 'ARMATURE':
          obj_classtype = 'classtype_skeleton'
@@ -2642,6 +2645,31 @@ class CV_MESH_SETTINGS(bpy.types.PropertyGroup):
    v3: bpy.props.FloatVectorProperty(name="v3",size=3)
 #}
 
+class CV_LIGHT_SETTINGS(bpy.types.PropertyGroup):
+#{
+   bp0: bpy.props.BoolProperty( name="bp0" );
+#}
+
+class CV_LIGHT_PANEL(bpy.types.Panel):
+#{
+   bl_label="[Skate Rift]"
+   bl_idname="SCENE_PT_cv_light"
+   bl_space_type='PROPERTIES'
+   bl_region_type='WINDOW'
+   bl_context='data'
+
+   def draw(_,context):
+   #{
+      active_object = context.active_object
+      if active_object == None: return
+
+      if active_object.type != 'LIGHT': return
+
+      data = active_object.data.cv_data
+      _.layout.prop( data, "bp0", text="Only on during night" )
+   #}
+#}
+
 class CV_OBJ_SETTINGS(bpy.types.PropertyGroup):
 #{
    uid: bpy.props.IntProperty( name="" )
@@ -2709,7 +2737,7 @@ class CV_BONE_SETTINGS(bpy.types.PropertyGroup):
 
 class CV_BONE_PANEL(bpy.types.Panel):
 #{
-   bl_label="Bone Config"
+   bl_label="[Skate Rift]"
    bl_idname="SCENE_PT_cv_bone"
    bl_space_type='PROPERTIES'
    bl_region_type='WINDOW'
@@ -3002,7 +3030,8 @@ class CV_INTERFACE(bpy.types.Panel):
 classes = [CV_OBJ_SETTINGS,CV_OBJ_PANEL,CV_COMPILE,CV_INTERFACE,\
            CV_MESH_SETTINGS, CV_SCENE_SETTINGS, CV_BONE_SETTINGS,\
            CV_BONE_PANEL, CV_COLLECTION_SETTINGS, CV_COMPILE_THIS,\
-           CV_MATERIAL_SETTINGS, CV_MATERIAL_PANEL ]
+           CV_MATERIAL_SETTINGS, CV_MATERIAL_PANEL, CV_LIGHT_SETTINGS,\
+           CV_LIGHT_PANEL]
 
 def register():
 #{
@@ -3019,6 +3048,7 @@ def register():
          bpy.props.PointerProperty(type=CV_COLLECTION_SETTINGS)
    bpy.types.Material.cv_data = \
          bpy.props.PointerProperty(type=CV_MATERIAL_SETTINGS)
+   bpy.types.Light.cv_data = bpy.props.PointerProperty(type=CV_LIGHT_SETTINGS)
 
    cv_view_draw_handler = bpy.types.SpaceView3D.draw_handler_add(\
       cv_draw,(),'WINDOW','POST_VIEW')
index c1f325e232f5d9f57b2f41f6cd71fc85d13f88f2..74200096cc329ec697a63285c845994397e378be 100644 (file)
--- a/common.h
+++ b/common.h
@@ -114,7 +114,8 @@ VG_STATIC int   k_ragdoll_div = 1,
                 k_ragdoll_debug_collider = 1,
                 k_ragdoll_debug_constraints = 0;
 
-VG_STATIC int   k_debug_light_index = 1;
+VG_STATIC int   k_debug_light_indices = 0,
+                k_debug_light_complexity = 0;
 
 VG_STATIC int freecam = 0;
 VG_STATIC int walk_grid_iterations = 1;
@@ -156,6 +157,8 @@ VG_STATIC void common_var_temp(void)
    VG_VAR_I32( k_ragdoll_div );
    VG_VAR_I32( k_ragdoll_debug_collider );
    VG_VAR_I32( k_ragdoll_debug_constraints );
+   VG_VAR_I32( k_debug_light_indices );
+   VG_VAR_I32( k_debug_light_complexity );
 
    VG_VAR_F32( k_friction_lat );
 
index 0c4d0ab63588503e051c76626f31b0b8e54bc2a9..d20a0e8af04343db0096f7881958faff155e5232 100644 (file)
Binary files a/maps_src/mp_mtzero.mdl and b/maps_src/mp_mtzero.mdl differ
diff --git a/model.h b/model.h
index b2d258deb282916dfead2dd647893259e39b87ec..7c4e0d9cbade5266c18b85d45a2b3f09fe8d8e8a 100644 (file)
--- a/model.h
+++ b/model.h
@@ -276,7 +276,9 @@ struct classtype_world_light
    enum light_type 
    {
       k_light_type_point,
-      k_light_type_spot
+      k_light_type_spot,
+      k_light_type_point_nighttime_only,
+      k_light_type_spot_nighttime_only
    } 
    type;
 
index 2cf00b9878d0427d386964f645e99463f0fb60bd..91dc6a19cf7116cae9b1a1e5a110418ab4dbc1ae 100644 (file)
@@ -72,35 +72,57 @@ vec3 scene_do_lighting( vec3 diffuse, vec3 wnormal )
    vec4 light_dir_1    = texelFetch( uLightsArray, light_indices.y*3+2 );
    vec4 light_dir_2    = texelFetch( uLightsArray, light_indices.z*3+2 );
 
-   //return vec3(fract(distance(light_co_0.xyz,aWorldCo)),
-   //            fract(distance(light_co_1.xyz,aWorldCo)),
-   //            fract(distance(light_co_2.xyz,aWorldCo)));
-
-  // return vec3(fract(light_indices.x * 0.125), fract(light_indices.y*0.125),
-  //             fract(light_indices.z * 0.125 ));
-
-   total_light += newlight_compute_spot
-                  ( 
-                     wnormal, halfview,
-                     light_colour_0.rgb,
-                     light_co_0.xyz,
-                     light_dir_0
-                  ) * board_shadow;
-
-   total_light += newlight_compute_spot
-                  ( 
-                     wnormal, halfview,
-                     light_colour_1.rgb,
-                     light_co_1.xyz,
-                     light_dir_1
-                  ) * board_shadow;
-   total_light += newlight_compute_spot
-                  ( 
-                     wnormal, halfview,
-                     light_colour_2.rgb,
-                     light_co_2.xyz,
-                     light_dir_2
-                  ) * board_shadow;
+   if( g_debug_indices == 1 )
+   {
+      float rings = min( fract(distance(light_co_0.xyz,aWorldCo)),
+                      min( fract(distance(light_co_1.xyz,aWorldCo)),
+                           fract(distance(light_co_2.xyz,aWorldCo)) ) 
+                        );
+               
+      return vec3(fract(light_indices.x * 0.125), fract(light_indices.y*0.125),
+                  fract(light_indices.z * 0.125 )) + (rings-0.5) * 0.25;
+   }
+
+   if( g_debug_complexity == 1 )
+   {
+      return vec3(1.0,0.0,0.0) * ( light_indices.w/3.0 );
+   }
+
+   if( light_indices.w >= 1 )
+   {
+      total_light += newlight_compute_spot
+                     ( 
+                        wnormal, halfview,
+                        light_colour_0.rgb,
+                        light_co_0.xyz,
+                        light_dir_0
+                     ) * board_shadow 
+                       * step( world.day_phase, light_colour_0.w );
+
+      if( light_indices.w >= 2 )
+      {
+         total_light += newlight_compute_spot
+                        ( 
+                           wnormal, halfview,
+                           light_colour_1.rgb,
+                           light_co_1.xyz,
+                           light_dir_1
+                        ) * board_shadow
+                          * step( world.day_phase, light_colour_1.w );
+
+         if( light_indices.w >= 3 )
+         {
+            total_light += newlight_compute_spot
+                           ( 
+                              wnormal, halfview,
+                              light_colour_2.rgb,
+                              light_co_2.xyz,
+                              light_dir_2
+                           ) * board_shadow
+                             * step( world.day_phase, light_colour_2.w );
+         }
+      }
+   }
 
    vec3 fog_colour = scene_sky( -halfview, world );
    
index 43934098a427d5d5839a2736ed105961f2a136fc..ccf416eadd9a3d88469cb89388bab31167838ebc 100644 (file)
@@ -14,6 +14,9 @@ layout (std140) uniform ub_world_lighting
    int g_light_preview;
    int g_shadow_samples;
 
+   int g_debug_indices;
+   int g_debug_complexity;
+
    // g_time ?
 
    //vec4 g_point_light_positions[32];
index 68a46679a7b8001f383c465334a4612ffe9a3388..2017f7db76b844a612d883e67393a0a50df45751 100644 (file)
@@ -100,6 +100,9 @@ static struct vg_shader _shader_model_character_view = {
 "   int g_light_preview;\n"
 "   int g_shadow_samples;\n"
 "\n"
+"   int g_debug_indices;\n"
+"   int g_debug_complexity;\n"
+"\n"
 "   // g_time ?\n"
 "\n"
 "   //vec4 g_point_light_positions[32];\n"
index d1edd1dd50b84aa72e8ce14f16a5008284c5297f..2fb62ff6564cd9fa84d5cb21c294957046ec21f4 100644 (file)
@@ -91,6 +91,9 @@ static struct vg_shader _shader_model_sky = {
 "   int g_light_preview;\n"
 "   int g_shadow_samples;\n"
 "\n"
+"   int g_debug_indices;\n"
+"   int g_debug_complexity;\n"
+"\n"
 "   // g_time ?\n"
 "\n"
 "   //vec4 g_point_light_positions[32];\n"
index 63ff70263a051731d2f9b292992a0ff31884cd4c..f40c46147dc900a9f1c997f6338310ce962929c0 100644 (file)
@@ -101,6 +101,9 @@ static struct vg_shader _shader_scene_depth = {
 "   int g_light_preview;\n"
 "   int g_shadow_samples;\n"
 "\n"
+"   int g_debug_indices;\n"
+"   int g_debug_complexity;\n"
+"\n"
 "   // g_time ?\n"
 "\n"
 "   //vec4 g_point_light_positions[32];\n"
@@ -441,35 +444,57 @@ static struct vg_shader _shader_scene_depth = {
 "   vec4 light_dir_1    = texelFetch( uLightsArray, light_indices.y*3+2 );\n"
 "   vec4 light_dir_2    = texelFetch( uLightsArray, light_indices.z*3+2 );\n"
 "\n"
-"   //return vec3(fract(distance(light_co_0.xyz,aWorldCo)),\n"
-"   //            fract(distance(light_co_1.xyz,aWorldCo)),\n"
-"   //            fract(distance(light_co_2.xyz,aWorldCo)));\n"
-"\n"
-"  // return vec3(fract(light_indices.x * 0.125), fract(light_indices.y*0.125),\n"
-"  //             fract(light_indices.z * 0.125 ));\n"
-"\n"
-"   total_light += newlight_compute_spot\n"
-"                  ( \n"
-"                     wnormal, halfview,\n"
-"                     light_colour_0.rgb,\n"
-"                     light_co_0.xyz,\n"
-"                     light_dir_0\n"
-"                  ) * board_shadow;\n"
-"\n"
-"   total_light += newlight_compute_spot\n"
-"                  ( \n"
-"                     wnormal, halfview,\n"
-"                     light_colour_1.rgb,\n"
-"                     light_co_1.xyz,\n"
-"                     light_dir_1\n"
-"                  ) * board_shadow;\n"
-"   total_light += newlight_compute_spot\n"
-"                  ( \n"
-"                     wnormal, halfview,\n"
-"                     light_colour_2.rgb,\n"
-"                     light_co_2.xyz,\n"
-"                     light_dir_2\n"
-"                  ) * board_shadow;\n"
+"   if( g_debug_indices == 1 )\n"
+"   {\n"
+"      float rings = min( fract(distance(light_co_0.xyz,aWorldCo)),\n"
+"                      min( fract(distance(light_co_1.xyz,aWorldCo)),\n"
+"                           fract(distance(light_co_2.xyz,aWorldCo)) ) \n"
+"                        );\n"
+"               \n"
+"      return vec3(fract(light_indices.x * 0.125), fract(light_indices.y*0.125),\n"
+"                  fract(light_indices.z * 0.125 )) + (rings-0.5) * 0.25;\n"
+"   }\n"
+"\n"
+"   if( g_debug_complexity == 1 )\n"
+"   {\n"
+"      return vec3(1.0,0.0,0.0) * ( light_indices.w/3.0 );\n"
+"   }\n"
+"\n"
+"   if( light_indices.w >= 1 )\n"
+"   {\n"
+"      total_light += newlight_compute_spot\n"
+"                     ( \n"
+"                        wnormal, halfview,\n"
+"                        light_colour_0.rgb,\n"
+"                        light_co_0.xyz,\n"
+"                        light_dir_0\n"
+"                     ) * board_shadow \n"
+"                       * step( world.day_phase, light_colour_0.w );\n"
+"\n"
+"      if( light_indices.w >= 2 )\n"
+"      {\n"
+"         total_light += newlight_compute_spot\n"
+"                        ( \n"
+"                           wnormal, halfview,\n"
+"                           light_colour_1.rgb,\n"
+"                           light_co_1.xyz,\n"
+"                           light_dir_1\n"
+"                        ) * board_shadow\n"
+"                          * step( world.day_phase, light_colour_1.w );\n"
+"\n"
+"         if( light_indices.w >= 3 )\n"
+"         {\n"
+"            total_light += newlight_compute_spot\n"
+"                           ( \n"
+"                              wnormal, halfview,\n"
+"                              light_colour_2.rgb,\n"
+"                              light_co_2.xyz,\n"
+"                              light_dir_2\n"
+"                           ) * board_shadow\n"
+"                             * step( world.day_phase, light_colour_2.w );\n"
+"         }\n"
+"      }\n"
+"   }\n"
 "\n"
 "   vec3 fog_colour = scene_sky( -halfview, world );\n"
 "   \n"
index 5fed74774106ddcad531ee499cb0340b3bfd3640..89669553cc90128f814b4fd2b17c630a991ad6ec 100644 (file)
@@ -101,6 +101,9 @@ static struct vg_shader _shader_scene_position = {
 "   int g_light_preview;\n"
 "   int g_shadow_samples;\n"
 "\n"
+"   int g_debug_indices;\n"
+"   int g_debug_complexity;\n"
+"\n"
 "   // g_time ?\n"
 "\n"
 "   //vec4 g_point_light_positions[32];\n"
@@ -441,35 +444,57 @@ static struct vg_shader _shader_scene_position = {
 "   vec4 light_dir_1    = texelFetch( uLightsArray, light_indices.y*3+2 );\n"
 "   vec4 light_dir_2    = texelFetch( uLightsArray, light_indices.z*3+2 );\n"
 "\n"
-"   //return vec3(fract(distance(light_co_0.xyz,aWorldCo)),\n"
-"   //            fract(distance(light_co_1.xyz,aWorldCo)),\n"
-"   //            fract(distance(light_co_2.xyz,aWorldCo)));\n"
-"\n"
-"  // return vec3(fract(light_indices.x * 0.125), fract(light_indices.y*0.125),\n"
-"  //             fract(light_indices.z * 0.125 ));\n"
-"\n"
-"   total_light += newlight_compute_spot\n"
-"                  ( \n"
-"                     wnormal, halfview,\n"
-"                     light_colour_0.rgb,\n"
-"                     light_co_0.xyz,\n"
-"                     light_dir_0\n"
-"                  ) * board_shadow;\n"
-"\n"
-"   total_light += newlight_compute_spot\n"
-"                  ( \n"
-"                     wnormal, halfview,\n"
-"                     light_colour_1.rgb,\n"
-"                     light_co_1.xyz,\n"
-"                     light_dir_1\n"
-"                  ) * board_shadow;\n"
-"   total_light += newlight_compute_spot\n"
-"                  ( \n"
-"                     wnormal, halfview,\n"
-"                     light_colour_2.rgb,\n"
-"                     light_co_2.xyz,\n"
-"                     light_dir_2\n"
-"                  ) * board_shadow;\n"
+"   if( g_debug_indices == 1 )\n"
+"   {\n"
+"      float rings = min( fract(distance(light_co_0.xyz,aWorldCo)),\n"
+"                      min( fract(distance(light_co_1.xyz,aWorldCo)),\n"
+"                           fract(distance(light_co_2.xyz,aWorldCo)) ) \n"
+"                        );\n"
+"               \n"
+"      return vec3(fract(light_indices.x * 0.125), fract(light_indices.y*0.125),\n"
+"                  fract(light_indices.z * 0.125 )) + (rings-0.5) * 0.25;\n"
+"   }\n"
+"\n"
+"   if( g_debug_complexity == 1 )\n"
+"   {\n"
+"      return vec3(1.0,0.0,0.0) * ( light_indices.w/3.0 );\n"
+"   }\n"
+"\n"
+"   if( light_indices.w >= 1 )\n"
+"   {\n"
+"      total_light += newlight_compute_spot\n"
+"                     ( \n"
+"                        wnormal, halfview,\n"
+"                        light_colour_0.rgb,\n"
+"                        light_co_0.xyz,\n"
+"                        light_dir_0\n"
+"                     ) * board_shadow \n"
+"                       * step( world.day_phase, light_colour_0.w );\n"
+"\n"
+"      if( light_indices.w >= 2 )\n"
+"      {\n"
+"         total_light += newlight_compute_spot\n"
+"                        ( \n"
+"                           wnormal, halfview,\n"
+"                           light_colour_1.rgb,\n"
+"                           light_co_1.xyz,\n"
+"                           light_dir_1\n"
+"                        ) * board_shadow\n"
+"                          * step( world.day_phase, light_colour_1.w );\n"
+"\n"
+"         if( light_indices.w >= 3 )\n"
+"         {\n"
+"            total_light += newlight_compute_spot\n"
+"                           ( \n"
+"                              wnormal, halfview,\n"
+"                              light_colour_2.rgb,\n"
+"                              light_co_2.xyz,\n"
+"                              light_dir_2\n"
+"                           ) * board_shadow\n"
+"                             * step( world.day_phase, light_colour_2.w );\n"
+"         }\n"
+"      }\n"
+"   }\n"
 "\n"
 "   vec3 fog_colour = scene_sky( -halfview, world );\n"
 "   \n"
index 9d951119c45670b6fb8d4f892e6e88ee8819c0dd..61c14e61336cfa8500927bdff3d00d1c001c991e 100644 (file)
@@ -102,6 +102,9 @@ static struct vg_shader _shader_scene_route = {
 "   int g_light_preview;\n"
 "   int g_shadow_samples;\n"
 "\n"
+"   int g_debug_indices;\n"
+"   int g_debug_complexity;\n"
+"\n"
 "   // g_time ?\n"
 "\n"
 "   //vec4 g_point_light_positions[32];\n"
@@ -442,35 +445,57 @@ static struct vg_shader _shader_scene_route = {
 "   vec4 light_dir_1    = texelFetch( uLightsArray, light_indices.y*3+2 );\n"
 "   vec4 light_dir_2    = texelFetch( uLightsArray, light_indices.z*3+2 );\n"
 "\n"
-"   //return vec3(fract(distance(light_co_0.xyz,aWorldCo)),\n"
-"   //            fract(distance(light_co_1.xyz,aWorldCo)),\n"
-"   //            fract(distance(light_co_2.xyz,aWorldCo)));\n"
-"\n"
-"  // return vec3(fract(light_indices.x * 0.125), fract(light_indices.y*0.125),\n"
-"  //             fract(light_indices.z * 0.125 ));\n"
-"\n"
-"   total_light += newlight_compute_spot\n"
-"                  ( \n"
-"                     wnormal, halfview,\n"
-"                     light_colour_0.rgb,\n"
-"                     light_co_0.xyz,\n"
-"                     light_dir_0\n"
-"                  ) * board_shadow;\n"
-"\n"
-"   total_light += newlight_compute_spot\n"
-"                  ( \n"
-"                     wnormal, halfview,\n"
-"                     light_colour_1.rgb,\n"
-"                     light_co_1.xyz,\n"
-"                     light_dir_1\n"
-"                  ) * board_shadow;\n"
-"   total_light += newlight_compute_spot\n"
-"                  ( \n"
-"                     wnormal, halfview,\n"
-"                     light_colour_2.rgb,\n"
-"                     light_co_2.xyz,\n"
-"                     light_dir_2\n"
-"                  ) * board_shadow;\n"
+"   if( g_debug_indices == 1 )\n"
+"   {\n"
+"      float rings = min( fract(distance(light_co_0.xyz,aWorldCo)),\n"
+"                      min( fract(distance(light_co_1.xyz,aWorldCo)),\n"
+"                           fract(distance(light_co_2.xyz,aWorldCo)) ) \n"
+"                        );\n"
+"               \n"
+"      return vec3(fract(light_indices.x * 0.125), fract(light_indices.y*0.125),\n"
+"                  fract(light_indices.z * 0.125 )) + (rings-0.5) * 0.25;\n"
+"   }\n"
+"\n"
+"   if( g_debug_complexity == 1 )\n"
+"   {\n"
+"      return vec3(1.0,0.0,0.0) * ( light_indices.w/3.0 );\n"
+"   }\n"
+"\n"
+"   if( light_indices.w >= 1 )\n"
+"   {\n"
+"      total_light += newlight_compute_spot\n"
+"                     ( \n"
+"                        wnormal, halfview,\n"
+"                        light_colour_0.rgb,\n"
+"                        light_co_0.xyz,\n"
+"                        light_dir_0\n"
+"                     ) * board_shadow \n"
+"                       * step( world.day_phase, light_colour_0.w );\n"
+"\n"
+"      if( light_indices.w >= 2 )\n"
+"      {\n"
+"         total_light += newlight_compute_spot\n"
+"                        ( \n"
+"                           wnormal, halfview,\n"
+"                           light_colour_1.rgb,\n"
+"                           light_co_1.xyz,\n"
+"                           light_dir_1\n"
+"                        ) * board_shadow\n"
+"                          * step( world.day_phase, light_colour_1.w );\n"
+"\n"
+"         if( light_indices.w >= 3 )\n"
+"         {\n"
+"            total_light += newlight_compute_spot\n"
+"                           ( \n"
+"                              wnormal, halfview,\n"
+"                              light_colour_2.rgb,\n"
+"                              light_co_2.xyz,\n"
+"                              light_dir_2\n"
+"                           ) * board_shadow\n"
+"                             * step( world.day_phase, light_colour_2.w );\n"
+"         }\n"
+"      }\n"
+"   }\n"
 "\n"
 "   vec3 fog_colour = scene_sky( -halfview, world );\n"
 "   \n"
index 239a8ad7498f3935b6b18b15d4c0f2d53ca29e8d..a385437d445fb1157eab620ee8d350a2c72f19fb 100644 (file)
@@ -102,6 +102,9 @@ static struct vg_shader _shader_scene_standard = {
 "   int g_light_preview;\n"
 "   int g_shadow_samples;\n"
 "\n"
+"   int g_debug_indices;\n"
+"   int g_debug_complexity;\n"
+"\n"
 "   // g_time ?\n"
 "\n"
 "   //vec4 g_point_light_positions[32];\n"
@@ -442,35 +445,57 @@ static struct vg_shader _shader_scene_standard = {
 "   vec4 light_dir_1    = texelFetch( uLightsArray, light_indices.y*3+2 );\n"
 "   vec4 light_dir_2    = texelFetch( uLightsArray, light_indices.z*3+2 );\n"
 "\n"
-"   //return vec3(fract(distance(light_co_0.xyz,aWorldCo)),\n"
-"   //            fract(distance(light_co_1.xyz,aWorldCo)),\n"
-"   //            fract(distance(light_co_2.xyz,aWorldCo)));\n"
-"\n"
-"  // return vec3(fract(light_indices.x * 0.125), fract(light_indices.y*0.125),\n"
-"  //             fract(light_indices.z * 0.125 ));\n"
-"\n"
-"   total_light += newlight_compute_spot\n"
-"                  ( \n"
-"                     wnormal, halfview,\n"
-"                     light_colour_0.rgb,\n"
-"                     light_co_0.xyz,\n"
-"                     light_dir_0\n"
-"                  ) * board_shadow;\n"
-"\n"
-"   total_light += newlight_compute_spot\n"
-"                  ( \n"
-"                     wnormal, halfview,\n"
-"                     light_colour_1.rgb,\n"
-"                     light_co_1.xyz,\n"
-"                     light_dir_1\n"
-"                  ) * board_shadow;\n"
-"   total_light += newlight_compute_spot\n"
-"                  ( \n"
-"                     wnormal, halfview,\n"
-"                     light_colour_2.rgb,\n"
-"                     light_co_2.xyz,\n"
-"                     light_dir_2\n"
-"                  ) * board_shadow;\n"
+"   if( g_debug_indices == 1 )\n"
+"   {\n"
+"      float rings = min( fract(distance(light_co_0.xyz,aWorldCo)),\n"
+"                      min( fract(distance(light_co_1.xyz,aWorldCo)),\n"
+"                           fract(distance(light_co_2.xyz,aWorldCo)) ) \n"
+"                        );\n"
+"               \n"
+"      return vec3(fract(light_indices.x * 0.125), fract(light_indices.y*0.125),\n"
+"                  fract(light_indices.z * 0.125 )) + (rings-0.5) * 0.25;\n"
+"   }\n"
+"\n"
+"   if( g_debug_complexity == 1 )\n"
+"   {\n"
+"      return vec3(1.0,0.0,0.0) * ( light_indices.w/3.0 );\n"
+"   }\n"
+"\n"
+"   if( light_indices.w >= 1 )\n"
+"   {\n"
+"      total_light += newlight_compute_spot\n"
+"                     ( \n"
+"                        wnormal, halfview,\n"
+"                        light_colour_0.rgb,\n"
+"                        light_co_0.xyz,\n"
+"                        light_dir_0\n"
+"                     ) * board_shadow \n"
+"                       * step( world.day_phase, light_colour_0.w );\n"
+"\n"
+"      if( light_indices.w >= 2 )\n"
+"      {\n"
+"         total_light += newlight_compute_spot\n"
+"                        ( \n"
+"                           wnormal, halfview,\n"
+"                           light_colour_1.rgb,\n"
+"                           light_co_1.xyz,\n"
+"                           light_dir_1\n"
+"                        ) * board_shadow\n"
+"                          * step( world.day_phase, light_colour_1.w );\n"
+"\n"
+"         if( light_indices.w >= 3 )\n"
+"         {\n"
+"            total_light += newlight_compute_spot\n"
+"                           ( \n"
+"                              wnormal, halfview,\n"
+"                              light_colour_2.rgb,\n"
+"                              light_co_2.xyz,\n"
+"                              light_dir_2\n"
+"                           ) * board_shadow\n"
+"                             * step( world.day_phase, light_colour_2.w );\n"
+"         }\n"
+"      }\n"
+"   }\n"
 "\n"
 "   vec3 fog_colour = scene_sky( -halfview, world );\n"
 "   \n"
index c2c479ac1b933c3f64f0ce02433a17433778c2cc..46c1976a7933631ca933439b49578fc4ee4e78cf 100644 (file)
@@ -102,6 +102,9 @@ static struct vg_shader _shader_scene_standard_alphatest = {
 "   int g_light_preview;\n"
 "   int g_shadow_samples;\n"
 "\n"
+"   int g_debug_indices;\n"
+"   int g_debug_complexity;\n"
+"\n"
 "   // g_time ?\n"
 "\n"
 "   //vec4 g_point_light_positions[32];\n"
@@ -442,35 +445,57 @@ static struct vg_shader _shader_scene_standard_alphatest = {
 "   vec4 light_dir_1    = texelFetch( uLightsArray, light_indices.y*3+2 );\n"
 "   vec4 light_dir_2    = texelFetch( uLightsArray, light_indices.z*3+2 );\n"
 "\n"
-"   //return vec3(fract(distance(light_co_0.xyz,aWorldCo)),\n"
-"   //            fract(distance(light_co_1.xyz,aWorldCo)),\n"
-"   //            fract(distance(light_co_2.xyz,aWorldCo)));\n"
-"\n"
-"  // return vec3(fract(light_indices.x * 0.125), fract(light_indices.y*0.125),\n"
-"  //             fract(light_indices.z * 0.125 ));\n"
-"\n"
-"   total_light += newlight_compute_spot\n"
-"                  ( \n"
-"                     wnormal, halfview,\n"
-"                     light_colour_0.rgb,\n"
-"                     light_co_0.xyz,\n"
-"                     light_dir_0\n"
-"                  ) * board_shadow;\n"
-"\n"
-"   total_light += newlight_compute_spot\n"
-"                  ( \n"
-"                     wnormal, halfview,\n"
-"                     light_colour_1.rgb,\n"
-"                     light_co_1.xyz,\n"
-"                     light_dir_1\n"
-"                  ) * board_shadow;\n"
-"   total_light += newlight_compute_spot\n"
-"                  ( \n"
-"                     wnormal, halfview,\n"
-"                     light_colour_2.rgb,\n"
-"                     light_co_2.xyz,\n"
-"                     light_dir_2\n"
-"                  ) * board_shadow;\n"
+"   if( g_debug_indices == 1 )\n"
+"   {\n"
+"      float rings = min( fract(distance(light_co_0.xyz,aWorldCo)),\n"
+"                      min( fract(distance(light_co_1.xyz,aWorldCo)),\n"
+"                           fract(distance(light_co_2.xyz,aWorldCo)) ) \n"
+"                        );\n"
+"               \n"
+"      return vec3(fract(light_indices.x * 0.125), fract(light_indices.y*0.125),\n"
+"                  fract(light_indices.z * 0.125 )) + (rings-0.5) * 0.25;\n"
+"   }\n"
+"\n"
+"   if( g_debug_complexity == 1 )\n"
+"   {\n"
+"      return vec3(1.0,0.0,0.0) * ( light_indices.w/3.0 );\n"
+"   }\n"
+"\n"
+"   if( light_indices.w >= 1 )\n"
+"   {\n"
+"      total_light += newlight_compute_spot\n"
+"                     ( \n"
+"                        wnormal, halfview,\n"
+"                        light_colour_0.rgb,\n"
+"                        light_co_0.xyz,\n"
+"                        light_dir_0\n"
+"                     ) * board_shadow \n"
+"                       * step( world.day_phase, light_colour_0.w );\n"
+"\n"
+"      if( light_indices.w >= 2 )\n"
+"      {\n"
+"         total_light += newlight_compute_spot\n"
+"                        ( \n"
+"                           wnormal, halfview,\n"
+"                           light_colour_1.rgb,\n"
+"                           light_co_1.xyz,\n"
+"                           light_dir_1\n"
+"                        ) * board_shadow\n"
+"                          * step( world.day_phase, light_colour_1.w );\n"
+"\n"
+"         if( light_indices.w >= 3 )\n"
+"         {\n"
+"            total_light += newlight_compute_spot\n"
+"                           ( \n"
+"                              wnormal, halfview,\n"
+"                              light_colour_2.rgb,\n"
+"                              light_co_2.xyz,\n"
+"                              light_dir_2\n"
+"                           ) * board_shadow\n"
+"                             * step( world.day_phase, light_colour_2.w );\n"
+"         }\n"
+"      }\n"
+"   }\n"
 "\n"
 "   vec3 fog_colour = scene_sky( -halfview, world );\n"
 "   \n"
index cf19762aafa8a3478f2de73bc5fae251f208bb1b..da847978891afe57102c4689d151095c28abad64 100644 (file)
@@ -103,6 +103,9 @@ static struct vg_shader _shader_scene_terrain = {
 "   int g_light_preview;\n"
 "   int g_shadow_samples;\n"
 "\n"
+"   int g_debug_indices;\n"
+"   int g_debug_complexity;\n"
+"\n"
 "   // g_time ?\n"
 "\n"
 "   //vec4 g_point_light_positions[32];\n"
@@ -443,35 +446,57 @@ static struct vg_shader _shader_scene_terrain = {
 "   vec4 light_dir_1    = texelFetch( uLightsArray, light_indices.y*3+2 );\n"
 "   vec4 light_dir_2    = texelFetch( uLightsArray, light_indices.z*3+2 );\n"
 "\n"
-"   //return vec3(fract(distance(light_co_0.xyz,aWorldCo)),\n"
-"   //            fract(distance(light_co_1.xyz,aWorldCo)),\n"
-"   //            fract(distance(light_co_2.xyz,aWorldCo)));\n"
-"\n"
-"  // return vec3(fract(light_indices.x * 0.125), fract(light_indices.y*0.125),\n"
-"  //             fract(light_indices.z * 0.125 ));\n"
-"\n"
-"   total_light += newlight_compute_spot\n"
-"                  ( \n"
-"                     wnormal, halfview,\n"
-"                     light_colour_0.rgb,\n"
-"                     light_co_0.xyz,\n"
-"                     light_dir_0\n"
-"                  ) * board_shadow;\n"
-"\n"
-"   total_light += newlight_compute_spot\n"
-"                  ( \n"
-"                     wnormal, halfview,\n"
-"                     light_colour_1.rgb,\n"
-"                     light_co_1.xyz,\n"
-"                     light_dir_1\n"
-"                  ) * board_shadow;\n"
-"   total_light += newlight_compute_spot\n"
-"                  ( \n"
-"                     wnormal, halfview,\n"
-"                     light_colour_2.rgb,\n"
-"                     light_co_2.xyz,\n"
-"                     light_dir_2\n"
-"                  ) * board_shadow;\n"
+"   if( g_debug_indices == 1 )\n"
+"   {\n"
+"      float rings = min( fract(distance(light_co_0.xyz,aWorldCo)),\n"
+"                      min( fract(distance(light_co_1.xyz,aWorldCo)),\n"
+"                           fract(distance(light_co_2.xyz,aWorldCo)) ) \n"
+"                        );\n"
+"               \n"
+"      return vec3(fract(light_indices.x * 0.125), fract(light_indices.y*0.125),\n"
+"                  fract(light_indices.z * 0.125 )) + (rings-0.5) * 0.25;\n"
+"   }\n"
+"\n"
+"   if( g_debug_complexity == 1 )\n"
+"   {\n"
+"      return vec3(1.0,0.0,0.0) * ( light_indices.w/3.0 );\n"
+"   }\n"
+"\n"
+"   if( light_indices.w >= 1 )\n"
+"   {\n"
+"      total_light += newlight_compute_spot\n"
+"                     ( \n"
+"                        wnormal, halfview,\n"
+"                        light_colour_0.rgb,\n"
+"                        light_co_0.xyz,\n"
+"                        light_dir_0\n"
+"                     ) * board_shadow \n"
+"                       * step( world.day_phase, light_colour_0.w );\n"
+"\n"
+"      if( light_indices.w >= 2 )\n"
+"      {\n"
+"         total_light += newlight_compute_spot\n"
+"                        ( \n"
+"                           wnormal, halfview,\n"
+"                           light_colour_1.rgb,\n"
+"                           light_co_1.xyz,\n"
+"                           light_dir_1\n"
+"                        ) * board_shadow\n"
+"                          * step( world.day_phase, light_colour_1.w );\n"
+"\n"
+"         if( light_indices.w >= 3 )\n"
+"         {\n"
+"            total_light += newlight_compute_spot\n"
+"                           ( \n"
+"                              wnormal, halfview,\n"
+"                              light_colour_2.rgb,\n"
+"                              light_co_2.xyz,\n"
+"                              light_dir_2\n"
+"                           ) * board_shadow\n"
+"                             * step( world.day_phase, light_colour_2.w );\n"
+"         }\n"
+"      }\n"
+"   }\n"
 "\n"
 "   vec3 fog_colour = scene_sky( -halfview, world );\n"
 "   \n"
index 028392d04379bf0e70740f7d92779ffa9786625e..097046fe397afbb628d7e7472c27d9a35d6caa04 100644 (file)
@@ -101,6 +101,9 @@ static struct vg_shader _shader_scene_vertex_blend = {
 "   int g_light_preview;\n"
 "   int g_shadow_samples;\n"
 "\n"
+"   int g_debug_indices;\n"
+"   int g_debug_complexity;\n"
+"\n"
 "   // g_time ?\n"
 "\n"
 "   //vec4 g_point_light_positions[32];\n"
@@ -441,35 +444,57 @@ static struct vg_shader _shader_scene_vertex_blend = {
 "   vec4 light_dir_1    = texelFetch( uLightsArray, light_indices.y*3+2 );\n"
 "   vec4 light_dir_2    = texelFetch( uLightsArray, light_indices.z*3+2 );\n"
 "\n"
-"   //return vec3(fract(distance(light_co_0.xyz,aWorldCo)),\n"
-"   //            fract(distance(light_co_1.xyz,aWorldCo)),\n"
-"   //            fract(distance(light_co_2.xyz,aWorldCo)));\n"
-"\n"
-"  // return vec3(fract(light_indices.x * 0.125), fract(light_indices.y*0.125),\n"
-"  //             fract(light_indices.z * 0.125 ));\n"
-"\n"
-"   total_light += newlight_compute_spot\n"
-"                  ( \n"
-"                     wnormal, halfview,\n"
-"                     light_colour_0.rgb,\n"
-"                     light_co_0.xyz,\n"
-"                     light_dir_0\n"
-"                  ) * board_shadow;\n"
-"\n"
-"   total_light += newlight_compute_spot\n"
-"                  ( \n"
-"                     wnormal, halfview,\n"
-"                     light_colour_1.rgb,\n"
-"                     light_co_1.xyz,\n"
-"                     light_dir_1\n"
-"                  ) * board_shadow;\n"
-"   total_light += newlight_compute_spot\n"
-"                  ( \n"
-"                     wnormal, halfview,\n"
-"                     light_colour_2.rgb,\n"
-"                     light_co_2.xyz,\n"
-"                     light_dir_2\n"
-"                  ) * board_shadow;\n"
+"   if( g_debug_indices == 1 )\n"
+"   {\n"
+"      float rings = min( fract(distance(light_co_0.xyz,aWorldCo)),\n"
+"                      min( fract(distance(light_co_1.xyz,aWorldCo)),\n"
+"                           fract(distance(light_co_2.xyz,aWorldCo)) ) \n"
+"                        );\n"
+"               \n"
+"      return vec3(fract(light_indices.x * 0.125), fract(light_indices.y*0.125),\n"
+"                  fract(light_indices.z * 0.125 )) + (rings-0.5) * 0.25;\n"
+"   }\n"
+"\n"
+"   if( g_debug_complexity == 1 )\n"
+"   {\n"
+"      return vec3(1.0,0.0,0.0) * ( light_indices.w/3.0 );\n"
+"   }\n"
+"\n"
+"   if( light_indices.w >= 1 )\n"
+"   {\n"
+"      total_light += newlight_compute_spot\n"
+"                     ( \n"
+"                        wnormal, halfview,\n"
+"                        light_colour_0.rgb,\n"
+"                        light_co_0.xyz,\n"
+"                        light_dir_0\n"
+"                     ) * board_shadow \n"
+"                       * step( world.day_phase, light_colour_0.w );\n"
+"\n"
+"      if( light_indices.w >= 2 )\n"
+"      {\n"
+"         total_light += newlight_compute_spot\n"
+"                        ( \n"
+"                           wnormal, halfview,\n"
+"                           light_colour_1.rgb,\n"
+"                           light_co_1.xyz,\n"
+"                           light_dir_1\n"
+"                        ) * board_shadow\n"
+"                          * step( world.day_phase, light_colour_1.w );\n"
+"\n"
+"         if( light_indices.w >= 3 )\n"
+"         {\n"
+"            total_light += newlight_compute_spot\n"
+"                           ( \n"
+"                              wnormal, halfview,\n"
+"                              light_colour_2.rgb,\n"
+"                              light_co_2.xyz,\n"
+"                              light_dir_2\n"
+"                           ) * board_shadow\n"
+"                             * step( world.day_phase, light_colour_2.w );\n"
+"         }\n"
+"      }\n"
+"   }\n"
 "\n"
 "   vec3 fog_colour = scene_sky( -halfview, world );\n"
 "   \n"
index a6fa804d8e9d25d861442d545b88fa619f42d2fd..e9e052b4798bb60d5ba5542edb92dc63ca3d5c29 100644 (file)
@@ -109,6 +109,9 @@ static struct vg_shader _shader_scene_water = {
 "   int g_light_preview;\n"
 "   int g_shadow_samples;\n"
 "\n"
+"   int g_debug_indices;\n"
+"   int g_debug_complexity;\n"
+"\n"
 "   // g_time ?\n"
 "\n"
 "   //vec4 g_point_light_positions[32];\n"
@@ -449,35 +452,57 @@ static struct vg_shader _shader_scene_water = {
 "   vec4 light_dir_1    = texelFetch( uLightsArray, light_indices.y*3+2 );\n"
 "   vec4 light_dir_2    = texelFetch( uLightsArray, light_indices.z*3+2 );\n"
 "\n"
-"   //return vec3(fract(distance(light_co_0.xyz,aWorldCo)),\n"
-"   //            fract(distance(light_co_1.xyz,aWorldCo)),\n"
-"   //            fract(distance(light_co_2.xyz,aWorldCo)));\n"
-"\n"
-"  // return vec3(fract(light_indices.x * 0.125), fract(light_indices.y*0.125),\n"
-"  //             fract(light_indices.z * 0.125 ));\n"
-"\n"
-"   total_light += newlight_compute_spot\n"
-"                  ( \n"
-"                     wnormal, halfview,\n"
-"                     light_colour_0.rgb,\n"
-"                     light_co_0.xyz,\n"
-"                     light_dir_0\n"
-"                  ) * board_shadow;\n"
-"\n"
-"   total_light += newlight_compute_spot\n"
-"                  ( \n"
-"                     wnormal, halfview,\n"
-"                     light_colour_1.rgb,\n"
-"                     light_co_1.xyz,\n"
-"                     light_dir_1\n"
-"                  ) * board_shadow;\n"
-"   total_light += newlight_compute_spot\n"
-"                  ( \n"
-"                     wnormal, halfview,\n"
-"                     light_colour_2.rgb,\n"
-"                     light_co_2.xyz,\n"
-"                     light_dir_2\n"
-"                  ) * board_shadow;\n"
+"   if( g_debug_indices == 1 )\n"
+"   {\n"
+"      float rings = min( fract(distance(light_co_0.xyz,aWorldCo)),\n"
+"                      min( fract(distance(light_co_1.xyz,aWorldCo)),\n"
+"                           fract(distance(light_co_2.xyz,aWorldCo)) ) \n"
+"                        );\n"
+"               \n"
+"      return vec3(fract(light_indices.x * 0.125), fract(light_indices.y*0.125),\n"
+"                  fract(light_indices.z * 0.125 )) + (rings-0.5) * 0.25;\n"
+"   }\n"
+"\n"
+"   if( g_debug_complexity == 1 )\n"
+"   {\n"
+"      return vec3(1.0,0.0,0.0) * ( light_indices.w/3.0 );\n"
+"   }\n"
+"\n"
+"   if( light_indices.w >= 1 )\n"
+"   {\n"
+"      total_light += newlight_compute_spot\n"
+"                     ( \n"
+"                        wnormal, halfview,\n"
+"                        light_colour_0.rgb,\n"
+"                        light_co_0.xyz,\n"
+"                        light_dir_0\n"
+"                     ) * board_shadow \n"
+"                       * step( world.day_phase, light_colour_0.w );\n"
+"\n"
+"      if( light_indices.w >= 2 )\n"
+"      {\n"
+"         total_light += newlight_compute_spot\n"
+"                        ( \n"
+"                           wnormal, halfview,\n"
+"                           light_colour_1.rgb,\n"
+"                           light_co_1.xyz,\n"
+"                           light_dir_1\n"
+"                        ) * board_shadow\n"
+"                          * step( world.day_phase, light_colour_1.w );\n"
+"\n"
+"         if( light_indices.w >= 3 )\n"
+"         {\n"
+"            total_light += newlight_compute_spot\n"
+"                           ( \n"
+"                              wnormal, halfview,\n"
+"                              light_colour_2.rgb,\n"
+"                              light_co_2.xyz,\n"
+"                              light_dir_2\n"
+"                           ) * board_shadow\n"
+"                             * step( world.day_phase, light_colour_2.w );\n"
+"         }\n"
+"      }\n"
+"   }\n"
 "\n"
 "   vec3 fog_colour = scene_sky( -halfview, world );\n"
 "   \n"
index 7708caca72c96090823b26f7687b3f6b2c2de06c..bab38cd07110035514c9cc33225dda8181a37741 100644 (file)
@@ -106,6 +106,9 @@ static struct vg_shader _shader_scene_water_fast = {
 "   int g_light_preview;\n"
 "   int g_shadow_samples;\n"
 "\n"
+"   int g_debug_indices;\n"
+"   int g_debug_complexity;\n"
+"\n"
 "   // g_time ?\n"
 "\n"
 "   //vec4 g_point_light_positions[32];\n"
@@ -446,35 +449,57 @@ static struct vg_shader _shader_scene_water_fast = {
 "   vec4 light_dir_1    = texelFetch( uLightsArray, light_indices.y*3+2 );\n"
 "   vec4 light_dir_2    = texelFetch( uLightsArray, light_indices.z*3+2 );\n"
 "\n"
-"   //return vec3(fract(distance(light_co_0.xyz,aWorldCo)),\n"
-"   //            fract(distance(light_co_1.xyz,aWorldCo)),\n"
-"   //            fract(distance(light_co_2.xyz,aWorldCo)));\n"
-"\n"
-"  // return vec3(fract(light_indices.x * 0.125), fract(light_indices.y*0.125),\n"
-"  //             fract(light_indices.z * 0.125 ));\n"
-"\n"
-"   total_light += newlight_compute_spot\n"
-"                  ( \n"
-"                     wnormal, halfview,\n"
-"                     light_colour_0.rgb,\n"
-"                     light_co_0.xyz,\n"
-"                     light_dir_0\n"
-"                  ) * board_shadow;\n"
-"\n"
-"   total_light += newlight_compute_spot\n"
-"                  ( \n"
-"                     wnormal, halfview,\n"
-"                     light_colour_1.rgb,\n"
-"                     light_co_1.xyz,\n"
-"                     light_dir_1\n"
-"                  ) * board_shadow;\n"
-"   total_light += newlight_compute_spot\n"
-"                  ( \n"
-"                     wnormal, halfview,\n"
-"                     light_colour_2.rgb,\n"
-"                     light_co_2.xyz,\n"
-"                     light_dir_2\n"
-"                  ) * board_shadow;\n"
+"   if( g_debug_indices == 1 )\n"
+"   {\n"
+"      float rings = min( fract(distance(light_co_0.xyz,aWorldCo)),\n"
+"                      min( fract(distance(light_co_1.xyz,aWorldCo)),\n"
+"                           fract(distance(light_co_2.xyz,aWorldCo)) ) \n"
+"                        );\n"
+"               \n"
+"      return vec3(fract(light_indices.x * 0.125), fract(light_indices.y*0.125),\n"
+"                  fract(light_indices.z * 0.125 )) + (rings-0.5) * 0.25;\n"
+"   }\n"
+"\n"
+"   if( g_debug_complexity == 1 )\n"
+"   {\n"
+"      return vec3(1.0,0.0,0.0) * ( light_indices.w/3.0 );\n"
+"   }\n"
+"\n"
+"   if( light_indices.w >= 1 )\n"
+"   {\n"
+"      total_light += newlight_compute_spot\n"
+"                     ( \n"
+"                        wnormal, halfview,\n"
+"                        light_colour_0.rgb,\n"
+"                        light_co_0.xyz,\n"
+"                        light_dir_0\n"
+"                     ) * board_shadow \n"
+"                       * step( world.day_phase, light_colour_0.w );\n"
+"\n"
+"      if( light_indices.w >= 2 )\n"
+"      {\n"
+"         total_light += newlight_compute_spot\n"
+"                        ( \n"
+"                           wnormal, halfview,\n"
+"                           light_colour_1.rgb,\n"
+"                           light_co_1.xyz,\n"
+"                           light_dir_1\n"
+"                        ) * board_shadow\n"
+"                          * step( world.day_phase, light_colour_1.w );\n"
+"\n"
+"         if( light_indices.w >= 3 )\n"
+"         {\n"
+"            total_light += newlight_compute_spot\n"
+"                           ( \n"
+"                              wnormal, halfview,\n"
+"                              light_colour_2.rgb,\n"
+"                              light_co_2.xyz,\n"
+"                              light_dir_2\n"
+"                           ) * board_shadow\n"
+"                             * step( world.day_phase, light_colour_2.w );\n"
+"         }\n"
+"      }\n"
+"   }\n"
 "\n"
 "   vec3 fog_colour = scene_sky( -halfview, world );\n"
 "   \n"
diff --git a/world.h b/world.h
index 3f806cb8714e00dbabf0d8564dede4a7b9acd43b..ef935968257fd422b9be0f7f592c332fcefbdb55 100644 (file)
--- a/world.h
+++ b/world.h
@@ -93,6 +93,9 @@ struct world_instance
       int g_light_preview;
       int g_shadow_samples;
 
+      int g_debug_indices;
+      int g_debug_complexity;
+
 #if 0
       v4f g_point_light_positions[32];
       v4f g_point_light_colours[32];
@@ -625,6 +628,8 @@ VG_STATIC void world_update( world_instance *world, v3f pos )
    g_time += vg.time_delta * (1.0/(k_day_length*60.0));
 
    world->ub_lighting.g_time = g_time;
+   world->ub_lighting.g_debug_indices = k_debug_light_indices;
+   world->ub_lighting.g_debug_complexity = k_debug_light_complexity;
 
    glBindBuffer( GL_UNIFORM_BUFFER, world->ubo_lighting );
    glBufferSubData( GL_UNIFORM_BUFFER, 0, 
@@ -734,7 +739,7 @@ VG_STATIC void world_update( world_instance *world, v3f pos )
                                                         0xff00ff00 );
    }
 
-   if( k_debug_light_index )
+   if( k_debug_light_indices )
    {
       for( int i=0; i<world->light_count; i++ )
       {
index b6c2f15db41125191eb1b871332a06b43b318500..026701a1bf89148d574543fe9c4120b4d70438ec 100644 (file)
@@ -450,7 +450,7 @@ VG_STATIC float colour_luminance( v3f v )
 }
 
 VG_STATIC float calc_light_influence( world_instance *world, v3f position, 
-                                      v3f normal, int light )
+                                      int light )
 {
    struct world_light *world_light = &world->lights[ light ];
    struct classtype_world_light *inf = world_light->inf;
@@ -462,16 +462,15 @@ VG_STATIC float calc_light_influence( world_instance *world, v3f position,
    float quadratic = v3_dot( light_delta, light_delta ),
          attenuation = 1.0f/( 1.0f + quadratic );
 
-   v3_normalize( light_delta );
-   //attenuation *= vg_maxf( 0.0, v3_dot( light_delta, normal ) );
-
    float quadratic_light = attenuation * colour_luminance( inf->colour );
 
-   if( inf->type == k_light_type_point )
+   if( (inf->type == k_light_type_point) ||
+       (inf->type == k_light_type_point_nighttime_only) )
    {
       return quadratic_light;
    }
-   else if( inf->type == k_light_type_spot )
+   else if( (inf->type == k_light_type_spot) ||
+            (inf->type == k_light_type_spot_nighttime_only) )
    {
       v3f dir;
       q_mulv( world_light->node->q, (v3f){0.0f,1.0f,0.0f}, dir );
@@ -494,31 +493,23 @@ VG_STATIC void world_scene_compute_light_clusters( world_instance *world,
       vert->lights[0] = 0;
       vert->lights[1] = 1;
       vert->lights[2] = 2;
-      vert->lights[3] = 3;
-
-      float influences[4] = { 0.0f, 0.0f, 0.0f, 0.0f };
-
-      v3f co, norm;
-      v3_copy( vert->co, co );
+      vert->lights[3] = 0;
 
-      norm[0] = vert->norm[0];
-      norm[1] = vert->norm[1];
-      norm[2] = vert->norm[2];
-
-      v3_muls( norm, 1.0f/127.0f, norm );
+      float influences[3] = { 0.0f, 0.0f, 0.0f };
+      const int N = vg_list_size( influences );
 
       for( int j=0; j<world->light_count; j ++ )
       {
-         float influence = calc_light_influence( world, co, norm, j );
+         float influence = calc_light_influence( world, vert->co, j );
 
-         int best_pos = 4;
+         int best_pos = N;
          for( int k=best_pos-1; k>=0; k -- )
             if( influence > influences[k] )
                best_pos = k;
 
-         if( best_pos < 4 )
+         if( best_pos < N )
          {
-            for( int k=3; k>best_pos; k -- )
+            for( int k=N-1; k>best_pos; k -- )
             {
                influences[k] = influences[k-1];
                vert->lights[k] = vert->lights[k-1];
@@ -528,6 +519,12 @@ VG_STATIC void world_scene_compute_light_clusters( world_instance *world,
             vert->lights[best_pos] = j;
          }
       }
+
+      for( int j=0; j<N; j++ )
+      {
+         if( influences[j] > 0.00000125f )
+            vert->lights[3] ++ ;
+      }
    }
 }
 
@@ -669,7 +666,17 @@ VG_STATIC void world_post_process( world_instance *world )
 
          /* colour  + night */
          v3_muls( inf->colour, inf->colour[3] * 2.0f, light_dst[i*3+0] );
-         light_dst[i*3+0][3] = 1.0f;
+         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] );