Commit Graph

231 Commits

Author SHA1 Message Date
Campbell Barton 4b9ff3cd42 Cleanup: comment blocks, trailing space in comments 2021-06-24 15:59:34 +10:00
Jeroen Bakker 7b30a3e98d Performance: Use parallel range for ImBuf scanline processor.
Scanline processor did its own heurestic what didn't scale well when
having a multiple cores. In stead of using our own code this patch will
leave it to TBB to determine how to split the scanlines over the
available threads.

Performance of the IMB_transform before this change was 0.002123s, with
this change 0.001601s. This change increases performance in other areas
as well including color management conversions.

Reviewed By: zeddb

Differential Revision: https://developer.blender.org/D11578
2021-06-11 15:55:22 +02:00
Jeroen Bakker 28617bb167 Sequencer: Transform ImBuf Processor.
Inside the sequencer the cropping and transform of images/buffers were
implemented locally. This reduced the optimizations that a compiler
could do and added confusing code styles. This patch adds
`IMB_transform` to reduce the confusion and increases compiler
optimizations as more code can be inlined and we can keep track of
indices inside the inner loop.

This increases end-user performance by 30% when playing back aa video
in VSE.

Reviewed By: ISS, zeddb

Differential Revision: https://developer.blender.org/D11549
2021-06-11 09:34:44 +02:00
Sebastian Parborg 14508ef100 FFmpeg: Fix seeking not returning the correct frame when not using TC index
Fixed the logic for seeking in ffmpeg video files.
The main fix is that we now apply a small offset in ffmpeg_get_seek_pos
to make sure we don't get the frame in front of the seek position when
seeking backward.

The rest of the changes is general cleanup and untangling code.

Reviewed By: Richard Antalik

Differential Revision: http://developer.blender.org/D11492
2021-06-05 02:48:09 +02:00
Campbell Barton 35ddcb4041 Cleanup: clang-format, spelling 2021-02-12 07:49:40 +11:00
Jeroen Bakker 549d9f8727 Fix T81206: Do not limit gl texture size in image editor
This patch will show textures in the image editor with the maximum
available resolution determined by the GPU Hardware/Driver.
Currently the size is limited by the user preference texture size limit.

An image user can set the `IMA_SHOW_MAX_RESOLUTION` flag to request
gpu textures in the max supported resolution. When this flag isn't
set the gpu texture is limited by the user preference setting.

When the gl resolution limit is disabled the GPU texture is always
created for the max supported resolution.

Reviewed By: Clément Foucault

Maniphest Tasks: T81206

Differential Revision: https://developer.blender.org/D9160
2021-02-09 08:12:29 +01:00
Richard Antalik 5713626422 VSE: Improve motion-picture workflow
This commit resolves problem introduced in e1665c3d31 - it was
difficult to import media at their original resolution.
This is done by using original resolution as reference for scale.

All crop and strip transform values and their animation is converted
form old files.

To make both workflows easy to use, sequencer tool settings have been
created with preset for preffered scaling method. This setting is in
sequencer timeline header and add image or movie strip operator
properties.

Two new operators have been added:
`sequencer.strip_transform_fit` operator with 3 options: Scale To Fit,
Scale to Fill and Stretch To Fill.
Operator can fail if strip image or video is not loaded currently, this
case should be either sanitized or data loaded on demand.

`sequencer.strip_transform_clear` operator with 4 options:
Clear position, scale, rotation and all (previous 3 options combined).

Reviewed By: sergey, fsiddi

Differential Revision: https://developer.blender.org/D9582
2020-12-16 20:38:28 +01:00
Campbell Barton 934c2c8ac5 Cleanup: clang-tidy, remove invalid comments 2020-11-12 15:18:08 +11:00
Campbell Barton 99f56b4c16 Cleanup: use 'filepath' instead of 'name' for ImBuf utilities 2020-11-11 16:14:06 +11:00
Campbell Barton a5f8071bdf Cleanup: use bool for imbuf save callbacks 2020-11-11 16:14:05 +11:00
Campbell Barton 23c71a5fab ImBuf: support detecting the file format from in-memory images
Add `IMB_ispic_type_from_memory` so we can detect the file format
of in-memory images.

This removes `is_a_filepath` callback and uses a magic check for
photo-shop files that's compatible with OIIO.

Even though OIIO doesn't support packed images, we can still use the
file magic for detecting the format.

This change allows D9500 (a fix for unpacking images),
to be implemented without a significant performance penalty,
although the actual performance cost would depend heavily on the
blend file.

Reviewed By: dfelinto, sergey

Ref D9517
2020-11-10 22:25:05 +11:00
Richard Antalik e1665c3d31 VSE: Media transform redesign
This patch changes behavior of strip transform and crop feature.

Purpose of this change is to allow display arbitrary portion of input
image, simplify user interface and workflow.
Offset and Crop values in old files are converted in versioning.
Offset animation is also converted. Crop animation and animation of
crop or offset enable properties is not taken into account

