Shaders/Drivers with software-based Black Frame Insertion

Advanced display talk, display hackers, advanced game programmers, scientists, display researchers, display manufacturers, vision researchers & Advanced Display Articles on Blur Busters. The masters on Blur Busters.
Post Reply
User avatar
Chief Blur Buster
Site Admin
Posts: 11647
Joined: 05 Dec 2013, 15:44
Location: Toronto / Hamilton, Ontario, Canada
Contact:

Shaders/Drivers with software-based Black Frame Insertion

Post by Chief Blur Buster » 19 Feb 2017, 14:51

Software Based Black Insertion Drivers

RLBURNSIDE, I see you know how to use ShaderToy!

Are you able to write a ShaderToy that adds BFI to 60Hz?

Basically, I'd like to black out every other refresh cycle of a 120Hz refresh rate, and run that ShaderToy on everything in Windows. This is because I have some monitors that can only do backlight-based motion blur reduction at 120Hz, but I'd like to have 60Hz pure low persistence without SOE (Soap Opera Effect) for 60Hz material. It'd flicker quite a lot, but would solve a problem I've been having without needing to add BFI support to the software (some software does, like WinUAE Amiga Emulator, has built-in BFI support for blur-free 60Hz on 120Hz displays). But I'd like to be able to do this globally, for the whole windows desktop. This'd work excellently too, for blur-free 60fps MP4s, YouTube, and GoPro videos too on the 120Hz strobe-backlight monitors (e.g. LightBoost & ULMB) that I currently have, since ShaderToy-driven BFI will easily turn the 120Hz strobing into 60Hz strobing.

I'm wondering if there's a way to create a special Windows driver: This special windows driver could in be configurable to do 120Hz SBS too, supporting 120Hz 2D (via 60Hz SBS), as well as the option of doing BFI for blur-reduced 60fps during forced-120Hz operation (e.g. LightBoost/ULMB).
Head of Blur Busters - BlurBusters.com | TestUFO.com | Follow @BlurBusters on Twitter

Image
Forum Rules wrote:  1. Rule #1: Be Nice. This is published forum rule #1. Even To Newbies & People You Disagree With!
  2. Please report rule violations If you see a post that violates forum rules, then report the post.
  3. ALWAYS respect indie testers here. See how indies are bootstrapping Blur Busters research!

RLBURNSIDE
Posts: 104
Joined: 06 Apr 2015, 16:09

Re: 4K DLP hack for 120 fps -- [for TI 4K projectors]

Post by RLBURNSIDE » 19 Feb 2017, 17:02

It would indeed be great to be able to apply any arbitrary image-space processing tech via a fake windows display driver + shader injection.

I'll look into it! If I get this working, of course. I'm planning on buying either the Optoma UHD 65 or the Acer 4K model (the smaller one) shown at ISE 2017. Both should be out by june for under 3 grand. Not bad to get a 4K, 120hz, HDR, 140-inch projected image for 3k, innit?

For BFI on a 3D projector it might be possible to do it with a windows custom desktop manager program that can span multiple desktops into a final image. You know, have two pages side by side on the same monitor, but each one is treated as a separate screen.

The page on the right need only be set to black and then you just switch the projector into SBS 3D mode and voila, BFI. No driver hacks or shaders required whatsoever. Of course you lose 50% of your horizontal resolution doing that (or 50% vertical if you do it with over-under 3D).

Of course you could also do it for games with SweetFX with a custom windows desktop resolution of 960 x 1080, render the game in fullscreen, then the shader just scales the U texture coordinate by 2 and sets the value to black after U > 0.5. That would get you BFI in SBS mode but your screen aspect ratio would be wrong, you'd need to be able to hack only the X part of the FOV (FOV sliders are typically implemented isomorphically...what we'd need here is an anamorphic slider. I've implemented this in games before, to decouple the x / y resolution multiple from the FOV, i.e. treat "X" as something else, or just set it to 2.37:1 for example, to use an anamorphic lens but get the full frame of real rendered pixels instead of scaling the image vertically). You can always just set a custom windows res of 2560x1080 and let the GPU scale it to 1920x1080 anamorphic for that, which works well in all games / movies / desktop, but I digress.

It's probably easier to just render the game as 1920 x 1080 as you normally would and then use Sweet FX to compress it all leftward, set the right half of the image to black. It would amount to a sort of supersampling AA in the X direction only, so it's not like it would be entirely a waste of rendering power.

