Log in

View Full Version : Please help converting this script to a pixel shader


ZORAX
18th October 2015, 20:40
Can someone please help me create a pixel shader based on this simple AviSynth script? I’d like to use it with MPC-HC.


# Constants
# Pos = desired position of the bottom video border on screen, as ratio (0 to 1)
Pos = 0.83
ScreenAR = 16.0 / 9.0

# Math
# Derives a screen height based on the video width
ScreenHeight = Round(last.Width / ScreenAR)

# Converts the relative Pos to an absolute number of lines with mod2
Pos = Round(ScreenHeight * Pos / 2) * 2

# Calculates how much black border to add on top and bottom of the video to fill the screen AR
Top = Pos - last.Height
Bottom = ScreenHeight – Pos

# Check if it’s possible to fit the new video on the desired screen position, and if so adds the respective borders. Else, just return the original video unchanged, with no letterboxing at all.
# This is to prevent non-anamorphic videos from being resized to something that would not fit the screen. Since the math is really simple, we are not losing anything if it doesn’t fit.

last.Height <= Pos ? AddBorders(0, Top, 0, Bottom) : last


The script works like a letterboxing script, but the difference is it moves the video up on screen, instead of keeping it at the vertical center. The main purpose is to allow displaying subtitles BELOW the video when watching anamorphic movies, which I find much better on a 16:9 screen.

Thanks a lot.

Shiandow
18th October 2015, 22:48
You can't do letter-boxing with a shader since you can't control the video size. MPC-HC should have an option to move the video up and down though (I think it was Ctrl+Numpad 8).