If the transition point was above or equal to 1.0, it would cause a
divide by 0 error a few lines down. This could cause audio data to
become corrupted with NAN audio data when mixing, which can cause
certain audio encoders (namely the FFmpeg AAC encoder) to fail.
It was possible for the transition point to be above or equal to 1.0 if
the stinger media file was no longer loadable for whatever reason.
Add option in properties that let you choose how audio is mixed during
transition:
- Fade Out/Fade In (existing behavior, default)
- Crossfade
Closesjp9000/obs-studio#1028
Allows using a video file as a means of transitioning, transitioning two
targets at a specific time during the video playback. Audio for target
A fades out to the transition point, and then audio for target B fades
in after the transition point.
In transitions, because the 'to' and 'from' are always rendered to
textures, the end result will always have premultiplied alpha. This
would cause alpha to have blackish edges during transition, and cause
semi-transparent images to appear darker than they were supposed to.
To replicate, simply set the transparency of a source to 50%, then
transition between that scene and another scene. The source will appear
to "pop" in and out unnaturally due to the premultiplied alpha effect of
the render targets.
To fix this, the solution is to simply convert premultiplied alpha to
straight alpha in the transition pixel shaders.
This reverts commit 0edaebe192.
The commit was actually less optimal than it was before. Shaders are
always fully unfolded and both sides of a branch are always executed.
Despite that fact, the "avoid branching" commit actually *added* two
extra unnecessary instructions with the same number of actual sample
instructions, making it arguably less optimal than before.
This was tested via the D3DDissamble function.
Branching is not recommended in shaders and only recently gained
widespread support without causing massive branch misprediction issues. Also sampling inside a branch will cause cache misses and additional texture load instructions.
These functions were mistakenly not marked as static. They are not used
outside of their compiled object module files, therefore there's no
reason for them not to be static.