Commit Graph

3047 Commits

Author SHA1 Message Date
2fe0cf54a5 Fix T40712: Duplicators don't generate orco and UV coordinates in Cycles viewport preview.
Fix T39286: Display percentage ignored in Cycles viewport.

The threaded depsgraph update changes included a cleanup of the global
is_rendering flag, which was replaced by a general EvalContext being
passed to dupli functions.

Problem is that the global flag was true for viewport duplis before
(ugly hack), which was used as a check for generating dupli orco/UV from
mesh data layers. The new flag is stricter and only true for actual
renders, which disables these attributes and breaks the Cycles
Texture Coordinates and UVMap nodes.

The solution is to extend the simple for_render boolean to an enum:
* VIEWPORT: OpenGL viewport drawing (dupli tex coords omitted)
* PREVIEW: Viewport preview render (simplified modifiers)
* RENDER: Full render with all details and attributes

There are still some areas that need to be examined, in particular
modifiers seem to totally ignore the EvaluationContext!
Instead they generally execute without render params from the depsgraph
(BKE_object_handle_update_ex) and are built with render settings
explicitly.

Differential Revision: https://developer.blender.org/D613
2014-07-07 10:54:14 +02:00
6ff6883f99 Fix T40843: Cycles does not support viewport render override 2014-07-04 16:34:15 +06:00
3f1ed437c1 Follow-up to rBcc1372546ad5: Fix for segmentation fault in pipeline (freestyle/wm related).
Render->freestyle_bmain is set to NULL after BKE_main_free() so that
the struct Main is not considered for tagging any longer.
2014-07-03 11:09:11 +09:00
cc1372546a Fix for segmentation fault in pipeline (freestyle/wm related) 2014-07-01 19:43:52 +02:00
6c6fa749f6 Second attempt to fix T40833: Crash when rendering with freestyle.
The cause of the crash was identified in an uninitialized member variable
`Main->lock`.  Now that struct Main has a few member variables whose
values are dynamically allocated, per-render Freestyle-specific Main data
structures will be allocated and released using `BKE_main_new()` and
`BKE_main_free()`, respectively.

This revision complements the commit rB6135556f4556.
2014-07-01 23:36:53 +09:00
78cdc707ab Add render result caching.
Simply add an option to render settings to save an EXR cache,
just when the render is finished. Also changed RE_ReadRenderResult() to read
cache instead of temp sample files (those are fully volatile now anyway).

Path to save cached render results is an UserPreferences setting.

Also added 'Reload render' feature to the Image Editor (so one can now re-open a blend,
and in an Image Editor hit ctrl-R to (try to) reload last render from cache).

Reviewers: campbellbarton, sergey

Differential Revision: https://developer.blender.org/D553
2014-06-28 19:23:34 +02:00
414c70435d T39690: Modifications to Blender's 'temp dir' system.
Current temporary data of Blender suffers one major issue - default 'temp' dir on Windows is never
automatically cleaned up, and can end being quite big when used by Blender, especially when we have
to store per-process data (using getpid() in file names).

To address this, this patch:
* Divides tempdir paths in two, one for 'base' temp dir (the same as previous unique tempdir path),
  the other is a mkdtemp-generated sub-dir, specific to each Blender instance.
* Only uses base tempdir when we need some shallow persistance accross Blender sessions - and we always
  reuse the same filename (quit.blend...) or generate small file (crash reports...).
* Uses temp sub-dir for heavy files like pointcache or renderEXRs (Save Buffer option).
* Erases temp sub-dir on quit or crash.

To get this working it also adds a working 'recursive delete' to BLI_delete() under Windows.

Note that, as in current code, the 'recover render result' hack-feature that was possible
with SaveBuffer option is still removed. A real renderresult cache feature will be added
soon, though.

Reviewers: campbellbarton, brecht, sergey

Reviewed By: campbellbarton, sergey

CC: sergey

