[Bf-blender-cvs] [3d63b9a88f] blender2.8: Clay Engine: Hidden wire
Clément Foucault
noreply at git.blender.org
Thu Feb 16 14:02:43 CET 2017
Commit: 3d63b9a88f969f2766cb37c8d3c937e1054a8154
Author: Clément Foucault
Date: Thu Feb 16 14:00:37 2017 +0100
Branches: blender2.8
https://developer.blender.org/rB3d63b9a88f969f2766cb37c8d3c937e1054a8154
Clay Engine: Hidden wire
===================================================================
M source/blender/draw/engines/clay/clay.c
M source/blender/draw/intern/draw_mode_pass.c
M source/blender/draw/intern/draw_mode_pass.h
===================================================================
diff --git a/source/blender/draw/engines/clay/clay.c b/source/blender/draw/engines/clay/clay.c
index 85fb53f618..1673dd219c 100644
--- a/source/blender/draw/engines/clay/clay.c
+++ b/source/blender/draw/engines/clay/clay.c
@@ -132,9 +132,11 @@ typedef struct CLAY_PassList{
/* engine specific */
struct DRWPass *depth_pass;
struct DRWPass *depth_pass_cull;
+ struct DRWPass *depth_pass_hidden_wire;
struct DRWPass *clay_pass;
struct DRWPass *wire_overlay_pass;
struct DRWPass *wire_outline_pass;
+ struct DRWPass *wire_outline_pass_hidden_wire;
} CLAY_PassList;
//#define GTAO
@@ -609,6 +611,7 @@ static void CLAY_create_cache(CLAY_PassList *passes, CLAY_StorageList *stl, cons
DRWShadingGroup *clay_shgrp;
DRWShadingGroup *depth_shgrp;
DRWShadingGroup *depth_shgrp_cull;
+ DRWShadingGroup *depth_shgrp_hidden_wire;
/* Depth Pass */
{
@@ -616,6 +619,8 @@ static void CLAY_create_cache(CLAY_PassList *passes, CLAY_StorageList *stl, cons
depth_shgrp_cull = DRW_shgroup_create(data.depth_sh, passes->depth_pass_cull);
passes->depth_pass = DRW_pass_create("Depth Pass", DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS);
depth_shgrp = DRW_shgroup_create(data.depth_sh, passes->depth_pass);
+ passes->depth_pass_hidden_wire = DRW_pass_create("Depth Pass Hidden Wire", DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS | DRW_STATE_CULL_BACK);
+ depth_shgrp_hidden_wire = DRW_shgroup_create(data.depth_sh, passes->depth_pass_hidden_wire);
}
/* Clay Pass */
@@ -629,6 +634,7 @@ static void CLAY_create_cache(CLAY_PassList *passes, CLAY_StorageList *stl, cons
{
DRW_pass_setup_common(&passes->wire_overlay_pass,
&passes->wire_outline_pass,
+ &passes->wire_outline_pass_hidden_wire,
&passes->non_meshes_pass,
&passes->ob_center_pass);
}
@@ -641,11 +647,12 @@ static void CLAY_create_cache(CLAY_PassList *passes, CLAY_StorageList *stl, cons
}
CollectionEngineSettings *ces_mode_ob = BKE_object_collection_engine_get(ob, COLLECTION_MODE_OBJECT, "");
- //CollectionEngineSettings *ces_mode_ed = BKE_object_collection_engine_get(ob, COLLECTION_MODE_EDIT, "");
+ CollectionEngineSettings *ces_mode_ed = BKE_object_collection_engine_get(ob, COLLECTION_MODE_EDIT, "");
struct Batch *geom;
bool do_wire = BKE_collection_engine_property_value_get_bool(ces_mode_ob, "show_wire");
bool do_cull = BKE_collection_engine_property_value_get_bool(ces_mode_ob, "show_backface_culling");
+ bool do_occlude_wire = BKE_collection_engine_property_value_get_bool(ces_mode_ed, "show_occlude_wire");
bool do_outlines = ((ob->base_flag & BASE_SELECTED) != 0) || do_wire;
switch (ob->type) {
@@ -653,16 +660,26 @@ static void CLAY_create_cache(CLAY_PassList *passes, CLAY_StorageList *stl, cons
geom = DRW_cache_surface_get(ob);
/* Depth Prepass */
- DRW_shgroup_call_add((do_cull) ? depth_shgrp_cull : depth_shgrp, geom, ob->obmat);
+ if (do_occlude_wire)
+ DRW_shgroup_call_add(depth_shgrp_hidden_wire, geom, ob->obmat);
+ else
+ DRW_shgroup_call_add((do_cull) ? depth_shgrp_cull : depth_shgrp, geom, ob->obmat);
/* Shading */
- clay_shgrp = CLAY_object_shgrp_get(ob, stl, passes);
- DRW_shgroup_call_add(clay_shgrp, geom, ob->obmat);
+ if (!do_occlude_wire) {
+ clay_shgrp = CLAY_object_shgrp_get(ob, stl, passes);
+ DRW_shgroup_call_add(clay_shgrp, geom, ob->obmat);
+ }
//DRW_shgroup_wire_overlay(passes->wire_overlay_pass, ob);
/* Wires / Outlines */
- DRW_shgroup_wire_outline(passes->wire_outline_pass, ob, do_wire, false, do_outlines);
+ if (do_occlude_wire) {
+ DRW_shgroup_wire_outline(passes->wire_outline_pass_hidden_wire, ob, true, false, true);
+ }
+ else {
+ DRW_shgroup_wire_outline(passes->wire_outline_pass, ob, do_wire, false, do_outlines);
+ }
break;
case OB_LAMP:
@@ -732,6 +749,11 @@ static void CLAY_view_draw(RenderEngine *UNUSED(engine), const bContext *context
//DRW_draw_pass(passes->wire_overlay_pass);
DRW_draw_pass(passes->wire_outline_pass);
DRW_draw_pass(passes->non_meshes_pass);
+
+ /* Hidden Wires */
+ DRW_draw_pass(passes->depth_pass_hidden_wire);
+ DRW_draw_pass(passes->wire_outline_pass_hidden_wire);
+
DRW_draw_pass(passes->ob_center_pass);
DRW_draw_manipulator();
diff --git a/source/blender/draw/intern/draw_mode_pass.c b/source/blender/draw/intern/draw_mode_pass.c
index a31ab7c4c1..32a9417735 100644
--- a/source/blender/draw/intern/draw_mode_pass.c
+++ b/source/blender/draw/intern/draw_mode_pass.c
@@ -161,7 +161,8 @@ static DRWShadingGroup *shgroup_instance(DRWPass *pass, struct Batch *geom)
/* This Function setup the passes needed for the mode rendering.
* The passes are populated by the rendering engine using the DRW_shgroup_* functions. */
-void DRW_pass_setup_common(DRWPass **wire_overlay, DRWPass **wire_outline, DRWPass **non_meshes, DRWPass **ob_center)
+void DRW_pass_setup_common(DRWPass **wire_overlay, DRWPass **wire_outline, DRWPass **wire_outline_pass_hidden_wire,
+ DRWPass **non_meshes, DRWPass **ob_center)
{
UI_GetThemeColor4fv(TH_WIRE, colorWire);
UI_GetThemeColor4fv(TH_WIRE_EDIT, colorWireEdit);
@@ -192,6 +193,14 @@ void DRW_pass_setup_common(DRWPass **wire_overlay, DRWPass **wire_outline, DRWPa
*wire_outline = DRW_pass_create("Wire + Outlines Pass", state);
}
+ if (wire_outline_pass_hidden_wire) {
+ /* This pass can draw mesh outlines and/or fancy wireframe */
+ /* Fancy wireframes are not meant to be occluded (without Z offset) */
+ /* Outlines and Fancy Wires use the same VBO */
+ DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS | DRW_STATE_BLEND;
+ *wire_outline_pass_hidden_wire = DRW_pass_create("Wire + Outlines Pass", state);
+ }
+
if (non_meshes) {
/* Non Meshes Pass (Camera, empties, lamps ...) */
struct Batch *geom;
diff --git a/source/blender/draw/intern/draw_mode_pass.h b/source/blender/draw/intern/draw_mode_pass.h
index 6e260dac7a..b0fd3e69bd 100644
--- a/source/blender/draw/intern/draw_mode_pass.h
+++ b/source/blender/draw/intern/draw_mode_pass.h
@@ -30,7 +30,8 @@ struct DRWPass;
struct Batch;
struct Object;
-void DRW_pass_setup_common(struct DRWPass **wire_overlay, struct DRWPass **wire_outline, struct DRWPass **non_meshes, struct DRWPass **ob_center);
+void DRW_pass_setup_common(struct DRWPass **wire_overlay, struct DRWPass **wire_outline, struct DRWPass **wire_outline_pass_hidden_wire,
+ struct DRWPass **non_meshes, struct DRWPass **ob_center);
void DRW_shgroup_wire_overlay(struct DRWPass *wire_overlay, struct Object *ob);
void DRW_shgroup_wire_outline(
More information about the Bf-blender-cvs
mailing list