obs-studio/libobs-d3d11
James Park ba21fb947e libobs: Fix various alpha issues
There are cases where alpha is multiplied unnecessarily. This change
attempts to use premultiplied alpha blending for composition.

To keep this change simple, The filter chain will continue to use
straight alpha. Otherwise, every source would need to modified to output
premultiplied, and every filter modified for premultiplied input.

"DrawAlphaDivide" shader techniques have been added to convert from
premultiplied alpha to straight alpha for final output. "DrawMatrix"
techniques ignore alpha, so they do not appear to need changing.

One remaining issue is that scale effects are set up here to use the
same shader logic for both scale filters (straight alpha - incorrectly),
and output composition (premultiplied alpha - correctly). A fix could be
made to add additional shaders for straight alpha, but the "real" fix
may be to eliminate the straight alpha path at some point.

For graphics, SrcBlendAlpha and DestBlendAlpha were both ONE, and could
combine together to form alpha values greater than one. This is not as
noticeable of a problem for UNORM targets because the channels are
clamped, but it will likely become a problem in more situations if FLOAT
targets are used.

This change switches DestBlendAlpha to INVSRCALPHA. The blending
behavior of stacked transparents is preserved without overflowing the
alpha channel.

obs-transitions: Use premultiplied alpha blend, and simplify shaders
because both inputs and outputs use premultiplied alpha now.

Fixes https://obsproject.com/mantis/view.php?id=1108
2019-05-08 20:26:52 -07:00
..
CMakeLists.txt libobs/graphics: Support debug markers 2019-04-08 02:05:37 -07:00
d3d11-duplicator.cpp libobs-d3d11: Allow multiple display captures of same monitor 2018-01-09 19:49:54 -08:00
d3d11-indexbuffer.cpp libobs-d3d11: Use linked list for all objects (for rebuilding) 2016-11-03 09:23:21 -07:00
d3d11-rebuild.cpp libobs-d3d11: Reset handle and re-lock if texture rebuilt 2019-03-03 08:43:06 -08:00
d3d11-samplerstate.cpp libobs-d3d11: Use linked list for all objects (for rebuilding) 2016-11-03 09:23:21 -07:00
d3d11-shader.cpp libobs: Add HLSL annotation parsing 2018-09-08 05:22:12 -07:00
d3d11-shaderprocessor.cpp libobs-d3d11: Store shader samplers as pointers 2016-11-03 09:23:10 -07:00
d3d11-shaderprocessor.hpp libobs-d3d11: Store shader samplers as pointers 2016-11-03 09:23:10 -07:00
d3d11-stagesurf.cpp libobs/graphics: Add NV12 texture support 2019-02-07 17:00:46 -08:00
d3d11-subsystem.cpp libobs/graphics: Support debug markers 2019-04-08 02:05:37 -07:00
d3d11-subsystem.hpp libobs: Fix various alpha issues 2019-05-08 20:26:52 -07:00
d3d11-texture2d.cpp libobs-d3d11: Use discrete function to get shared handle 2019-03-03 08:41:23 -08:00
d3d11-vertexbuffer.cpp libobs-d3d11: Use linked list for all objects (for rebuilding) 2016-11-03 09:23:21 -07:00
d3d11-zstencilbuffer.cpp libobs-d3d11: Use linked list for all objects (for rebuilding) 2016-11-03 09:23:21 -07:00