libretro / common-shaders

Collection of commonly used Cg shaders. These shaders are usable by either HLSL and/or Cg runtime compilers. The cg2glsl script will translate most of these into GLSL shaders.
http://www.libretro.com
1.05k stars 250 forks source link

Apply to a video stream? #67

Open b- opened 8 years ago

b- commented 8 years ago

Let me preface this by mentioning I know nothing about shaders outside of the context of video gaming, and little about them inside of it.

I love the PhosphorLUT shader, and it seems useful outside of RetroArch, say, for nostalgia purposes, or perhaps for other emulators that don't support the libretro framework, or for video processing. (on a 4K screen it's easier on the eyes than any other upscaling method I've seen).

I figure the latter would probably be relatively easy, even. But I have no idea where to start. In short (unless someone more knowledgeable than me thinks this is the wrong question to ask), is it possible to pipe an arbitrary video stream to a set of .cg programs, to "watch" it with the filters applied? What about for a capture card or TV tuner? I guess if patching VLC to process with .cg filters (if this doesn't exist natively within it already) would solve these.

If I'm not out of my mind for wanting to do so as a first program in a new language, would anyone have the faintest idea where to start to go about doing that?

inactive123 commented 8 years ago

Would using the builtin ffmpeg core inside RetroArch not be an option if you just want to apply shaders to video streams?

The ffmpeg core is also available as a standalone libretro core, for use with any libretro-compatible frontend.

hizzlekizzle commented 8 years ago

You should be able to use RA's FFmpeg core in conjunction with the GPU-filtered video-dumping feature to upscale/process videos, though it'll be slower-than-realtime.

If RA's FFmpeg core is insufficient for whatever reason, MPV media player also supports shaders, though not the Cg shaders we use, and the featureset is pretty limited (for example, I don't think it supports external lookup textures, which are needed for the PhosphorLUT shader).

You could also try porting the shader over to ReShade, which can inject shaders into DirectX video streams and is apparently pretty robust, but it's closed-source, Windows-only and uses a proprietary shader language. You might also try looking into letoram's ArcanFE, which can hijack video streams and apply shaders (possibly including our Cg shaders...?) to the output.