Commit Graph

694 Commits

Author SHA1 Message Date
7ca74fc1c0 Code cleanup: use 'const' for arrays (blenloader, gpu, imbuf, makesdna, modifiers, nodes) 2014-04-27 00:25:16 +10:00
87628cc5fb Fix GLSL after 7765b73f6d (Transparent Depth). 2014-04-21 16:32:08 +02:00
1b9db9911d Code cleanup: use bools
also rename BLI_omp_thread_count -> BLI_system_thread_count_omp
2014-04-17 16:04:28 +10:00
5d189069a4 Fix regression, sculpting on mesh with matcaps (without multires/ 2014-04-15 20:12:51 +03:00
41b8f88732 Split Normals I (3/5): Add 3Dview shading support of split normals.
Mostly monkey coding in gpu ("modern" VBO drawing) and DM variants ("legacy" drawing) code...

Reviewers: brecht

Reviewed By: brecht

CC: campbellbarton

Differential Revision: https://developer.blender.org/D367
2014-04-13 12:34:45 +02:00
a15b3c4d11 Code cleanup: use bool 2014-04-11 11:33:29 +10:00
52af5fa31f Change GPU deletion at GPU buffer update time. This should be detected
and done at PBVH update time, since it is possible to have no triangles
to display in a buffer if node is hidden.
2014-04-11 03:16:16 +03:00
7cdaf56b30 Dyntopo: use hidden face flags in more places 2014-04-11 07:51:14 +10:00
6292b60a3f Dyntopo: Minor display optimization.
While hiding, flush the hidden flags to the faces. This avoids iterating
through all the loops while updating the GPU buffers.
2014-04-10 22:31:39 +03:00
a068dda5f3 Code cleanup: ifdef unused linklist for GPU drawobject's 2014-04-09 15:42:18 +10:00
9de24c82ba View3D: disable LOD when game engine is disabled or ifdef'd 2014-04-09 11:52:34 +10:00
d8c4763fb0 More stack cleanup on GPU_buffers 2014-04-09 04:42:26 +03:00
b5d3f183b0 Add material storage to derivedmesh.
The variables are considered invalid unless DM_update_materials is
called prior to use. Only use case currently is
mesh drawing. This helps with excessive allocation on the stack during
GPUObject creation, but may help elsewhere in the future as well.
2014-04-09 04:03:44 +03:00
2496636a65 GPU: replace callocs with malloc since reallocs aren't cleared 2014-04-09 09:31:20 +10:00
ebaf3781fa Dyntopo: replace GHash with GSet, saves some memory 2014-04-08 14:45:48 +10:00
cced07661a Matcaps.
Instead of setting color every time, just set it on material enable.
Handles all cases of surfaces. Thanks to Campbell for pointing out!
2014-04-08 01:25:49 +03:00
c6d85407d4 Forgotten to add this on last commit. This would cause dyntopo to always
refresh all its nodes if show diffuse was on.
2014-04-03 04:03:46 +03:00
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
965e5039f5 Refactor to recent matcap built-ins to not use the built in system.
Those variables would get declared on fragment shader level and since we
use reserved opengl variables, some compilers would throw an error
(NVIDIA allows, some ATI compilers may break). Instead, use a separate
opengl built-in category especially for them. This works on NVIDIA, and
will wait for tests of this commit from ATI users.
2014-04-02 15:08:04 +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
9630fa7c7e Fix T38973: GLSL error, when using Cycles Light Path node. 2014-03-06 09:06:20 +01:00
88f1c283a7 Tweak to T38766 fix: cycles now support setting viewport alpha for a material. 2014-02-24 19:53:14 +01:00
7ef1ed15f1 Fix T38766: blender material transparency setting not taken into account for viewport. 2014-02-24 15:44:22 +01:00
a3f4736a4d Fix T38766: cycles viewport incorrectly taking blender internal alpha into account. 2014-02-24 15:35:26 +01:00
b7fa08f88a Code cleanup: style 2014-02-22 11:14:15 +11:00
a252e27fec Fix T38633: glsl not working well with mixed cycles/blender material nodes. 2014-02-14 15:11:58 +01:00
1f5029b184 Fix T38503: crash in non-threadsafe VBO free code during render. 2014-02-07 13:33:15 +01:00
d900f5be55 Code cleanup: use bools where possible 2014-02-03 19:35:44 +11:00
6c1c6f22ce Removed the omat matrix from DupliObject.
This was storing the original object matrix, which builds on the
assumption that obmat is modified during dupli construction, which is a
bad hack.

Now the obmats are still modified, but this only happens outside of the
dupli system itself and the original ("omat") is stored as local
variables in the same place where the obmat manipulation takes place.
This is easier to follow and avoids hidden hacks as much as possible.

Reviewed By: campbellbarton

Differential Revision: https://developer.blender.org/D254
2014-01-23 10:20:42 +01:00
c02c2dfdd9 BGE Bitmap Text: add in check if the character is outside the range 2014-01-23 13:37:09 +11:00
2f46ed5564 Fix T38325: Game Engine Bitmap fonts failed for characters >128 2014-01-23 13:29:49 +11:00
621bf47e91 Docs: doxygen file descriptions for BLF, GPU and WM 2014-01-19 23:15:25 +11:00
09ce3c18ee Blender Internal: Tweak GLSL preview of the spot lamp to use shadow buffer also for ray shadows, to solve inconsistency with the sun lamp. 2014-01-18 02:23:44 +09:00
6489c1f94d Blender Internal: Correct GLSL preview, material using shader nodes didn't consider "Transparency" is a shader pipeline option. 2014-01-17 16:32:45 +09:00
6e8321f2c0 Fix GLSL compatible_pow to give 1.0 for 0 ^ 0 2014-01-14 22:58:07 +04:00
c48c62a831 Code Cleanup: replace checks for ima->source with BKE_image_is_animated 2014-01-14 04:59:58 +11:00
aad731d51c Code cleanup: remove BKE_object_where_is_calc_simul function.
It doesn't make any sense anymore with the current depsgraph and probably was
not useful for a long time, just a leftover from the pre 2.04 game engine.
2014-01-09 00:17:18 +01: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
0dabf824fb Fix T38045: Clone stamp crashes
Issue seems to be caused by thread-unsafe IMB_freeImBuf.
Now use generic BKE_image_release_ibuf to de-reference
image buffer which was acquired from image datablock.
2014-01-03 23:00:53 +06: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
709041ed0b Threaded object update and EvaluationContext
Summary:
Made objects update happening from multiple threads. It is a task-based
scheduling system which uses current dependency graph for spawning new
tasks. This means threading happens on object level, but the system is
flexible enough for higher granularity.

Technical details:

- Uses task scheduler which was recently committed to trunk
  (that one which Brecht ported from Cycles).

- Added two utility functions to dependency graph:
  * DAG_threaded_update_begin, which is called to  initialize threaded
    objects update. It will also schedule root DAG node to the queue,
    hence starting evaluation process.

    Initialization will calculate how much parents are to be evaluation
    before current DAG node can be scheduled. This value is used by task
    threads for faster detecting which nodes might be scheduled.

  * DAG_threaded_update_handle_node_updated which is  called from task
    thread function when node was fully handled.

	This function decreases num_pending_parents of node children and
	schedules children with zero valency.

    As it might have become clear, task thread receives DAG nodes and
    decides which callback to call for it.

    Currently only BKE_object_handle_update is called for object nodes.

    In the future it'll call node->callback() from Ali's new DAG.

- This required adding some workarounds to the render pipeline.
  Mainly to stop using get_object_dm() from modifiers' apply callback.
  Such a call was only a workaround for dependency graph glitch when
  rendering scene with, say, boolean modifiers before displaying
  this scene.

  Such change moves workaround from one place to another, so overall
  hackentropy remains the same.

- Added paradigm of EvaluaitonContext. Currently it's more like just a
  more reliable replacement for G.is_rendering which fails in some
  circumstances.

  Future idea of this context is to also store all the local data needed
  for objects evaluation such as local time, Copy-on-Write data and so.

  There're two types of EvaluationContext:

  * Context used for viewport updated and owned by Main. In the future
    this context might be easily moved to Window or Screen to allo
    per-window/per-screen local time.

  * Context used by render engines to evaluate objects for render purposes.
    Render engine is an owner of this context.

  This context is passed to all object update routines.

Reviewers: brecht, campbellbarton

Reviewed By: brecht

CC: lukastoenne

Differential Revision: https://developer.blender.org/D94
2013-12-26 17:24:42 +06:00
e9e08a1d12 Game Engine: Level of detail support and tools
Levels of detail can be added and modified in the object panel. The object
panel also contains new tools for generating levels of detail, setting up
levels of detail based on object names (useful for importing), and
clearing an object's level of detail settings. This is meant as a game
engine feature, though the level of details settings can be previewed in
the viewport.

Reviewed By: moguri, nexyon, brecht

Differential Revision: http://developer.blender.org/D109
2013-12-17 17:03:27 -08:00