Commit Graph

153 Commits

Author SHA1 Message Date
03bd418d16 Fix T39517,
Issue here is that "show diffuse" option does not respect its intended
purpose which is to be used only for masking.

There are a couple of caveats here:

Dyntopo and multires -always- have mask data enabled, and thus as soon
as one goes to dyntopo mode or adds a multires modifier he would get the
default grey color instead.

Matcaps would break when nodes asked for a diffuse material color (this
was broken before too). Solved by adding global material state for when
matcaps are enabled. Also matcaps don't always played well with VBOs
off.

Added a few more missing updates for mask operators to notify
show_diffuse property as changed. This was also needed on rebuilding
dyntopo pbvh.

Also make zero mask color duller again after artist feedback.
2014-04-03 00:39:42 +03:00
8c730b1059 Fix T39520, show diffuse not working in dyntopo.
Was marked as a todo in the code.

This does not yet take care of correct display for multi material
meshes, since it would need correct separation of faces during pbvh
creation. Instead we just take material of first face in node and assume
that the rest faces have the same. This will create some funky effects
if one attempts to sculpt in this way.

Note: This does not yet address T39517
2014-04-02 18:56:19 +03:00
e60b18d51d Dyntopo: Delete OpenGL buffers of nodes that do not have any more
triangles.

It is possible to end up with such nodes using brushes in aggressive
collapse mode. Those nodes should normally be cleaned up, since they can
never be actually reused (adding more geometry to a node requires the
node having some geometry to begin with) but until we support dynamic
nodes, better delete those to avoid binding graphics driver resources.

If such zero elements buffers were used, GL error out of memory would be
reported.
2014-04-02 01:41:14 +03:00
bfe29e0ef7 Revert 7955cb78d it causes GPU_pbvh_buffers_diffuse_changed to always
return false, causing update of all pbvh nodes all the time.
2014-04-01 20:17:23 +03:00
3ed49a810d Make matcaps suck less
This commit does various changes for matcaps:

One is taking advantage of drawing with pbvh (which would only happen
with dyntopo previously) and drawing with partial redraw during
sculpting.

The second one is support for masks. To make this work in the special
case of multires, which uses flat shading, I use the only available flat
shaded builtins in OpenGL 2.0 which are color and secondary color.

Abusing colors in that way is also essential for flat shading to work if
we are to use pbvh draw in multires, since it is the color that is being
interpolated flatly, not the normal (which can only interpolated
smoothly). The pbvh drawing code for multires used last triangle
element's normal to compute the shading which would only produce smooth
results. This could change if we did the shading in the vertex shader
for flat shaded primitives, but this is more complex and makes it harder
to have one shader to rule the mole.

Also increased the brightness of the default diffuse color for
sculpting. This should be useful since artists like to tweak the
lighting settings and it will give them the full dynamic range of the
lights, but also it helps with correct brightness of sculpted matcaps.

Reviewers: brecht

Differential Revision: https://developer.blender.org/D435
2014-04-01 19:27:13 +03:00
7955cb78d6 Fix for "Show Diffuse Color" was having affect on mesh without mask
Only happened with VBOs enabled.
2014-04-01 14:00:15 +06:00
9904127e33 Code cleanup: use bool instead of int 2014-04-01 13:55:25 +06:00
617557b08e Code cleanup: remove TRUE/FALSE & WITH_BOOL_COMPAT define 2014-04-01 15:22:28 +11:00
6bba006bf2 Cleanup: Minor spelling fixes: 2014-03-29 11:56:32 +02:00
6a1b7facf9 GPU_pbvh_buffers: Use triangles to render multires.
A question here might be: why?

The answer is that GPUs will convert this to triangles so we are wasting
memory during conversion of the element buffer to a triangle buffer
anyway.

The second reason is that some modern GPUs are slower rendering GL_QUADS

The third reason is that due to element caching, this should not in
theory be slower (cached elements do not get recalculated on the GPU).
2014-03-29 11:40:53 +02:00
b7fa08f88a Code cleanup: style 2014-02-22 11:14:15 +11:00
1f5029b184 Fix T38503: crash in non-threadsafe VBO free code during render. 2014-02-07 13:33:15 +01:00
621bf47e91 Docs: doxygen file descriptions for BLF, GPU and WM 2014-01-19 23:15:25 +11:00
d9697bc145 Fix T38024 crash when rebuilding sculpt mode buffers.
Main issue here is that glBuf* calls were invoked from threads different than
main thread. This caused a crash (since those do not have a GL context active).

Fix here is twofold:
* add an ID buffer in buffer pool that handles pbvh buffers and is freed
from main thread when gpu_buffer_pool_free_unused is called.

