Commit Graph

3028 Commits

Author SHA1 Message Date
0d57724c64 Fix T38062: normal map baking gave randomly values 127 or 128 in flat areas.
Due to float precision issues it was basically random which of the two was used,
now it's slightly biased towards 128, which is the convention for flat colors.
The small difference between 127 and 128 could give problems with sharp glossy
shaders where it would be visible as seams.
2014-01-08 23:36:11 +01:00
61c9cacbd7 Fix T38074: sequence rendering gave "No camera" warning for other scenes that
didn't need a camera because they use only compositing nodes.
2014-01-08 18:29:16 +01:00
4529fe9010 Fix for RE_engine_begin_result using a NULL pointer 2014-01-08 15:43:49 +11:00
71f689843d Fix deadlock happening when using Save Buffers for render
Summary:
Issue was caused by the same tile being written twice to
the EXR file. This was happening because of partial update
of work-in-progress tiles was merging result to the final
render result in order to make color management pipeline
happy.

We need to avoid such a merges and keep memory usage as
low as possible when Save Buffers is enabled.

Now render pipeline will allocate special display buffer
in render layer which will contain combined pass in the
display space. This keeps memory usage as low as we can
do at this moment.

There's one weak thing which is changing color management
settings during rendering would lead to lossy conversion.
This is because render result's display buffer uses color
space from the time when rendering was invoked.

This is actually what was happening in previous release
already actually so not a big issue.

Reviewers: brecht

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D162
2014-01-01 22:32:47 +06:00
9939ec06dd Fix T37994: crash in preview render after recent color management changes.
Reviewed By: brecht
2013-12-31 15:03:06 +01:00
0d6ae3fda2 Main API: refactor naming, use BKE_main_ prefix and add main arg. 2013-12-30 13:25:27 +11:00
873c6e5479 Fix movie output when using render border
Reported by @plasmasolutions in IRC.
2013-12-29 17:25:56 +06:00
602dcb47b0 Fix T36474: Blender 2.68a crashes upon rendering
Summary:
Original issue was caused by wring detection of whether
SS modifier is being applied for render/viewport. After
recent dependency graph commit this was no longer an
issue.

But it still might have happen conflict between viewport
draw and scene_update_for_newframe() invoked from render
thread when using external engines like Cycles.

Solved by adding viewport lock while scene is being
updated and objects being exported to the render engine.

Same lock was already used for Blender Internal.

Reviewers: brecht

Reviewed By: brecht

Maniphest Tasks: T36474

Differential Revision: https://developer.blender.org/D138
2013-12-27 18:52:41 +06:00
feac8ee090 Fix out-of-date comment which came from DAG-MT branch 2013-12-27 02:32:56 +06: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
15927e05e4 Fix T37675: blender internal viewport render not updating properly with volumes. 2013-12-18 15:46:30 +01:00
c5d7ea091f Changes to partial update during rendering
Summary:
Mainly addressed to solve old TODO with color managed fallback
to CPU mode when displaying render result during rendering.

That fallback was caused by the fact that partial image update
was always acquiring image buffer for composite output and was
only modifying display buffer directly.

This was a big issue for Cycles rendering which renders layers
one by one and wanted to display progress of each individual
layer. This lead to situations when display buffer was based on
what Cycles passes via RenderResult and didn't take layer/pass
from image editor header into account.

Now made it so image buffer which partial update is operating
with always corresponds to what is set in image editor header.

To make Cycles displaying progress of all the layers one by one
made it so image_rect_update switches image editor user to
newly rendering render layer. It happens only once when render
engine starts rendering next render layer, so should not be
annoying for navigation during rendering.

Additional change to render engines was done to make it so
they're able to merge composite output to final result
without marking tile as done. This is done via do_merge_result
argument to end_result() callback. This argument is optional
so should not break script compatibility.

Additional changes:

- Partial display update for Blender Internal now happens from
  the same thread as tile rendering. This makes it so display
  conversion (which could be pretty heavy actually) is done in
  separate threads. Also gives better UI feedback when rendering
  easy scene with small tiles.

- Avoid freeing/allocating byte buffer for render result
  if it's owned by the image buffer. Only mark it as invalid
  for color management.

  Saves loads of buffer re-allocations in cases when having
  several image editors opened with render result. This change
  in conjunction with the rest of the patch gave around
  50%-100% speedup of render time when displaying non-combined
  pass during rendering on my laptop.

