[Bf-blender-cvs] [9034351b8de] tmp-eevee-glsl-cleanup: Merge branch 'master' into tmp-eevee-glsl-cleanup

Clément Foucault noreply at git.blender.org
Wed Jul 15 13:41:00 CEST 2020


Commit: 9034351b8def3c3fd3b8d001a559dd91e2f28c14
Author: Clément Foucault
Date:   Wed Jul 15 14:23:59 2020 +0200
Branches: tmp-eevee-glsl-cleanup
https://developer.blender.org/rB9034351b8def3c3fd3b8d001a559dd91e2f28c14

Merge branch 'master' into tmp-eevee-glsl-cleanup

===================================================================



===================================================================

diff --cc source/blender/draw/engines/eevee/eevee_lookdev.c
index 7a4e2eb1cb4,b89772441fa..403a8e2af55
--- a/source/blender/draw/engines/eevee/eevee_lookdev.c
+++ b/source/blender/draw/engines/eevee/eevee_lookdev.c
@@@ -149,90 -150,94 +149,91 @@@ void EEVEE_lookdev_cache_init(EEVEE_Dat
    }
  
    if (LOOK_DEV_STUDIO_LIGHT_ENABLED(v3d)) {
+     const View3DShading *shading = &v3d->shading;
      StudioLight *sl = BKE_studiolight_find(shading->lookdev_light,
                                             STUDIOLIGHT_ORIENTATIONS_MATERIAL_MODE);
 -    if (sl && (sl->flag & STUDIOLIGHT_TYPE_WORLD)) {
 -      GPUShader *shader = probe_render ? EEVEE_shaders_default_studiolight_sh_get() :
 -                                         EEVEE_shaders_background_studiolight_sh_get();
 +    if (sl == NULL || (sl->flag & STUDIOLIGHT_TYPE_WORLD) == 0) {
 +      return;
 +    }
 +
 +    GPUShader *shader = probe_render ? EEVEE_shaders_studiolight_probe_sh_get() :
 +                                       EEVEE_shaders_studiolight_background_sh_get();
  
 -      const Scene *scene_eval = DEG_get_evaluated_scene(draw_ctx->depsgraph);
 -      int cube_res = scene_eval->eevee.gi_cubemap_resolution;
 +    const Scene *scene_eval = DEG_get_evaluated_scene(draw_ctx->depsgraph);
 +    int cube_res = scene_eval->eevee.gi_cubemap_resolution;
  
 -      /* If one of the component is missing we start from scratch. */
 -      if ((stl->lookdev_grid_data == NULL) || (stl->lookdev_cube_data == NULL) ||
 -          (txl->lookdev_grid_tx == NULL) || (txl->lookdev_cube_tx == NULL) ||
 -          (g_data->light_cache && g_data->light_cache->ref_res != cube_res)) {
 -        eevee_lookdev_lightcache_delete(vedata);
 -      }
 +    /* If one of the component is missing we start from scratch. */
 +    if ((stl->lookdev_grid_data == NULL) || (stl->lookdev_cube_data == NULL) ||
 +        (txl->lookdev_grid_tx == NULL) || (txl->lookdev_cube_tx == NULL) ||
 +        (g_data->light_cache && g_data->light_cache->ref_res != cube_res)) {
 +      eevee_lookdev_lightcache_delete(vedata);
 +    }
  
 -      if (stl->lookdev_lightcache == NULL) {
 +    if (stl->lookdev_lightcache == NULL) {
  #if defined(IRRADIANCE_SH_L2)
 -        int grid_res = 4;
 -#elif defined(IRRADIANCE_CUBEMAP)
 -        int grid_res = 8;
 +      int grid_res = 4;
  #elif defined(IRRADIANCE_HL2)
 -        int grid_res = 4;
 +      int grid_res = 4;
  #endif
  
 -        stl->lookdev_lightcache = EEVEE_lightcache_create(
 -            1, 1, cube_res, 8, (int[3]){grid_res, grid_res, 1});
 -
 -        /* XXX: Fix memleak. TODO find out why. */
 -        MEM_SAFE_FREE(stl->lookdev_cube_mips);
 -
 -        /* We do this to use a special light cache for lookdev.
 -         * This light-cache needs to be per viewport. But we need to
 -         * have correct freeing when the viewport is closed. So we
 -         * need to reference all textures to the txl and the memblocks
 -         * to the stl. */
 -        stl->lookdev_grid_data = stl->lookdev_lightcache->grid_data;
 -        stl->lookdev_cube_data = stl->lookdev_lightcache->cube_data;
 -        stl->lookdev_cube_mips = stl->lookdev_lightcache->cube_mips;
 -        txl->lookdev_grid_tx = stl->lookdev_lightcache->grid_tx.tex;
 -        txl->lookdev_cube_tx = stl->lookdev_lightcache->cube_tx.tex;
 -      }
 -
 -      g_data->light_cache = stl->lookdev_lightcache;
 -
 -      DRWShadingGroup *grp = *r_grp = DRW_shgroup_create(shader, pass);
 -      axis_angle_to_mat3_single(g_data->studiolight_matrix, 'Z', shading->studiolight_rot_z);
 -      DRW_shgroup_uniform_mat3(grp, "StudioLightMatrix", g_data->studiolight_matrix);
 -
 -      if (probe_render) {
 -        DRW_shgroup_uniform_float_copy(
 -            grp, "studioLightIntensity", shading->studiolight_intensity);
 -        BKE_studiolight_ensure_flag(sl, STUDIOLIGHT_EQUIRECT_RADIANCE_GPUTEXTURE);
 -        DRW_shgroup_uniform_texture(grp, "image", sl->equirect_radiance_gputexture);
 -        /* Do not fadeout when doing probe rendering, only when drawing the background */
 -        DRW_shgroup_uniform_float_copy(grp, "backgroundAlpha", 1.0f);
 -      }
 -      else {
 -        float background_alpha = g_data->background_alpha * shading->studiolight_background;
 -        float studiolight_blur = powf(shading->studiolight_blur, 2.5f);
 -        DRW_shgroup_uniform_float_copy(grp, "backgroundAlpha", background_alpha);
 -        DRW_shgroup_uniform_float_copy(grp, "studioLightBlur", studiolight_blur);
 -        DRW_shgroup_uniform_texture(grp, "probeCubes", txl->lookdev_cube_tx);
 -        DRW_shgroup_uniform_block(grp, "probe_block", sldata->probe_ubo);
 -        DRW_shgroup_uniform_block(grp, "grid_block", sldata->grid_ubo);
 -        DRW_shgroup_uniform_block(grp, "planar_block", sldata->planar_ubo);
 -        DRW_shgroup_uniform_block(grp, "common_block", sldata->common_ubo);
 -        DRW_shgroup_uniform_block(grp, "renderpass_block", sldata->renderpass_ubo.combined);
 -      }
 -
 -      DRW_shgroup_call(grp, DRW_cache_fullscreen_quad_get(), NULL);
 -
 -      /* Do we need to recalc the lightprobes? */
 -      if (g_data->studiolight_index != sl->index ||
 -          g_data->studiolight_rot_z != shading->studiolight_rot_z ||
 -          g_data->studiolight_intensity != shading->studiolight_intensity ||
 -          g_data->studiolight_cubemap_res != scene->eevee.gi_cubemap_resolution ||
 -          g_data->studiolight_glossy_clamp != scene->eevee.gi_glossy_clamp ||
 -          g_data->studiolight_filter_quality != scene->eevee.gi_filter_quality) {
 -        stl->lookdev_lightcache->flag |= LIGHTCACHE_UPDATE_WORLD;
 -        g_data->studiolight_index = sl->index;
 -        g_data->studiolight_rot_z = shading->studiolight_rot_z;
 -        g_data->studiolight_intensity = shading->studiolight_intensity;
 -        g_data->studiolight_cubemap_res = scene->eevee.gi_cubemap_resolution;
 -        g_data->studiolight_glossy_clamp = scene->eevee.gi_glossy_clamp;
 -        g_data->studiolight_filter_quality = scene->eevee.gi_filter_quality;
 -      }
 +      stl->lookdev_lightcache = EEVEE_lightcache_create(
 +          1, 1, cube_res, 8, (int[3]){grid_res, grid_res, 1});
 +
 +      /* XXX: Fix memleak. TODO find out why. */
 +      MEM_SAFE_FREE(stl->lookdev_cube_mips);
 +
 +      /* We do this to use a special light cache for lookdev.
 +       * This light-cache needs to be per viewport. But we need to
 +       * have correct freeing when the viewport is closed. So we
 +       * need to reference all textures to the txl and the memblocks
 +       * to the stl. */
 +      stl->lookdev_grid_data = stl->lookdev_lightcache->grid_data;
 +      stl->lookdev_cube_data = stl->lookdev_lightcache->cube_data;
 +      stl->lookdev_cube_mips = stl->lookdev_lightcache->cube_mips;
 +      txl->lookdev_grid_tx = stl->lookdev_lightcache->grid_tx.tex;
 +      txl->lookdev_cube_tx = stl->lookdev_lightcache->cube_tx.tex;
 +    }
 +
 +    g_data->light_cache = stl->lookdev_lightcache;
 +
 +    DRWShadingGroup *grp = DRW_shgroup_create(shader, pass);
 +    axis_angle_to_mat3_single(g_data->studiolight_matrix, 'Z', shading->studiolight_rot_z);
 +    DRW_shgroup_uniform_mat3(grp, "StudioLightMatrix", g_data->studiolight_matrix);
 +
 +    if (probe_render) {
 +      /* Avoid artifact with equirectangular mapping. */
 +      eGPUSamplerState state = (GPU_SAMPLER_FILTER | GPU_SAMPLER_REPEAT_S);
 +      DRW_shgroup_uniform_float_copy(grp, "studioLightIntensity", shading->studiolight_intensity);
 +      BKE_studiolight_ensure_flag(sl, STUDIOLIGHT_EQUIRECT_RADIANCE_GPUTEXTURE);
 +      DRW_shgroup_uniform_texture_ex(grp, "studioLight", sl->equirect_radiance_gputexture, state);
 +      /* Do not fadeout when doing probe rendering, only when drawing the background */
 +      DRW_shgroup_uniform_float_copy(grp, "backgroundAlpha", 1.0f);
 +    }
 +    else {
 +      float background_alpha = g_data->background_alpha * shading->studiolight_background;
 +      float studiolight_blur = powf(shading->studiolight_blur, 2.5f);
 +      DRW_shgroup_uniform_float_copy(grp, "backgroundAlpha", background_alpha);
 +      DRW_shgroup_uniform_float_copy(grp, "studioLightBlur", studiolight_blur);
 +      DRW_shgroup_uniform_texture(grp, "probeCubes", txl->lookdev_cube_tx);
 +    }
 +
 +    /* Common UBOs are setup latter. */
 +    *r_shgrp = grp;
 +
 +    /* Do we need to recalc the lightprobes? */
 +    if (g_data->studiolight_index != sl->index ||
 +        g_data->studiolight_rot_z != shading->studiolight_rot_z ||
 +        g_data->studiolight_intensity != shading->studiolight_intensity ||
 +        g_data->studiolight_cubemap_res != scene->eevee.gi_cubemap_resolution ||
 +        g_data->studiolight_glossy_clamp != scene->eevee.gi_glossy_clamp ||
 +        g_data->studiolight_filter_quality != scene->eevee.gi_filter_quality) {
 +      stl->lookdev_lightcache->flag |= LIGHTCACHE_UPDATE_WORLD;
 +      g_data->studiolight_index = sl->index;
 +      g_data->studiolight_rot_z = shading->studiolight_rot_z;
 +      g_data->studiolight_intensity = shading->studiolight_intensity;
 +      g_data->studiolight_cubemap_res = scene->eevee.gi_cubemap_resolution;
 +      g_data->studiolight_glossy_clamp = scene->eevee.gi_glossy_clamp;
 +      g_data->studiolight_filter_quality = scene->eevee.gi_filter_quality;
      }
    }
  }



More information about the Bf-blender-cvs mailing list