Skip to content

Commit

Permalink
Added depth buffer motion blur button
Browse files Browse the repository at this point in the history
  • Loading branch information
Chryfi authored and mchorse committed Jun 15, 2022
1 parent 597addf commit a09cc28
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,9 @@ public class MinemaConfig {
public final ConfigString videoEncoderParamsAlpha = new ConfigString(
"-f rawvideo -pix_fmt rgb32 -s %WIDTH%x%HEIGHT% -r %FPS% -i - -vf %DEFVF% -c:v libx264 -preset ultrafast -tune zerolatency -qp 18 -pix_fmt yuv420p %NAME%_rgb.mp4 -vf %DEFVF%,alphaextract,format=yuv420p %NAME%_alpha.mp4");
public static final ConfigString videoEncoderParamsDepth = new ConfigString(
"-f rawvideo -pix_fmt bgra64be -s %WIDTH%x%HEIGHT% -r %FPS% -i - -vf %DEFVF% -preset ultrafast -tune zerolatency -qp 6 -pix_fmt bgra64be %NAME%_depth_%d.png");
public static final ConfigEnum<BitDepth> depthBufferBitDepth = new ConfigEnum<>(BitDepth.BIT16CHANNELS4);
"-f rawvideo -pix_fmt bgr48be -s %WIDTH%x%HEIGHT% -r %FPS% -i - -vf %DEFVF% -preset ultrafast -tune zerolatency -qp 6 -pix_fmt bgr48be %NAME%_depth_%d.png");
public static final ConfigEnum<BitDepth> depthBufferBitDepth = new ConfigEnum<>(BitDepth.BIT16CHANNELS3);
public final ConfigBoolean depthBufferMotionBlur = new ConfigBoolean(false);
public final ConfigEnum<SnapResolution> snapResolution = new ConfigEnum<>(SnapResolution.MOD2);
public final ConfigBoolean enableEncoderLogging = new ConfigBoolean(true);

Expand Down Expand Up @@ -120,6 +121,7 @@ public MinemaConfig(File path) {
videoEncoderParamsAlpha.link(cfg, ENCODING_CATEGORY, "videoEncoderParamsAlpha", LANG_KEY);
videoEncoderParamsDepth.link(cfg, ENCODING_CATEGORY, "videoEncoderParamsDepth", LANG_KEY);
depthBufferBitDepth.link(cfg, ENCODING_CATEGORY, "depthBufferBitDepth", LANG_KEY);
depthBufferMotionBlur.link(cfg, ENCODING_CATEGORY, "depthBufferMotionBlur", LANG_KEY);
snapResolution.link(cfg, ENCODING_CATEGORY, "snapResolution", LANG_KEY);
enableEncoderLogging.link(cfg, ENCODING_CATEGORY, "enableEncoderLogging", LANG_KEY);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,17 @@ else if (!this.isColor)
}
else
{
if (this.isColor)
/* dont do linear mixing for 32 bit depth buffer - I could not make it work */
boolean linearMixingCondition = (cfg.depthBufferMotionBlur.get() || this.isColor) && !(!this.isColor && MinemaConfig.depthBufferBitDepth.get().getBytesPerChannel() == 4);

if (linearMixingCondition)
{
defvf += cfg.motionBlurLinearMixing.get() ? ",format=pix_fmts=rgba64le,lutrgb=r=gammaval(2.2):g=gammaval(2.2):b=gammaval(2.2)" : "";
}

for (int i = 0; i < cfg.motionBlurLevel.get().getExp(cfg.frameRate.get()); i++)
{
if (this.isColor)
if (cfg.depthBufferMotionBlur.get() || this.isColor)
{
defvf += ",tblend=all_mode=average,framestep=2";
}
Expand All @@ -129,7 +132,7 @@ else if (!this.isColor)
}
}

if (this.isColor)
if (linearMixingCondition)
{
defvf += cfg.motionBlurLinearMixing.get() ? ",lutrgb=r=gammaval(1/2.2):g=gammaval(1/2.2):b=gammaval(1/2.2)" : "";
}
Expand Down
5 changes: 4 additions & 1 deletion src/main/resources/assets/minema/lang/en_US.lang
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,11 @@ minema.config.videoEncoderParamsAlpha.tooltip=Arguments for the video encoding p
minema.config.videoEncoderParamsDepth=Encoder Arguments (depth buffer)
minema.config.videoEncoderParamsDepth.tooltip=Arguments for exporting the depth buffer when 'Use depth' option is enabled. Placeholders are the same. Example arguments: 8 bits "-f rawvideo -pix_fmt bgr24 -s %WIDTH%x%HEIGHT% -r %FPS% -i - -vf %DEFVF% -c:v libx264 -preset ultrafast -tune zerolatency -qp 6 -pix_fmt yuv420p %NAME%_depth.mp4",\n16 bits 4 channels "-f rawvideo -pix_fmt bgra64be -s %WIDTH%x%HEIGHT% -r %FPS% -i - -vf %DEFVF% -preset ultrafast -tune zerolatency -qp 6 -pix_fmt bgra64be %NAME%_depth_%d.png",\n32 bits float "-f rawvideo -pix_fmt gbrpf32be -s %WIDTH%x%HEIGHT% -r %FPS% -i - -vf %DEFVF% -preset ultrafast -tune zerolatency -qp 6 -compression zip1 -pix_fmt gbrpf32le %NAME%_depth_%d.exr"

minema.config.depthBufferMotionBlur=Depth buffer motion blur
minema.config.depthBufferMotionBlur.tooltip=Use motion blur in the depth buffer when motion blur is activated in the capturing settings. Motion blur in the depth buffer is not very useful for masking, but useful for post process DOF.

minema.config.depthBufferBitDepth=Bit depth for depth buffer
minema.config.depthBufferBitDepth.tooltip=The bit depth that should be used internally for the depth buffer. 16 bits with 4 channels saves the render distance or the manually defined distance in the alpha channel. 32 bits saves the depth values multiplied with the render distance in the green channel.
minema.config.depthBufferBitDepth.tooltip=The bit depth that should be used internally for the depth buffer. 16 bits with 4 channels saves the render distance or the manually defined distance in the alpha channel. 32 bits saves the depth values multiplied with the render distance.

minema.config.snapResolution=Snap Resolution
minema.config.snapResolution.tooltip=If necessary, snaps the recording resolution to the next lower resolution so that width and height is divisible by this modulus. FFMpeg only needs mod2, some other encoders might need more.
Expand Down

0 comments on commit a09cc28

Please sign in to comment.