Changes in behavior and interface:
- If image is added to timeline it is scaled to fit inside preview area
while maintaining aspect ratio. Image is centered. This is considered
as a baseline for further transformation.
- Scale and rotation was added, so it is possible to transform image at
it's original resolution.
- Crop will not affect image transformation (does not move image).
- Values of Crop and Transform Position are in pixels, these values are
corrected if preview is fraction of project resolution.
- Transform and Mirror panel has been removed and new Transform panel
and Crop panel is moved to Adjust panel. Mirror is now part of new
Transform panel.

Technical changes:
- Preprocessing stage must work on duplicated image, because original is
cached. Previously Crop and Offset could run at once and required only
one duplication of image. This is not the case with new algorithms, so
duplication on demand is implemented. Transformation can read original
image and will output new image that is safe to modify. It should be
possible to add crop step to transform algorithm, so that Crop won't
require previous duplication though.
- Use Crop and Use Translation checkboxes were removed. Individual
values are compared to default values to check if image needs to be
processed. In case of transform this will be done also if resolution of
source.

Reviewed By: sergey

Differential Revision: https://developer.blender.org/D8393
2020-11-02 22:15:52 +01:00
Richard Antalik 6b3eca661d Revert "VSE: Media transform redesign"
This reverts commit 0277579b28.

This commit caused build errors on Linux.
2020-11-02 20:59:21 +01:00
Richard Antalik 0277579b28 VSE: Media transform redesign
This patch changes behavior of strip transform and crop feature.

Purpose of this change is to allow display arbitrary portion of input
image, simplify user interface and workflow.
Offset and Crop values in old files are converted in versioning.
Offset animation is also converted. Crop animation and animation of
crop or offset enable properties is not taken into account

Changes in behavior and interface:
- If image is added to timeline it is scaled to fit inside preview area
while maintaining aspect ratio. Image is centered. This is considered
as a baseline for further transformation.
- Scale and rotation was added, so it is possible to transform image at
it's original resolution.
- Crop will not affect image transformation (does not move image).
- Values of Crop and Transform Position are in pixels, these values are
corrected if preview is fraction of project resolution.
- Transform and Mirror panel has been removed and new Transform panel
and Crop panel is moved to Adjust panel. Mirror is now part of new
Transform panel.

Technical changes:
- Preprocessing stage must work on duplicated image, because original is
cached. Previously Crop and Offset could run at once and required only
one duplication of image. This is not the case with new algorithms, so
duplication on demand is implemented. Transformation can read original
image and will output new image that is safe to modify. It should be
possible to add crop step to transform algorithm, so that Crop won't
require previous duplication though.
- Use Crop and Use Translation checkboxes were removed. Individual
values are compared to default values to check if image needs to be
processed. In case of transform this will be done also if resolution of
source.

Reviewed By: sergey

Differential Revision: https://developer.blender.org/D8393
2020-11-02 20:19:16 +01:00
Clément Foucault ab95cdaba9 GPUTexture: Change texture creation API
This is to modernize the API:
- Add meaningful name to all textures (except DRW textures).
- Remove unused err_out argument: only used for offscreen python.
- Add mipmap count to creation functions for future changes.
- Clarify the data usage in creation functions.

This is a cleanup commit, there is no functional change.

# Conflicts:
#	source/blender/gpu/GPU_texture.h
2020-09-05 17:49:14 +02:00
Sebastian Parborg 2115232a16 Cleanup: Clang-Tidy readability-inconsistent-declaration-parameter-name fix
No functional changes
2020-09-04 21:04:16 +02:00
Jacques Lucke 7283e6fb73 Merge branch 'blender-v2.90-release' into master 2020-08-07 10:04:57 +02:00
Jacques Lucke 91694b9b58 Code Style: use "#pragma once" in source directory
This replaces header include guards with `#pragma once`.
A couple of include guards are not removed yet (e.g. `__RNA_TYPES_H__`),
because they are used in other places.

This patch has been generated by P1561 followed by `make format`.

Differential Revision: https://developer.blender.org/D8466
2020-08-07 09:50:34 +02:00
Clément Foucault 55401fbb3d IMB: Refactor util_gpu.c to not expose enum getters
This was causing compiler error on MSVC and is not a good idea
in general.
2020-07-30 16:44:57 +02:00
Clément Foucault 5f6fb5bb41 Cleanup: Split gpu_texture_image.c into BKE and IMB modules
This is in order to disolve GPU_draw.h into more meaningful code blocks.

All the Image related function are in `image_gpu.c`.
All the MovieClip related function are in `movieclip.c`.

The IMB module now has a connection with GPU. This is not strickly
necessary and the code could be move to `image_gpu.c` if needed.

The Image garbage collection is also ported to `image_gpu.c`.
2020-07-29 23:06:37 +02:00
Campbell Barton 71d0f6f896 Cleanup: spelling 2020-07-19 17:37:02 +10:00
Sybren A. Stüvel b9f565881e VSE: Python API, allow creation of VSE Movie strips with missing file
It was already possible to create Sound and Image strips that reference
non-existing files. Now it's also possible to create Movie strips
referencing missing files via the Python API call
`Sequences.new_movie()`. In this case, the duration of the strip will be
set to 1 frame.

Note that this commit does not change anything in the user interface.