- Partial display buffer update was wrong for buffers with number
  of channels different from 4.

- Remove unused window from RenderJob.

- Made image_buffer_rect_update static since it's only used
  in single file.

Reviewers: brecht

Reviewed By: brecht

CC: dingto

Differential Revision: http://developer.blender.org/D98
2013-12-17 23:42:38 +06:00
ce893552c3 Image cache rewrite to using generic movie cache
Summary:
Behaves very much the same as cache for Movie Clip datablock:

- Image now have `MovieCache *cache` field which replaced
  legacy `ListBase ibufs`.

  This allows image datablock to easily keep of image
  buffers which are owned by itself. This field isn't
  saved to the file and getting restored on undo steps.

  However, cache limit is global for movies, sequences
  and image datablocks now. So overall cached image buffers
  size will not go above cache limit size in user
  preferences.

- Image buffers which are marked as BITMAPDIRTY will never
  be freed from the cache.

- Added utility function to iterate over image buffers
  saved in movie cache.

- Movie cache cleanup check callback now have ImBuf argument
  which can be used in a condition of cleanup.

- Added some utility functions which replaces legacy ibufs
  iterations with image cache iteration which happens from
  inside a lock.

- Fixed `image_mem_size()` which was only counting one of
  the buffers if both float and byte buffer present.

Additional notes:

- `BKE_image_get_first_ibuf()` is rather stupid, but direct
  access to ibufs->first was also the same stupid idea.

  Would consider avoid this function is another project.

- There are some places which doesn't look threadsafe, but
  they already were not so much threadsafe anyway before.

  So think not a big deal with solving this later.

Finally solves infinite memory usage by image sequences! :)

Reviewers: brecht, campbellbarton

Reviewed By: brecht

CC: sebastian_k

Differential Revision: http://developer.blender.org/D95
2013-12-13 16:30:00 +06:00
ec4ed2e3df Code Cleanup: replace global debug checks in raycast with DEBUG ifdef 2013-12-12 15:30:50 +11:00
f3d13bec6d Code Cleanup: correct fabsf/fabs/abs use 2013-12-04 09:24:38 +11:00
46eef60d93 Cleanup: Internal degrees removal.
This patch changes most of the reamining degrees usage in internal code into radians.
I let a few which I know off asside, for reasons explained below - and I'm not sure to have found out all of them.

WARNING: this introduces forward incompatibility, which means files saved from this version won't open 100% correctly
         in previous versions (a few angle properties would use radians values as degrees...).

Details:
- Data:
-- Lamp.spotsize: Game engine exposed this setting in degrees, to not break the API here I kept it as such
                  (using getter/setter functions), still using radians internally.
-- Mesh.smoothresh: Didn't touch to this one, as we will hopefully replace it completely by loop normals currently in dev.

- Modifiers:
-- EdgeSplitModifierData.split_angle, BevelModifierData.bevel_angle: Done.