* do not create glbuffers in derivedmesh creation routine, rather tag nodes
for update and create those in the draw function
(guaranteed to be called from main thread)

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D169
2014-01-05 04:58:27 +02:00
ba8d65a9a7 Code clean-up change naming of gpu buffers used by pbvh to better
reflect that. Previous name GPU_Buffers was very similar to GPU_Buffer,
renamed to GPU_PBVH_Buffers
2014-01-03 12:48:12 +02:00
bbce51d116 replace hashes with sets where possible. 2013-08-25 20:03:45 +00:00
f3ceee51fa fix for GPU_update_bmesh_buffers not setting bmesh vertex index values as dirty (could cause errors later). 2013-08-24 11:46:08 +00:00
b9ae749480 Make GPU buffers allocation/freeing safe for threading
Code in GPU_buffers_free was already trying to be safe
for threading, by skipping OGL calls there, but in fact
it was still buggy.

Namely, freeing was doing buffers shift in a cycle, and
if two threads will call this function shifting will go
crazy.

Now made it so GPU_buffers_alloc and GPU_buffers_free
are using mutex lock, so they're completely safe for
threading. Same goes to gpu_buffer_setup function.

It required minor functions reshuffle, so there're no
locks happening from locked thread, but it's all very
straightforward change

--
svn merge -r58276:58277 ^/branches/soc-2013-depsgraph_mt
2013-08-19 10:06:05 +00:00
3fbd8abcfd OpenGL VBO's: free VBO pool before redraw, otherwise this just holds onto memory
after objects are deleted until another big object is added. There's no good reason
to do this, or to think that our pool is somehow much faster than using the OpenGL
API to allocate and free buffers.
2013-08-09 19:55:43 +00:00
04ea8c0ee8 remove the pointer from BLI_bitmap's typedef,
hides that an arg passed is really an array which may be modified by other functions.
2013-07-22 23:20:48 +00:00
a6b505ef0b style cleanup 2013-06-06 06:02:46 +00:00
f18fad668f Fix textured draw mode + dyntopo crash fix to cover more cases. 2013-06-05 15:54:41 +00:00
aa96f0290a Obsessive Null Checking Compulsion case:
Textured draw mode + DynTopo crashed after recent specularity tweak.
2013-06-05 09:10:56 +00:00
4a7f37f6ed Fix #35602: VBO + dynamic topology sculpt did not show specularity. 2013-06-04 17:10:57 +00:00
0408684763 avoid per-vertex mask layer lookups for dyntopo. 2013-05-02 06:09:05 +00:00
89bda7899d style cleanup & some spelling 2013-02-03 10:28:28 +00:00
9a50f45469 Skip hidden faces in PBVH BMesh ray intersection test
Moved the GPU function gpu_bmesh_face_visible() to BKE_paint and
inverted the test to match equivalent tests for other mesh types:
paint_is_bmesh_face_hidden().

Changed BKE_pbvh_bmesh_node_save_orig() to not save hidden faces into
the triangle array.

Modified the non-use-original branch of pbvh_bmesh_node_raycast() to
skip hidden faces.

Fixes bug #33914:
projects.blender.org/tracker/index.php?func=detail&aid=33914&group_id=9&atid=498
2013-01-19 16:10:21 +00:00
5ddc7d64a8 optimize bmesh operations that use triangle BMFace's (dyn-topo and mesh conversion). 2013-01-16 21:09:54 +00:00
d342e3ef0f Use GPU_Buffers to draw wireframe when in dynamic-topology sculpt mode
This adds an override to the CDDM edge drawing function that switches
to GPU_Buffers drawing for PBVHes of type PBVH_BMESH.

Within the GPU_Buffers code, glPolygonMode() is used to draw lines
instead of faces.
2012-12-30 18:30:13 +00:00
d383c32413 Add GPU_buffers support for drawing dynamic topology nodes
The GPU interface for PBVH drawing gets a new pair of build/update
buffers functions for drawing BMFaces and BMVerts.

TODO: the diffuse color is hardcoded to 0.8 gray rather than using
material color.

