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

[Request] Side-by-side shader for playing on an HMD #34

Open vgf89 opened 10 years ago

vgf89 commented 10 years ago

Would it be possible to create a simple side-by-side type shader (scale game down a little, place same cloned video on left and right side of screen) for use with an HMD (Oculus Rift, Google Cardboard/other phone HMD)?

hunterk commented 9 years ago

Whoops, just noticed this issue.

Sure. I just pushed something to the 'misc' subdirectory. I don't know of any way to make it place the side-by-side images perfectly for all resolutions, so I put some runtime parameters in that you can adjust to line things up.

vgf89 commented 9 years ago

The only setting that appears to really be missing is the ability to set the y-position (or reworking the settings to have separation, height, and width instead, so that everything stays centered)

hizzlekizzle commented 9 years ago

Ha, I actually had it in there for awhile and then took it out because I didn't think it was necessary. I just re-added it. Let me know if it needs any more work.

vgf89 commented 9 years ago

test Not sure what's going on with the pincushion settings. The blue-ish area flickers different shades (also shows up with yellow for a few frames on the Chrono Trigger start animation).

The blue area gets close to surrounding, rather than overlapping, the game if you turn the curvature radius down. test2

Same problem in Super Mario World. No idea what's going on here, but it seems to be grabbing the color from some edge or corner of the game image, given how it behaves with the Chrono Trigger start screen and the color here.

Also, some Super Mario World test3

It seems to happen regardless of what libretro core I use. This problem only happens with the pincushion distortion on.

hizzlekizzle commented 9 years ago

Yeah, that's not really intended, but it is indeed functioning as expected (though it's not as immediate on my end; may be GPU-specific...). You can try increasing the value after '#define d' in the shader code, which mitigates the effect, but also reduces the curvature effect. So, crank it up and turn the radius down and see if it keeps the weird out-of-bounds color stuff from taking over.

I don't have a HMD, so I was just coding blind, based on what oculus rift pics I could find online, but can you make a screenshot of an ideal placement and curvature (assuming the weirdness wasn't happening) that I can use as a guide?

HelenSkelter commented 8 years ago

Is there any chance a version of this could be made without barrel distortion? Most of the hmds i've used looked just fine without it. Here's a good example of what I mean: https://i.ytimg.com/vi/7BkXnryT33I/maxresdefault.jpg

hizzlekizzle commented 8 years ago

You can disable the pincushion effect in the parameters.

You can also try this other version I made in glsl that's a little different: https://github.com/hizzlekizzle/glsl-shaders/blob/master/misc/side-by-side-simple.glsl

HelenSkelter commented 8 years ago

That one works way better, however I don't seem to be able edit the parameters on the android version. Specifically it looks shifted to the right with the right view cutoff so I'm trying to edit the horizontal placement.

HelenSkelter commented 8 years ago

Okay so since the current version crashes when I try to open the Menu Parameters I used an older version and got everything adjusted well. Thank you very much!

hizzlekizzle commented 8 years ago

Awesome! I'm glad it worked for you. I'm not sure why it crashes on the current version and adb didn't give me any good clues :/ I haven't tried any nightlies to see if they act any better but hopefully, it'll be fixed in the next release.

HelenSkelter commented 8 years ago

Oh I'll try the nightlies as well. That would be great, I'm having weird issues with the menu in the older version (1.2) that shows down the process.

What exactly would it take to get this included as a default shader with profile and/or added in as a Cardboard/SBS mode? I can go through and make profiles if that'd help.

HelenSkelter commented 8 years ago

Oh also I posted instructions on how I got it working here if that helps anything:

https://www.reddit.com/r/GoogleCardboard/comments/44kow7/i_got_retroarch_working_in_sbs_with_no_artifacts/

hizzlekizzle commented 8 years ago

@HelenSkelter I added in a preset that you can load directly instead of doing the glslp hokey pokey you described in the post. I went ahead and put in your settings in the preset, as well. https://github.com/hizzlekizzle/glsl-shaders/blob/master/misc/cardboard-vr.glslp

Also, have you tried the anaglyph-to-side-by-side.glsl shader that's in there? It lets you play virtualboy games in 3D. You just need to go into the core options and set the anaglyph preset to any option other than red/blue or yellow/blue. I think red/electric cyan works well.

HelenSkelter commented 8 years ago

Oh thank you very much, that'll save me a lot of time. I had but I didn't know to avoid those combinations before, that's really neat! I wonder if something like that is possible for those Anaglyph 3D Master System games.

Unfortunately those settings vary widely between systems. Would the best option be to make a profile for every system and then post them somewhere?