But BFI on a projector is not ideal because of the lumens cost, it's much better to render two successive 960 x 1080p images and then push them to the display as a single 1920 x 1080 SBS frame which will then be shown in the proper sequence. There's no reason this shouldn't work with 3D capable LCD monitors too. But those already support over 144hz refresh rate already so it's pointless. And the challenge is tricking the game into thinking it's rendering to a 120hz capable device context. A DX11 / 12 wrapper could intercept calls to do all this off-screen rendering internally but that's not going to get it working on windows desktop.

All these 1080p DLP projector hacks are doing is trading spatial resolution for temporal. But on the 4K DLPs, you trade spatial resolution for spatial resolution + temporal resolution. If the screen is static, you would still see a perfectly resolved 4K image, because the samples for each subframe are jittered diagonally.

Maybe Tim Lottes (who reads this forum sometimes) can get AMD to add a custom 4K mode to AMD drivers for this. He's probably way too busy but I for one would certainly invest in an AMD GPU if it gave me some ability to do custom desktop hackery like this.

The way VR frame compositing engines work is basically what we'd need for this to work in games. The game needs to believe it's running at 120fps at 2716 x 1528, with each alternate frame having a 0.5 pixel diagonal offset, and once two new frames are ready, pack them together using my shadertoy code above and present every 60th of a second to the actual projector which only accepts 60fps. But these projectors are definitely capable of running at 120 fps internally.

There's also the question of effective bit depth. I asked TI about whether they support 10-bit at 4K60 on their new wobulation chips and they said yes. So that means they are in fact doing 10-bit 2.7K 120 which is actually what we should render our games / movies to.

The diagonal sample jitter / offset can also be defeated in some of these DLP models, using a "silent mode".

Of course this all begs the question: why don't they simply expose a PC resolution of 2716 x 1528 x 120 and be done with it. Or 96hz with 10-bit (the literal maximum that HDMI 2.0a can support over 18gbps for half-res 2160p).

I even asked several of these projector companies why they don't add 120hz modes at 1080p at least and they all said "why would you need more than 60hz" ... /facepalm

RLBURNSIDE
Posts: 104
Joined: 06 Apr 2015, 16:09

Re: 4K DLP hack for 120 fps -- [for TI 4K projectors]

Post by RLBURNSIDE » 19 Feb 2017, 17:36

Ask and ye shall receive!

A BFI shader for MPC-HC.

Step 1) Save this HLSL code to BFI.hlsl:
--------------------------

Code: Select all

// BFI Shader for Blurbusters.com
// Author RLBURNSIDE
// Public domain - use as you wish

sampler s0 : register(s0);

float4 main(float2 tex : TEXCOORD0) : COLOR
{
	// Set your 3D projector to SBS 3D mode and voila, the right half of the image side is black and the left side contains the entire frame, squeezed in
	if (tex.x < 0.5)
	{
		tex.x *= 2.0;	
		float4 colour = tex2D(s0, tex);
		return colour;
	}
	else
	{
		return float4(0,0,0,0);
	}
}
--------------------------

Step 2) Drop it into : C:\Program Files (x86)\MPC-HC\Shaders (you will need admin rights)
Step 3) Add it to Post-resize shaders. (View->Options->Playback->Shaders)
Step 4) Watch a movie or tv show in MPC-HC fullscreen
Step 5) Activate SBS 3D mode on your projector

It should also work for any game as a post processing effect via SweetFX or similar. Might need some minor code tweaks depending on the interface.

Took me 2 minutes :)

ps make sure your 3D settings show the left eye first, otherwise you will incur an 8.33 ms latency hit. All projectors support swapping eyes or you can just change the sign on the shader inequality then subtract 0.5 (right before the *= 2.0 line)

RLBURNSIDE
Posts: 104
Joined: 06 Apr 2015, 16:09

Re: 4K DLP hack for 120 fps -- [for TI 4K projectors]

Post by RLBURNSIDE » 19 Feb 2017, 17:47

Here's the equivalent shadertoy:

https://www.shadertoy.com/view/MslczM

User avatar
Chief Blur Buster
Site Admin
Posts: 11647
Joined: 05 Dec 2013, 15:44
Location: Toronto / Hamilton, Ontario, Canada
Contact:

Shaders/Drivers with software-based Black Frame Insertion