The Python API of the `MovieStrip` class is extended with a function
`reload_if_needed()`. This function only performs disk I/O if the movie
strip cannot produce frames, that is either when its filepath points to
a non-existing file, or when the video sequence editor has not been
shown yet (for example because it is in an inactive workspace).

This allows for the following:

```
import bpy

scene = bpy.context.scene
vse = scene.sequence_editor_create()

filepath = bpy.path.abspath('//demo.mkv')
strip = vse.sequences.new_movie("movie", filepath,
    channel=2,
    frame_start=47,
    file_must_exist=False)
strip.frame_final_end = 327
```

This will create a new movie strip, even when `demo.mkv` does not exist.

Once `demo.mkv` has appeared at the expected location, either
`strip.reload_if_needed()` or `strip.filepath = strip.filepath` will
load it.

Differential Revision: https://developer.blender.org/D8257

Reviewed By: Sergey, ISS
2020-07-13 15:09:18 +02:00
Jacques Lucke 725973485a Clang Tidy: enable readability-non-const-parameter warning
Clang Tidy reported a couple of false positives. I disabled
those `NOLINTNEXTLINE`.

Differential Revision: https://developer.blender.org/D8199
2020-07-13 11:27:09 +02:00
Antonio Vazquez 29f3af9527 GPencil: Refactor of Draw Engine, Vertex Paint and all internal functions
This commit is a full refactor of the grease pencil modules including Draw Engine, Modifiers, VFX, depsgraph update, improvements in operators and conversion of Sculpt and Weight paint tools to real brushes.

Also, a huge code cleanup has been done at all levels.

Thanks to @fclem for his work and yo @pepeland and @mendio for the testing and help in the development.

Differential Revision: https://developer.blender.org/D6293
2020-03-09 16:27:24 +01:00
Jacques Lucke d8198b27df Cleanup: make remaining imbuf headers work in C++ 2020-03-02 15:20:13 +01:00
Campbell Barton a9fbd05e7d Fix image undo restoring float/byte tiles into the wrong buffer type
This also resolves the (unlikely) issue of undo having uninitialized
zbuf data, now it's cleared instead.
2019-10-15 12:24:26 +11:00
Campbell Barton 151cc02b6f Image: support storing full image buffers for each undo step
Update image undo to store buffers for each step:

- Undo buffers share tiles to avoid using too much memory.
- Undo support for different sized buffers
  allowing operations such as crop or resize.
- Paint tiles have been split into separate API/storage.
- Painting speed wont be impacted significantly
  since storing the extra tiles is done after the stroke & only
  for the first undo step.

Resolves T61263, see D5939 for details.
2019-10-02 00:44:17 +10:00
Campbell Barton d0279f7d36 Cleanup: use const for image blending functions 2019-09-25 17:19:08 +10:00
Jeroen Bakker 6670019607 Workbench: Specular Highlighting for MatCaps
With Blender 2.80 we introduced a more flexible matcap system. One
change we did was to multiply the matcap with the base color that was
shaded. As matcaps contains diffuse and specular lighting in a single
texture this lead to rendering artifacts. Artists were complaining that
everything looked to metalic.

We now support a separate `diffuse` and `specular` pass for matcaps.

`shaded_color = diffuse_light * base_color + specular_light`

For matcaps to support this feature they need to be multilayer openexr
files with 2 renderpasses (named `diffuse` and `specular`). In the future
we can change this to first pass/second pass in stead of this naming
convention.

Reviewed By: fclem, brecht

Differential Revision: https://developer.blender.org/D5335
2019-08-27 08:56:56 +02:00
Campbell Barton 2790740813 Cleanup: spelling 2019-08-17 00:57:05 +10:00
Campbell Barton 502c2c233d Cleanup: misc spelling fixes in variable names & defines
T68045 by @luzpaz
2019-08-01 17:35:59 +10:00
Campbell Barton c497a7efab ImBuf: add crop function (move out of screendump.c) 2019-07-04 21:15:18 +10:00
Brecht Van Lommel 7aaa7aa9dd Images: change alpha settings to support channel packing
This also replaces the Use Alpha setting. We now have these alpha modes:

* Straight: store RGB and alpha channels separately with alpha acting as a
  mask, also known as unassociated alpha.
* Premultiplied: transparent RGB pixels are multiplied by the alpha channel.
  The natural format for renders.
* Channel Packed: different images are packed in the RGB and alpha channels,
  and they should not influence each other. Channel packing is commonly used
  by game engines to save memory.
* None: ignore alpha channel from the file and make image fully opaque.

Cycles OSL does not correctly support Channel Packed and None yet, we are
missing fine control over the OpenImageIO texture cache to do that.

Fixes T53672
2019-05-19 14:36:42 +02:00
Brecht Van Lommel bb8ed813f3 Cleanup: remove unused image buffer code 2019-05-19 14:16:36 +02:00
Richard Antalik 337cac760b VSE: Cache rewrite
This patch implements new cache system.
Aim is to give user more control over cache, so it can be maximally
utilized. This is done through sequencer timeline side panel
in category proxy & cache.
Cached images are also visualized in timeline, controled by
sequencer timeline view->cache menu

