Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/draw')
-rw-r--r--source/blender/draw/engines/eevee/eevee_engine.c2
-rw-r--r--source/blender/draw/engines/eevee/eevee_materials.c277
-rw-r--r--source/blender/draw/engines/eevee/eevee_private.h8
-rw-r--r--source/blender/draw/engines/eevee/eevee_render.c2
-rw-r--r--source/blender/draw/engines/eevee/eevee_renderpasses.c12
-rw-r--r--source/blender/draw/engines/eevee/shaders/default_world_frag.glsl4
-rw-r--r--source/blender/draw/engines/eevee/shaders/effect_bloom_frag.glsl6
-rw-r--r--source/blender/draw/engines/eevee/shaders/renderpass_postprocess_frag.glsl64
-rw-r--r--source/blender/draw/engines/eevee/shaders/shadow_accum_frag.glsl8
-rw-r--r--source/blender/draw/engines/overlay/shaders/motion_path_line_vert.glsl9
-rw-r--r--source/blender/draw/intern/draw_cache.c48
-rw-r--r--source/blender/draw/intern/draw_manager_data.c38
-rw-r--r--source/blender/draw/intern/shaders/common_view_lib.glsl1
13 files changed, 252 insertions, 227 deletions
diff --git a/source/blender/draw/engines/eevee/eevee_engine.c b/source/blender/draw/engines/eevee/eevee_engine.c
index 6480847092b..a886fa26589 100644
--- a/source/blender/draw/engines/eevee/eevee_engine.c
+++ b/source/blender/draw/engines/eevee/eevee_engine.c
@@ -120,7 +120,7 @@ void EEVEE_cache_populate(void *vedata, Object *ob)
bool cast_shadow = false;
if (ob_visibility & OB_VISIBLE_PARTICLES) {
- EEVEE_hair_cache_populate(vedata, sldata, ob, &cast_shadow);
+ EEVEE_particle_hair_cache_populate(vedata, sldata, ob, &cast_shadow);
}
if (DRW_object_is_renderable(ob) && (ob_visibility & OB_VISIBLE_SELF)) {
diff --git a/source/blender/draw/engines/eevee/eevee_materials.c b/source/blender/draw/engines/eevee/eevee_materials.c
index 7661dfb41a5..89e45148ee8 100644
--- a/source/blender/draw/engines/eevee/eevee_materials.c
+++ b/source/blender/draw/engines/eevee/eevee_materials.c
@@ -1728,6 +1728,144 @@ BLI_INLINE Material *eevee_object_material_get(Object *ob, int slot)
return ma;
}
+static void eevee_hair_cache_populate(EEVEE_Data *vedata,
+ EEVEE_ViewLayerData *sldata,
+ Object *ob,
+ ParticleSystem *psys,
+ ModifierData *md,
+ int matnr,
+ bool *cast_shadow)
+{
+ EEVEE_PassList *psl = vedata->psl;
+ EEVEE_StorageList *stl = vedata->stl;
+ const DRWContextState *draw_ctx = DRW_context_state_get();
+ Scene *scene = draw_ctx->scene;
+
+ DRWShadingGroup *shgrp = NULL;
+ Material *ma = eevee_object_material_get(ob, matnr - 1);
+
+ float *color_p = &ma->r;
+ float *metal_p = &ma->metallic;
+ float *spec_p = &ma->spec;
+ float *rough_p = &ma->roughness;
+
+ bool use_ssr = ((stl->effects->enabled_effects & EFFECT_SSR) != 0);
+ const bool holdout = (ob->base_flag & BASE_HOLDOUT) != 0;
+
+ shgrp = DRW_shgroup_hair_create(ob, psys, md, psl->depth_pass, e_data.default_hair_prepass_sh);
+
+ shgrp = DRW_shgroup_hair_create(
+ ob, psys, md, psl->depth_pass_clip, e_data.default_hair_prepass_clip_sh);
+
+ shgrp = NULL;
+
+ if (ma->use_nodes && ma->nodetree && !holdout) {
+ static int ssr_id;
+ ssr_id = (use_ssr) ? 1 : -1;
+ static float half = 0.5f;
+ static float error_col[3] = {1.0f, 0.0f, 1.0f};
+ static float compile_col[3] = {0.5f, 0.5f, 0.5f};
+ struct GPUMaterial *gpumat = EEVEE_material_hair_get(scene, ma);
+
+ switch (GPU_material_status(gpumat)) {
+ case GPU_MAT_SUCCESS: {
+ bool use_diffuse = GPU_material_flag_get(gpumat, GPU_MATFLAG_DIFFUSE);
+ bool use_glossy = GPU_material_flag_get(gpumat, GPU_MATFLAG_GLOSSY);
+ bool use_refract = GPU_material_flag_get(gpumat, GPU_MATFLAG_REFRACT);
+
+ shgrp = DRW_shgroup_material_hair_create(ob, psys, md, psl->material_pass, gpumat);
+
+ if (!use_diffuse && !use_glossy && !use_refract) {
+ /* HACK: Small hack to avoid issue when utilTex is needed for
+ * world_normals_get and none of the bsdfs are present.
+ * This binds utilTex even if not needed. */
+ DRW_shgroup_uniform_texture(shgrp, "utilTex", e_data.util_tex);
+ }
+
+ add_standard_uniforms(shgrp,
+ sldata,
+ vedata,
+ &ssr_id,
+ NULL,
+ use_diffuse,
+ use_glossy,
+ use_refract,
+ false,
+ false,
+ DEFAULT_RENDER_PASS_FLAG);
+
+ /* Add the hair to all the render_passes that are enabled */
+ RENDER_PASS_ITER_BEGIN(stl->g_data->render_passes, render_pass_index, render_pass_flag)
+ shgrp = DRW_shgroup_material_hair_create(
+ ob, psys, md, psl->material_accum_pass[render_pass_index], gpumat);
+ if (!use_diffuse && !use_glossy && !use_refract) {
+ /* Small hack to avoid issue when utilTex is needed for
+ * world_normals_get and none of the bsdfs that need it are present.
+ * This binds `utilTex` even if not needed. */
+ DRW_shgroup_uniform_texture(shgrp, "utilTex", e_data.util_tex);
+ }
+
+ add_standard_uniforms(shgrp,
+ sldata,
+ vedata,
+ &ssr_id,
+ NULL,
+ use_diffuse,
+ use_glossy,
+ use_refract,
+ false,
+ false,
+ render_pass_flag);
+ RENDER_PASS_ITER_END(render_pass_index)
+
+ break;
+ }
+ case GPU_MAT_QUEUED: {
+ stl->g_data->queued_shaders_count++;
+ color_p = compile_col;
+ metal_p = spec_p = rough_p = ½
+ break;
+ }
+ case GPU_MAT_FAILED:
+ default:
+ color_p = error_col;
+ metal_p = spec_p = rough_p = ½
+ break;
+ }
+ }
+
+ /* Fallback to default shader */
+ if (shgrp == NULL) {
+ shgrp = EEVEE_default_shading_group_get(sldata, vedata, ob, psys, md, true, holdout, use_ssr);
+ DRW_shgroup_uniform_vec3(shgrp, "basecol", color_p, 1);
+ DRW_shgroup_uniform_float(shgrp, "metallic", metal_p, 1);
+ DRW_shgroup_uniform_float(shgrp, "specular", spec_p, 1);
+ DRW_shgroup_uniform_float(shgrp, "roughness", rough_p, 1);
+
+ RENDER_PASS_ITER_BEGIN(stl->g_data->render_passes, render_pass_index, render_pass_flag)
+ shgrp = EEVEE_default_hair_render_pass_shading_group_get(
+ sldata,
+ vedata,
+ ob,
+ psys,
+ md,
+ holdout,
+ use_ssr,
+ psl->material_accum_pass[render_pass_index],
+ render_pass_flag);
+
+ DRW_shgroup_uniform_vec3(shgrp, "basecol", color_p, 1);
+ DRW_shgroup_uniform_float(shgrp, "metallic", metal_p, 1);
+ DRW_shgroup_uniform_float(shgrp, "specular", spec_p, 1);
+ DRW_shgroup_uniform_float(shgrp, "roughness", rough_p, 1);
+ RENDER_PASS_ITER_END(render_pass_index)
+ }
+
+ /* Shadows */
+ DRW_shgroup_hair_create(ob, psys, md, psl->shadow_pass, e_data.default_hair_prepass_sh);
+ *cast_shadow = true;
+}
+
void EEVEE_materials_cache_populate(EEVEE_Data *vedata,
EEVEE_ViewLayerData *sldata,
Object *ob,
@@ -1906,18 +2044,12 @@ void EEVEE_materials_cache_populate(EEVEE_Data *vedata,
}
}
-void EEVEE_hair_cache_populate(EEVEE_Data *vedata,
- EEVEE_ViewLayerData *sldata,
- Object *ob,
- bool *cast_shadow)
+void EEVEE_particle_hair_cache_populate(EEVEE_Data *vedata,
+ EEVEE_ViewLayerData *sldata,
+ Object *ob,
+ bool *cast_shadow)
{
- EEVEE_PassList *psl = vedata->psl;
- EEVEE_StorageList *stl = vedata->stl;
const DRWContextState *draw_ctx = DRW_context_state_get();
- Scene *scene = draw_ctx->scene;
-
- bool use_ssr = ((stl->effects->enabled_effects & EFFECT_SSR) != 0);
- const bool holdout = (ob->base_flag & BASE_HOLDOUT) != 0;
if (ob->type == OB_MESH) {
if (ob != draw_ctx->object_edit) {
@@ -1934,130 +2066,7 @@ void EEVEE_hair_cache_populate(EEVEE_Data *vedata,
if (draw_as != PART_DRAW_PATH) {
continue;
}
-
- DRWShadingGroup *shgrp = NULL;
- Material *ma = eevee_object_material_get(ob, part->omat - 1);
-
- float *color_p = &ma->r;
- float *metal_p = &ma->metallic;
- float *spec_p = &ma->spec;
- float *rough_p = &ma->roughness;
-
- shgrp = DRW_shgroup_hair_create(
- ob, psys, md, psl->depth_pass, e_data.default_hair_prepass_sh);
-
- shgrp = DRW_shgroup_hair_create(
- ob, psys, md, psl->depth_pass_clip, e_data.default_hair_prepass_clip_sh);
-
- shgrp = NULL;
-
- if (ma->use_nodes && ma->nodetree && !holdout) {
- static int ssr_id;
- ssr_id = (use_ssr) ? 1 : -1;
- static float half = 0.5f;
- static float error_col[3] = {1.0f, 0.0f, 1.0f};
- static float compile_col[3] = {0.5f, 0.5f, 0.5f};
- struct GPUMaterial *gpumat = EEVEE_material_hair_get(scene, ma);
-
- switch (GPU_material_status(gpumat)) {
- case GPU_MAT_SUCCESS: {
- bool use_diffuse = GPU_material_flag_get(gpumat, GPU_MATFLAG_DIFFUSE);
- bool use_glossy = GPU_material_flag_get(gpumat, GPU_MATFLAG_GLOSSY);
- bool use_refract = GPU_material_flag_get(gpumat, GPU_MATFLAG_REFRACT);
-
- shgrp = DRW_shgroup_material_hair_create(ob, psys, md, psl->material_pass, gpumat);
-
- if (!use_diffuse && !use_glossy && !use_refract) {
- /* HACK: Small hack to avoid issue when utilTex is needed for
- * world_normals_get and none of the bsdfs are present.
- * This binds utilTex even if not needed. */
- DRW_shgroup_uniform_texture(shgrp, "utilTex", e_data.util_tex);
- }
-
- add_standard_uniforms(shgrp,
- sldata,
- vedata,
- &ssr_id,
- NULL,
- use_diffuse,
- use_glossy,
- use_refract,
- false,
- false,
- DEFAULT_RENDER_PASS_FLAG);
-
- /* Add the hair to all the render_passes that are enabled */
- RENDER_PASS_ITER_BEGIN(
- stl->g_data->render_passes, render_pass_index, render_pass_flag)
- shgrp = DRW_shgroup_material_hair_create(
- ob, psys, md, psl->material_accum_pass[render_pass_index], gpumat);
- if (!use_diffuse && !use_glossy && !use_refract) {
- /* Small hack to avoid issue when utilTex is needed for
- * world_normals_get and none of the bsdfs that need it are present.
- * This binds `utilTex` even if not needed. */
- DRW_shgroup_uniform_texture(shgrp, "utilTex", e_data.util_tex);
- }
-
- add_standard_uniforms(shgrp,
- sldata,
- vedata,
- &ssr_id,
- NULL,
- use_diffuse,
- use_glossy,
- use_refract,
- false,
- false,
- render_pass_flag);
- RENDER_PASS_ITER_END(render_pass_index)
-
- break;
- }
- case GPU_MAT_QUEUED: {
- stl->g_data->queued_shaders_count++;
- color_p = compile_col;
- metal_p = spec_p = rough_p = ½
- break;
- }
- case GPU_MAT_FAILED:
- default:
- color_p = error_col;
- metal_p = spec_p = rough_p = ½
- break;
- }
- }
-
- /* Fallback to default shader */
- if (shgrp == NULL) {
- shgrp = EEVEE_default_shading_group_get(
- sldata, vedata, ob, psys, md, true, holdout, use_ssr);
- DRW_shgroup_uniform_vec3(shgrp, "basecol", color_p, 1);
- DRW_shgroup_uniform_float(shgrp, "metallic", metal_p, 1);
- DRW_shgroup_uniform_float(shgrp, "specular", spec_p, 1);
- DRW_shgroup_uniform_float(shgrp, "roughness", rough_p, 1);
-
- RENDER_PASS_ITER_BEGIN(stl->g_data->render_passes, render_pass_index, render_pass_flag)
- shgrp = EEVEE_default_hair_render_pass_shading_group_get(
- sldata,
- vedata,
- ob,
- psys,
- md,
- holdout,
- use_ssr,
- psl->material_accum_pass[render_pass_index],
- render_pass_flag);
-
- DRW_shgroup_uniform_vec3(shgrp, "basecol", color_p, 1);
- DRW_shgroup_uniform_float(shgrp, "metallic", metal_p, 1);
- DRW_shgroup_uniform_float(shgrp, "specular", spec_p, 1);
- DRW_shgroup_uniform_float(shgrp, "roughness", rough_p, 1);
- RENDER_PASS_ITER_END(render_pass_index)
- }
-
- /* Shadows */
- DRW_shgroup_hair_create(ob, psys, md, psl->shadow_pass, e_data.default_hair_prepass_sh);
- *cast_shadow = true;
+ eevee_hair_cache_populate(vedata, sldata, ob, psys, md, part->omat, cast_shadow);
}
}
}
diff --git a/source/blender/draw/engines/eevee/eevee_private.h b/source/blender/draw/engines/eevee/eevee_private.h
index a2ed0a16d89..9a8b2cb793a 100644
--- a/source/blender/draw/engines/eevee/eevee_private.h
+++ b/source/blender/draw/engines/eevee/eevee_private.h
@@ -897,10 +897,10 @@ void EEVEE_materials_cache_populate(EEVEE_Data *vedata,
EEVEE_ViewLayerData *sldata,
Object *ob,
bool *cast_shadow);
-void EEVEE_hair_cache_populate(EEVEE_Data *vedata,
- EEVEE_ViewLayerData *sldata,
- Object *ob,
- bool *cast_shadow);
+void EEVEE_particle_hair_cache_populate(EEVEE_Data *vedata,
+ EEVEE_ViewLayerData *sldata,
+ Object *ob,
+ bool *cast_shadow);
void EEVEE_materials_cache_finish(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata);
struct GPUMaterial *EEVEE_material_world_lightprobe_get(struct Scene *scene, struct World *wo);
struct GPUMaterial *EEVEE_material_world_background_get(struct Scene *scene, struct World *wo);
diff --git a/source/blender/draw/engines/eevee/eevee_render.c b/source/blender/draw/engines/eevee/eevee_render.c
index 3a5d9e96b80..ed81665bcfb 100644
--- a/source/blender/draw/engines/eevee/eevee_render.c
+++ b/source/blender/draw/engines/eevee/eevee_render.c
@@ -204,7 +204,7 @@ void EEVEE_render_cache(void *vedata,
const int ob_visibility = DRW_object_visibility_in_active_context(ob);
if (ob_visibility & OB_VISIBLE_PARTICLES) {
- EEVEE_hair_cache_populate(vedata, sldata, ob, &cast_shadow);
+ EEVEE_particle_hair_cache_populate(vedata, sldata, ob, &cast_shadow);
}
if (ob_visibility & OB_VISIBLE_SELF) {
diff --git a/source/blender/draw/engines/eevee/eevee_renderpasses.c b/source/blender/draw/engines/eevee/eevee_renderpasses.c
index 2f9e8f3d555..e9dcb6376bb 100644
--- a/source/blender/draw/engines/eevee/eevee_renderpasses.c
+++ b/source/blender/draw/engines/eevee/eevee_renderpasses.c
@@ -88,7 +88,17 @@ void EEVEE_renderpasses_init(EEVEE_Data *vedata)
View3D *v3d = draw_ctx->v3d;
if (v3d) {
- g_data->render_passes = v3d->shading.render_pass;
+ const Scene *scene = draw_ctx->scene;
+ eViewLayerEEVEEPassType render_pass = v3d->shading.render_pass;
+ if (render_pass == EEVEE_RENDER_PASS_AO &&
+ ((scene->eevee.flag & SCE_EEVEE_GTAO_ENABLED) == 0)) {
+ render_pass = EEVEE_RENDER_PASS_COMBINED;
+ }
+ else if (render_pass == EEVEE_RENDER_PASS_BLOOM &&
+ ((scene->eevee.flag & SCE_EEVEE_BLOOM_ENABLED) == 0)) {
+ render_pass = EEVEE_RENDER_PASS_COMBINED;
+ }
+ g_data->render_passes = render_pass;
}
else {
eViewLayerEEVEEPassType enabled_render_passes = view_layer->eevee.render_passes;
diff --git a/source/blender/draw/engines/eevee/shaders/default_world_frag.glsl b/source/blender/draw/engines/eevee/shaders/default_world_frag.glsl
index 1faa02fd354..8c876cf582c 100644
--- a/source/blender/draw/engines/eevee/shaders/default_world_frag.glsl
+++ b/source/blender/draw/engines/eevee/shaders/default_world_frag.glsl
@@ -12,7 +12,9 @@ uniform float studioLightIntensity = 1.0;
uniform float studioLightBlur = 0.0;
in vec3 viewPosition;
-# define M_PI 3.14159265358979323846
+# ifndef M_PI
+# define M_PI 3.14159265358979323846
+# endif
vec3 background_transform_to_world(vec3 viewvec)
{
diff --git a/source/blender/draw/engines/eevee/shaders/effect_bloom_frag.glsl b/source/blender/draw/engines/eevee/shaders/effect_bloom_frag.glsl
index 18f92c0dd33..489e87e9a7d 100644
--- a/source/blender/draw/engines/eevee/shaders/effect_bloom_frag.glsl
+++ b/source/blender/draw/engines/eevee/shaders/effect_bloom_frag.glsl
@@ -202,9 +202,9 @@ vec4 step_resolve(void)
#else
vec3 blur = upsample_filter(sourceBuffer, uvcoordsvar.xy, sourceBufferTexelSize);
#endif
- vec3 base = bloomAddBase ? textureLod(baseBuffer, uvcoordsvar.xy, 0.0).rgb : vec3(0.0);
- vec3 cout = base + blur * bloomColor;
- return vec4(cout, 1.0);
+ vec4 base = bloomAddBase ? textureLod(baseBuffer, uvcoordsvar.xy, 0.0) : vec4(0.0);
+ vec3 cout = base.rgb + blur * bloomColor;
+ return vec4(cout, base.a);
}
void main(void)
diff --git a/source/blender/draw/engines/eevee/shaders/renderpass_postprocess_frag.glsl b/source/blender/draw/engines/eevee/shaders/renderpass_postprocess_frag.glsl
index 5214301bc03..03520c55a85 100644
--- a/source/blender/draw/engines/eevee/shaders/renderpass_postprocess_frag.glsl
+++ b/source/blender/draw/engines/eevee/shaders/renderpass_postprocess_frag.glsl
@@ -15,6 +15,38 @@ uniform sampler2D inputColorBuffer;
out vec4 fragColor;
+vec3 safe_divide_even_color(vec3 a, vec3 b)
+{
+ vec3 result = vec3((b.r != 0.0) ? a.r / b.r : 0.0,
+ (b.g != 0.0) ? a.g / b.g : 0.0,
+ (b.b != 0.0) ? a.b / b.b : 0.0);
+ /* try to get gray even if b is zero */
+ if (b.r == 0.0) {
+ if (b.g == 0.0) {
+ result = result.bbb;
+ }
+ else if (b.b == 0.0) {
+ result = result.ggg;
+ }
+ else {
+ result.r = 0.5 * (result.g + result.b);
+ }
+ }
+ else if (b.g == 0.0) {
+ if (b.b == 0.0) {
+ result = result.rrr;
+ }
+ else {
+ result.g = 0.5 * (result.r + result.b);
+ }
+ }
+ else if (b.b == 0.0) {
+ result.b = 0.5 * (result.r + result.g);
+ }
+
+ return result;
+}
+
void main()
{
ivec2 texel = ivec2(gl_FragCoord.xy);
@@ -58,41 +90,13 @@ void main()
else if (postProcessType == PASS_POST_ACCUMULATED_LIGHT) {
vec3 accumulated_light = texelFetch(inputBuffer, texel, 0).rgb;
vec3 accumulated_color = texelFetch(inputColorBuffer, texel, 0).rgb;
-
- /* Fix INF in the case a color component is 0.0 */
- if (accumulated_color.r == 0.0) {
- accumulated_color.r = 1.0;
- accumulated_light.r = 0.0;
- }
- if (accumulated_color.g == 0.0) {
- accumulated_color.g = 1.0;
- accumulated_light.g = 0.0;
- }
- if (accumulated_color.b == 0.0) {
- accumulated_color.b = 1.0;
- accumulated_light.b = 0.0;
- }
- fragColor = vec4(accumulated_light / accumulated_color, 1.0);
+ fragColor = vec4(safe_divide_even_color(accumulated_light, accumulated_color), 1.0);
}
else if (postProcessType == PASS_POST_TWO_LIGHT_BUFFERS) {
vec3 accumulated_light = texelFetch(inputBuffer, texel, 0).rgb +
texelFetch(inputSecondLightBuffer, texel, 0).rgb;
vec3 accumulated_color = texelFetch(inputColorBuffer, texel, 0).rgb;
-
- /* Fix INF in the case a color component is 0.0 */
- if (accumulated_color.r == 0.0) {
- accumulated_color.r = 1.0;
- accumulated_light.r = 0.0;
- }
- if (accumulated_color.g == 0.0) {
- accumulated_color.g = 1.0;
- accumulated_light.g = 0.0;
- }
- if (accumulated_color.b == 0.0) {
- accumulated_color.b = 1.0;
- accumulated_light.b = 0.0;
- }
- fragColor = vec4(accumulated_light / accumulated_color, 1.0);
+ fragColor = vec4(safe_divide_even_color(accumulated_light, accumulated_color), 1.0);
}
else {
/* Output error color: Unknown how to post process this pass. */
diff --git a/source/blender/draw/engines/eevee/shaders/shadow_accum_frag.glsl b/source/blender/draw/engines/eevee/shaders/shadow_accum_frag.glsl
index fa02bee45b7..5778f02f692 100644
--- a/source/blender/draw/engines/eevee/shaders/shadow_accum_frag.glsl
+++ b/source/blender/draw/engines/eevee/shaders/shadow_accum_frag.glsl
@@ -11,7 +11,7 @@ void main()
{
if (laNumLight == 0) {
/* Early exit: No lights in scene */
- fragColor.r = 0.0;
+ fragColor.r = 1.0;
return;
}
@@ -19,7 +19,7 @@ void main()
float depth = texelFetch(depthBuffer, texel, 0).r;
if (depth == 1.0f) {
/* Early exit background does not receive shadows */
- fragColor.r = 1.0;
+ fragColor.r = 0.0;
return;
}
@@ -40,6 +40,7 @@ void main()
vec3 worldPosition = transform_point(ViewMatrixInverse, viewPosition);
vec3 true_normal = normalize(cross(dFdx(viewPosition), dFdy(viewPosition)));
+ vec3 N = normal_view_to_world(true_normal);
for (int i = 0; i < MAX_LIGHT && i < laNumLight; i++) {
LightData ld = lights_data[i];
@@ -48,8 +49,9 @@ void main()
l_vector.xyz = ld.l_position - worldPosition;
l_vector.w = length(l_vector.xyz);
+ float light_input = smoothstep(0.2, -0.2, -dot(N, normalize(l_vector.xyz)));
float l_vis = light_shadowing(
- ld, worldPosition, viewPosition, tracing_depth, true_normal, rand.x, true, 1.0);
+ ld, worldPosition, viewPosition, tracing_depth, true_normal, rand.x, true, light_input);
accum_light += l_vis;
}
diff --git a/source/blender/draw/engines/overlay/shaders/motion_path_line_vert.glsl b/source/blender/draw/engines/overlay/shaders/motion_path_line_vert.glsl
index 6d7f673731e..7486f287a79 100644
--- a/source/blender/draw/engines/overlay/shaders/motion_path_line_vert.glsl
+++ b/source/blender/draw/engines/overlay/shaders/motion_path_line_vert.glsl
@@ -32,7 +32,7 @@ void main()
float intensity; /* how faint */
- vec3 blend_base = (abs(frame - frameCurrent) == 1) ?
+ vec3 blend_base = (abs(frame - frameCurrent) == 0) ?
colorCurrentFrame.rgb :
colorBackground.rgb; /* "bleed" cframe color to ease color blending */
bool use_custom_color = customColor.x >= 0.0;
@@ -78,13 +78,12 @@ void main()
else {
/* green - on frameCurrent */
if (selected) {
- intensity = 0.5f;
+ intensity = 0.92f;
}
else {
- intensity = 0.99f;
+ intensity = 0.75f;
}
- finalColor_geom.rgb = clamp(
- mix(colorCurrentFrame.rgb, colorBackground.rgb, intensity) - 0.1, 0.0, 0.1);
+ finalColor_geom.rgb = mix(colorBackground.rgb, blend_base, intensity);
}
}
diff --git a/source/blender/draw/intern/draw_cache.c b/source/blender/draw/intern/draw_cache.c
index 8057d167e2f..f37e5b14d83 100644
--- a/source/blender/draw/intern/draw_cache.c
+++ b/source/blender/draw/intern/draw_cache.c
@@ -836,12 +836,12 @@ GPUBatch *DRW_cache_object_surface_get(Object *ob)
int DRW_cache_object_material_count_get(struct Object *ob)
{
- Mesh *me = (ob->runtime.mesh_eval != NULL) ? ob->runtime.mesh_eval : (Mesh *)ob->data;
- short type = (ob->runtime.mesh_eval != NULL) ? OB_MESH : ob->type;
+ Mesh *me = BKE_object_get_evaluated_mesh(ob);
+ short type = (me != NULL) ? OB_MESH : ob->type;
switch (type) {
case OB_MESH:
- return DRW_mesh_material_count_get(me);
+ return DRW_mesh_material_count_get((me != NULL) ? me : ob->data);
case OB_CURVE:
case OB_SURF:
case OB_FONT:
@@ -2807,7 +2807,7 @@ GPUBatch *DRW_cache_curve_edge_wire_get(Object *ob)
BLI_assert(ob->type == OB_CURVE);
struct Curve *cu = ob->data;
- struct Mesh *mesh_eval = ob->runtime.mesh_eval;
+ struct Mesh *mesh_eval = BKE_object_get_evaluated_mesh(ob);
if (mesh_eval != NULL) {
return DRW_mesh_batch_cache_get_loose_edges(mesh_eval);
}
@@ -2845,7 +2845,7 @@ GPUBatch *DRW_cache_curve_surface_get(Object *ob)
BLI_assert(ob->type == OB_CURVE);
struct Curve *cu = ob->data;
- struct Mesh *mesh_eval = ob->runtime.mesh_eval;
+ struct Mesh *mesh_eval = BKE_object_get_evaluated_mesh(ob);
if (mesh_eval != NULL) {
return DRW_mesh_batch_cache_get_surface(mesh_eval);
}
@@ -2859,7 +2859,7 @@ GPUBatch *DRW_cache_curve_loose_edges_get(Object *ob)
BLI_assert(ob->type == OB_CURVE);
struct Curve *cu = ob->data;
- struct Mesh *mesh_eval = ob->runtime.mesh_eval;
+ struct Mesh *mesh_eval = BKE_object_get_evaluated_mesh(ob);
if (mesh_eval != NULL) {
return DRW_mesh_batch_cache_get_loose_edges(mesh_eval);
}
@@ -2875,7 +2875,7 @@ GPUBatch *DRW_cache_curve_face_wireframe_get(Object *ob)
BLI_assert(ob->type == OB_CURVE);
struct Curve *cu = ob->data;
- struct Mesh *mesh_eval = ob->runtime.mesh_eval;
+ struct Mesh *mesh_eval = BKE_object_get_evaluated_mesh(ob);
if (mesh_eval != NULL) {
return DRW_mesh_batch_cache_get_wireframes_face(mesh_eval);
}
@@ -2888,7 +2888,7 @@ GPUBatch *DRW_cache_curve_edge_detection_get(Object *ob, bool *r_is_manifold)
{
BLI_assert(ob->type == OB_CURVE);
struct Curve *cu = ob->data;
- struct Mesh *mesh_eval = ob->runtime.mesh_eval;
+ struct Mesh *mesh_eval = BKE_object_get_evaluated_mesh(ob);
if (mesh_eval != NULL) {
return DRW_mesh_batch_cache_get_edge_detection(mesh_eval, r_is_manifold);
}
@@ -2905,7 +2905,7 @@ GPUBatch **DRW_cache_curve_surface_shaded_get(Object *ob,
BLI_assert(ob->type == OB_CURVE);
struct Curve *cu = ob->data;
- struct Mesh *mesh_eval = ob->runtime.mesh_eval;
+ struct Mesh *mesh_eval = BKE_object_get_evaluated_mesh(ob);
if (mesh_eval != NULL) {
return DRW_mesh_batch_cache_get_surface_shaded(mesh_eval, gpumat_array, gpumat_array_len);
}
@@ -2957,7 +2957,7 @@ GPUBatch *DRW_cache_text_edge_wire_get(Object *ob)
{
BLI_assert(ob->type == OB_FONT);
struct Curve *cu = ob->data;
- struct Mesh *mesh_eval = ob->runtime.mesh_eval;
+ struct Mesh *mesh_eval = BKE_object_get_evaluated_mesh(ob);
const bool has_surface = (cu->flag & (CU_FRONT | CU_BACK)) || cu->ext1 != 0.0f ||
cu->ext2 != 0.0f;
if (!has_surface) {
@@ -2975,7 +2975,7 @@ GPUBatch *DRW_cache_text_surface_get(Object *ob)
{
BLI_assert(ob->type == OB_FONT);
struct Curve *cu = ob->data;
- struct Mesh *mesh_eval = ob->runtime.mesh_eval;
+ struct Mesh *mesh_eval = BKE_object_get_evaluated_mesh(ob);
if (cu->editfont && (cu->flag & CU_FAST)) {
return NULL;
}
@@ -2991,7 +2991,7 @@ GPUBatch *DRW_cache_text_edge_detection_get(Object *ob, bool *r_is_manifold)
{
BLI_assert(ob->type == OB_FONT);
struct Curve *cu = ob->data;
- struct Mesh *mesh_eval = ob->runtime.mesh_eval;
+ struct Mesh *mesh_eval = BKE_object_get_evaluated_mesh(ob);
if (cu->editfont && (cu->flag & CU_FAST)) {
return NULL;
}
@@ -3007,7 +3007,7 @@ GPUBatch *DRW_cache_text_loose_edges_get(Object *ob)
{
BLI_assert(ob->type == OB_FONT);
struct Curve *cu = ob->data;
- struct Mesh *mesh_eval = ob->runtime.mesh_eval;
+ struct Mesh *mesh_eval = BKE_object_get_evaluated_mesh(ob);
if (cu->editfont && (cu->flag & CU_FAST)) {
return NULL;
}
@@ -3024,7 +3024,7 @@ GPUBatch *DRW_cache_text_face_wireframe_get(Object *ob)
{
BLI_assert(ob->type == OB_FONT);
struct Curve *cu = ob->data;
- struct Mesh *mesh_eval = ob->runtime.mesh_eval;
+ struct Mesh *mesh_eval = BKE_object_get_evaluated_mesh(ob);
if (cu->editfont && (cu->flag & CU_FAST)) {
return NULL;
}
@@ -3042,7 +3042,7 @@ GPUBatch **DRW_cache_text_surface_shaded_get(Object *ob,
{
BLI_assert(ob->type == OB_FONT);
struct Curve *cu = ob->data;
- struct Mesh *mesh_eval = ob->runtime.mesh_eval;
+ struct Mesh *mesh_eval = BKE_object_get_evaluated_mesh(ob);
if (cu->editfont && (cu->flag & CU_FAST)) {
return NULL;
}
@@ -3065,7 +3065,7 @@ GPUBatch *DRW_cache_surf_surface_get(Object *ob)
BLI_assert(ob->type == OB_SURF);
struct Curve *cu = ob->data;
- struct Mesh *mesh_eval = ob->runtime.mesh_eval;
+ struct Mesh *mesh_eval = BKE_object_get_evaluated_mesh(ob);
if (mesh_eval != NULL) {
return DRW_mesh_batch_cache_get_surface(mesh_eval);
}
@@ -3079,7 +3079,7 @@ GPUBatch *DRW_cache_surf_edge_wire_get(Object *ob)
BLI_assert(ob->type == OB_SURF);
struct Curve *cu = ob->data;
- struct Mesh *mesh_eval = ob->runtime.mesh_eval;
+ struct Mesh *mesh_eval = BKE_object_get_evaluated_mesh(ob);
if (mesh_eval != NULL) {
return DRW_mesh_batch_cache_get_loose_edges(mesh_eval);
}
@@ -3093,7 +3093,7 @@ GPUBatch *DRW_cache_surf_face_wireframe_get(Object *ob)
BLI_assert(ob->type == OB_SURF);
struct Curve *cu = ob->data;
- struct Mesh *mesh_eval = ob->runtime.mesh_eval;
+ struct Mesh *mesh_eval = BKE_object_get_evaluated_mesh(ob);
if (mesh_eval != NULL) {
return DRW_mesh_batch_cache_get_wireframes_face(mesh_eval);
}
@@ -3106,7 +3106,7 @@ GPUBatch *DRW_cache_surf_edge_detection_get(Object *ob, bool *r_is_manifold)
{
BLI_assert(ob->type == OB_SURF);
struct Curve *cu = ob->data;
- struct Mesh *mesh_eval = ob->runtime.mesh_eval;
+ struct Mesh *mesh_eval = BKE_object_get_evaluated_mesh(ob);
if (mesh_eval != NULL) {
return DRW_mesh_batch_cache_get_edge_detection(mesh_eval, r_is_manifold);
}
@@ -3120,7 +3120,7 @@ GPUBatch *DRW_cache_surf_loose_edges_get(Object *ob)
BLI_assert(ob->type == OB_SURF);
struct Curve *cu = ob->data;
- struct Mesh *mesh_eval = ob->runtime.mesh_eval;
+ struct Mesh *mesh_eval = BKE_object_get_evaluated_mesh(ob);
if (mesh_eval != NULL) {
return DRW_mesh_batch_cache_get_loose_edges(mesh_eval);
}
@@ -3139,7 +3139,7 @@ GPUBatch **DRW_cache_surf_surface_shaded_get(Object *ob,
BLI_assert(ob->type == OB_SURF);
struct Curve *cu = ob->data;
- struct Mesh *mesh_eval = ob->runtime.mesh_eval;
+ struct Mesh *mesh_eval = BKE_object_get_evaluated_mesh(ob);
if (mesh_eval != NULL) {
return DRW_mesh_batch_cache_get_surface_shaded(mesh_eval, gpumat_array, gpumat_array_len);
}
@@ -3398,7 +3398,7 @@ GPUBatch *DRW_cache_cursor_get(bool crosshair_lines)
void drw_batch_cache_validate(Object *ob)
{
- struct Mesh *mesh_eval = ob->runtime.mesh_eval;
+ struct Mesh *mesh_eval = BKE_object_get_evaluated_mesh(ob);
switch (ob->type) {
case OB_MESH:
DRW_mesh_batch_cache_validate((Mesh *)ob->data);
@@ -3436,7 +3436,7 @@ void drw_batch_cache_generate_requested(Object *ob)
DRW_object_use_hide_faces(ob)) ||
((mode == CTX_MODE_EDIT_MESH) && DRW_object_is_in_edit_mode(ob))));
- struct Mesh *mesh_eval = ob->runtime.mesh_eval;
+ struct Mesh *mesh_eval = BKE_object_get_evaluated_mesh(ob);
switch (ob->type) {
case OB_MESH:
DRW_mesh_batch_cache_create_requested(ob, (Mesh *)ob->data, scene, is_paint_mode, use_hide);
@@ -3457,7 +3457,7 @@ void drw_batch_cache_generate_requested(Object *ob)
void DRW_batch_cache_free_old(Object *ob, int ctime)
{
- struct Mesh *mesh_eval = ob->runtime.mesh_eval;
+ struct Mesh *mesh_eval = BKE_object_get_evaluated_mesh(ob);
switch (ob->type) {
case OB_MESH:
diff --git a/source/blender/draw/intern/draw_manager_data.c b/source/blender/draw/intern/draw_manager_data.c
index fbdabb44b15..43e8e2a4733 100644
--- a/source/blender/draw/intern/draw_manager_data.c
+++ b/source/blender/draw/intern/draw_manager_data.c
@@ -1203,6 +1203,19 @@ static DRWShadingGroup *drw_shgroup_material_create_ex(GPUPass *gpupass, DRWPass
return grp;
}
+static void drw_shgroup_material_texture(DRWShadingGroup *grp,
+ GPUMaterialTexture *tex,
+ const char *name,
+ int textarget)
+{
+ GPUTexture *gputex = GPU_texture_from_blender(tex->ima, tex->iuser, NULL, textarget);
+ DRW_shgroup_uniform_texture(grp, name, gputex);
+
+ GPUTexture **gputex_ref = BLI_memblock_alloc(DST.vmempool->images);
+ *gputex_ref = gputex;
+ GPU_texture_ref(gputex);
+}
+
static DRWShadingGroup *drw_shgroup_material_inputs(DRWShadingGroup *grp,
struct GPUMaterial *material)
{
@@ -1210,35 +1223,20 @@ static DRWShadingGroup *drw_shgroup_material_inputs(DRWShadingGroup *grp,
/* Bind all textures needed by the material. */
for (GPUMaterialTexture *tex = textures.first; tex; tex = tex->next) {
- GPUTexture *gputex;
-
if (tex->ima) {
/* Image */
- GPUTexture **gputex_ref = BLI_memblock_alloc(DST.vmempool->images);
-
- int textarget;
- if (tex->type == GPU_TEX2D_ARRAY) {
- textarget = GL_TEXTURE_2D_ARRAY;
- }
- else if (tex->type == GPU_TEX1D_ARRAY) {
- textarget = GL_TEXTURE_1D_ARRAY;
+ if (tex->tiled_mapping_name[0]) {
+ drw_shgroup_material_texture(grp, tex, tex->sampler_name, GL_TEXTURE_2D_ARRAY);
+ drw_shgroup_material_texture(grp, tex, tex->tiled_mapping_name, GL_TEXTURE_1D_ARRAY);
}
else {
- textarget = GL_TEXTURE_2D;
+ drw_shgroup_material_texture(grp, tex, tex->sampler_name, GL_TEXTURE_2D);
}
- *gputex_ref = gputex = GPU_texture_from_blender(tex->ima, tex->iuser, NULL, textarget);
-
- GPU_texture_ref(gputex);
}
else if (tex->colorband) {
/* Color Ramp */
- gputex = *tex->colorband;
+ DRW_shgroup_uniform_texture(grp, tex->sampler_name, *tex->colorband);
}
- else {
- continue;
- }
-
- DRW_shgroup_uniform_texture(grp, tex->shadername, gputex);
}
GPUUniformBuffer *ubo = GPU_material_uniform_buffer_get(material);
diff --git a/source/blender/draw/intern/shaders/common_view_lib.glsl b/source/blender/draw/intern/shaders/common_view_lib.glsl
index 6605e1165d4..cfe79cb3ee0 100644
--- a/source/blender/draw/intern/shaders/common_view_lib.glsl
+++ b/source/blender/draw/intern/shaders/common_view_lib.glsl
@@ -164,6 +164,7 @@ uniform mat4 ModelMatrixInverse;
#define normal_object_to_world(n) (transpose(mat3(ModelMatrixInverse)) * n)
#define normal_world_to_object(n) (transpose(mat3(ModelMatrix)) * n)
#define normal_world_to_view(n) (mat3(ViewMatrix) * n)
+#define normal_view_to_world(n) (mat3(ViewMatrixInverse) * n)
#define point_object_to_ndc(p) (ViewProjectionMatrix * vec4((ModelMatrix * vec4(p, 1.0)).xyz, 1.0))
#define point_object_to_view(p) ((ViewMatrix * vec4((ModelMatrix * vec4(p, 1.0)).xyz, 1.0)).xyz)