Post by Chief Blur Buster » 19 Feb 2017, 20:31

Fantastic,

This looks like it has lots of promise.
Note: I added [/code] and

Code: Select all

 wrappers to your code, to pretty-ify it.[/i]

Is there another code snippet that does 120Hz frame-sequential for the certain 3D projectors that is able to handle it?  I know my BENQ is able to handle 720p in frame-sequential.

Also, if you can somehow pull this off at the OS-level (game-compatible / browser-compatible preferably) [b]I'd love to write a Blur Busters article about this[/b] (in co-operation with you), if you're interested.   In whichever way you wish to publish it (open source or otherwise).

One simpler possibility is a full screen always-on-top window whose alpha transparency alternates between 0 and 255 in a VSYNC-synchronized way.   If some easy utility can be created, this would solve a lot of people's problem with lack of single-strobe 60Hz (a common complaint by Falkentyne).   

You can see how 60Hz single-strobe can be achieved via software-based BFI with 120Hz LightBoost/ULMB -- via looking at http://www.testufo.com/blackframes on a gaming monitor with its blur reducing feature (ULMB/LightBoost/etc) enabled.   Crystal clear 60fps motion.
Head of Blur Busters - BlurBusters.com | TestUFO.com | Follow @BlurBusters on Twitter

Image
Forum Rules wrote:  1. Rule #1: Be Nice. This is published forum rule #1. Even To Newbies & People You Disagree With!
  2. Please report rule violations If you see a post that violates forum rules, then report the post.
  3. ALWAYS respect indie testers here. See how indies are bootstrapping Blur Busters research!

RLBURNSIDE
Posts: 104
Joined: 06 Apr 2015, 16:09

Re: Shaders/Drivers with software-based Black Frame Insertio

Post by RLBURNSIDE » 19 Feb 2017, 22:18

It's possible to write a BFI shadertoy on a 120hz native projector or monitor, no problem, just by checking the global timer modulo 16.666 ms, if it's greater than 8.33ms it's black.

But as you say, it's a far greater challenge to do native 120hz BFI whilst only rendering at 60hz internally, which would allow you to keep higher visual fidelity.

A few options present themselves, like actually rendering at 120hz but dropping 1/2 the frames and substitute black in their stead (or calling Clear() for odd-numbered frames inside a wrapped Present()). That's do-able with a dx9/10/11/12/gl dll wrapper, or possibly with a fake display driver wrapper or some other dark magic. I haven't written any drivers but I know for audio there are a few out there which do something similar, i.e. to aggregate several audio devices and treat as one with a greater number of channels, like 16 or 32 for instance. You seem to want a 60hz graphics driver which sends a black frame in between real frames, so in other words, a 120hz native display.

It's within the possibility of what a wrapper can do. Doing it for games is different than doing it for movies. I believe I could find a way to do 120hz BFI in media player classic but I'd have to do a bit of inspecting other shaders to see how to get the frame index or global time, in which case it's trivial. You could also do it with a capture card capturing at 60hz and play it back via MPC-HC to the real graphics driver. It would likely add a frame or two of latency though.

TBH none of these options seem that compelling to me personally to invest time, at least not before I get my other 4K120 hz hack working. Rendering 120 frames per second just to clear half of them to black also seems ridiculously wasteful to my engineering sensibilities and not a solution I'm too keen on spending time on. HDR and mega-contrast and 120hz (at true 1080p or above res) are far more important to me.

I do see a difference in motion blur with BFI on using the MPC-HC shader I just wrote but getting true 120hz and no lumens lost seems way more compelling. I have a 144hz Gsync monitor as well as my 1080p projector and I use my projector all the time and monitor only to read the news or do work on it. But getting true 120hz on my monitor is a big upgrade to me, and it's not obvious to me (yet) how I can watch 24p or 60p content at 120hz by packing two subframes into a single 60hz frame, without writing either a DLL wrapper or a driver wrapper.

RLBURNSIDE
Posts: 104
Joined: 06 Apr 2015, 16:09

Re: Shaders/Drivers with software-based Black Frame Insertio

Post by RLBURNSIDE » 20 Feb 2017, 01:25

BFI is now enabled. Although it uses the frame counter to pick even / odd frames which results in intermittent flickering when the framerate changes. Maybe V-sync is off due to G-sync on my monitor, not sure.

Post Reply