Functional changes:
 - NOT use IMB_moviecache API
 - refactor names of cached image types
 - each scene owns 1 sequencer cache
 - merge preprocess cache into per-sequencer cache
 - cache links images rendered per frame in order as they are created
 - add cache content visualization tool
 - add RNA properties to control the cache

More info can be found in design notes in blenkernel/intern/seqcache.c
and in https://developer.blender.org/D4443

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D4443
2019-04-28 14:50:48 -07:00
Campbell Barton e9a01c1d2f Cleanup: comments (long lines) in imbuf 2019-04-22 06:30:08 +10:00
Campbell Barton 333cdbb410 Cleanup: comment blocks 2019-04-18 07:59:28 +02:00
Campbell Barton e12c08e8d1 ClangFormat: apply to source, most of intern
Apply clang format as proposed in T53211.

For details on usage and instructions for migrating branches
without conflicts, see:

https://wiki.blender.org/wiki/Tools/ClangFormat
2019-04-17 06:21:24 +02:00
Campbell Barton 72ede30d0f Cleanup: pass const image data to IMB_ibImageFromMemory 2019-03-25 09:08:29 +11:00
Campbell Barton de13d0a80c doxygen: add newline after \file
While \file doesn't need an argument, it can't have another doxy
command after it.
2019-02-18 08:22:12 +11:00
Campbell Barton eef4077f18 Cleanup: remove redundant doxygen \file argument
Move \ingroup onto same line to be more compact and
make it clear the file is in the group.
2019-02-06 15:45:22 +11:00
Campbell Barton 65ec7ec524 Cleanup: remove redundant, invalid info from headers
BF-admins agree to remove header information that isn't useful,
to reduce noise.

- BEGIN/END license blocks

  Developers should add non license comments as separate comment blocks.
  No need for separator text.

- Contributors

  This is often invalid, outdated or misleading
  especially when splitting files.

  It's more useful to git-blame to find out who has developed the code.

See P901 for script to perform these edits.
2019-02-02 01:36:28 +11:00
Campbell Barton 88a80fcec8 Cleanup: commas at the end of enums
Without this clang-format may wrap them onto a single line.
2019-01-16 00:03:03 +11:00
Campbell Barton bcf0c71433 Cleanup: remove non-existing function declarations 2018-12-31 00:58:54 +11:00
Brecht Van Lommel a6ea38d345 Cleanup: remove unused interlace code after removal of fields. 2018-07-10 17:58:08 +02:00
Campbell Barton e74bd46ede Cleanup: trailing space for imbuf module 2018-06-17 17:04:54 +02:00
Campbell Barton 75fc1c3507 Cleanup: trailing whitespace (comment blocks)
Strip unindented comment blocks - mainly headers to avoid conflicts.
2018-06-01 18:19:39 +02:00
Sybren A. Stüvel b0a767b85b IMB_metadata improvements
- Metadata handling is now separate from `ImBuf *`, allowing it to be
  used with a generic `IDProperty *`.
- Merged `IMB_metadata_add_field()` and `IMB_metadata_change_field()`
  into a more robust `IMB_metadata_set_field()`. This new function
  doesn't return any status (it now always succeeds, and the previously
  existing return value was never checked anyway).
- Removed `IMB_metadata_del_field()` as it was never actually used
  anywhere.
- Use `IMB_metadata_ensure()` instead of having
  `IMB_metadata_set_field()` create the containing `IDProperty` for
  you.
- Deduplicated function declarations, moved `intern/IMB_metadata.h` out
  of `intern/`. Note that this does mean that we have some extra
  `#include "IMB_metadata.h"` lines now, as the metadata functions are
  no longer declared in `IMB_imbuf.h`.
- Deduplicated function declarations, all metadata-related declarations
  are now in imbuf/IMB_metadata.h.

Part of: https://developer.blender.org/D2273

Reviewed by: @campbellbarton
2018-04-05 16:50:23 +02:00
Campbell Barton 4041385ddd Cleanup: remove redundant imbuf return values
Some functions always returned the input argument
which was never used.

This made code read as if there might be a leak.

Now return a boolean (true the imbuf is modified).
2018-04-02 17:34:52 +02:00
Brecht Van Lommel d30cc1ea0b Fix buffer overflows in TIFF, PNG, IRIS, DPX, HDR and AVI loading.
Solves these security issues from T52924:
CVE-2017-2899
CVE-2017-2900
CVE-2017-2901
CVE-2017-2902
CVE-2017-2903
CVE-2017-2904
CVE-2017-2905
CVE-2017-2906
CVE-2017-2907
CVE-2017-2918