Differential Revision: https://developer.blender.org/D531
2014-06-23 13:42:54 +02:00
3bd965bc03 Fix T40764: Keyframed Render Layers Don't Work as Intended 2014-06-23 14:33:58 +06:00
ca0c0e7549 Implement resolution divider in the Blender Internal
Currently resolution divider is not exposed to the
interface yet, and i'm not even sure it needs to be
exposed because it's somewhat weird configuration.
Need to check how often artists are changing start
resolution in Cycles.

Pretty much straightforward implementation with the
only weak part: render result is getting re-allocated
and upscaled when current resolution is finished.
Not sure how to make it faster actually. Maybe it's
just a matter of making upscale fast enough.

Needed to fix some possible memory leak happening
in Freestyle when canceling rendering on a special
stage -- it was missing temp bmain free,

Reviewers: campbellbarton, dingto

CC: sebastian_k, fsiddi, venomgfx

Differential Revision: https://developer.blender.org/D609
2014-06-20 17:32:45 +06:00
Dalai Felinto
1ef5669ad7 Fixup for fd0b7428 Bake-API: allow custom UV to be baked 2014-06-18 18:58:36 -03:00
Dalai Felinto
fd0b74280e Bake-API: allow custom UV to be baked
Note: the custom UV option is only available when calling the operator
via a script. It's currently not exposed in the UI since it's intended
to be used by scripters

To test it:
bpy.ops.object.bake(type='UV', use_clear=True, uv_layer='MyNewUV')

Reviewers: campbellbarton

Differential Revision: https://developer.blender.org/D546
2014-06-17 12:16:43 -03:00
Dalai Felinto
b0708dd718 Bake-API: handle objects with no faces (fix T40601)
Also it has a better error handling for the BVHTree creation
Fix for 2.71
2014-06-13 14:37:59 -03:00
6a75ecda9b Code cleanup: spelling 2014-06-14 00:47:10 +10:00
Dalai Felinto
a8a536d23d Bake-API: new approach for cage
There is a new option to select whether you want to use cage or not.
When not using cage the results will be more similar with Blender
Internal, where the inwards rays (trying to hit the highpoly objects)
don't always come from smooth normals. So if the active object has sharp
edges and an EdgeSplit modifier you get bad corners.

This is useful, however, to bake to planes without the need of adding
extra loops around the edges.

When cage is "on" the user can decide on setting a cage extrusion or to
pick a Custom Cage object. The cage extrusion option works in a
duplicated copy of the active object with EdgeSplit modifiers removed to
inforce smooth normals. The custom cage option takes an object with the
same number of faces as the active object (and the same face ordering).

The custom cage now controls the direction and the origin of the
rays casted to the highpoly objects. The direction is a ray from the
point in the cage mesh to the equivalent point to the base mesh. That
means the face normals are entirely ignored when using a cage object.

For developers:
When using an object cage the ray is calculated from the cage mesh to
the base mesh. It uses the barycentric coordinate from the base mesh UV,
so we expect both meshes to have the same primitive ids (which won't be
the case if the cage gets edited in a destructive way).

That fixes T40023 (giving the expected result when 'use_cage' is false).

Thanks for Andy Davies (metalliandy) for the consulting with normal
baking workflow and extensive testing. His 'stress-test' file will be
added later to our svn tests folder. (The file itself is not public yet
since he still has to add testing notes to it).

Many thanks for the reviewers.

More on cages:
http://wiki.polycount.com/NormalMap/#Working_with_Cages

Reviewers: campbellbarton, sergey

CC: adriano, metalliandy, brecht, malkavian