TODO: only VBO drawing is implemented, no immediate mode.
2012-12-30 18:24:54 +00:00
9046c292f8 fix [#33598] Regression in 2.65 while opening a 2.64 file
VBO's were using a material limit half the size of the rest of blender.
2012-12-18 11:17:20 +00:00
9b948717b0 code cleanup: float <> double conversion. 2012-11-03 18:23:30 +00:00
25591e958d style cleanup: tabs & whitespace 2012-11-03 15:35:03 +00:00
b4e484e211 Fix for own r51737.
Refactoring of draw code showed another problem: The MCol we want to draw may change without dm rebuild (e.g. when enabling solid textured option)! Also, choosing which MCol layer to use in GPU code is stupid, different draw modes use different layers/order of precedence!

Solved this by adding a new colType parameter to GPU_color_setup, and removing any 'color choosing' code from gpu_buffers.c.
2012-10-30 11:00:06 +00:00
f139377a1a Complete fix for [#33002] Wrong vertex color.
Appart from the color glitch, there was several problems with vpaint:
* "fast_update" mode was never on, because of wrong testing code;
* drawing refresh during stroke in "fast_update" (i.e. no dm rebuild) mode was broken in VBO mode, because updated (tess data) mcol wasn't moved to colors GPUBuffer.

Solved the later point by adding a new DM_DIRTY_MCOL_UPDATE_DRAW flag to DerivedMesh dirty var, which is set each time vpaint stroke directly update me->mcol, and forces GPU_color_setup() to refresh the gpu's colors buffer.

Also got rid of the uggly GPU_color3_upload(), which basically did the same thing, but with an additional intermediate buffer !
2012-10-29 16:26:18 +00:00
2b9e70c81e Fix #32943: sculpt mode draw crash with VBO and flat shaded, hidden faces. 2012-10-23 11:07:05 +00:00
6e62491c5a Fix #32522: Object's diffuse color not showing in Sculpt Mode
Added option to display object's diffuse color multiplied by sculpting
mask. This option could be found in Options panel of toolshelf when in
sculpting mode.

Thanks to Nicholas and Brecht for reviewing the patch!
2012-10-22 17:33:53 +00:00
3a52a876b6 Fix for drawing meshes with VBOs disabled in sculpt mode
* This is another fix for r51118. Was drawing flat-shaded GPU buffers
  with VBOs even when VBOs were disabled in the preferences.
2012-10-20 00:45:44 +00:00
5ad61e9642 Fix for VBO drawing in multires sculpting
Was a mistake in a code cleanup commit, r51118.

Fixes bug [#32919] Sculting performance regression in svn_51118
projects.blender.org/tracker/?func=detail&aid=32919&group_id=9&atid=498
2012-10-19 02:38:50 +00:00
0c0fa7dde6 Improve flat-shaded VBO drawing for sculpt meshes
Separate vertex copies are now made for flat-shading, such that the
normal is correctly flat-shaded. The element index buffer is not
created in this case.
2012-10-06 16:52:52 +00:00
1df170bb96 Code cleanups for PBVH GPU buffers
* De-duplicate GPU code to check if VBO should be used.

* Add a flag to indicate if the buffer should be drawn smooth or not,
  rather than checking each time the node is drawn.
2012-10-06 16:42:11 +00:00
323ad98496 Fix: gpu_colors_enable could cause 3d display corruption because it always enables glColorMaterial. Make sure to call gpu_colors_disable even if we don't have a mask layer, to match gpu_colors_enable above 2012-10-01 07:53:54 +00:00
df298490b8 mask data is no longer automatically added when sculpting (except when there is a multi-res modifier). 2012-10-01 05:19:57 +00:00
168ffbfb67 Revert changes made to support diffuse color when sculpting
This changes are not stable enough and trying fix it could backfire in some
other regressions which isn't wanted so much close to the release.

This means objects will have gray color as diffuse which becomes darker in
masked areas for 2.64.

Proper fix is aimed for 2.65.

This commit reverts 50827 and 50898.
2012-09-30 15:04:46 +00:00
b2167e771a Fix #32663: Sculpt masks are too dark
Scaled mask multiplier to 0.25..1.0 instead of 0.0..1.0.
2012-09-26 07:55:52 +00:00
2637efa2a3 Fix #32522: Object's diffuse color not showing in Sculpt Mode
It was missing since sculpting mask implementation.

Now object's color would be multiplied by sculpt mask value.

For VBOs it's done by storing final color in VertexBufferFormat and
mimic behavior of setMaterial callback for getting current diffuse
color.

For non-VBOs diffuse color is getting from current OpenGL context.
2012-09-23 14:16:52 +00:00
32cf7fcdb1 code cleanup: spelling 2012-07-16 23:23:33 +00:00
0adf252c9b Fix #31593: Every time I switch between edit and object mode, it crashes
Crash was caused by incorrect restoring OpenGL context due to some
weird bit operations used to indicate whether stuff like color arrays
is initialized resulting in some unpredictable results on different
platforms and drivers.
2012-06-05 08:41:53 +00:00
032d83ecc4 style cleanup: defines with braces 2012-05-27 20:13:59 +00:00
dab1d8e487 style cleanup 2012-05-22 22:03:41 +00:00