[Bf-blender-cvs] [330fecc9b7f] master: Assets: Use textures (and shadows) for automatic object previews

Severin noreply at git.blender.org
Wed May 19 17:58:06 CEST 2021


Commit: 330fecc9b7f69c11258ea926ce760e51b4f3dd78
Author: Severin
Date:   Wed May 19 17:51:25 2021 +0200
Branches: master
https://developer.blender.org/rB330fecc9b7f69c11258ea926ce760e51b4f3dd78

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.

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

M	source/blender/editors/render/render_preview.c
M	source/blender/editors/space_view3d/view3d_draw.c

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

diff --git a/source/blender/editors/render/render_preview.c b/source/blender/editors/render/render_preview.c
index 157f2b3ecb4..e28fe8a5d04 100644
--- a/source/blender/editors/render/render_preview.c
+++ b/source/blender/editors/render/render_preview.c
@@ -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,
diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c
index 1ef37ba4f9b..0a89b7d0292 100644
--- a/source/blender/editors/space_view3d/view3d_draw.c
+++ b/source/blender/editors/space_view3d/view3d_draw.c
@@ -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,



More information about the Bf-blender-cvs mailing list