Differential Revision: https://developer.blender.org/D547
2014-06-11 02:39:35 -03:00
650f1d0a6f Blender Internal: Fix for lamp option "Specular" not working when "Only Shadow" is enabled.
This is followup to rB8008d9bdfd57. Blender Render and GLSL preview
now produce the same results.
2014-06-05 16:08:15 +09:00
edfd989e86 Fix T40315: Boolean modifier with Freestyle edges.
The helper function `make_freestyle_edge_mark_hash()` was referring to the
original mesh to determine Freestyle edge marks for individual derived mesh edges.
This is no longer necessary now that derived meshes deliver CD_FREESTYLE_EDGE
and CD_FREESTYLE_FACE layers of their own.  The reference of the original mesh
was also inappropriate since the edges coming from one of the operands of a boolean
modifier don't have proper CD_ORIGINDEX values but ORIGINDEX_NONE's.

Many thanks to Sergey Sharybin for patch contributions and discussions.
2014-06-01 16:24:18 +09:00
Dalai Felinto
50a7843ab1 Bake-API: replacing some MEM_callocN by MEM_mallocN
As suggested and reviewed by Campbell Barton. This is the most trivial of the cases. I will look if I can do it elsewhere in the bake code
2014-05-29 23:18:21 -03:00
Dalai Felinto
2a9efa4e51 Bake-API: Support for batch baking
When "Selected to Active" is not on, we bake all the selected objects.
This is the same behaviour we have for Blender Internal.

Dev note: I moved most of the validation tests to outside the bake()
routine so the function can be called in loop.

Reviewers: campbellbarton

Differential Revision: https://developer.blender.org/D560
2014-05-29 22:56:57 -03:00
Dalai Felinto
2057a3a2fc Proper fix T40156 Cycles Baking and applyRotation issues
This should be the final fix for the applyrotation issue. It baffles me
that the fix involves discarding the scale transformations for the
normals but it works so I'm happy with it.

Reviewers: campbellbarton

Differential Revision: https://developer.blender.org/D554
2014-05-29 12:20:55 -03:00
5811076d0d Fix crash rendering linked scenes in compo
Simply linking scene (lib.blend) without compo into another one (compo.blend),
using it in a compositor and rendering it would crash.
2014-05-23 17:42:15 +02:00
561be3ac53 Bake API: compare with NULL rather then casting to bool 2014-05-23 14:54:12 +10:00
c56bbccb0d Fix T39901: Crashes if the resolution % is changed while rendering an animation
Copy render percentage. dimensions and border settings and use them for all the
frames in the animation render.
2014-05-22 14:39:31 +02:00
049b6cfa6d Fix for image garbage collection failing to run for render-only views
Check for freeing old images was running per-object, move this to viewport drawing.
2014-05-22 11:58:07 +10:00
Dalai Felinto
8d297394ba Bake API: partial fix T40156 (applyRotation issues)
This fixes most of the cases, the only situation not addressed is when
the highpoly object(s) has non-uniform scale.

mul_transposed_mat3_m4_v3() should take care of non-uniform scales so
I'm a bit confused on why it doesn't work. The lowpoly object can have
any transformation, the only issue is if the highpoly object has
non-uniform scale.

Test file of the remaining issue:
https://developer.blender.org/file/info/PHID-FILE-tpw2xgddyzxtpg3e7xzs/

Reference reading:
http://www.unknownroad.com/rtfm/graphics/rt_normals.html
2014-05-21 15:10:57 -03:00
27cebb2651 Fix T39711: cycles particle motion blur affected by viewport draw method. 2014-05-21 15:51:37 +02:00
f8554ed61a Fix T39669: Freestyle: Curve with extrude>0 causes warnings in console.
The reported Freestyle warnings were due to wrong normals of filled faces at both ends
of a 2D extruded curve. The problem is detailed in the comment #19 of T39669.

The cause of the bug was an inconsistency in the use of vertex indices between
BKE_mesh_nurbs_displist_to_mdata() and init_render_curve() in the case of
DispList::type equal to DL_INDEX3.

This commit also fixes a related bug that the normals of filled faces were not inverted
when a scale of the curve object is set to a negative value (e.g., the Z scale was -1).

Reviewers: campbellbarton

Reviewed By: campbellbarton