Differential Revision: https://developer.blender.org/D2999
2018-01-17 19:59:47 +01:00
Brecht Van Lommel 0d4fd7528f Fix T46560: 2D paint smear and soften brushes not working with alpha.
Interpolate rather than do alpha over mix, matching projection paint.
2017-07-21 00:47:43 +02:00
Bastien Montagne eeb9e5316a Make whole ID copying code use const source pointer.
Noisy change, but safe, and better do it sooner than later if we are to
rework copying code. Also, previous commit shows this *is* useful to
catch some mistakes.
2017-06-14 22:38:11 +02:00
Sergey Sharybin ef0c02cb4d Speedup of regular 2D painting
Yet another commit which makes painting aware of multi-threaded systems.
2016-05-06 11:49:09 +02:00
Sergey Sharybin 9b89071c9c Multi-thread generated image creation
Gives about 2x speedup on laptop when creating new hires generated image,
regardless of it's type (color, color grid, uv grid).
2016-05-05 23:47:22 +02:00
Sergey Sharybin c81d9fda46 Optimize threaded scanline processor
Avoid memory allocation for task data.
2016-05-05 14:18:11 +02:00
Sergey Sharybin c795d31a1f Simplify scanline threaded processor used by GPU_verify_image
Just avoid some unneeded initialization functions when the threaded
processor is simple enough to only depend on current chunk start
scanline and number of scanlines.
2016-05-05 13:16:56 +02:00
Brecht Van Lommel 31d1895abf Fix T46951: invalid OpenGL mipmaps when using high bit depth textures. 2015-12-15 01:47:48 +01:00
Campbell Barton fdc8b12726 Cleanup: whitespace, unused var 2015-08-06 13:03:07 +10:00
Antony Riakiotakis 6c44265bc9 Merge all changes to blenderplayer from gooseberry branch:
* Allows sound playback for movies
* Allow play-pause with space button
* Allow displaying a position indicator with the I button
2015-06-12 12:12:24 +02:00
Antony Riakiotakis 2f2f7c0e87 Fix T44882, color picker in texpainting doing linear interpolation even
when mipmap is off.

We used to always have nearest interpolation for texpaint but at least
make this work with mipmap off correctly.

Also added conversion casts to avoid integer overflow in filtering code
2015-05-29 13:38:20 +02:00
Campbell Barton 5d30c23c35 doxygen: corrections/updates
Also add depsgraph & physics
2015-05-20 14:12:22 +10:00
Antony Riakiotakis 50bfc4bfa0 Metadata display support - patch by Julian and me.
Basically, blender adds a few metadata fields to images when
we render an image. Those metadata can now be viewed in the
image editor.

Also, made sure metadata are available when we write imbufs
to disc with "Save As". There may be more cases here that need
fixing, but this means that loading an image with metadata
will now properly preserve them in blender.
2015-04-21 18:37:06 +02:00
Dalai Felinto d5f1b9c222 Multi-View and Stereo 3D
Official Documentation:
http://www.blender.org/manual/render/workflows/multiview.html

Implemented Features
====================
Builtin Stereo Camera
* Convergence Mode
* Interocular Distance
* Convergence Distance
* Pivot Mode

Viewport
* Cameras
* Plane
* Volume

Compositor
* View Switch Node
* Image Node Multi-View OpenEXR support

Sequencer
* Image/Movie Strips 'Use Multiview'

UV/Image Editor
* Option to see Multi-View images in Stereo-3D or its individual images
* Save/Open Multi-View (OpenEXR, Stereo3D, individual views) images

I/O
* Save/Open Multi-View (OpenEXR, Stereo3D, individual views) images

Scene Render Views
* Ability to have an arbitrary number of views in the scene

Missing Bits
============
First rule of Multi-View bug report: If something is not working as it should *when Views is off* this is a severe bug, do mention this in the report.

Second rule is, if something works *when Views is off* but doesn't (or crashes) when *Views is on*, this is a important bug. Do mention this in the report.

Everything else is likely small todos, and may wait until we are sure none of the above is happening.

Apart from that there are those known issues:
* Compositor Image Node poorly working for Multi-View OpenEXR
(this was working prefectly before the 'Use Multi-View' functionality)
* Selecting camera from Multi-View when looking from camera is problematic
* Animation Playback (ctrl+F11) doesn't support stereo formats
* Wrong filepath when trying to play back animated scene
* Viewport Rendering doesn't support Multi-View
* Overscan Rendering
* Fullscreen display modes need to warn the user
* Object copy should be aware of views suffix

Acknowledgments
===============
* Francesco Siddi for the help with the original feature specs and design
* Brecht Van Lommel for the original review of the code and design early on
* Blender Foundation for the Development Fund to support the project wrap up

Final patch reviewers:
* Antony Riakiotakis (psy-fi)
* Campbell Barton (ideasman42)
* Julian Eisel (Severin)
* Sergey Sharybin (nazgul)
* Thomas Dinged (dingto)

Code contributors of the original branch in github:
* Alexey Akishin
* Gabriel Caraballo
2015-04-06 10:40:12 -03:00
Antony Riakiotakis a180c8e2ed Allow multiple strips to use the same directory when custom proxy
directory is used.

This is done by appending the name of the file as extra folder. Existing
projects may need to regenerate their proxies but it should be possible
now to have all proxies nicely in the same custom folder.

