_.type = 1
_.angle = math.cos(data.spot_size*0.5)
#}
+
+ if data.cv_data.bp0:
+ _.type += 2
#}
@staticmethod
for obj in collection.all_objects:
#{
- if obj.parent: continue
+ #if obj.parent: continue
def _extend( p, n, d ):
#{
#{
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'
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="" )
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'
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():
#{
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')
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;
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 );
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;
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 );
int g_light_preview;
int g_shadow_samples;
+ int g_debug_indices;
+ int g_debug_complexity;
+
// g_time ?
//vec4 g_point_light_positions[32];
" 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"
" 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"
" 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"
" 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"
" 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"
" 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"
" 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"
" 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"
" 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"
" 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"
" 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"
" 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"
" 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"
" 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"
" 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"
" 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"
" 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"
" 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"
" 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"
" 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"
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];
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,
0xff00ff00 );
}
- if( k_debug_light_index )
+ if( k_debug_light_indices )
{
for( int i=0; i<world->light_count; i++ )
{
}
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;
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 );
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];
vert->lights[best_pos] = j;
}
}
+
+ for( int j=0; j<N; j++ )
+ {
+ if( influences[j] > 0.00000125f )
+ vert->lights[3] ++ ;
+ }
}
}
/* 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] );