Changeset View
Changeset View
Standalone View
Standalone View
source/blender/draw/engines/eevee/eevee_shaders.cc
| Show All 12 Lines | |||||
| #include "BLI_dynstr.h" | #include "BLI_dynstr.h" | ||||
| #include "BLI_string_utils.h" | #include "BLI_string_utils.h" | ||||
| #include "DNA_world_types.h" | #include "DNA_world_types.h" | ||||
| #include "MEM_guardedalloc.h" | #include "MEM_guardedalloc.h" | ||||
| #include "GPU_capabilities.h" | #include "GPU_capabilities.h" | ||||
| #include "GPU_context.h" | |||||
| #include "GPU_material.h" | #include "GPU_material.h" | ||||
| #include "GPU_shader.h" | #include "GPU_shader.h" | ||||
| #include "NOD_shader.h" | #include "NOD_shader.h" | ||||
| #include "eevee_engine.h" | #include "eevee_engine.h" | ||||
| #include "eevee_private.h" | #include "eevee_private.h" | ||||
| static const char *filter_defines = | |||||
| #if defined(IRRADIANCE_SH_L2) | |||||
| "#define IRRADIANCE_SH_L2\n"; | |||||
| #elif defined(IRRADIANCE_HL2) | |||||
| "#define IRRADIANCE_HL2\n"; | |||||
| #endif | |||||
| static struct { | static struct { | ||||
| /* Lookdev */ | /* Lookdev */ | ||||
| struct GPUShader *studiolight_probe_sh; | struct GPUShader *studiolight_probe_sh; | ||||
| struct GPUShader *studiolight_background_sh; | struct GPUShader *studiolight_background_sh; | ||||
| /* Probes */ | /* Probes */ | ||||
| struct GPUShader *probe_grid_display_sh; | struct GPUShader *probe_grid_display_sh; | ||||
| struct GPUShader *probe_cube_display_sh; | struct GPUShader *probe_cube_display_sh; | ||||
| ▲ Show 20 Lines • Show All 116 Lines • ▼ Show 20 Lines | static struct { | ||||
| } surface; | } surface; | ||||
| struct { | struct { | ||||
| bNodeTree *ntree; | bNodeTree *ntree; | ||||
| bNodeSocketValueRGBA *color_socket; | bNodeSocketValueRGBA *color_socket; | ||||
| } world; | } world; | ||||
| } e_data = {nullptr}; /* Engine data */ | } e_data = {nullptr}; /* Engine data */ | ||||
| extern "C" char datatoc_engine_eevee_legacy_shared_h[]; | |||||
| extern "C" char datatoc_common_hair_lib_glsl[]; | extern "C" char datatoc_common_hair_lib_glsl[]; | ||||
| extern "C" char datatoc_common_math_lib_glsl[]; | extern "C" char datatoc_common_math_lib_glsl[]; | ||||
| extern "C" char datatoc_common_math_geom_lib_glsl[]; | extern "C" char datatoc_common_math_geom_lib_glsl[]; | ||||
| extern "C" char datatoc_common_view_lib_glsl[]; | extern "C" char datatoc_common_view_lib_glsl[]; | ||||
| extern "C" char datatoc_gpu_shader_codegen_lib_glsl[]; | extern "C" char datatoc_gpu_shader_codegen_lib_glsl[]; | ||||
| extern "C" char datatoc_ambient_occlusion_lib_glsl[]; | extern "C" char datatoc_ambient_occlusion_lib_glsl[]; | ||||
| extern "C" char datatoc_background_vert_glsl[]; | |||||
| extern "C" char datatoc_bsdf_common_lib_glsl[]; | extern "C" char datatoc_bsdf_common_lib_glsl[]; | ||||
| extern "C" char datatoc_bsdf_lut_frag_glsl[]; | |||||
| extern "C" char datatoc_bsdf_sampling_lib_glsl[]; | extern "C" char datatoc_bsdf_sampling_lib_glsl[]; | ||||
| extern "C" char datatoc_btdf_lut_frag_glsl[]; | |||||
| extern "C" char datatoc_closure_type_lib_glsl[]; | extern "C" char datatoc_closure_type_lib_glsl[]; | ||||
| extern "C" char datatoc_closure_eval_volume_lib_glsl[]; | extern "C" char datatoc_closure_eval_volume_lib_glsl[]; | ||||
| extern "C" char datatoc_common_uniforms_lib_glsl[]; | extern "C" char datatoc_common_uniforms_lib_glsl[]; | ||||
| extern "C" char datatoc_common_utiltex_lib_glsl[]; | extern "C" char datatoc_common_utiltex_lib_glsl[]; | ||||
| extern "C" char datatoc_cryptomatte_lib_glsl[]; | |||||
| extern "C" char datatoc_cryptomatte_frag_glsl[]; | |||||
| extern "C" char datatoc_cryptomatte_vert_glsl[]; | |||||
| extern "C" char datatoc_cubemap_lib_glsl[]; | extern "C" char datatoc_cubemap_lib_glsl[]; | ||||
| extern "C" char datatoc_default_frag_glsl[]; | |||||
| extern "C" char datatoc_lookdev_world_frag_glsl[]; | |||||
| extern "C" char datatoc_effect_bloom_frag_glsl[]; | |||||
| extern "C" char datatoc_effect_dof_bokeh_frag_glsl[]; | |||||
| extern "C" char datatoc_effect_dof_dilate_tiles_frag_glsl[]; | |||||
| extern "C" char datatoc_effect_dof_downsample_frag_glsl[]; | |||||
| extern "C" char datatoc_effect_dof_filter_frag_glsl[]; | |||||
| extern "C" char datatoc_effect_dof_flatten_tiles_frag_glsl[]; | |||||
| extern "C" char datatoc_effect_dof_gather_frag_glsl[]; | |||||
| extern "C" char datatoc_effect_dof_lib_glsl[]; | extern "C" char datatoc_effect_dof_lib_glsl[]; | ||||
| extern "C" char datatoc_effect_dof_reduce_frag_glsl[]; | |||||
| extern "C" char datatoc_effect_dof_resolve_frag_glsl[]; | |||||
| extern "C" char datatoc_effect_dof_scatter_frag_glsl[]; | |||||
| extern "C" char datatoc_effect_dof_scatter_vert_glsl[]; | |||||
| extern "C" char datatoc_effect_dof_setup_frag_glsl[]; | |||||
| extern "C" char datatoc_effect_downsample_cube_frag_glsl[]; | |||||
| extern "C" char datatoc_effect_downsample_frag_glsl[]; | |||||
| extern "C" char datatoc_effect_gtao_frag_glsl[]; | |||||
| extern "C" char datatoc_effect_minmaxz_frag_glsl[]; | |||||
| extern "C" char datatoc_effect_mist_frag_glsl[]; | |||||
| extern "C" char datatoc_effect_motion_blur_frag_glsl[]; | |||||
| extern "C" char datatoc_effect_reflection_lib_glsl[]; | extern "C" char datatoc_effect_reflection_lib_glsl[]; | ||||
| extern "C" char datatoc_effect_reflection_resolve_frag_glsl[]; | |||||
| extern "C" char datatoc_effect_reflection_trace_frag_glsl[]; | |||||
| extern "C" char datatoc_effect_subsurface_frag_glsl[]; | |||||
| extern "C" char datatoc_effect_temporal_aa_glsl[]; | |||||
| extern "C" char datatoc_effect_translucency_frag_glsl[]; | |||||
| extern "C" char datatoc_effect_velocity_resolve_frag_glsl[]; | |||||
| extern "C" char datatoc_effect_velocity_tile_frag_glsl[]; | |||||
| extern "C" char datatoc_irradiance_lib_glsl[]; | extern "C" char datatoc_irradiance_lib_glsl[]; | ||||
| extern "C" char datatoc_lightprobe_cube_display_frag_glsl[]; | |||||
| extern "C" char datatoc_lightprobe_cube_display_vert_glsl[]; | |||||
| extern "C" char datatoc_lightprobe_filter_diffuse_frag_glsl[]; | |||||
| extern "C" char datatoc_lightprobe_filter_glossy_frag_glsl[]; | |||||
| extern "C" char datatoc_lightprobe_filter_visibility_frag_glsl[]; | |||||
| extern "C" char datatoc_lightprobe_geom_glsl[]; | |||||
| extern "C" char datatoc_lightprobe_grid_display_frag_glsl[]; | |||||
| extern "C" char datatoc_lightprobe_grid_display_vert_glsl[]; | |||||
| extern "C" char datatoc_lightprobe_grid_fill_frag_glsl[]; | |||||
| extern "C" char datatoc_lightprobe_lib_glsl[]; | extern "C" char datatoc_lightprobe_lib_glsl[]; | ||||
| extern "C" char datatoc_lightprobe_planar_display_frag_glsl[]; | |||||
| extern "C" char datatoc_lightprobe_planar_display_vert_glsl[]; | |||||
| extern "C" char datatoc_lightprobe_planar_downsample_frag_glsl[]; | |||||
| extern "C" char datatoc_lightprobe_planar_downsample_geom_glsl[]; | |||||
| extern "C" char datatoc_lightprobe_planar_downsample_vert_glsl[]; | |||||
| extern "C" char datatoc_lightprobe_vert_glsl[]; | |||||
| extern "C" char datatoc_lights_lib_glsl[]; | extern "C" char datatoc_lights_lib_glsl[]; | ||||
| extern "C" char datatoc_closure_eval_lib_glsl[]; | extern "C" char datatoc_closure_eval_lib_glsl[]; | ||||
| extern "C" char datatoc_closure_eval_surface_lib_glsl[]; | extern "C" char datatoc_closure_eval_surface_lib_glsl[]; | ||||
| extern "C" char datatoc_closure_eval_diffuse_lib_glsl[]; | extern "C" char datatoc_closure_eval_diffuse_lib_glsl[]; | ||||
| extern "C" char datatoc_closure_eval_glossy_lib_glsl[]; | extern "C" char datatoc_closure_eval_glossy_lib_glsl[]; | ||||
| extern "C" char datatoc_closure_eval_refraction_lib_glsl[]; | extern "C" char datatoc_closure_eval_refraction_lib_glsl[]; | ||||
| extern "C" char datatoc_closure_eval_translucent_lib_glsl[]; | extern "C" char datatoc_closure_eval_translucent_lib_glsl[]; | ||||
| extern "C" char datatoc_ltc_lib_glsl[]; | extern "C" char datatoc_ltc_lib_glsl[]; | ||||
| extern "C" char datatoc_object_motion_frag_glsl[]; | |||||
| extern "C" char datatoc_object_motion_vert_glsl[]; | |||||
| extern "C" char datatoc_octahedron_lib_glsl[]; | extern "C" char datatoc_octahedron_lib_glsl[]; | ||||
| extern "C" char datatoc_prepass_frag_glsl[]; | extern "C" char datatoc_prepass_frag_glsl[]; | ||||
| extern "C" char datatoc_random_lib_glsl[]; | extern "C" char datatoc_random_lib_glsl[]; | ||||
| extern "C" char datatoc_raytrace_lib_glsl[]; | extern "C" char datatoc_raytrace_lib_glsl[]; | ||||
| extern "C" char datatoc_renderpass_lib_glsl[]; | extern "C" char datatoc_renderpass_lib_glsl[]; | ||||
| extern "C" char datatoc_renderpass_postprocess_frag_glsl[]; | |||||
| extern "C" char datatoc_shadow_accum_frag_glsl[]; | |||||
| extern "C" char datatoc_shadow_frag_glsl[]; | |||||
| extern "C" char datatoc_shadow_vert_glsl[]; | |||||
| extern "C" char datatoc_ssr_lib_glsl[]; | extern "C" char datatoc_ssr_lib_glsl[]; | ||||
| extern "C" char datatoc_surface_frag_glsl[]; | extern "C" char datatoc_surface_frag_glsl[]; | ||||
| extern "C" char datatoc_surface_geom_glsl[]; | extern "C" char datatoc_surface_geom_glsl[]; | ||||
| extern "C" char datatoc_surface_lib_glsl[]; | extern "C" char datatoc_surface_lib_glsl[]; | ||||
| extern "C" char datatoc_surface_vert_glsl[]; | extern "C" char datatoc_surface_vert_glsl[]; | ||||
| extern "C" char datatoc_update_noise_frag_glsl[]; | |||||
| extern "C" char datatoc_volumetric_accum_frag_glsl[]; | |||||
| extern "C" char datatoc_volumetric_frag_glsl[]; | extern "C" char datatoc_volumetric_frag_glsl[]; | ||||
| extern "C" char datatoc_volumetric_geom_glsl[]; | extern "C" char datatoc_volumetric_geom_glsl[]; | ||||
| extern "C" char datatoc_volumetric_integration_frag_glsl[]; | |||||
| extern "C" char datatoc_volumetric_lib_glsl[]; | extern "C" char datatoc_volumetric_lib_glsl[]; | ||||
| extern "C" char datatoc_volumetric_resolve_frag_glsl[]; | |||||
| extern "C" char datatoc_volumetric_scatter_frag_glsl[]; | |||||
| extern "C" char datatoc_volumetric_vert_glsl[]; | extern "C" char datatoc_volumetric_vert_glsl[]; | ||||
| extern "C" char datatoc_world_vert_glsl[]; | extern "C" char datatoc_world_vert_glsl[]; | ||||
| /* *********** FUNCTIONS *********** */ | /* *********** FUNCTIONS *********** */ | ||||
| static void eevee_shader_library_ensure(void) | static void eevee_shader_library_ensure(void) | ||||
| { | { | ||||
| if (e_data.lib == nullptr) { | if (e_data.lib == nullptr) { | ||||
| e_data.lib = DRW_shader_library_create(); | e_data.lib = DRW_shader_library_create(); | ||||
| /* NOTE: These need to be ordered by dependencies. */ | /* NOTE: These need to be ordered by dependencies. */ | ||||
| DRW_SHADER_LIB_ADD_SHARED(e_data.lib, engine_eevee_legacy_shared); | |||||
| DRW_SHADER_LIB_ADD(e_data.lib, common_math_lib); | DRW_SHADER_LIB_ADD(e_data.lib, common_math_lib); | ||||
| DRW_SHADER_LIB_ADD(e_data.lib, common_math_geom_lib); | DRW_SHADER_LIB_ADD(e_data.lib, common_math_geom_lib); | ||||
| DRW_SHADER_LIB_ADD(e_data.lib, common_hair_lib); | DRW_SHADER_LIB_ADD(e_data.lib, common_hair_lib); | ||||
| DRW_SHADER_LIB_ADD(e_data.lib, common_view_lib); | DRW_SHADER_LIB_ADD(e_data.lib, common_view_lib); | ||||
| DRW_SHADER_LIB_ADD(e_data.lib, common_uniforms_lib); | DRW_SHADER_LIB_ADD(e_data.lib, common_uniforms_lib); | ||||
| DRW_SHADER_LIB_ADD(e_data.lib, gpu_shader_codegen_lib); | DRW_SHADER_LIB_ADD(e_data.lib, gpu_shader_codegen_lib); | ||||
| DRW_SHADER_LIB_ADD(e_data.lib, random_lib); | DRW_SHADER_LIB_ADD(e_data.lib, random_lib); | ||||
| DRW_SHADER_LIB_ADD(e_data.lib, renderpass_lib); | DRW_SHADER_LIB_ADD(e_data.lib, renderpass_lib); | ||||
| Show All 16 Lines | if (e_data.lib == nullptr) { | ||||
| DRW_SHADER_LIB_ADD(e_data.lib, closure_type_lib); | DRW_SHADER_LIB_ADD(e_data.lib, closure_type_lib); | ||||
| DRW_SHADER_LIB_ADD(e_data.lib, closure_eval_lib); | DRW_SHADER_LIB_ADD(e_data.lib, closure_eval_lib); | ||||
| DRW_SHADER_LIB_ADD(e_data.lib, closure_eval_diffuse_lib); | DRW_SHADER_LIB_ADD(e_data.lib, closure_eval_diffuse_lib); | ||||
| DRW_SHADER_LIB_ADD(e_data.lib, closure_eval_glossy_lib); | DRW_SHADER_LIB_ADD(e_data.lib, closure_eval_glossy_lib); | ||||
| DRW_SHADER_LIB_ADD(e_data.lib, closure_eval_translucent_lib); | DRW_SHADER_LIB_ADD(e_data.lib, closure_eval_translucent_lib); | ||||
| DRW_SHADER_LIB_ADD(e_data.lib, closure_eval_refraction_lib); | DRW_SHADER_LIB_ADD(e_data.lib, closure_eval_refraction_lib); | ||||
| DRW_SHADER_LIB_ADD(e_data.lib, closure_eval_surface_lib); | DRW_SHADER_LIB_ADD(e_data.lib, closure_eval_surface_lib); | ||||
| DRW_SHADER_LIB_ADD(e_data.lib, closure_eval_volume_lib); | DRW_SHADER_LIB_ADD(e_data.lib, closure_eval_volume_lib); | ||||
| DRW_SHADER_LIB_ADD(e_data.lib, cryptomatte_lib); | |||||
| DRW_SHADER_LIB_ADD(e_data.lib, surface_vert); | DRW_SHADER_LIB_ADD(e_data.lib, surface_vert); | ||||
| e_data.surface_lit_frag = DRW_shader_library_create_shader_string(e_data.lib, | e_data.surface_lit_frag = DRW_shader_library_create_shader_string(e_data.lib, | ||||
| datatoc_surface_frag_glsl); | datatoc_surface_frag_glsl); | ||||
| e_data.surface_prepass_frag = DRW_shader_library_create_shader_string( | e_data.surface_prepass_frag = DRW_shader_library_create_shader_string( | ||||
| e_data.lib, datatoc_prepass_frag_glsl); | e_data.lib, datatoc_prepass_frag_glsl); | ||||
| e_data.surface_geom_barycentric = DRW_shader_library_create_shader_string( | e_data.surface_geom_barycentric = DRW_shader_library_create_shader_string( | ||||
| e_data.lib, datatoc_surface_geom_glsl); | e_data.lib, datatoc_surface_geom_glsl); | ||||
| } | } | ||||
| } | } | ||||
| void EEVEE_shaders_material_shaders_init(void) | void EEVEE_shaders_material_shaders_init(void) | ||||
| { | { | ||||
| eevee_shader_extra_init(); | |||||
| eevee_shader_library_ensure(); | eevee_shader_library_ensure(); | ||||
| } | } | ||||
| DRWShaderLibrary *EEVEE_shader_lib_get(void) | DRWShaderLibrary *EEVEE_shader_lib_get(void) | ||||
| { | { | ||||
| eevee_shader_library_ensure(); | eevee_shader_library_ensure(); | ||||
| return e_data.lib; | return e_data.lib; | ||||
| } | } | ||||
| GPUShader *EEVEE_shaders_probe_filter_glossy_sh_get(void) | GPUShader *EEVEE_shaders_probe_filter_glossy_sh_get(void) | ||||
| { | { | ||||
| if (e_data.probe_filter_glossy_sh == nullptr) { | if (e_data.probe_filter_glossy_sh == NULL) { | ||||
| e_data.probe_filter_glossy_sh = DRW_shader_create_with_shaderlib( | e_data.probe_filter_glossy_sh = DRW_shader_create_from_info_name( | ||||
| datatoc_lightprobe_vert_glsl, | "eevee_legacy_probe_filter_glossy"); | ||||
| datatoc_lightprobe_geom_glsl, | |||||
| datatoc_lightprobe_filter_glossy_frag_glsl, | |||||
| e_data.lib, | |||||
| filter_defines); | |||||
| } | } | ||||
| return e_data.probe_filter_glossy_sh; | return e_data.probe_filter_glossy_sh; | ||||
| } | } | ||||
| GPUShader *EEVEE_shaders_probe_filter_diffuse_sh_get(void) | GPUShader *EEVEE_shaders_probe_filter_diffuse_sh_get(void) | ||||
| { | { | ||||
| if (e_data.probe_filter_diffuse_sh == nullptr) { | if (e_data.probe_filter_diffuse_sh == NULL) { | ||||
| e_data.probe_filter_diffuse_sh = DRW_shader_create_fullscreen_with_shaderlib( | const char *create_info_name = | ||||
| datatoc_lightprobe_filter_diffuse_frag_glsl, e_data.lib, filter_defines); | #if defined(IRRADIANCE_SH_L2) | ||||
| "eevee_legacy_probe_filter_diffuse_sh_l2"; | |||||
| #elif defined(IRRADIANCE_HL2) | |||||
| "eevee_legacy_probe_filter_diffuse_hl2"; | |||||
| #else | |||||
| nullptr; | |||||
| /* Should not reach this case. Either mode above should be defined. */ | |||||
| BLI_assert_unreachable(); | |||||
| #endif | |||||
| e_data.probe_filter_diffuse_sh = DRW_shader_create_from_info_name(create_info_name); | |||||
| } | } | ||||
| return e_data.probe_filter_diffuse_sh; | return e_data.probe_filter_diffuse_sh; | ||||
| } | } | ||||
| GPUShader *EEVEE_shaders_probe_filter_visibility_sh_get(void) | GPUShader *EEVEE_shaders_probe_filter_visibility_sh_get(void) | ||||
| { | { | ||||
| if (e_data.probe_filter_visibility_sh == nullptr) { | if (e_data.probe_filter_visibility_sh == NULL) { | ||||
| e_data.probe_filter_visibility_sh = DRW_shader_create_fullscreen_with_shaderlib( | e_data.probe_filter_visibility_sh = DRW_shader_create_from_info_name( | ||||
| datatoc_lightprobe_filter_visibility_frag_glsl, e_data.lib, filter_defines); | "eevee_legacy_probe_filter_visiblity"); | ||||
| } | } | ||||
| return e_data.probe_filter_visibility_sh; | return e_data.probe_filter_visibility_sh; | ||||
| } | } | ||||
| GPUShader *EEVEE_shaders_probe_grid_fill_sh_get(void) | GPUShader *EEVEE_shaders_probe_grid_fill_sh_get(void) | ||||
| { | { | ||||
| if (e_data.probe_grid_fill_sh == nullptr) { | if (e_data.probe_grid_fill_sh == NULL) { | ||||
| e_data.probe_grid_fill_sh = DRW_shader_create_fullscreen_with_shaderlib( | const char *create_info_name = | ||||
| datatoc_lightprobe_grid_fill_frag_glsl, e_data.lib, filter_defines); | #if defined(IRRADIANCE_SH_L2) | ||||
| "eevee_legacy_probe_grid_fill_sh_l2"; | |||||
| #elif defined(IRRADIANCE_HL2) | |||||
| "eevee_legacy_probe_grid_fill_hl2"; | |||||
| #else | |||||
| nullptr; | |||||
| /* Should not reach this case. `data_size` will not be defined otherwise. */ | |||||
| BLI_assert_unreachable(); | |||||
| #endif | |||||
| e_data.probe_grid_fill_sh = DRW_shader_create_from_info_name(create_info_name); | |||||
| } | } | ||||
| return e_data.probe_grid_fill_sh; | return e_data.probe_grid_fill_sh; | ||||
| } | } | ||||
| GPUShader *EEVEE_shaders_probe_planar_downsample_sh_get(void) | GPUShader *EEVEE_shaders_probe_planar_downsample_sh_get(void) | ||||
| { | { | ||||
| if (e_data.probe_planar_downsample_sh == nullptr) { | if (e_data.probe_planar_downsample_sh == NULL) { | ||||
| e_data.probe_planar_downsample_sh = DRW_shader_create_with_shaderlib( | e_data.probe_planar_downsample_sh = DRW_shader_create_from_info_name( | ||||
| datatoc_lightprobe_planar_downsample_vert_glsl, | "eevee_legacy_lightprobe_planar_downsample"); | ||||
| datatoc_lightprobe_planar_downsample_geom_glsl, | |||||
| datatoc_lightprobe_planar_downsample_frag_glsl, | |||||
| e_data.lib, | |||||
| nullptr); | |||||
| } | } | ||||
| return e_data.probe_planar_downsample_sh; | return e_data.probe_planar_downsample_sh; | ||||
| } | } | ||||
| GPUShader *EEVEE_shaders_studiolight_probe_sh_get(void) | GPUShader *EEVEE_shaders_studiolight_probe_sh_get(void) | ||||
| { | { | ||||
| if (e_data.studiolight_probe_sh == nullptr) { | if (e_data.studiolight_probe_sh == NULL) { | ||||
| e_data.studiolight_probe_sh = DRW_shader_create_with_shaderlib(datatoc_background_vert_glsl, | e_data.studiolight_probe_sh = DRW_shader_create_from_info_name( | ||||
| nullptr, | "eevee_legacy_studiolight_probe"); | ||||
| datatoc_lookdev_world_frag_glsl, | |||||
| e_data.lib, | |||||
| SHADER_DEFINES); | |||||
| } | } | ||||
| return e_data.studiolight_probe_sh; | return e_data.studiolight_probe_sh; | ||||
| } | } | ||||
| GPUShader *EEVEE_shaders_studiolight_background_sh_get(void) | GPUShader *EEVEE_shaders_studiolight_background_sh_get(void) | ||||
| { | { | ||||
| if (e_data.studiolight_background_sh == nullptr) { | if (e_data.studiolight_background_sh == NULL) { | ||||
| e_data.studiolight_background_sh = DRW_shader_create_with_shaderlib( | e_data.studiolight_background_sh = DRW_shader_create_from_info_name( | ||||
| datatoc_background_vert_glsl, | "eevee_legacy_studiolight_background"); | ||||
| nullptr, | |||||
| datatoc_lookdev_world_frag_glsl, | |||||
| e_data.lib, | |||||
| "#define LOOKDEV_BG\n" SHADER_DEFINES); | |||||
| } | } | ||||
| return e_data.studiolight_background_sh; | return e_data.studiolight_background_sh; | ||||
| } | } | ||||
| GPUShader *EEVEE_shaders_probe_cube_display_sh_get(void) | GPUShader *EEVEE_shaders_probe_cube_display_sh_get(void) | ||||
| { | { | ||||
| if (e_data.probe_cube_display_sh == nullptr) { | if (e_data.probe_cube_display_sh == NULL) { | ||||
| e_data.probe_cube_display_sh = DRW_shader_create_with_shaderlib( | e_data.probe_cube_display_sh = DRW_shader_create_from_info_name( | ||||
| datatoc_lightprobe_cube_display_vert_glsl, | "eevee_legacy_lightprobe_cube_display"); | ||||
| nullptr, | |||||
| datatoc_lightprobe_cube_display_frag_glsl, | |||||
| e_data.lib, | |||||
| SHADER_DEFINES); | |||||
| } | } | ||||
| return e_data.probe_cube_display_sh; | return e_data.probe_cube_display_sh; | ||||
| } | } | ||||
| GPUShader *EEVEE_shaders_probe_grid_display_sh_get(void) | GPUShader *EEVEE_shaders_probe_grid_display_sh_get(void) | ||||
| { | { | ||||
| if (e_data.probe_grid_display_sh == nullptr) { | if (e_data.probe_grid_display_sh == NULL) { | ||||
| e_data.probe_grid_display_sh = DRW_shader_create_with_shaderlib( | const char *probe_display_grid_info_name = NULL; | ||||
| datatoc_lightprobe_grid_display_vert_glsl, | #if defined(IRRADIANCE_SH_L2) | ||||
| nullptr, | probe_display_grid_info_name = "eevee_legacy_lightprobe_grid_display_common_sh_l2"; | ||||
| datatoc_lightprobe_grid_display_frag_glsl, | #elif defined(IRRADIANCE_HL2) | ||||
| e_data.lib, | probe_display_grid_info_name = "eevee_legacy_lightprobe_grid_display_common_hl2"; | ||||
| filter_defines); | #endif | ||||
| BLI_assert(probe_display_grid_info_name != NULL); | |||||
| e_data.probe_grid_display_sh = DRW_shader_create_from_info_name(probe_display_grid_info_name); | |||||
| } | } | ||||
| return e_data.probe_grid_display_sh; | return e_data.probe_grid_display_sh; | ||||
| } | } | ||||
| GPUShader *EEVEE_shaders_probe_planar_display_sh_get(void) | GPUShader *EEVEE_shaders_probe_planar_display_sh_get(void) | ||||
| { | { | ||||
| if (e_data.probe_planar_display_sh == nullptr) { | if (e_data.probe_planar_display_sh == NULL) { | ||||
| e_data.probe_planar_display_sh = DRW_shader_create_with_shaderlib( | e_data.probe_planar_display_sh = DRW_shader_create_from_info_name( | ||||
| datatoc_lightprobe_planar_display_vert_glsl, | "eevee_legacy_probe_planar_display"); | ||||
| nullptr, | |||||
| datatoc_lightprobe_planar_display_frag_glsl, | |||||
| e_data.lib, | |||||
| nullptr); | |||||
| } | } | ||||
| return e_data.probe_planar_display_sh; | return e_data.probe_planar_display_sh; | ||||
| } | } | ||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /** \name Down-sampling | /** \name Down-sampling | ||||
| * \{ */ | * \{ */ | ||||
| GPUShader *EEVEE_shaders_effect_color_copy_sh_get(void) | GPUShader *EEVEE_shaders_effect_color_copy_sh_get(void) | ||||
| { | { | ||||
| if (e_data.color_copy_sh == nullptr) { | if (e_data.color_copy_sh == NULL) { | ||||
| e_data.color_copy_sh = DRW_shader_create_fullscreen_with_shaderlib( | e_data.color_copy_sh = DRW_shader_create_from_info_name("eevee_legacy_color_copy"); | ||||
| datatoc_effect_downsample_frag_glsl, e_data.lib, "#define COPY_SRC\n"); | |||||
| } | } | ||||
| return e_data.color_copy_sh; | return e_data.color_copy_sh; | ||||
| } | } | ||||
| GPUShader *EEVEE_shaders_effect_downsample_sh_get(void) | GPUShader *EEVEE_shaders_effect_downsample_sh_get(void) | ||||
| { | { | ||||
| if (e_data.downsample_sh == nullptr) { | if (e_data.downsample_sh == NULL) { | ||||
| e_data.downsample_sh = DRW_shader_create_fullscreen_with_shaderlib( | e_data.downsample_sh = DRW_shader_create_from_info_name("eevee_legacy_downsample"); | ||||
| datatoc_effect_downsample_frag_glsl, e_data.lib, nullptr); | |||||
| } | } | ||||
| return e_data.downsample_sh; | return e_data.downsample_sh; | ||||
| } | } | ||||
| GPUShader *EEVEE_shaders_effect_downsample_cube_sh_get(void) | GPUShader *EEVEE_shaders_effect_downsample_cube_sh_get(void) | ||||
| { | { | ||||
| if (e_data.downsample_cube_sh == nullptr) { | if (e_data.downsample_cube_sh == NULL) { | ||||
| e_data.downsample_cube_sh = DRW_shader_create_with_shaderlib( | e_data.downsample_cube_sh = DRW_shader_create_from_info_name( | ||||
| datatoc_lightprobe_vert_glsl, | "eevee_legacy_effect_downsample_cube"); | ||||
| datatoc_lightprobe_geom_glsl, | |||||
| datatoc_effect_downsample_cube_frag_glsl, | |||||
| e_data.lib, | |||||
| nullptr); | |||||
| } | } | ||||
| return e_data.downsample_cube_sh; | return e_data.downsample_cube_sh; | ||||
| } | } | ||||
| GPUShader *EEVEE_shaders_effect_minz_downlevel_sh_get(void) | GPUShader *EEVEE_shaders_effect_minz_downlevel_sh_get(void) | ||||
| { | { | ||||
| if (e_data.minz_downlevel_sh == nullptr) { | if (e_data.minz_downlevel_sh == NULL) { | ||||
| e_data.minz_downlevel_sh = DRW_shader_create_fullscreen(datatoc_effect_minmaxz_frag_glsl, | e_data.minz_downlevel_sh = DRW_shader_create_from_info_name("eevee_legacy_minz_downlevel"); | ||||
| "#define MIN_PASS\n"); | |||||
| } | } | ||||
| return e_data.minz_downlevel_sh; | return e_data.minz_downlevel_sh; | ||||
| } | } | ||||
| GPUShader *EEVEE_shaders_effect_maxz_downlevel_sh_get(void) | GPUShader *EEVEE_shaders_effect_maxz_downlevel_sh_get(void) | ||||
| { | { | ||||
| if (e_data.maxz_downlevel_sh == nullptr) { | if (e_data.maxz_downlevel_sh == NULL) { | ||||
| e_data.maxz_downlevel_sh = DRW_shader_create_fullscreen(datatoc_effect_minmaxz_frag_glsl, | e_data.maxz_downlevel_sh = DRW_shader_create_from_info_name("eevee_legacy_maxz_downlevel"); | ||||
| "#define MAX_PASS\n"); | |||||
| } | } | ||||
| return e_data.maxz_downlevel_sh; | return e_data.maxz_downlevel_sh; | ||||
| } | } | ||||
| GPUShader *EEVEE_shaders_effect_minz_downdepth_sh_get(void) | GPUShader *EEVEE_shaders_effect_minz_downdepth_sh_get(void) | ||||
| { | { | ||||
| if (e_data.minz_downdepth_sh == nullptr) { | if (e_data.minz_downdepth_sh == NULL) { | ||||
| e_data.minz_downdepth_sh = DRW_shader_create_fullscreen(datatoc_effect_minmaxz_frag_glsl, | e_data.minz_downdepth_sh = DRW_shader_create_from_info_name("eevee_legacy_minz_downdepth"); | ||||
| "#define MIN_PASS\n"); | |||||
| } | } | ||||
| return e_data.minz_downdepth_sh; | return e_data.minz_downdepth_sh; | ||||
| } | } | ||||
| GPUShader *EEVEE_shaders_effect_maxz_downdepth_sh_get(void) | GPUShader *EEVEE_shaders_effect_maxz_downdepth_sh_get(void) | ||||
| { | { | ||||
| if (e_data.maxz_downdepth_sh == nullptr) { | if (e_data.maxz_downdepth_sh == NULL) { | ||||
| e_data.maxz_downdepth_sh = DRW_shader_create_fullscreen(datatoc_effect_minmaxz_frag_glsl, | e_data.maxz_downdepth_sh = DRW_shader_create_from_info_name("eevee_legacy_maxz_downdepth"); | ||||
| "#define MAX_PASS\n"); | |||||
| } | } | ||||
| return e_data.maxz_downdepth_sh; | return e_data.maxz_downdepth_sh; | ||||
| } | } | ||||
| GPUShader *EEVEE_shaders_effect_minz_downdepth_layer_sh_get(void) | GPUShader *EEVEE_shaders_effect_minz_downdepth_layer_sh_get(void) | ||||
| { | { | ||||
| if (e_data.minz_downdepth_layer_sh == nullptr) { | if (e_data.minz_downdepth_layer_sh == NULL) { | ||||
| e_data.minz_downdepth_layer_sh = DRW_shader_create_fullscreen(datatoc_effect_minmaxz_frag_glsl, | e_data.minz_downdepth_layer_sh = DRW_shader_create_from_info_name( | ||||
| "#define MIN_PASS\n" | "eevee_legacy_minz_downdepth_layer"); | ||||
| "#define LAYERED\n"); | |||||
| } | } | ||||
| return e_data.minz_downdepth_layer_sh; | return e_data.minz_downdepth_layer_sh; | ||||
| } | } | ||||
| GPUShader *EEVEE_shaders_effect_maxz_downdepth_layer_sh_get(void) | GPUShader *EEVEE_shaders_effect_maxz_downdepth_layer_sh_get(void) | ||||
| { | { | ||||
| if (e_data.maxz_downdepth_layer_sh == nullptr) { | if (e_data.maxz_downdepth_layer_sh == NULL) { | ||||
| e_data.maxz_downdepth_layer_sh = DRW_shader_create_fullscreen(datatoc_effect_minmaxz_frag_glsl, | e_data.maxz_downdepth_layer_sh = DRW_shader_create_from_info_name( | ||||
| "#define MAX_PASS\n" | "eevee_legacy_maxz_downdepth_layer"); | ||||
| "#define LAYERED\n"); | |||||
| } | } | ||||
| return e_data.maxz_downdepth_layer_sh; | return e_data.maxz_downdepth_layer_sh; | ||||
| } | } | ||||
| GPUShader *EEVEE_shaders_effect_maxz_copydepth_layer_sh_get(void) | GPUShader *EEVEE_shaders_effect_maxz_copydepth_layer_sh_get(void) | ||||
| { | { | ||||
| if (e_data.maxz_copydepth_layer_sh == nullptr) { | if (e_data.maxz_copydepth_layer_sh == NULL) { | ||||
| e_data.maxz_copydepth_layer_sh = DRW_shader_create_fullscreen(datatoc_effect_minmaxz_frag_glsl, | e_data.maxz_copydepth_layer_sh = DRW_shader_create_from_info_name( | ||||
| "#define MAX_PASS\n" | "eevee_legacy_maxz_copydepth_layer"); | ||||
| "#define COPY_DEPTH\n" | |||||
| "#define LAYERED\n"); | |||||
| } | } | ||||
| return e_data.maxz_copydepth_layer_sh; | return e_data.maxz_copydepth_layer_sh; | ||||
| } | } | ||||
| GPUShader *EEVEE_shaders_effect_minz_copydepth_sh_get(void) | GPUShader *EEVEE_shaders_effect_minz_copydepth_sh_get(void) | ||||
| { | { | ||||
| if (e_data.minz_copydepth_sh == nullptr) { | if (e_data.minz_copydepth_sh == NULL) { | ||||
| e_data.minz_copydepth_sh = DRW_shader_create_fullscreen(datatoc_effect_minmaxz_frag_glsl, | e_data.minz_copydepth_sh = DRW_shader_create_from_info_name("eevee_legacy_minz_copydepth"); | ||||
| "#define MIN_PASS\n" | |||||
| "#define COPY_DEPTH\n"); | |||||
| } | } | ||||
| return e_data.minz_copydepth_sh; | return e_data.minz_copydepth_sh; | ||||
| } | } | ||||
| GPUShader *EEVEE_shaders_effect_maxz_copydepth_sh_get(void) | GPUShader *EEVEE_shaders_effect_maxz_copydepth_sh_get(void) | ||||
| { | { | ||||
| if (e_data.maxz_copydepth_sh == nullptr) { | if (e_data.maxz_copydepth_sh == NULL) { | ||||
| e_data.maxz_copydepth_sh = DRW_shader_create_fullscreen(datatoc_effect_minmaxz_frag_glsl, | e_data.maxz_copydepth_sh = DRW_shader_create_from_info_name("eevee_legacy_maxz_copydepth"); | ||||
| "#define MAX_PASS\n" | |||||
| "#define COPY_DEPTH\n"); | |||||
| } | } | ||||
| return e_data.maxz_copydepth_sh; | return e_data.maxz_copydepth_sh; | ||||
| } | } | ||||
| /** \} */ | /** \} */ | ||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /** \name GGX LUT | /** \name GGX LUT | ||||
| * \{ */ | * \{ */ | ||||
| GPUShader *EEVEE_shaders_ggx_lut_sh_get(void) | GPUShader *EEVEE_shaders_ggx_lut_sh_get(void) | ||||
| { | { | ||||
| if (e_data.ggx_lut_sh == nullptr) { | if (e_data.ggx_lut_sh == NULL) { | ||||
| e_data.ggx_lut_sh = DRW_shader_create_fullscreen_with_shaderlib( | e_data.ggx_lut_sh = DRW_shader_create_from_info_name("eevee_legacy_ggx_lut_bsdf"); | ||||
| datatoc_bsdf_lut_frag_glsl, e_data.lib, nullptr); | |||||
| } | } | ||||
| return e_data.ggx_lut_sh; | return e_data.ggx_lut_sh; | ||||
| } | } | ||||
| GPUShader *EEVEE_shaders_ggx_refraction_lut_sh_get(void) | GPUShader *EEVEE_shaders_ggx_refraction_lut_sh_get(void) | ||||
| { | { | ||||
| if (e_data.ggx_refraction_lut_sh == nullptr) { | if (e_data.ggx_refraction_lut_sh == NULL) { | ||||
| e_data.ggx_refraction_lut_sh = DRW_shader_create_fullscreen_with_shaderlib( | e_data.ggx_refraction_lut_sh = DRW_shader_create_from_info_name("eevee_legacy_ggx_lut_btdf"); | ||||
| datatoc_btdf_lut_frag_glsl, e_data.lib, nullptr); | |||||
| } | } | ||||
| return e_data.ggx_refraction_lut_sh; | return e_data.ggx_refraction_lut_sh; | ||||
| } | } | ||||
| /** \} */ | /** \} */ | ||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /** \name Mist | /** \name Mist | ||||
| * \{ */ | * \{ */ | ||||
| GPUShader *EEVEE_shaders_effect_mist_sh_get(void) | GPUShader *EEVEE_shaders_effect_mist_sh_get(void) | ||||
| { | { | ||||
| if (e_data.mist_sh == nullptr) { | if (e_data.mist_sh == NULL) { | ||||
| e_data.mist_sh = DRW_shader_create_fullscreen_with_shaderlib( | e_data.mist_sh = DRW_shader_create_from_info_name("eevee_legacy_effect_mist_FIRST_PASS"); | ||||
| datatoc_effect_mist_frag_glsl, e_data.lib, "#define FIRST_PASS\n"); | |||||
| } | } | ||||
| return e_data.mist_sh; | return e_data.mist_sh; | ||||
| } | } | ||||
| /** \} */ | /** \} */ | ||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /** \name Motion Blur | /** \name Motion Blur | ||||
| * \{ */ | * \{ */ | ||||
| #define TILE_SIZE_STR "#define EEVEE_VELOCITY_TILE_SIZE " STRINGIFY(EEVEE_VELOCITY_TILE_SIZE) "\n" | #define TILE_SIZE_STR "#define EEVEE_VELOCITY_TILE_SIZE " STRINGIFY(EEVEE_VELOCITY_TILE_SIZE) "\n" | ||||
| GPUShader *EEVEE_shaders_effect_motion_blur_sh_get(void) | GPUShader *EEVEE_shaders_effect_motion_blur_sh_get(void) | ||||
| { | { | ||||
| if (e_data.motion_blur_sh == nullptr) { | if (e_data.motion_blur_sh == NULL) { | ||||
| e_data.motion_blur_sh = DRW_shader_create_fullscreen_with_shaderlib( | e_data.motion_blur_sh = DRW_shader_create_from_info_name("eevee_legacy_effect_motion_blur"); | ||||
| datatoc_effect_motion_blur_frag_glsl, e_data.lib, TILE_SIZE_STR); | |||||
| } | } | ||||
| return e_data.motion_blur_sh; | return e_data.motion_blur_sh; | ||||
| } | } | ||||
| GPUShader *EEVEE_shaders_effect_motion_blur_object_sh_get(void) | GPUShader *EEVEE_shaders_effect_motion_blur_object_sh_get(void) | ||||
| { | { | ||||
| if (e_data.motion_blur_object_sh == nullptr) { | if (e_data.motion_blur_object_sh == NULL) { | ||||
| e_data.motion_blur_object_sh = DRW_shader_create_with_shaderlib( | e_data.motion_blur_object_sh = DRW_shader_create_from_info_name( | ||||
| datatoc_object_motion_vert_glsl, | "eevee_legacy_effect_motion_blur_object"); | ||||
| nullptr, | |||||
| datatoc_object_motion_frag_glsl, | |||||
| e_data.lib, | |||||
| nullptr); | |||||
| } | } | ||||
| return e_data.motion_blur_object_sh; | return e_data.motion_blur_object_sh; | ||||
| } | } | ||||
| GPUShader *EEVEE_shaders_effect_motion_blur_hair_sh_get(void) | GPUShader *EEVEE_shaders_effect_motion_blur_hair_sh_get(void) | ||||
| { | { | ||||
| if (e_data.motion_blur_hair_sh == nullptr) { | if (e_data.motion_blur_hair_sh == NULL) { | ||||
| e_data.motion_blur_hair_sh = DRW_shader_create_with_shaderlib(datatoc_object_motion_vert_glsl, | e_data.motion_blur_hair_sh = DRW_shader_create_from_info_name( | ||||
| nullptr, | "eevee_legacy_effect_motion_blur_object_hair"); | ||||
| datatoc_object_motion_frag_glsl, | |||||
| e_data.lib, | |||||
| "#define HAIR\n"); | |||||
| } | } | ||||
| return e_data.motion_blur_hair_sh; | return e_data.motion_blur_hair_sh; | ||||
| } | } | ||||
| GPUShader *EEVEE_shaders_effect_motion_blur_velocity_tiles_sh_get(void) | GPUShader *EEVEE_shaders_effect_motion_blur_velocity_tiles_sh_get(void) | ||||
| { | { | ||||
| if (e_data.velocity_tiles_sh == nullptr) { | if (e_data.velocity_tiles_sh == NULL) { | ||||
| e_data.velocity_tiles_sh = DRW_shader_create_fullscreen(datatoc_effect_velocity_tile_frag_glsl, | e_data.velocity_tiles_sh = DRW_shader_create_from_info_name( | ||||
| "#define TILE_GATHER\n" TILE_SIZE_STR); | "eevee_legacy_effect_motion_blur_velocity_tiles_GATHER"); | ||||
| } | } | ||||
| return e_data.velocity_tiles_sh; | return e_data.velocity_tiles_sh; | ||||
| } | } | ||||
| GPUShader *EEVEE_shaders_effect_motion_blur_velocity_tiles_expand_sh_get(void) | GPUShader *EEVEE_shaders_effect_motion_blur_velocity_tiles_expand_sh_get(void) | ||||
| { | { | ||||
| if (e_data.velocity_tiles_expand_sh == nullptr) { | if (e_data.velocity_tiles_expand_sh == NULL) { | ||||
| e_data.velocity_tiles_expand_sh = DRW_shader_create_fullscreen( | e_data.velocity_tiles_expand_sh = DRW_shader_create_from_info_name( | ||||
| datatoc_effect_velocity_tile_frag_glsl, "#define TILE_EXPANSION\n" TILE_SIZE_STR); | "eevee_legacy_effect_motion_blur_velocity_tiles_EXPANSION"); | ||||
| } | } | ||||
| return e_data.velocity_tiles_expand_sh; | return e_data.velocity_tiles_expand_sh; | ||||
| } | } | ||||
| #undef TILE_SIZE_STR | #undef TILE_SIZE_STR | ||||
| /** \} */ | /** \} */ | ||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /** \name Ambient Occlusion | /** \name Ambient Occlusion | ||||
| * \{ */ | * \{ */ | ||||
| GPUShader *EEVEE_shaders_effect_ambient_occlusion_sh_get(void) | GPUShader *EEVEE_shaders_effect_ambient_occlusion_sh_get(void) | ||||
| { | { | ||||
| if (e_data.gtao_sh == nullptr) { | if (e_data.gtao_sh == NULL) { | ||||
| e_data.gtao_sh = DRW_shader_create_fullscreen_with_shaderlib( | e_data.gtao_sh = DRW_shader_create_from_info_name("eevee_legacy_ambient_occlusion"); | ||||
| datatoc_effect_gtao_frag_glsl, e_data.lib, nullptr); | |||||
| } | } | ||||
| return e_data.gtao_sh; | return e_data.gtao_sh; | ||||
| } | } | ||||
| GPUShader *EEVEE_shaders_effect_ambient_occlusion_debug_sh_get(void) | GPUShader *EEVEE_shaders_effect_ambient_occlusion_debug_sh_get(void) | ||||
| { | { | ||||
| if (e_data.gtao_debug_sh == nullptr) { | if (e_data.gtao_debug_sh == NULL) { | ||||
| e_data.gtao_debug_sh = DRW_shader_create_fullscreen_with_shaderlib( | e_data.gtao_debug_sh = DRW_shader_create_from_info_name( | ||||
| datatoc_effect_gtao_frag_glsl, | "eevee_legacy_ambient_occlusion_debug"); | ||||
| e_data.lib, | |||||
| "#define DEBUG_AO\n" | |||||
| "#define ENABLE_DEFERED_AO"); | |||||
| } | } | ||||
| return e_data.gtao_debug_sh; | return e_data.gtao_debug_sh; | ||||
| } | } | ||||
| /** \} */ | /** \} */ | ||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /** \name Render Passes | /** \name Render Passes | ||||
| * \{ */ | * \{ */ | ||||
| GPUShader *EEVEE_shaders_renderpasses_post_process_sh_get(void) | GPUShader *EEVEE_shaders_renderpasses_post_process_sh_get(void) | ||||
| { | { | ||||
| if (e_data.postprocess_sh == nullptr) { | if (e_data.postprocess_sh == NULL) { | ||||
| e_data.postprocess_sh = DRW_shader_create_fullscreen_with_shaderlib( | e_data.postprocess_sh = DRW_shader_create_from_info_name("eevee_legacy_post_process"); | ||||
| datatoc_renderpass_postprocess_frag_glsl, e_data.lib, nullptr); | |||||
| } | } | ||||
| return e_data.postprocess_sh; | return e_data.postprocess_sh; | ||||
| } | } | ||||
| /** \} */ | /** \} */ | ||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /** \name Cryptomatte | /** \name Cryptomatte | ||||
| * \{ */ | * \{ */ | ||||
| GPUShader *EEVEE_shaders_cryptomatte_sh_get(bool is_hair) | GPUShader *EEVEE_shaders_cryptomatte_sh_get(bool is_hair) | ||||
| { | { | ||||
| const int index = is_hair ? 1 : 0; | const int index = is_hair ? 1 : 0; | ||||
| if (e_data.cryptomatte_sh[index] == nullptr) { | if (e_data.cryptomatte_sh[index] == NULL) { | ||||
| DynStr *ds = BLI_dynstr_new(); | const char *crytomatte_sh_info_name = NULL; | ||||
| BLI_dynstr_append(ds, SHADER_DEFINES); | |||||
| BLI_dynstr_append(ds, "#define attrib_load() \n"); | |||||
| if (is_hair) { | if (is_hair) { | ||||
| BLI_dynstr_append(ds, "#define HAIR_SHADER\n"); | crytomatte_sh_info_name = "eevee_legacy_cryptomatte_hair"; | ||||
| } | } | ||||
| else { | else { | ||||
| BLI_dynstr_append(ds, "#define MESH_SHADER\n"); | crytomatte_sh_info_name = "eevee_legacy_cryptomatte_mesh"; | ||||
| } | } | ||||
| char *defines = BLI_dynstr_get_cstring(ds); | |||||
| e_data.cryptomatte_sh[index] = DRW_shader_create_with_shaderlib(datatoc_cryptomatte_vert_glsl, | e_data.cryptomatte_sh[index] = DRW_shader_create_from_info_name(crytomatte_sh_info_name); | ||||
| nullptr, | |||||
| datatoc_cryptomatte_frag_glsl, | |||||
| e_data.lib, | |||||
| defines); | |||||
| BLI_dynstr_free(ds); | |||||
| MEM_freeN(defines); | |||||
| } | } | ||||
| return e_data.cryptomatte_sh[index]; | return e_data.cryptomatte_sh[index]; | ||||
| } | } | ||||
| /** \} */ | /** \} */ | ||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /** \name Raytraced Reflections | /** \name Raytraced Reflections | ||||
| * \{ */ | * \{ */ | ||||
| struct GPUShader *EEVEE_shaders_effect_reflection_trace_sh_get(void) | struct GPUShader *EEVEE_shaders_effect_reflection_trace_sh_get(void) | ||||
| { | { | ||||
| if (e_data.reflection_trace == nullptr) { | if (e_data.reflection_trace == NULL) { | ||||
| e_data.reflection_trace = DRW_shader_create_fullscreen_with_shaderlib( | e_data.reflection_trace = DRW_shader_create_from_info_name( | ||||
| datatoc_effect_reflection_trace_frag_glsl, | "eevee_legacy_effect_reflection_trace"); | ||||
| e_data.lib, | |||||
| SHADER_DEFINES "#define STEP_RAYTRACE\n"); | |||||
| } | } | ||||
| return e_data.reflection_trace; | return e_data.reflection_trace; | ||||
| } | } | ||||
| struct GPUShader *EEVEE_shaders_effect_reflection_resolve_sh_get(void) | struct GPUShader *EEVEE_shaders_effect_reflection_resolve_sh_get(void) | ||||
| { | { | ||||
| if (e_data.reflection_resolve == nullptr) { | if (e_data.reflection_resolve == NULL) { | ||||
| e_data.reflection_resolve = DRW_shader_create_fullscreen_with_shaderlib( | e_data.reflection_resolve = DRW_shader_create_from_info_name( | ||||
| datatoc_effect_reflection_resolve_frag_glsl, | "eevee_legacy_effect_reflection_resolve"); | ||||
| e_data.lib, | |||||
| SHADER_DEFINES "#define STEP_RESOLVE\n"); | |||||
| } | } | ||||
| return e_data.reflection_resolve; | return e_data.reflection_resolve; | ||||
| } | } | ||||
| /** \} */ | /** \} */ | ||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /** \name Shadows | /** \name Shadows | ||||
| * \{ */ | * \{ */ | ||||
| struct GPUShader *EEVEE_shaders_shadow_sh_get() | struct GPUShader *EEVEE_shaders_shadow_sh_get() | ||||
| { | { | ||||
| if (e_data.shadow_sh == nullptr) { | if (e_data.shadow_sh == NULL) { | ||||
| e_data.shadow_sh = DRW_shader_create_with_shaderlib( | e_data.shadow_sh = DRW_shader_create_from_info_name("eevee_legacy_shader_shadow"); | ||||
| datatoc_shadow_vert_glsl, nullptr, datatoc_shadow_frag_glsl, e_data.lib, nullptr); | |||||
| } | } | ||||
| return e_data.shadow_sh; | return e_data.shadow_sh; | ||||
| } | } | ||||
| struct GPUShader *EEVEE_shaders_shadow_accum_sh_get() | struct GPUShader *EEVEE_shaders_shadow_accum_sh_get() | ||||
| { | { | ||||
| if (e_data.shadow_accum_sh == nullptr) { | if (e_data.shadow_accum_sh == NULL) { | ||||
| e_data.shadow_accum_sh = DRW_shader_create_fullscreen_with_shaderlib( | e_data.shadow_accum_sh = DRW_shader_create_from_info_name("eevee_legacy_shader_shadow_accum"); | ||||
| datatoc_shadow_accum_frag_glsl, e_data.lib, SHADER_DEFINES); | |||||
| } | } | ||||
| return e_data.shadow_accum_sh; | return e_data.shadow_accum_sh; | ||||
| } | } | ||||
| /** \} */ | /** \} */ | ||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /** \name Subsurface | /** \name Subsurface | ||||
| * \{ */ | * \{ */ | ||||
| struct GPUShader *EEVEE_shaders_subsurface_first_pass_sh_get() | struct GPUShader *EEVEE_shaders_subsurface_first_pass_sh_get() | ||||
| { | { | ||||
| if (e_data.sss_sh[0] == nullptr) { | if (e_data.sss_sh[0] == NULL) { | ||||
| e_data.sss_sh[0] = DRW_shader_create_fullscreen_with_shaderlib( | e_data.sss_sh[0] = DRW_shader_create_from_info_name( | ||||
| datatoc_effect_subsurface_frag_glsl, e_data.lib, "#define FIRST_PASS\n"); | "eevee_legacy_shader_effect_subsurface_common_FIRST_PASS"); | ||||
| } | } | ||||
| return e_data.sss_sh[0]; | return e_data.sss_sh[0]; | ||||
| } | } | ||||
| struct GPUShader *EEVEE_shaders_subsurface_second_pass_sh_get() | struct GPUShader *EEVEE_shaders_subsurface_second_pass_sh_get() | ||||
| { | { | ||||
| if (e_data.sss_sh[1] == nullptr) { | if (e_data.sss_sh[1] == NULL) { | ||||
| e_data.sss_sh[1] = DRW_shader_create_fullscreen_with_shaderlib( | |||||
| datatoc_effect_subsurface_frag_glsl, e_data.lib, "#define SECOND_PASS\n"); | e_data.sss_sh[1] = DRW_shader_create_from_info_name( | ||||
| "eevee_legacy_shader_effect_subsurface_common_SECOND_PASS"); | |||||
| } | } | ||||
| return e_data.sss_sh[1]; | return e_data.sss_sh[1]; | ||||
| } | } | ||||
| struct GPUShader *EEVEE_shaders_subsurface_translucency_sh_get() | struct GPUShader *EEVEE_shaders_subsurface_translucency_sh_get() | ||||
| { | { | ||||
| if (e_data.sss_sh[2] == nullptr) { | if (e_data.sss_sh[2] == NULL) { | ||||
| e_data.sss_sh[2] = DRW_shader_create_fullscreen_with_shaderlib( | e_data.sss_sh[2] = DRW_shader_create_from_info_name( | ||||
| datatoc_effect_translucency_frag_glsl, | "eevee_legacy_shader_effect_subsurface_translucency"); | ||||
| e_data.lib, | |||||
| "#define EEVEE_TRANSLUCENCY\n" SHADER_DEFINES); | |||||
| } | } | ||||
| return e_data.sss_sh[2]; | return e_data.sss_sh[2]; | ||||
| } | } | ||||
| /** \} */ | /** \} */ | ||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /** \name Volumes | /** \name Volumes | ||||
| * \{ */ | * \{ */ | ||||
| struct GPUShader *EEVEE_shaders_volumes_clear_sh_get() | struct GPUShader *EEVEE_shaders_volumes_clear_sh_get() | ||||
| { | { | ||||
| if (e_data.volumetric_clear_sh == nullptr) { | if (e_data.volumetric_clear_sh == NULL) { | ||||
| e_data.volumetric_clear_sh = DRW_shader_create_with_shaderlib(datatoc_volumetric_vert_glsl, | e_data.volumetric_clear_sh = DRW_shader_create_from_info_name("eevee_legacy_volumes_clear"); | ||||
| datatoc_volumetric_geom_glsl, | |||||
| datatoc_volumetric_frag_glsl, | |||||
| e_data.lib, | |||||
| SHADER_DEFINES | |||||
| "#define STANDALONE\n" | |||||
| "#define VOLUMETRICS\n" | |||||
| "#define CLEAR\n"); | |||||
| } | } | ||||
| return e_data.volumetric_clear_sh; | return e_data.volumetric_clear_sh; | ||||
| } | } | ||||
| struct GPUShader *EEVEE_shaders_volumes_scatter_sh_get() | struct GPUShader *EEVEE_shaders_volumes_scatter_sh_get() | ||||
| { | { | ||||
| if (e_data.scatter_sh == nullptr) { | if (e_data.scatter_sh == NULL) { | ||||
| e_data.scatter_sh = DRW_shader_create_with_shaderlib(datatoc_volumetric_vert_glsl, | e_data.scatter_sh = DRW_shader_create_from_info_name("eevee_legacy_volumes_scatter"); | ||||
| datatoc_volumetric_geom_glsl, | |||||
| datatoc_volumetric_scatter_frag_glsl, | |||||
| e_data.lib, | |||||
| SHADER_DEFINES | |||||
| "#define STANDALONE\n" | |||||
| "#define VOLUMETRICS\n" | |||||
| "#define VOLUME_SHADOW\n"); | |||||
| } | } | ||||
| return e_data.scatter_sh; | return e_data.scatter_sh; | ||||
| } | } | ||||
| struct GPUShader *EEVEE_shaders_volumes_scatter_with_lights_sh_get() | struct GPUShader *EEVEE_shaders_volumes_scatter_with_lights_sh_get() | ||||
| { | { | ||||
| if (e_data.scatter_with_lights_sh == nullptr) { | if (e_data.scatter_with_lights_sh == NULL) { | ||||
| e_data.scatter_with_lights_sh = DRW_shader_create_with_shaderlib( | e_data.scatter_with_lights_sh = DRW_shader_create_from_info_name( | ||||
| datatoc_volumetric_vert_glsl, | "eevee_legacy_volumes_scatter_with_lights"); | ||||
| datatoc_volumetric_geom_glsl, | |||||
| datatoc_volumetric_scatter_frag_glsl, | |||||
| e_data.lib, | |||||
| SHADER_DEFINES | |||||
| "#define STANDALONE\n" | |||||
| "#define VOLUMETRICS\n" | |||||
| "#define VOLUME_LIGHTING\n" | |||||
| "#define VOLUME_SHADOW\n"); | |||||
| } | } | ||||
| return e_data.scatter_with_lights_sh; | return e_data.scatter_with_lights_sh; | ||||
| } | } | ||||
| struct GPUShader *EEVEE_shaders_volumes_integration_sh_get() | struct GPUShader *EEVEE_shaders_volumes_integration_sh_get() | ||||
| { | { | ||||
| if (e_data.volumetric_integration_sh == nullptr) { | if (e_data.volumetric_integration_sh == NULL) { | ||||
| e_data.volumetric_integration_sh = DRW_shader_create_with_shaderlib( | e_data.volumetric_integration_sh = DRW_shader_create_from_info_name( | ||||
| datatoc_volumetric_vert_glsl, | (USE_VOLUME_OPTI) ? "eevee_legacy_volumes_integration_OPTI" : | ||||
| datatoc_volumetric_geom_glsl, | "eevee_legacy_volumes_integration"); | ||||
| datatoc_volumetric_integration_frag_glsl, | |||||
| e_data.lib, | |||||
| USE_VOLUME_OPTI ? "#define USE_VOLUME_OPTI\n" | |||||
| "#define STANDALONE\n" SHADER_DEFINES : | |||||
| "#define STANDALONE\n" SHADER_DEFINES); | |||||
| } | } | ||||
| return e_data.volumetric_integration_sh; | return e_data.volumetric_integration_sh; | ||||
| } | } | ||||
| struct GPUShader *EEVEE_shaders_volumes_resolve_sh_get(bool accum) | struct GPUShader *EEVEE_shaders_volumes_resolve_sh_get(bool accum) | ||||
| { | { | ||||
| const int index = accum ? 1 : 0; | const int index = accum ? 1 : 0; | ||||
| if (e_data.volumetric_resolve_sh[index] == nullptr) { | if (e_data.volumetric_resolve_sh[index] == NULL) { | ||||
| e_data.volumetric_resolve_sh[index] = DRW_shader_create_fullscreen_with_shaderlib( | e_data.volumetric_resolve_sh[index] = DRW_shader_create_from_info_name( | ||||
| datatoc_volumetric_resolve_frag_glsl, | (accum) ? "eevee_legacy_volumes_resolve_accum" : "eevee_legacy_volumes_resolve"); | ||||
| e_data.lib, | |||||
| accum ? "#define VOLUMETRICS_ACCUM\n" SHADER_DEFINES : SHADER_DEFINES); | |||||
| } | } | ||||
| return e_data.volumetric_resolve_sh[index]; | return e_data.volumetric_resolve_sh[index]; | ||||
| } | } | ||||
| struct GPUShader *EEVEE_shaders_volumes_accum_sh_get() | struct GPUShader *EEVEE_shaders_volumes_accum_sh_get() | ||||
| { | { | ||||
| if (e_data.volumetric_accum_sh == nullptr) { | if (e_data.volumetric_accum_sh == NULL) { | ||||
| e_data.volumetric_accum_sh = DRW_shader_create_fullscreen_with_shaderlib( | e_data.volumetric_accum_sh = DRW_shader_create_from_info_name("eevee_legacy_volumes_accum"); | ||||
| datatoc_volumetric_accum_frag_glsl, e_data.lib, SHADER_DEFINES); | |||||
| } | } | ||||
| return e_data.volumetric_accum_sh; | return e_data.volumetric_accum_sh; | ||||
| } | } | ||||
| /** \} */ | /** \} */ | ||||
| GPUShader *EEVEE_shaders_velocity_resolve_sh_get(void) | GPUShader *EEVEE_shaders_velocity_resolve_sh_get(void) | ||||
| { | { | ||||
| if (e_data.velocity_resolve_sh == nullptr) { | if (e_data.velocity_resolve_sh == NULL) { | ||||
| e_data.velocity_resolve_sh = DRW_shader_create_fullscreen_with_shaderlib( | e_data.velocity_resolve_sh = DRW_shader_create_from_info_name("eevee_legacy_velocity_resolve"); | ||||
| datatoc_effect_velocity_resolve_frag_glsl, e_data.lib, nullptr); | |||||
| } | } | ||||
| return e_data.velocity_resolve_sh; | return e_data.velocity_resolve_sh; | ||||
| } | } | ||||
| GPUShader *EEVEE_shaders_update_noise_sh_get(void) | GPUShader *EEVEE_shaders_update_noise_sh_get(void) | ||||
| { | { | ||||
| if (e_data.update_noise_sh == nullptr) { | if (e_data.update_noise_sh == NULL) { | ||||
| e_data.update_noise_sh = DRW_shader_create_fullscreen_with_shaderlib( | e_data.update_noise_sh = DRW_shader_create_from_info_name("eevee_legacy_update_noise"); | ||||
| datatoc_update_noise_frag_glsl, e_data.lib, nullptr); | |||||
| } | } | ||||
| return e_data.update_noise_sh; | return e_data.update_noise_sh; | ||||
| } | } | ||||
| GPUShader *EEVEE_shaders_taa_resolve_sh_get(EEVEE_EffectsFlag enabled_effects) | GPUShader *EEVEE_shaders_taa_resolve_sh_get(EEVEE_EffectsFlag enabled_effects) | ||||
| { | { | ||||
| GPUShader **sh; | |||||
| const char *define = nullptr; | |||||
| if (enabled_effects & EFFECT_TAA_REPROJECT) { | if (enabled_effects & EFFECT_TAA_REPROJECT) { | ||||
| sh = &e_data.taa_resolve_reproject_sh; | if (e_data.taa_resolve_reproject_sh == NULL) { | ||||
| define = "#define USE_REPROJECTION\n"; | e_data.taa_resolve_reproject_sh = DRW_shader_create_from_info_name( | ||||
| "eevee_legacy_taa_resolve_reprojection"); | |||||
| } | |||||
| return e_data.taa_resolve_reproject_sh; | |||||
| } | } | ||||
| else { | else { | ||||
| sh = &e_data.taa_resolve_sh; | if (e_data.taa_resolve_sh == NULL) { | ||||
| e_data.taa_resolve_sh = DRW_shader_create_from_info_name("eevee_legacy_taa_resolve_basic"); | |||||
| } | } | ||||
| if (*sh == nullptr) { | return e_data.taa_resolve_sh; | ||||
| *sh = DRW_shader_create_fullscreen_with_shaderlib( | |||||
| datatoc_effect_temporal_aa_glsl, e_data.lib, define); | |||||
| } | } | ||||
| return *sh; | |||||
| } | } | ||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /** \name Bloom | /** \name Bloom | ||||
| * \{ */ | * \{ */ | ||||
| GPUShader *EEVEE_shaders_bloom_blit_get(bool high_quality) | GPUShader *EEVEE_shaders_bloom_blit_get(bool high_quality) | ||||
| { | { | ||||
| int index = high_quality ? 1 : 0; | int index = high_quality ? 1 : 0; | ||||
| if (e_data.bloom_blit_sh[index] == nullptr) { | if (e_data.bloom_blit_sh[index] == NULL) { | ||||
| const char *define = high_quality ? "#define STEP_BLIT\n" | e_data.bloom_blit_sh[index] = DRW_shader_create_from_info_name( | ||||
| "#define HIGH_QUALITY\n" : | high_quality ? "eevee_legacy_bloom_blit_hq" : "eevee_legacy_bloom_blit"); | ||||
| "#define STEP_BLIT\n"; | |||||
| e_data.bloom_blit_sh[index] = DRW_shader_create_fullscreen_with_shaderlib( | |||||
| datatoc_effect_bloom_frag_glsl, e_data.lib, define); | |||||
| } | } | ||||
| return e_data.bloom_blit_sh[index]; | return e_data.bloom_blit_sh[index]; | ||||
| } | } | ||||
| GPUShader *EEVEE_shaders_bloom_downsample_get(bool high_quality) | GPUShader *EEVEE_shaders_bloom_downsample_get(bool high_quality) | ||||
| { | { | ||||
| int index = high_quality ? 1 : 0; | int index = high_quality ? 1 : 0; | ||||
| if (e_data.bloom_downsample_sh[index] == nullptr) { | if (e_data.bloom_downsample_sh[index] == NULL) { | ||||
| const char *define = high_quality ? "#define STEP_DOWNSAMPLE\n" | e_data.bloom_downsample_sh[index] = DRW_shader_create_from_info_name( | ||||
| "#define HIGH_QUALITY\n" : | high_quality ? "eevee_legacy_bloom_downsample_hq" : "eevee_legacy_bloom_downsample"); | ||||
| "#define STEP_DOWNSAMPLE\n"; | |||||
| e_data.bloom_downsample_sh[index] = DRW_shader_create_fullscreen_with_shaderlib( | |||||
| datatoc_effect_bloom_frag_glsl, e_data.lib, define); | |||||
| } | } | ||||
| return e_data.bloom_downsample_sh[index]; | return e_data.bloom_downsample_sh[index]; | ||||
| } | } | ||||
| GPUShader *EEVEE_shaders_bloom_upsample_get(bool high_quality) | GPUShader *EEVEE_shaders_bloom_upsample_get(bool high_quality) | ||||
| { | { | ||||
| int index = high_quality ? 1 : 0; | int index = high_quality ? 1 : 0; | ||||
| if (e_data.bloom_upsample_sh[index] == nullptr) { | if (e_data.bloom_upsample_sh[index] == NULL) { | ||||
| const char *define = high_quality ? "#define STEP_UPSAMPLE\n" | e_data.bloom_upsample_sh[index] = DRW_shader_create_from_info_name( | ||||
| "#define HIGH_QUALITY\n" : | high_quality ? "eevee_legacy_bloom_upsample_hq" : "eevee_legacy_bloom_upsample"); | ||||
| "#define STEP_UPSAMPLE\n"; | |||||
| e_data.bloom_upsample_sh[index] = DRW_shader_create_fullscreen_with_shaderlib( | |||||
| datatoc_effect_bloom_frag_glsl, e_data.lib, define); | |||||
| } | } | ||||
| return e_data.bloom_upsample_sh[index]; | return e_data.bloom_upsample_sh[index]; | ||||
| } | } | ||||
| GPUShader *EEVEE_shaders_bloom_resolve_get(bool high_quality) | GPUShader *EEVEE_shaders_bloom_resolve_get(bool high_quality) | ||||
| { | { | ||||
| int index = high_quality ? 1 : 0; | int index = high_quality ? 1 : 0; | ||||
| if (e_data.bloom_resolve_sh[index] == nullptr) { | if (e_data.bloom_resolve_sh[index] == NULL) { | ||||
| const char *define = high_quality ? "#define STEP_RESOLVE\n" | e_data.bloom_resolve_sh[index] = DRW_shader_create_from_info_name( | ||||
| "#define HIGH_QUALITY\n" : | high_quality ? "eevee_legacy_bloom_resolve_hq" : "eevee_legacy_bloom_resolve"); | ||||
| "#define STEP_RESOLVE\n"; | |||||
| e_data.bloom_resolve_sh[index] = DRW_shader_create_fullscreen_with_shaderlib( | |||||
| datatoc_effect_bloom_frag_glsl, e_data.lib, define); | |||||
| } | } | ||||
| return e_data.bloom_resolve_sh[index]; | return e_data.bloom_resolve_sh[index]; | ||||
| } | } | ||||
| /** \} */ | /** \} */ | ||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /** \name Depth of field | /** \name Depth of field | ||||
| * \{ */ | * \{ */ | ||||
| GPUShader *EEVEE_shaders_depth_of_field_bokeh_get(void) | GPUShader *EEVEE_shaders_depth_of_field_bokeh_get(void) | ||||
| { | { | ||||
| if (e_data.dof_bokeh_sh == nullptr) { | if (e_data.dof_bokeh_sh == NULL) { | ||||
| e_data.dof_bokeh_sh = DRW_shader_create_fullscreen_with_shaderlib( | e_data.dof_bokeh_sh = DRW_shader_create_from_info_name("eevee_legacy_depth_of_field_bokeh"); | ||||
| datatoc_effect_dof_bokeh_frag_glsl, e_data.lib, DOF_SHADER_DEFINES); | |||||
| } | } | ||||
| return e_data.dof_bokeh_sh; | return e_data.dof_bokeh_sh; | ||||
| } | } | ||||
| GPUShader *EEVEE_shaders_depth_of_field_setup_get(void) | GPUShader *EEVEE_shaders_depth_of_field_setup_get(void) | ||||
| { | { | ||||
| if (e_data.dof_setup_sh == nullptr) { | if (e_data.dof_setup_sh == NULL) { | ||||
| e_data.dof_setup_sh = DRW_shader_create_fullscreen_with_shaderlib( | e_data.dof_setup_sh = DRW_shader_create_from_info_name("eevee_legacy_depth_of_field_setup"); | ||||
| datatoc_effect_dof_setup_frag_glsl, e_data.lib, DOF_SHADER_DEFINES); | |||||
| } | } | ||||
| return e_data.dof_setup_sh; | return e_data.dof_setup_sh; | ||||
| } | } | ||||
| GPUShader *EEVEE_shaders_depth_of_field_flatten_tiles_get(void) | GPUShader *EEVEE_shaders_depth_of_field_flatten_tiles_get(void) | ||||
| { | { | ||||
| if (e_data.dof_flatten_tiles_sh == nullptr) { | if (e_data.dof_flatten_tiles_sh == NULL) { | ||||
| e_data.dof_flatten_tiles_sh = DRW_shader_create_fullscreen_with_shaderlib( | e_data.dof_flatten_tiles_sh = DRW_shader_create_from_info_name( | ||||
| datatoc_effect_dof_flatten_tiles_frag_glsl, e_data.lib, DOF_SHADER_DEFINES); | "eevee_legacy_depth_of_field_flatten_tiles"); | ||||
| } | } | ||||
| return e_data.dof_flatten_tiles_sh; | return e_data.dof_flatten_tiles_sh; | ||||
| } | } | ||||
| GPUShader *EEVEE_shaders_depth_of_field_dilate_tiles_get(bool b_pass) | GPUShader *EEVEE_shaders_depth_of_field_dilate_tiles_get(bool b_pass) | ||||
| { | { | ||||
| int pass = b_pass; | int pass = b_pass; | ||||
| if (e_data.dof_dilate_tiles_sh[pass] == nullptr) { | if (e_data.dof_dilate_tiles_sh[pass] == NULL) { | ||||
| e_data.dof_dilate_tiles_sh[pass] = DRW_shader_create_fullscreen_with_shaderlib( | |||||
| datatoc_effect_dof_dilate_tiles_frag_glsl, | e_data.dof_dilate_tiles_sh[pass] = DRW_shader_create_from_info_name( | ||||
| e_data.lib, | (pass == 0) ? "eevee_legacy_depth_of_field_dilate_tiles_MINMAX" : | ||||
| (pass == 0) ? DOF_SHADER_DEFINES "#define DILATE_MODE_MIN_MAX\n" : | "eevee_legacy_depth_of_field_dilate_tiles_MINABS"); | ||||
| DOF_SHADER_DEFINES "#define DILATE_MODE_MIN_ABS\n"); | |||||
| } | } | ||||
| return e_data.dof_dilate_tiles_sh[pass]; | return e_data.dof_dilate_tiles_sh[pass]; | ||||
| } | } | ||||
| GPUShader *EEVEE_shaders_depth_of_field_downsample_get(void) | GPUShader *EEVEE_shaders_depth_of_field_downsample_get(void) | ||||
| { | { | ||||
| if (e_data.dof_downsample_sh == nullptr) { | if (e_data.dof_downsample_sh == NULL) { | ||||
| e_data.dof_downsample_sh = DRW_shader_create_fullscreen_with_shaderlib( | e_data.dof_downsample_sh = DRW_shader_create_from_info_name( | ||||
| datatoc_effect_dof_downsample_frag_glsl, e_data.lib, DOF_SHADER_DEFINES); | "eevee_legacy_depth_of_field_downsample"); | ||||
| } | } | ||||
| return e_data.dof_downsample_sh; | return e_data.dof_downsample_sh; | ||||
| } | } | ||||
| GPUShader *EEVEE_shaders_depth_of_field_reduce_get(bool b_is_copy_pass) | GPUShader *EEVEE_shaders_depth_of_field_reduce_get(bool b_is_copy_pass) | ||||
| { | { | ||||
| int is_copy_pass = b_is_copy_pass; | int is_copy_pass = b_is_copy_pass; | ||||
| if (e_data.dof_reduce_sh[is_copy_pass] == nullptr) { | if (e_data.dof_reduce_sh[is_copy_pass] == NULL) { | ||||
| e_data.dof_reduce_sh[is_copy_pass] = DRW_shader_create_fullscreen_with_shaderlib( | e_data.dof_reduce_sh[is_copy_pass] = DRW_shader_create_from_info_name( | ||||
| datatoc_effect_dof_reduce_frag_glsl, | (is_copy_pass) ? "eevee_legacy_depth_of_field_reduce_COPY_PASS" : | ||||
| e_data.lib, | "eevee_legacy_depth_of_field_reduce_REDUCE_PASS"); | ||||
| (is_copy_pass) ? DOF_SHADER_DEFINES "#define COPY_PASS\n" : | |||||
| DOF_SHADER_DEFINES "#define REDUCE_PASS\n"); | |||||
| } | } | ||||
| return e_data.dof_reduce_sh[is_copy_pass]; | return e_data.dof_reduce_sh[is_copy_pass]; | ||||
| } | } | ||||
| GPUShader *EEVEE_shaders_depth_of_field_gather_get(EEVEE_DofGatherPass pass, bool b_use_bokeh_tx) | GPUShader *EEVEE_shaders_depth_of_field_gather_get(EEVEE_DofGatherPass pass, bool b_use_bokeh_tx) | ||||
| { | { | ||||
| int use_bokeh_tx = b_use_bokeh_tx; | int use_bokeh_tx = b_use_bokeh_tx; | ||||
| if (e_data.dof_gather_sh[pass][use_bokeh_tx] == nullptr) { | if (e_data.dof_gather_sh[pass][use_bokeh_tx] == NULL) { | ||||
| DynStr *ds = BLI_dynstr_new(); | const char *dof_gather_info_name = NULL; | ||||
| BLI_dynstr_append(ds, DOF_SHADER_DEFINES); | |||||
| switch (pass) { | switch (pass) { | ||||
| case DOF_GATHER_FOREGROUND: | case DOF_GATHER_FOREGROUND: | ||||
| BLI_dynstr_append(ds, "#define DOF_FOREGROUND_PASS\n"); | dof_gather_info_name = (b_use_bokeh_tx) ? | ||||
| "eevee_legacy_depth_of_field_gather_FOREGROUND_BOKEH" : | |||||
| "eevee_legacy_depth_of_field_gather_FOREGROUND"; | |||||
| break; | break; | ||||
| case DOF_GATHER_BACKGROUND: | case DOF_GATHER_BACKGROUND: | ||||
| BLI_dynstr_append(ds, "#define DOF_BACKGROUND_PASS\n"); | dof_gather_info_name = (b_use_bokeh_tx) ? | ||||
| "eevee_legacy_depth_of_field_gather_BACKGROUND_BOKEH" : | |||||
| "eevee_legacy_depth_of_field_gather_BACKGROUND"; | |||||
| break; | break; | ||||
| case DOF_GATHER_HOLEFILL: | case DOF_GATHER_HOLEFILL: | ||||
| BLI_dynstr_append(ds, | dof_gather_info_name = (b_use_bokeh_tx) ? | ||||
| "#define DOF_BACKGROUND_PASS\n" | "eevee_legacy_depth_of_field_gather_HOLEFILL_BOKEH" : | ||||
| "#define DOF_HOLEFILL_PASS\n"); | "eevee_legacy_depth_of_field_gather_HOLEFILL"; | ||||
| break; | break; | ||||
| default: | default: | ||||
| BLI_assert_unreachable(); | |||||
| break; | break; | ||||
| } | } | ||||
| BLI_assert(dof_gather_info_name != NULL); | |||||
| if (use_bokeh_tx) { | e_data.dof_gather_sh[pass][use_bokeh_tx] = DRW_shader_create_from_info_name( | ||||
| BLI_dynstr_append(ds, "#define DOF_BOKEH_TEXTURE\n"); | dof_gather_info_name); | ||||
| } | |||||
| char *define = BLI_dynstr_get_cstring(ds); | |||||
| BLI_dynstr_free(ds); | |||||
| e_data.dof_gather_sh[pass][use_bokeh_tx] = DRW_shader_create_fullscreen_with_shaderlib( | |||||
| datatoc_effect_dof_gather_frag_glsl, e_data.lib, define); | |||||
| MEM_freeN(define); | |||||
| } | } | ||||
| return e_data.dof_gather_sh[pass][use_bokeh_tx]; | return e_data.dof_gather_sh[pass][use_bokeh_tx]; | ||||
| } | } | ||||
| GPUShader *EEVEE_shaders_depth_of_field_filter_get(void) | GPUShader *EEVEE_shaders_depth_of_field_filter_get(void) | ||||
| { | { | ||||
| if (e_data.dof_filter_sh == nullptr) { | if (e_data.dof_filter_sh == NULL) { | ||||
| e_data.dof_filter_sh = DRW_shader_create_fullscreen_with_shaderlib( | e_data.dof_filter_sh = DRW_shader_create_from_info_name("eevee_legacy_depth_of_field_filter"); | ||||
| datatoc_effect_dof_filter_frag_glsl, e_data.lib, DOF_SHADER_DEFINES); | |||||
| } | } | ||||
| return e_data.dof_filter_sh; | return e_data.dof_filter_sh; | ||||
| } | } | ||||
| GPUShader *EEVEE_shaders_depth_of_field_scatter_get(bool b_is_foreground, bool b_use_bokeh_tx) | GPUShader *EEVEE_shaders_depth_of_field_scatter_get(bool b_is_foreground, bool b_use_bokeh_tx) | ||||
| { | { | ||||
| int is_foreground = b_is_foreground; | int is_foreground = b_is_foreground; | ||||
| int use_bokeh_tx = b_use_bokeh_tx; | int use_bokeh_tx = b_use_bokeh_tx; | ||||
| if (e_data.dof_scatter_sh[is_foreground][use_bokeh_tx] == nullptr) { | if (e_data.dof_scatter_sh[is_foreground][use_bokeh_tx] == NULL) { | ||||
| DynStr *ds = BLI_dynstr_new(); | const char *dof_filter_info_name = NULL; | ||||
| if (b_is_foreground) { | |||||
| BLI_dynstr_append(ds, DOF_SHADER_DEFINES); | dof_filter_info_name = (b_use_bokeh_tx) ? | ||||
| BLI_dynstr_append( | "eevee_legacy_depth_of_field_scatter_FOREGROUND_BOKEH" : | ||||
| ds, (is_foreground) ? "#define DOF_FOREGROUND_PASS\n" : "#define DOF_BACKGROUND_PASS\n"); | "eevee_legacy_depth_of_field_scatter_FOREGROUND"; | ||||
| if (use_bokeh_tx) { | |||||
| BLI_dynstr_append(ds, "#define DOF_BOKEH_TEXTURE\n"); | |||||
| } | } | ||||
| else { | |||||
| char *define = BLI_dynstr_get_cstring(ds); | dof_filter_info_name = (b_use_bokeh_tx) ? | ||||
| BLI_dynstr_free(ds); | "eevee_legacy_depth_of_field_scatter_BACKGROUND_BOKEH" : | ||||
| "eevee_legacy_depth_of_field_scatter_BACKGROUND"; | |||||
| e_data.dof_scatter_sh[is_foreground][use_bokeh_tx] = DRW_shader_create_with_shaderlib( | } | ||||
| datatoc_effect_dof_scatter_vert_glsl, | BLI_assert(dof_filter_info_name != NULL); | ||||
| nullptr, | e_data.dof_scatter_sh[is_foreground][use_bokeh_tx] = DRW_shader_create_from_info_name( | ||||
| datatoc_effect_dof_scatter_frag_glsl, | dof_filter_info_name); | ||||
| e_data.lib, | |||||
| define); | |||||
| MEM_freeN(define); | |||||
| } | } | ||||
| return e_data.dof_scatter_sh[is_foreground][use_bokeh_tx]; | return e_data.dof_scatter_sh[is_foreground][use_bokeh_tx]; | ||||
| } | } | ||||
| GPUShader *EEVEE_shaders_depth_of_field_resolve_get(bool b_use_bokeh_tx, bool b_use_hq_gather) | GPUShader *EEVEE_shaders_depth_of_field_resolve_get(bool b_use_bokeh_tx, bool b_use_hq_gather) | ||||
| { | { | ||||
| int use_hq_gather = b_use_hq_gather; | int use_hq_gather = b_use_hq_gather; | ||||
| int use_bokeh_tx = b_use_bokeh_tx; | int use_bokeh_tx = b_use_bokeh_tx; | ||||
| if (e_data.dof_resolve_sh[use_bokeh_tx][use_hq_gather] == nullptr) { | if (e_data.dof_resolve_sh[use_bokeh_tx][use_hq_gather] == NULL) { | ||||
| DynStr *ds = BLI_dynstr_new(); | const char *dof_resolve_info_name = NULL; | ||||
| BLI_dynstr_append(ds, DOF_SHADER_DEFINES); | |||||
| BLI_dynstr_append(ds, "#define DOF_RESOLVE_PASS\n"); | |||||
| if (use_bokeh_tx) { | if (b_use_hq_gather) { | ||||
| BLI_dynstr_append(ds, "#define DOF_BOKEH_TEXTURE\n"); | dof_resolve_info_name = (b_use_bokeh_tx) ? "eevee_legacy_depth_of_field_resolve_HQ_BOKEH" : | ||||
| "eevee_legacy_depth_of_field_resolve_HQ"; | |||||
| } | } | ||||
| else { | |||||
| BLI_dynstr_appendf(ds, "#define DOF_SLIGHT_FOCUS_DENSITY %d\n", use_hq_gather ? 4 : 2); | dof_resolve_info_name = (b_use_bokeh_tx) ? "eevee_legacy_depth_of_field_resolve_LQ_BOKEH" : | ||||
| "eevee_legacy_depth_of_field_resolve_LQ"; | |||||
| char *define = BLI_dynstr_get_cstring(ds); | } | ||||
| BLI_dynstr_free(ds); | BLI_assert(dof_resolve_info_name != NULL); | ||||
| e_data.dof_resolve_sh[use_bokeh_tx][use_hq_gather] = DRW_shader_create_from_info_name( | |||||
| e_data.dof_resolve_sh[use_bokeh_tx][use_hq_gather] = | dof_resolve_info_name); | ||||
| DRW_shader_create_fullscreen_with_shaderlib( | |||||
| datatoc_effect_dof_resolve_frag_glsl, e_data.lib, define); | |||||
| MEM_freeN(define); | |||||
| } | } | ||||
| return e_data.dof_resolve_sh[use_bokeh_tx][use_hq_gather]; | return e_data.dof_resolve_sh[use_bokeh_tx][use_hq_gather]; | ||||
| } | } | ||||
| /** \} */ | /** \} */ | ||||
| Material *EEVEE_material_default_diffuse_get(void) | Material *EEVEE_material_default_diffuse_get(void) | ||||
| { | { | ||||
| ▲ Show 20 Lines • Show All 139 Lines • ▼ Show 20 Lines | if (e_data.default_world == nullptr) { | ||||
| copy_v3_fl(&e_data.default_world->horr, 0.0f); | copy_v3_fl(&e_data.default_world->horr, 0.0f); | ||||
| e_data.default_world->use_nodes = 0; | e_data.default_world->use_nodes = 0; | ||||
| e_data.default_world->nodetree = nullptr; | e_data.default_world->nodetree = nullptr; | ||||
| BLI_listbase_clear(&e_data.default_world->gpumaterial); | BLI_listbase_clear(&e_data.default_world->gpumaterial); | ||||
| } | } | ||||
| return e_data.default_world; | return e_data.default_world; | ||||
| } | } | ||||
| static char *eevee_get_defines(int options) | /* Select create info configuration and base source for given material types. | ||||
| { | * Each configuration has an associated base source and create-info. | ||||
| char *str = nullptr; | * Source is provided separately, rather than via create-info as source is manipulated | ||||
| * by `eevee_shader_material_create_info_amend`. | |||||
| DynStr *ds = BLI_dynstr_new(); | * | ||||
| BLI_dynstr_append(ds, SHADER_DEFINES); | * We also retain the previous behaviour for ensuring library includes occur in the | ||||
| * correct order. */ | |||||
| static const char *eevee_get_vert_info(int options, char **r_src) | |||||
| { | |||||
| const char *info_name = NULL; | |||||
| /* Permutations */ | |||||
| const bool is_hair = (options & (VAR_MAT_HAIR)) != 0; | |||||
| const bool is_point_cloud = (options & (VAR_MAT_POINTCLOUD)) != 0; | |||||
| if ((options & VAR_WORLD_BACKGROUND) != 0) { | |||||
| BLI_dynstr_append(ds, "#define WORLD_BACKGROUND\n"); | |||||
| } | |||||
| if ((options & VAR_MAT_VOLUME) != 0) { | if ((options & VAR_MAT_VOLUME) != 0) { | ||||
| BLI_dynstr_append(ds, "#define VOLUMETRICS\n"); | *r_src = DRW_shader_library_create_shader_string(e_data.lib, datatoc_volumetric_vert_glsl); | ||||
| } | info_name = "eevee_legacy_material_volumetric_vert"; | ||||
| if ((options & VAR_MAT_MESH) != 0) { | |||||
| BLI_dynstr_append(ds, "#define MESH_SHADER\n"); | |||||
| } | } | ||||
| if ((options & VAR_MAT_DEPTH) != 0) { | else if ((options & (VAR_WORLD_PROBE | VAR_WORLD_BACKGROUND)) != 0) { | ||||
| BLI_dynstr_append(ds, "#define DEPTH_SHADER\n"); | *r_src = DRW_shader_library_create_shader_string(e_data.lib, datatoc_world_vert_glsl); | ||||
| } | info_name = "eevee_legacy_material_world_vert"; | ||||
| if ((options & VAR_MAT_HAIR) != 0) { | |||||
| BLI_dynstr_append(ds, "#define HAIR_SHADER\n"); | |||||
| } | |||||
| if ((options & VAR_MAT_POINTCLOUD) != 0) { | |||||
| BLI_dynstr_append(ds, "#define POINTCLOUD_SHADER\n"); | |||||
| } | } | ||||
| if ((options & VAR_WORLD_PROBE) != 0) { | else { | ||||
| BLI_dynstr_append(ds, "#define PROBE_CAPTURE\n"); | *r_src = DRW_shader_library_create_shader_string(e_data.lib, datatoc_surface_vert_glsl); | ||||
| if (is_hair) { | |||||
| info_name = "eevee_legacy_mateiral_surface_vert_hair"; | |||||
| } | } | ||||
| if ((options & VAR_MAT_HASH) != 0) { | else if (is_point_cloud) { | ||||
| BLI_dynstr_append(ds, "#define USE_ALPHA_HASH\n"); | info_name = "eevee_legacy_mateiral_surface_vert_pointcloud"; | ||||
| } | } | ||||
| if ((options & VAR_MAT_BLEND) != 0) { | else { | ||||
| BLI_dynstr_append(ds, "#define USE_ALPHA_BLEND\n"); | info_name = "eevee_legacy_material_surface_vert"; | ||||
| } | } | ||||
| if ((options & VAR_MAT_REFRACT) != 0) { | |||||
| BLI_dynstr_append(ds, "#define USE_REFRACTION\n"); | |||||
| } | } | ||||
| if ((options & VAR_MAT_LOOKDEV) != 0) { | |||||
| BLI_dynstr_append(ds, "#define LOOKDEV\n"); | return info_name; | ||||
| } | } | ||||
| if ((options & VAR_MAT_HOLDOUT) != 0) { | |||||
| BLI_dynstr_append(ds, "#define HOLDOUT\n"); | static const char *eevee_get_geom_info(int options, char **r_src) | ||||
| { | |||||
| const char *info_name = NULL; | |||||
| if (GPU_backend_get_type() == GPU_BACKEND_METAL) { | |||||
| /* Geometry shading is unsupported in Metal. Vertex-shader based workarounds will instead | |||||
| * be injected where appropriate. For volumetric rendering, volumetric_vert_no_geom replaces | |||||
| * the default volumetric_vert + volumetric_geom combination. | |||||
| * See: `source/blender/gpu/intern/gpu_shader_create_info.cc` for further details. */ | |||||
| *r_src = NULL; | |||||
| return NULL; | |||||
| } | } | ||||
| str = BLI_dynstr_get_cstring(ds); | if ((options & VAR_MAT_VOLUME) != 0) { | ||||
| BLI_dynstr_free(ds); | *r_src = DRW_shader_library_create_shader_string(e_data.lib, datatoc_volumetric_geom_glsl); | ||||
| info_name = "eevee_legacy_material_volumetric_geom"; | |||||
| } | |||||
| return str; | return info_name; | ||||
| } | } | ||||
| static char *eevee_get_vert(int options) | static const char *eevee_get_frag_info(int options, char **r_src) | ||||
| { | { | ||||
| char *str = nullptr; | const char *info_name = NULL; | ||||
| const bool is_alpha_hash = ((options & VAR_MAT_HASH) != 0); | |||||
| bool is_alpha_blend = ((options & VAR_MAT_BLEND) != 0); | |||||
| const bool is_hair = (options & (VAR_MAT_HAIR)) != 0; | |||||
| const bool is_point_cloud = (options & (VAR_MAT_POINTCLOUD)) != 0; | |||||
| if ((options & VAR_MAT_VOLUME) != 0) { | if ((options & VAR_MAT_VOLUME) != 0) { | ||||
| str = DRW_shader_library_create_shader_string(e_data.lib, datatoc_volumetric_vert_glsl); | /* -- VOLUME FRAG - | ||||
| * Select create info permutation for `volume_frag`. */ | |||||
| info_name = "eevee_legacy_material_volumetric_frag"; | |||||
| *r_src = DRW_shader_library_create_shader_string(e_data.lib, datatoc_volumetric_frag_glsl); | |||||
| } | } | ||||
| else if ((options & (VAR_WORLD_PROBE | VAR_WORLD_BACKGROUND)) != 0) { | else if ((options & VAR_MAT_DEPTH) != 0) { | ||||
| str = DRW_shader_library_create_shader_string(e_data.lib, datatoc_world_vert_glsl); | /* -- PREPASS FRAG - | ||||
| * Select create info permutation for `prepass_frag`. */ | |||||
| if (is_alpha_hash) { | |||||
| /* Alpha hash material variants. */ | |||||
| if (is_hair) { | |||||
| info_name = "eevee_legacy_material_prepass_frag_alpha_hash_hair"; | |||||
| } | |||||
| else if (is_point_cloud) { | |||||
| info_name = "eevee_legacy_material_prepass_frag_alpha_hash_pointcloud"; | |||||
| } | |||||
| else { | |||||
| info_name = "eevee_legacy_material_prepass_frag_alpha_hash"; | |||||
| } | |||||
| } | |||||
| else { | |||||
| /* Opaque material variants. */ | |||||
| if (is_hair) { | |||||
| info_name = "eevee_legacy_material_prepass_frag_opaque_hair"; | |||||
| } | |||||
| else if (is_point_cloud) { | |||||
| info_name = "eevee_legacy_material_prepass_frag_opaque_pointcloud"; | |||||
| } | |||||
| else { | |||||
| info_name = "eevee_legacy_material_prepass_frag_opaque"; | |||||
| } | |||||
| } | |||||
| *r_src = BLI_strdup(e_data.surface_prepass_frag); | |||||
| } | |||||
| else { | |||||
| /* -- SURFACE FRAG -- | |||||
| * Select create info permutation for `surface_frag`. */ | |||||
| if (is_alpha_blend) { | |||||
| info_name = "eevee_legacy_material_surface_frag_alpha_blend"; | |||||
| } | } | ||||
| else { | else { | ||||
| str = DRW_shader_library_create_shader_string(e_data.lib, datatoc_surface_vert_glsl); | info_name = "eevee_legacy_material_surface_frag_opaque"; | ||||
| } | |||||
| *r_src = BLI_strdup(e_data.surface_lit_frag); | |||||
| } | } | ||||
| return str; | return info_name; | ||||
| } | } | ||||
| static char *eevee_get_geom(int options) | static char *eevee_get_defines(int options) | ||||
| { | { | ||||
| char *str = nullptr; | char *str = nullptr; | ||||
| if ((options & VAR_MAT_VOLUME) != 0) { | DynStr *ds = BLI_dynstr_new(); | ||||
| str = DRW_shader_library_create_shader_string(e_data.lib, datatoc_volumetric_geom_glsl); | |||||
| } | |||||
| return str; | /* Global EEVEE defines included for CreateInfo shaders via `engine_eevee_shared_defines.h` in | ||||
| } | * eevee_legacy_common_lib CreateInfo. */ | ||||
| static char *eevee_get_frag(int options) | /* Defines which affect bindings are instead injected via CreateInfo permutations. To specify new | ||||
| { | * permutations, references to GPUShaderCreateInfo variants should be fetched in: | ||||
| char *str = nullptr; | * `eevee_get_vert/geom/frag_info(..)` | ||||
| * | |||||
| * CreateInfo's for EEVEE materials are declared in: | |||||
| * `eevee/shaders/infos/eevee_legacy_material_info.hh` | |||||
| * | |||||
| * This function should only contain defines which alter behaviour, but do not affect shader | |||||
| * resources. */ | |||||
| if ((options & VAR_WORLD_BACKGROUND) != 0) { | |||||
| BLI_dynstr_append(ds, "#define WORLD_BACKGROUND\n"); | |||||
| } | |||||
| if ((options & VAR_MAT_VOLUME) != 0) { | if ((options & VAR_MAT_VOLUME) != 0) { | ||||
| str = DRW_shader_library_create_shader_string(e_data.lib, datatoc_volumetric_frag_glsl); | BLI_dynstr_append(ds, "#define VOLUMETRICS\n"); | ||||
| } | } | ||||
| else if ((options & VAR_MAT_DEPTH) != 0) { | if ((options & VAR_MAT_MESH) != 0) { | ||||
| str = BLI_strdup(e_data.surface_prepass_frag); | BLI_dynstr_append(ds, "#define MESH_SHADER\n"); | ||||
| } | } | ||||
| else { | if ((options & VAR_MAT_DEPTH) != 0) { | ||||
| str = BLI_strdup(e_data.surface_lit_frag); | BLI_dynstr_append(ds, "#define DEPTH_SHADER\n"); | ||||
| } | |||||
| if ((options & VAR_WORLD_PROBE) != 0) { | |||||
| BLI_dynstr_append(ds, "#define PROBE_CAPTURE\n"); | |||||
| } | |||||
| if ((options & VAR_MAT_REFRACT) != 0) { | |||||
| BLI_dynstr_append(ds, "#define USE_REFRACTION\n"); | |||||
| } | |||||
| if ((options & VAR_MAT_HOLDOUT) != 0) { | |||||
| BLI_dynstr_append(ds, "#define HOLDOUT\n"); | |||||
| } | } | ||||
| str = BLI_dynstr_get_cstring(ds); | |||||
| BLI_dynstr_free(ds); | |||||
| return str; | return str; | ||||
| } | } | ||||
| static void eevee_material_post_eval(void *UNUSED(thunk), | static void eevee_material_post_eval(void *UNUSED(thunk), | ||||
| GPUMaterial *mat, | GPUMaterial *mat, | ||||
| GPUCodegenOutput *codegen) | GPUCodegenOutput *codegen) | ||||
| { | { | ||||
| /* Fetch material-specific Create-info's and source. */ | |||||
| uint64_t options = GPU_material_uuid_get(mat); | uint64_t options = GPU_material_uuid_get(mat); | ||||
| char *vert = NULL; | |||||
| char *vert = eevee_get_vert(options); | char *geom = NULL; | ||||
| char *geom = eevee_get_geom(options); | char *frag = NULL; | ||||
| char *frag = eevee_get_frag(options); | |||||
| const char *vert_info_name = eevee_get_vert_info(options, &vert); | |||||
| const char *geom_info_name = eevee_get_geom_info(options, &geom); | |||||
| const char *frag_info_name = eevee_get_frag_info(options, &frag); | |||||
| char *defines = eevee_get_defines(options); | char *defines = eevee_get_defines(options); | ||||
| eevee_shader_material_create_info_amend(mat, codegen, frag, vert, geom, defines); | eevee_shader_material_create_info_amend( | ||||
| mat, codegen, vert, geom, frag, vert_info_name, geom_info_name, frag_info_name, defines); | |||||
| MEM_SAFE_FREE(defines); | MEM_SAFE_FREE(defines); | ||||
| MEM_SAFE_FREE(vert); | MEM_SAFE_FREE(vert); | ||||
| MEM_SAFE_FREE(geom); | MEM_SAFE_FREE(geom); | ||||
| MEM_SAFE_FREE(frag); | MEM_SAFE_FREE(frag); | ||||
| } | } | ||||
| static struct GPUMaterial *eevee_material_get_ex( | static struct GPUMaterial *eevee_material_get_ex( | ||||
| ▲ Show 20 Lines • Show All 59 Lines • ▼ Show 20 Lines | struct GPUMaterial *EEVEE_material_get( | ||||
| } | } | ||||
| /* Returned material should be ready to be drawn. */ | /* Returned material should be ready to be drawn. */ | ||||
| BLI_assert(GPU_material_status(mat) == GPU_MAT_SUCCESS); | BLI_assert(GPU_material_status(mat) == GPU_MAT_SUCCESS); | ||||
| return mat; | return mat; | ||||
| } | } | ||||
| void EEVEE_shaders_free(void) | void EEVEE_shaders_free(void) | ||||
| { | { | ||||
| eevee_shader_extra_exit(); | |||||
| MEM_SAFE_FREE(e_data.surface_prepass_frag); | MEM_SAFE_FREE(e_data.surface_prepass_frag); | ||||
| MEM_SAFE_FREE(e_data.surface_lit_frag); | MEM_SAFE_FREE(e_data.surface_lit_frag); | ||||
| MEM_SAFE_FREE(e_data.surface_geom_barycentric); | MEM_SAFE_FREE(e_data.surface_geom_barycentric); | ||||
| DRW_SHADER_FREE_SAFE(e_data.lookdev_background); | DRW_SHADER_FREE_SAFE(e_data.lookdev_background); | ||||
| DRW_SHADER_FREE_SAFE(e_data.update_noise_sh); | DRW_SHADER_FREE_SAFE(e_data.update_noise_sh); | ||||
| DRW_SHADER_FREE_SAFE(e_data.color_copy_sh); | DRW_SHADER_FREE_SAFE(e_data.color_copy_sh); | ||||
| DRW_SHADER_FREE_SAFE(e_data.downsample_sh); | DRW_SHADER_FREE_SAFE(e_data.downsample_sh); | ||||
| DRW_SHADER_FREE_SAFE(e_data.downsample_cube_sh); | DRW_SHADER_FREE_SAFE(e_data.downsample_cube_sh); | ||||
| ▲ Show 20 Lines • Show All 107 Lines • Show Last 20 Lines | |||||