Next commits will include operators to copy directory settings between
selected strips, making the process faster.
2015-03-25 12:05:34 +01:00
Antony Riakiotakis 67fcf5256d Move allocation of imbuf from array to allocimbuf.
Skip allocation of temporary imbuf
2015-02-23 17:19:31 +01:00
Antony Riakiotakis 1940cf5a0b After discussion on irc change new function to only allocate from a
buffer only. scaling can be done separately
2015-02-23 16:30:37 +01:00
Antony Riakiotakis 041f706506 IMB library: Add function that scales an array of byte or float pixels.
Function just wraps the array in an imbuf and does regular imbuf
scaling.
2015-02-23 15:51:30 +01:00
Antony Riakiotakis b58b182753 Get rid of the file touch hack.
If user cancels, there's an issue with leftover files.
Instead use a hash to record files that have akready been registered for
generation and skip them if so.

That should guarantee things will go smoothly and when a file exists it
is assumed to be valid.
2015-01-30 16:00:30 +01:00
Sergey Sharybin 7c72ba60d7 Sequencer: Option to skip strip proxy generation if they already exists
This is a per-strip option next to the build proxy size which tells blender
whether to skip building proxy size if the file for it already exists or not.
The option is called "Overwrite" for simplicity.

This option is enabled by default to avoid changes in the file behavior.

TODO: Would be nice to do something like that for movie clips as well.
2015-01-28 17:32:33 +05:00
Antony Riakiotakis f745564e4e GSOC 2013 paint
Yep, at last it's here!

There are a few minor issues remaining but development can go on in
master after discussion at blender institute.

For full list of features see:

http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.72/Painting

Thanks to Sergey and Campbell for the extensive review and to the
countless artists that have given their input and reported issues during
development.
2014-07-21 12:02:05 +02:00
Dalai Felinto 3312b20ac8 IMB buffer functions to take a mask as input
The mask make sure the conversion only happens in a few areas of the
buffer.

New Functions:
* IMB_buffer_byte_from_float_mask
* IMB_buffer_float_from_float_mask

The functions are an adaptation of their maskless counterparts without accepting different profiles for the input and output buffers.

Review: Sergey Sharybin
2014-05-02 20:56:16 -03:00
Campbell Barton 863352dfdc Correct issue with IMB_ispic returning bool 2014-04-30 10:43:46 +10:00
Campbell Barton a15b3c4d11 Code cleanup: use bool 2014-04-11 11:33:29 +10:00
Campbell Barton 617557b08e Code cleanup: remove TRUE/FALSE & WITH_BOOL_COMPAT define 2014-04-01 15:22:28 +11:00
Campbell Barton d900f5be55 Code cleanup: use bools where possible 2014-02-03 19:35:44 +11:00
Dalai Felinto 4abb8fde95 Photoshop PSD support
We now support the combined layer of Photoshop files (stored as layer 0
in the file). This way users can keep their files as multilayer PSD and
Blender always handle them as flat images.

For perfect alpha this requires an OpenImageIO update:
342cc2633f

Photoshop sample files:
https://github.com/OpenImageIO/oiio-images

Brecht has some pending fixes to push for OIIO as well, so we may as
well wait to update our libraries.

What works:
===========
* 8bit images (with or without alpha)
* 16bits images (alpha discarded)
* Photoshop files saved with 'Maximum Compatibility'
* Cycles, Blender internal,  BGE (and player)

Known limitations
(due to OIIO dependency):
=========================
* Images with less than 4 channels show a wrong thumbnail (bug may be in  OIIO)
* Packed images are not supported
* We do not write PSD files.

Note: old Blenders have support for PSD via Quicktime library. But due
to license issues this was discontinued.

Many thanks for Brecht van Lommel for reviewing the patch, suggesting
multiple improvements and to help solving the alpha issue.
2013-10-08 21:17:24 +00:00
Campbell Barton fc6c283271 code cleanup: use bool for imbuf allocation functions. 2013-09-10 01:00:03 +00:00
Brecht Van Lommel 70eaf2fe44 Image paint: 2D painting now supports texture masks and does masking more
consistent with projection painting.

Also did some refactoring of this code, moving the brush image creation code
out of brush.c and making it consistent with image updating code.
2013-05-12 09:14:13 +00:00
Brecht Van Lommel 63f05576b8 More image painting fixes:
* 2D image painting support for masking to limit the max contribution of a stroke
  to a pixel, to get it working compatible with projection painting. Not strictly
  a bugfix, but the inconsistency here was annoying.

* Fix python errors in Texture Mask panel in image editor, was missing overlay
  options.

* Clamp paint mask to 0..1 in case some texture exceeds it, this could give black
  pixels due to integer overflow.
2013-04-30 06:07:42 +00:00
Brecht Van Lommel fe6c45e36e Fix #34233: bad alpha blending for 3D texture painting. Same changes as the
previous fix for 2D image painting were done, and also:

* For brushes that do masking (keeping the max contribution to a pixel limited),
  the alpha from textures is now part of the mask. In many cases the logic
  worked out the same and where it didn't it used to cause artifacts.

* Color interpolation for smear and soften tools now happens in premultipied
  space, to avoid bleeding of RGB colors from zero alpha areas.

* Fix a few cases where byte <=> float conversion was not doing the proper
  straight <=> premul conversion.

* Replace some float division by constants with multiplications, is faster.