- Postprocessing:
-- WipeVars.angle (sequencer's effect), NodeBokehImage.angle, NodeBoxMask.rotation, NodeEllipseMask.rotation: Done.

- BGE:
-- bConstraintActuator: Orientation type done (the minloc[0] & maxloc[0] cases). Did not touch to 'limit location' type,
                        it can also limit rotation, but it exposes through RNA the same limit_min/limit_max, which hence
                        can be either distance or angle values, depending on the mode. Will leave this to BGE team.
-- bSoundActuator.cone_outer_angle_3d, bSoundActuator.cone_inner_angle_3d: Done (note I kept degrees in BGE itself,
                                                                           as it seems this is the expected value here...).
-- bRadarSensor.angle: Done.

Reviewers: brecht, campbellbarton, sergey, gaiaclary, dfelinto, moguri, jbakker, lukastoenne, howardt

Reviewed By: brecht, campbellbarton, sergey, gaiaclary, moguri, jbakker, lukastoenne, howardt
Thanks to all!

Differential Revision: http://developer.blender.org/D59
2013-12-03 20:35:45 +01:00
cc55913798 Fix T37225: UV map for closed curves incorrectly generated
Summary:
Curve ORCO was not calculating properly for cyclic 2D curves.

- Needed to split vertices for blender internal renderer.
  Otherwise it's not possible to map last face to a proper
  texture location.

- Needed to tweak curve->mesh conversion to respect cyclic
  flag along U direction.

- Removed check for orcodm in curve.c:add_orco_dm since
  this code is only called if there're enabled constructive
  modifiers on the curve.

Reviewers: brecht

Maniphest Tasks: T37225

Differential Revision: http://developer.blender.org/D45
2013-11-26 03:02:13 +06:00
ab9822eff8 Blender Internal: Add "Lamp Data" shader node that allows shaders to acquire information such as light vector from specified Lamp.
For now this provides the following outputs:

- Color
- Light Vector
- Distance
- Shadow
- Visibility Factor

Note: Color output is multiplied by the lamp energy.  Multiplication of
color*max(dot(light_vector,normal_vector),0)*shadow*visibility_factor
produces the exact same result as the Lambert shader.

Many thanks to Brecht for code review and discussion!
2013-11-25 22:19:47 +09:00
5feb0d2bfe Fix T37359: Dynamic Paint deletes inactive texture from smoke domain when using a material as brush color 2013-11-22 15:25:19 +02:00
885354daec Optimization for render result save
Skip byte->float conversion if output file format
supports high bit depths but configured to only
output 8 bits per channel.

Gives around 30% speedup when re-exporting movie file
to PNG image sequence here on laptop.

Possible further optimization:

- Skip color space conversion in imbuf_for_write
  function if we've got already have buffer in
  that space.

  This doesn't seem to happen often after tweak
  to render result to imbuf.

- Skip black alpha-under if original image is
  opaque,

  This is a bit tricky to detect.
2013-11-22 16:52:12 +06:00
b0ea93aa9d * Remove more code for stars, missed those. Sorry! 2013-11-20 19:37:23 +01:00
30512d7c55 Blender Internal:
* Remove Stars feature. This was a quite minimalistic feature and there are
better alternatives with more control (particles for example).

Removal discussed during BCon13 developer meeting and already years before, time to do it..

Reviewed By: brecht
Differential Revision: http://developer.blender.org/D17
2013-11-20 19:13:41 +01:00
fb91a602c7 Blender Internal:
* Remove "Edge" post processing effect and the corresponding render layer.

Since we have freestyle, this is not needed anymore and was a very simple effect anyway (Zbuffer filter effect, could be added to the compositor if really needed again).

Reviewed By: brecht, ton
Differential Revision: http://developer.blender.org/D14
2013-11-19 20:30:49 +01:00
8b3524c215 Fix T37486: Displacement bake from multires crashes when preview level is on 0
Revert "Code cleanup: remove unused block from multire baker"

This reverts commit 63b01f6bee.

Multires displacement baker in fact uses level 0 for the
original subdivided mesh. Missed this when was making an
original commit.
2013-11-18 13:09:10 +06:00
ba7fd8cd5c Change the behavior of AO pass in Blender internal's shader/render node tree so that it becomes (1.0, 1.0, 1.0) when AO is disabled.
For materials using AO pass, this makes the material preview and the GLSL
preview more accurate, but shouldn't affect final rendering in most cases
because we usually enable AO when using the AO pass in node tree.

Thanks to Brecht for code review.
2013-11-12 10:59:40 +00:00
beae4f498d code cleanup: spelling 2013-10-31 14:10:01 +00:00
63b01f6bee Code cleanup: remove unused block from multire baker
Mapping from grid on ll 0 was not used and was incorrect
since bmesh merge anyway.
2013-10-29 16:43:58 +00:00
22396540d7 patch [#37219] RenderParts.partsdone is not a boolean, but a counter
from Lawrence D'Oliveiro (ldo)
2013-10-28 23:59:28 +00:00
01da2c0e53 fix [#37195] particles crash with viewport render 2013-10-26 22:38:12 +00:00
93edbf3510 add check for cmake that source files are not included multiple times 2013-10-25 06:21:38 +00:00
6193963daa style cleanup 2013-10-22 03:03:56 +00:00
3718c04844 Fix compositor rendering scenes multiple times in some cases
Issue was caused by Blender Internal changing LIB_DOIT flag
for scene when it gets updated for new frame. This leads into
conflict with flag used for tagging scenes fr render,

For now made it so nodes are being tagged instead of scene.
Only none node from those who're sharing the scene will be
tagged. And rendering scenes for node tree now checks for
node flag instead of scene's datablock one.

Ideally this tag would be replaced with scenes stored in an
array, but then it's not so clear how to check which node
to update.
2013-10-20 01:09:25 +00:00
a709cb2d55 Fix #37123: UV editor view does not update when using large faces
Update tagging was happening only after full triangle was handled.
Now made it so images are updating once in 0.5sec, progress bar
will still update only after the whole triangle is done.
2013-10-17 18:29:01 +00:00
ecf2eeef23 style cleanup 2013-10-16 04:08:20 +00:00
4f05cecbcd Fix duplicated key in ghash assert caused by object orco
Code was rather confusing, get_object_orco was only
checking for orco in cache for some objects and was
actually allocating orco for other objects.

Now made it so get_object_orco always only checks
the cache and only call set_object_orco if there's
no orco for it yet.
2013-10-15 09:08:08 +00:00
3cfd933d94 code cleanup: correct unsigned int in string formatting and use empty() checks for vectors. 2013-10-14 08:23:57 +00:00
014318370d * Silence Blender Internal / Volumetric printf. 2013-10-13 22:33:30 +00:00
f0dcff9aa9 Task scheduler ported form CYcles to C
Replaces ThreadedWorker and is gonna to be used
for threaded object update in the future and
some more upcoming changes.

But in general, it's to be used for any task
based subsystem in Blender.

Originally written by Brecht, with some fixes
and tweaks by self.
2013-10-12 14:08:59 +00:00
1a3011ac83 Fix #37045: blender internal SSS rendering black on some system when the SSS
reflection color was set to 1 1 1. BSSRDF parameter fit not converging properly
due to float precision issues.
2013-10-12 13:44:40 +00:00
b6db417ee4 code cleanup: use const's for vector args. 2013-10-12 02:19:37 +00:00
afab39b9d6 code cleanup: use const's for static arrays 2013-10-10 20:22:17 +00:00
33894a4cd5 Bake vertex colors should include vertex color alpha as well. 2013-10-10 12:50:34 +00:00
bbd9b5f476 Support for baking vertex colors to textures.
It allows effects such as baking vertex dirt maps to textures.
Also vertex based painting painting may be faster in the future,
so this is useful to have.

Thanks to Sergey for the review!
2013-10-10 11:00:12 +00:00
Lukas Toenne
c1541a940d Fix #36991, After rendering with Sampled Motion Blur, the moving objects place is wrong.
With mblur the render function was setting scene frame for each blur sample and calling DAG update, but not after the last sample is finished, leaving the scene in the wrong frame.
2013-10-09 16:49:13 +00:00
d917bdb095 Derivative map baker
Added support for derivative map baking, which
is accessable as a dedicated baker type. Works
pretty much the same as displacement map baker,
but gives you derivative map.

In fact, inernally this baker is just a filter
which applies on the result of displacement map.

Both regular and multires baking are supported.

Patch by Morten Mikkelsen and self.
2013-10-09 15:51:14 +00:00
06c6d3235c Fix #36884: blender spotlamp halo render was incorrectly showing light on the
backside of objects, after bugfix in revision 56145.

It now still always renders one step, but step size is clamped to fit within
the halo volume.
2013-09-30 15:27:45 +00:00
aa8488421f style cleanup: whitespace & odd indentation 2013-09-21 10:46:58 +00:00
7617eadae4 Clear color to gray when baking displacement map
This makes more sense to have no displacement if baking
non-normalized displacement map or have mid-level displacement
(which is likely be close to no displacement as well) when
baking normalized displacement.

In any way it's better than using default black color.
2013-09-20 10:14:54 +00:00
556fa5e205 Fix for margin which didn't work properly with normalized displacement baking 2013-09-20 09:28:58 +00:00
aa077fecd7 Fix for displacement bake buffer might be allocated twice
Issue was caused by missing NULL-pointer check in user-data
initialization.

This issue might have lead to wrong displacement map being
baked.
2013-09-20 09:28:52 +00:00