Differential Revision: https://developer.blender.org/D532
2014-05-17 08:51:00 +09:00
295c37caa4 Fix T39763: Blender renders disabled Render Layers using Blender Internal
For now only disables scene render if all the layers are disabled, but scene
will still be rendered if it's used in compo, has enabled layers which are
not used by compo.

Current pipeline doesn't allow to handle such cases nicely, so leaving it
for later.
2014-05-15 18:21:02 +02:00
48881ad1e0 Code cleanup: doxy comments 2014-05-14 15:00:47 +10:00
7fb96ff00d Fix T40142: Objects restricted in render/view don't produce duplis in
with correct transform for Blender Internal.

According to previous code the obmat must be modified even if the
duplicated object itself is filtered later. TBH i have no idea how/why
this works, but nobody else does either ... All obmats are restored
after BI messes with them during render, so should be fine ...
2014-05-12 08:55:47 +02:00
Dalai Felinto
8943dc60ec Bake API: selected to active needs differentials or it renders black when bump/displacement (fix T40101) 2014-05-10 10:06:53 -03:00
Dalai Felinto
4c5fe540bf ammend to [31cb7e39] Bake API: calculating differentials 2014-05-08 15:05:12 -03:00
Dalai Felinto
31cb7e395e Bake API: calculating differentials
Code with contribution from Brecht Van Lommel (he wrote the
bake_differentials actually ;)

Reviewers: brecht

Differential Revision: https://developer.blender.org/D510
2014-05-08 14:38:30 -03:00
5cee409d42 Followup fix to T39966.
The previous fix was not quite correct:
* It would use the same wireframe/bbox check in viewport- and regular render
* The duplicator loop in Blender Internal is more permissive now to avoid disabling wireframe duplicators, but this means we need to check is_object_hidden right before making render objects to ensure this still works.
2014-05-06 17:47:48 +02:00
fbfaa4770d Fix T39322, hair not rendered in rendered mode viewport after returning
from particle edit mode.

Check for object particle edit mode, not psys->edit. This won't get
freed on exit (which might be worth considering doing, maybe?)
2014-05-05 19:51:58 +03:00
48c1a7f8a4 Doxy cleanup: formatting 2014-05-03 23:45:17 +10:00
6ec2d72eca Alternative fix for T39941, this also fixes odd behavior of rendered preview.
The rendered preview didn't show active layer or wasn't updated if the
layer was disabled. Now the viewport always shows an active layer regardless
of whether it's enabled or disabled.
2014-05-03 18:29:58 +09:00
Dalai Felinto
97641a0ec9 Bake API - bpy.ops.object.bake()
New operator that can calls a bake function to the current render engine when available. This commit provides no feature for the users, but allows external engines to be accessed by the operator and be integrated with the baking api.

The API itself is simple. Blender sends a populated array of BakePixels to the renderer, and gets back an array of floats with the result.

The Blender Internal (and multires) system is still running independent, but we eventually will pipe it through the API as well. Cycles baking will come next as a separated commit

Python Operator:
----------------
The operator can be called with some arguments, or a user interface can be created for it. In that case the arguments can be ommited and the interface can expose the settings from bpy.context.scene.render.bake

bpy.ops.object.bake(type='COMBINED', filepath="", width=512, height=512, margin=16, use_selected_to_active=False, cage_extrusion=0, cage="", normal_space='TANGENT', normal_r='POS_X', normal_g='POS_Y', normal_b='POS_Z', save_mode='INTERNAL', use_clear=False, use_split_materials=False, use_automatic_name=False)
Note: external save mode is currently disabled.

Supported Features:
------------------
 * Margin - Baked result is extended this many pixels beyond the border of each UV "island," to soften seams in the texture.

 * Selected to Active - bake shading on the surface of selected object to the active object. The rays are cast from the lowpoly object inwards towards the highpoly object. If the highpoly object is not entirely involved by the lowpoly object, you can tweak the rays start point with Cage Extrusion. For even more control of the cage you can use a Cage object.

 * Cage Extrusion - distance to use for the inward ray cast when using selected to active

 * Custom Cage - object to use as cage (instead of the lowpoly object).

 * Normal swizzle - change the axis that gets mapped to RGB

 * Normal space - save as tangent or object normal spaces

