Assets: Use textures (and shadows) for automatic object previews

Textures may be important to be able to identify an object. They are also a way
to make many objects look more like when rendered with an advanced render
engine, without being that expensive.
So this seems like a simple way to increase usefulness of the automatic
previews.
This commit is contained in:
Severin 2021-05-19 17:51:25 +02:00
parent 857f39a3d7
commit 330fecc9b7
2 changed files with 16 additions and 5 deletions

View File

@ -70,6 +70,7 @@
#include "BKE_node.h"
#include "BKE_object.h"
#include "BKE_scene.h"
#include "BKE_screen.h"
#include "BKE_texture.h"
#include "BKE_world.h"
@ -776,16 +777,21 @@ static void object_preview_render(IconPreview *preview, IconPreviewSize *preview
U.pixelsize = 2.0f;
View3DShading shading;
BKE_screen_view3d_shading_init(&shading);
/* Enable shadows, makes it a bit easier to see the shape. */
shading.flag |= V3D_SHADING_SHADOW;
ImBuf *ibuf = ED_view3d_draw_offscreen_imbuf_simple(
depsgraph,
DEG_get_evaluated_scene(depsgraph),
NULL,
OB_SOLID,
&shading,
OB_TEXTURE,
DEG_get_evaluated_object(depsgraph, scene->camera),
preview_sized->sizex,
preview_sized->sizey,
IB_rect,
V3D_OFSDRAW_NONE,
V3D_OFSDRAW_OVERRIDE_SCENE_SETTINGS,
R_ALPHAPREMUL,
NULL,
NULL,

View File

@ -2022,7 +2022,6 @@ ImBuf *ED_view3d_draw_offscreen_imbuf_simple(Depsgraph *depsgraph,
source_shading_settings = shading_override;
}
memcpy(&v3d.shading, source_shading_settings, sizeof(View3DShading));
v3d.shading.type = drawtype;
if (drawtype == OB_MATERIAL) {
v3d.shading.flag = V3D_SHADING_SCENE_WORLD | V3D_SHADING_SCENE_LIGHTS;
@ -2032,6 +2031,12 @@ ImBuf *ED_view3d_draw_offscreen_imbuf_simple(Depsgraph *depsgraph,
v3d.shading.flag = V3D_SHADING_SCENE_WORLD_RENDER | V3D_SHADING_SCENE_LIGHTS_RENDER;
v3d.shading.render_pass = SCE_PASS_COMBINED;
}
else if (drawtype == OB_TEXTURE) {
drawtype = OB_SOLID;
v3d.shading.light = V3D_LIGHTING_STUDIO;
v3d.shading.color_type = V3D_SHADING_TEXTURE_COLOR;
}
v3d.shading.type = drawtype;
v3d.flag2 = V3D_HIDE_OVERLAYS;
@ -2072,7 +2077,7 @@ ImBuf *ED_view3d_draw_offscreen_imbuf_simple(Depsgraph *depsgraph,
return ED_view3d_draw_offscreen_imbuf(depsgraph,
scene,
drawtype,
v3d.shading.type,
&v3d,
&region,
width,