Note: float texture painting seems to have some issues updating the OpenGL
texture, but issue was already there before this commit.
2013-04-28 11:55:41 +00:00
Brecht Van Lommel 8f9150871c Fix part of #34233: bad alpha blending for 2D image painting. This is a very
old issue, the formulas here were never quite right, should all work ok now
with byte and float images.

Some differences:

* Colors with zero alpha from the background will never have an influence, so
  you don't get alpha fringes when painting over such areas. This does give
  hard edges when looking at the RGB channels alone, but there's no way to
  avoid that and fringes at the same time, same behavior as other painting apps.

* Add/Subtract/Multiply/Lighten/Darken now leave the alpha channel unchanged
  and work only the RGB channels, again same behavior as many other apps.

* Erase/Add alpha now compensates for premultiplied float images to keep the
  straight RGB colors the same.

Next: fix projection painting.
2013-04-27 12:51:23 +00:00
Campbell Barton 64d161de87 style cleanup:
also rename mesh_getVertexCos() --> BKE_mesh_vertexCos_get() to match curve function.
2013-03-26 07:29:01 +00:00
Sergey Sharybin 6dc4ea34e4 Multi-threaded frame calculation for movie clip proxies
This commit implements multi-threaded calculation of frames
when building proxies. Both scaling and undistortion steps
are now threaded.

Frames and proxy resolution are still handled one-by-one,
saving files after every single step. So if HDD is not so
fast, this commit could have not so much benefit.

Internal changes:

- Added IMB_scaleImBuf_threaded which scales given image
  buffer in multiple threads and uses bilinear filtering.

- libmv's camera intrinsics now have SetThreads() method
  which is used to specify how many OpenMP threads to use
  for buffer distortion/undistortion.

  And yeah, this code is using OpenMP for threading.

- Reshuffled a bit libmv-capi calls and added function
  BKE_tracking_distortion_set_threads to specify number
  of threads used by intrinscis.
2013-03-15 11:59:46 +00:00
Sergey Sharybin c69f571478 Remove unused IMB function which wasn't ported to new color management
Also marked some TODOs as actually solved.
2013-01-08 13:32:48 +00:00
Sergey Sharybin fa0805e287 Changes for opengl render to reflect new alpha premul pipeline
without hurting quick texture painting

- ED_view3d_draw_offscreen will now output buffer with
  transparent alpha, if sky needed it should be alpha-undered
  later.

- ED_view3d_draw_offscreen_imbuf now accepts alpha mode as an
  argument which could be either R_ADDSKY or R_PREMULALPHA

- OpenGL render and sequencer's opengl preview will now reflect
  scene's Alpha Mode

- Quick Edit will use OpenGL with transparent alpha mode
2013-01-05 15:33:18 +00:00
Sergey Sharybin 08cea96ab0 Alpha premul pipeline cleanup
This assumptions are now made:
- Internally float buffers are always linear alpha-premul colors
- Readers should worry about delivering float buffers with that
  assumptions.
- There's an input image setting to say whether it's stored with
  straight/premul alpha on the disk.
- Byte buffers are now assumed have straight alpha, readers should
  deliver straight alpha.

Some implementation details:

- Removed scene's color unpremultiply setting, which was very
  much confusing and was wrong for default settings.
  Now all renderers assumes to deliver premultiplied alpha.

- IMB_buffer_byte_from_float will now linearize alpha when
  converting from buffer.

- Sequencer's effects were changed to assume bytes have got
  straight alpha. Most of effects will work with bytes still,
  however for glow it was more tricky to avoid data loss, so
  there's a commented out glow implementation which converts
  byte buffer to floats first, operates on floats and returns
  bytes back. It's slower and not sure if it should actually
  be used -- who're using glow on alpha anyway?

- Sequencer modifiers should also be working nice with straight
  bytes now.

- GLSL preview will predivide float textures to make nice shading,
  shading with byte textures worked nice (GLSL was assuming straight
  alpha).

- Blender Internal will set alpha=1 to the whole sky. The same
  happens in Cycles and there's no way to avoid this -- sky is
  neither straight nor premul and doesn't fit color pipeline well.

- Straight alpha mode for render result was also eliminated.

- Conversion to correct alpha need to be done before linearizing
  float buffer.

- TIFF will now load and save files with proper alpha mode setting
  in file meta data header.

- Remove Use Alpha from texture mapping and replaced with image
  datablock setting.

  Behaves much more predictable and clear from code point of view
  and solves possible regressions when non-premultiplied images were
  used as textures with ignoring alpha channel.
2012-12-31 13:52:13 +00:00
Campbell Barton 5943c81a93 code cleanup: neareast -> nearest 2012-12-11 14:19:41 +00:00
Sergey Sharybin 316d33ea0b Change a way how image sequence/movie source is detecting for movie clip
Use IMB_testiffname to check whether file could be handled by ImBuf or
whether it should be handled by anim routines.

It solves the issue when file without extension is used for movie clip.
2012-11-05 10:32:47 +00:00
Brecht Van Lommel 85d9ba5cbb Fix issue after commit 50282: float texture painting non-color data textures did
not do correct partial updates, now it remembers if the opengl texture is a
non-color data texture or not and takes that into account for the update.