Supported Passes:
-----------------
Any pass that is supported by Blender renderlayer system. Though it's up to the external engine to provide a valid enum with its supported passes. Normal passes get a special treatment since we post-process them to converted and "swizzled"

Development Notes for External Engines:
---------------------------------------
(read them in bake_api.c)

* For a complete implementation example look at the Cycles Bake commit (next).

Review: D421
Reviewed by: Campbell Barton, Brecht van Lommel, Sergey Sharybin, Thomas Dinge

Normal map pipeline "consulting" by Andy Davies (metalliandy)
Original design by Brecht van Lommel.

The entire commit history can be found on the branch: bake-cycles
2014-05-02 21:19:08 -03:00
b62c2a913b Fix T39985: crash while rendering a scene with compositing nodes using another scene
The issue was caused by the wrong scene used to acquire render result for.

Now made it so render pipeline reports currently rendering scene to the job
via special callback.

This also solves missing tile highlight issue when rendering multiple scenes
in the compositor.
2014-05-02 14:54:13 +02:00
1552b56d9c Fix for missing render layer display buffer allocation 2014-05-02 14:54:12 +02:00
b2c2edf6ae Fix T39966: Whole Group option of dupligroup visualization of particles
does not work as expected for Viewport and Blender Internal.

As @sergey noticed, this was caused by rBfbf8595, which disabled
rendering for wireframe objects in the viewport. However, the same
function `is_object_hidden` is also used for skipping dupli objects then
which may themselves be renderable.

Now use two variants:
* is_object_restricted is the previous test for general viewport/render visibility (lets wireframe duplicators pass)
* is_object_hidden includes the wireframe check for actual render instances
2014-05-02 13:08:15 +02:00
4ca67869cc Code cleanup: remove unused includes
Opted to keep includes if they are used indirectly (even if removing is possible).
2014-05-01 04:47:51 +10:00
1f4cfb3974 Fix T39952: Printing tiles gives negative numbers 2014-04-30 09:34:37 +10:00
1dcf956849 Fix for wrong behavior of 'darken' blend mode with factor.
The formula was not consistent across Blender and behaved strangely, now it is
a simple linear blend between color1 and min(color1, color2).

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D489
2014-04-29 14:03:09 +02:00
4ff3ebf45c Fix T39940: animation of render layer on/off toggle not working during render. 2014-04-29 14:03:09 +02:00
7544961ea5 Fix T39942: Displacement of group instance objects when switching to textured viewport shading
Usual dupli object issue, sometimes it's needed that all the object in
dupli group have modified obmat.

Made it an utility function now, which is used by convertblender and
dupli draw code now.
2014-04-29 17:52:04 +06:00
182e97a2cd Fix T39941: Freestyle: Rendered preview crashes when non-primary render layer is selected and disabled.
Freestyle relies on render layer name (RenderLayer::name) to find the render layer that
corresponds to a scene render layer being rendered.

When the active render layer is disabled during preview rendering, the function
render_result_new() populates the list of render layers (RenderResult::layers) with an
unnamed render layer while setting the active scene render layer index to zero.

This commit fixes the missing initialization of the render layer name by referring to that of
the first in the list of scene render layers.
2014-04-29 20:41:48 +09:00
409fb4da0c Code cleanup: remove redundant matrix initialization 2014-04-29 18:13:20 +10:00
f2d25975b5 Code cleanup: use 'const' for arrays (render) 2014-04-27 00:25:15 +10:00
1e6fa59e4f Fix T39852: Crash (Blender internal) large objects
Add check when bounds reached inf
2014-04-24 03:07:45 +10:00
7cdf5992dd Add asserts to raytrace get/set_cut functions 2014-04-24 02:30:39 +10:00