Browse Source

Changed SCsub for shaders to find shaders automatically and create dependencies with include files

Bastiaan Olij 4 years ago
parent
commit
7f63c9e7c9
1 changed files with 12 additions and 43 deletions
  1. 12 43
      servers/rendering/renderer_rd/shaders/SCsub

+ 12 - 43
servers/rendering/renderer_rd/shaders/SCsub

@@ -3,46 +3,15 @@
 Import("env")
 
 if "RD_GLSL" in env["BUILDERS"]:
-    env.RD_GLSL("canvas.glsl")
-    env.RD_GLSL("canvas_occlusion.glsl")
-    env.RD_GLSL("canvas_sdf.glsl")
-    env.RD_GLSL("copy.glsl")
-    env.RD_GLSL("copy_to_fb.glsl")
-    env.RD_GLSL("cubemap_roughness.glsl")
-    env.RD_GLSL("cubemap_downsampler.glsl")
-    env.RD_GLSL("cubemap_filter.glsl")
-    env.RD_GLSL("scene_forward_clustered.glsl")
-    env.RD_GLSL("sky.glsl")
-    env.RD_GLSL("tonemap.glsl")
-    env.RD_GLSL("cube_to_dp.glsl")
-    env.RD_GLSL("giprobe.glsl")
-    env.RD_GLSL("giprobe_debug.glsl")
-    env.RD_GLSL("giprobe_sdf.glsl")
-    env.RD_GLSL("luminance_reduce.glsl")
-    env.RD_GLSL("bokeh_dof.glsl")
-    env.RD_GLSL("ssao.glsl")
-    env.RD_GLSL("ssao_downsample.glsl")
-    env.RD_GLSL("ssao_importance_map.glsl")
-    env.RD_GLSL("ssao_blur.glsl")
-    env.RD_GLSL("ssao_interleave.glsl")
-    env.RD_GLSL("roughness_limiter.glsl")
-    env.RD_GLSL("screen_space_reflection.glsl")
-    env.RD_GLSL("screen_space_reflection_filter.glsl")
-    env.RD_GLSL("screen_space_reflection_scale.glsl")
-    env.RD_GLSL("subsurface_scattering.glsl")
-    env.RD_GLSL("specular_merge.glsl")
-    env.RD_GLSL("gi.glsl")
-    env.RD_GLSL("resolve.glsl")
-    env.RD_GLSL("sdfgi_preprocess.glsl")
-    env.RD_GLSL("sdfgi_integrate.glsl")
-    env.RD_GLSL("sdfgi_direct_light.glsl")
-    env.RD_GLSL("sdfgi_debug.glsl")
-    env.RD_GLSL("sdfgi_debug_probes.glsl")
-    env.RD_GLSL("volumetric_fog.glsl")
-    env.RD_GLSL("particles.glsl")
-    env.RD_GLSL("particles_copy.glsl")
-    env.RD_GLSL("sort.glsl")
-    env.RD_GLSL("skeleton.glsl")
-    env.RD_GLSL("cluster_render.glsl")
-    env.RD_GLSL("cluster_store.glsl")
-    env.RD_GLSL("cluster_debug.glsl")
+    # find all include files
+    gl_include_files = [str(f) for f in Glob("*_inc.glsl")]
+
+    # find all shader code(all glsl files excluding our include files)
+    glsl_files = [str(f) for f in Glob("*.glsl") if str(f) not in gl_include_files]
+
+    # make sure we recompile shaders if include files change
+    env.Depends([f + ".gen.h" for f in glsl_files], gl_include_files)
+
+    # compile shaders
+    for glsl_file in glsl_files:
+        env.RD_GLSL(glsl_file)