Also includes some renaming ncd => is_data for consistency with color space
terminology used elsewhere.
2012-10-25 15:25:28 +00:00
Campbell Barton ae32c946e1 style cleanup: define float sizes for interpolation functions, add retirn's on newlines (to better add breakpoints). 2012-10-01 06:18:45 +00:00
Sergey Sharybin a73dd3476e Color Management, Stage 2: Switch color pipeline to use OpenColorIO
Replace old color pipeline which was supporting linear/sRGB color spaces
only with OpenColorIO-based pipeline.

This introduces two configurable color spaces:

- Input color space for images and movie clips. This space is used to convert
  images/movies from color space in which file is saved to Blender's linear
  space (for float images, byte images are not internally converted, only input
  space is stored for such images and used later).

  This setting could be found in image/clip data block settings.

- Display color space which defines space in which particular display is working.

  This settings could be found in scene's Color Management panel.

When render result is being displayed on the screen, apart from converting image
to display space, some additional conversions could happen.

This conversions are:

- View, which defines tone curve applying before display transformation.
  These are different ways to view the image on the same display device.
  For example it could be used to emulate film view on sRGB display.

- Exposure affects on image exposure before tone map is applied.

- Gamma is post-display gamma correction, could be used to match particular
  display gamma.

- RGB curves are user-defined curves which are applying before display
  transformation, could be used for different purposes.

All this settings by default are only applying on render result and does not
affect on other images. If some particular image needs to be affected by this
transformation, "View as Render" setting of image data block should be set to
truth. Movie clips are always affected by all display transformations.

This commit also introduces configurable color space in which sequencer is
working. This setting could be found in scene's Color Management panel and
it should be used if such stuff as grading needs to be done in color space
different from sRGB (i.e. when Film view on sRGB display is use, using VD16
space as sequencer's internal space would make grading working in space
which is close to the space using for display).

Some technical notes:

- Image buffer's float buffer is now always in linear space, even if it was
  created from 16bit byte images.

- Space of byte buffer is stored in image buffer's rect_colorspace property.

- Profile of image buffer was removed since it's not longer meaningful.

- OpenGL and GLSL is supposed to always work in sRGB space. It is possible
  to support other spaces, but it's quite large project which isn't so
  much important.

- Legacy Color Management option disabled is emulated by using None display.
  It could have some regressions, but there's no clear way to avoid them.

- If OpenColorIO is disabled on build time, it should make blender behaving
  in the same way as previous release with color management enabled.

More details could be found at this page (more details would be added soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Color_Management

--
Thanks to Xavier Thomas, Lukas Toene for initial work on OpenColorIO
integration and to Brecht van Lommel for some further development and code/
usecase review!
2012-09-15 10:05:07 +00:00
Campbell Barton a71b160184 fix for building on msvc2008 (also style cleanup) 2012-09-04 01:23:50 +00:00
Sergey Sharybin 1b487e9948 Some FFmpeg changes
- Make FFmpeg initialization called from creator, not from functions
  which requires FFmpeg. Makes it easier to follow when initialization
  should happen.

- Enable DNxHD codec. It was commented a while ago due to some strange
  behavior on some platforms. Re-tested it on Linux and Windows and
  it seemd to be working quite nice. Would let it be tested further,
  if it wouldn't be stable enough, easy to comment it again.

- Make non-error messages from writeffmpeg.c printed only if ffmpeg
  debug argument was passed to blender. Reduces console pollution
  with messages which are not useful for general troubleshooting.
  Error messages would still be printed to the console.

- Show FFmpeg error message when video stream failed to allocate.
  makes it easier to understand what exactly is wrong from Blender
  interface, no need to restart blender with FFmpeg debug flag and
  check for console messages.

  Used custom log callback for this which stores last error message
  in static variable. This is not thread safe, but with current
  design FFmpeg routines could not be called form several threads
  anyway, so think it's fine solution/
2012-08-26 11:01:14 +00:00
Campbell Barton 10f631094c fix [#32126] STAMP: Setting a background color causes color flicker
when rendering the sequencer can output float or char buffers which stamp wasn't accounting for.
2012-08-12 22:50:21 +00:00
Sergey Sharybin 6cf1a9834b Made image buffer threaded processor generic function,
so color management could use the same routines.

Should be no functional changes.
2012-08-07 16:47:46 +00:00
Campbell Barton 0b7593a3dc finish cleanup for plugins 2012-05-29 10:31:42 +00:00
Campbell Barton de6af75d4d code cleanup: use array size and const for vector args 2012-05-26 16:04:31 +00:00
Peter Schlaile 8bf1615ce3 == Sequencer ==
Bugfix: [#28159] sequencer strip crop values on proxy not scene render size

Also: IMB saturation change moved into imbuf-module.
2012-03-17 19:31:28 +00:00
Campbell Barton 89a963fb7f style cleanup: comment blocks 2012-03-09 18:28:30 +00:00
Campbell Barton 4f7bdc59d3 style cleanup: spelling.
also remove large, duplicate comments from sunsky.h
2012-03-09 00:41:09 +00:00