Some Medfaden Virtual boy core .cfg editing for 3D VR

Android Problem here

Hey guys so I became a bit intrigued I could almost 100% replacate a virtual boy with google cardboard to show my friends exactly what it was.

After doing a bit of research I came across a guy on youtube streaming from a pc running vbjin with a oculous plugin. But that was just too much for me to seem sane to my friends.

So a bit more digging I find there is sidebyside.glsl in the /misc section of shaders. So I thought maybe I can manage some minor coding myself for the 3D.

A bit more digging I find this .http://janstechblog.blogspot.com/2012/06/emulating-virtual-boy-on-3d-tv.html

Which is running in what I believe is the true intended 3d effect, screen by screen or sbs as its called. However it for a pc running on a 3d tv since the can convert the sbs to one 3d image

I need to edit this .cfg files for the core of medfaden.vb. Very easy on PC

So TL:dr is there is no .cfg file in /data/data/.com.retro and there is a config lacking the required stuff but very similar in data/android/.com.retro called “retroarch.cfg”

On android

Can anyone help me find where retroarch is hiding medfaden cfg file i need

Heres a little snip for the lazy "Unpack it and change the cfg file: Find the “vb.3dmode” and change it from “anaglyph” (the classic red/blue mode) to “sidebyside”.

  • Change “vb.stretch” to “full”.
  • Change “vb.3dreverse” if and only if the images are reversed (i.e. stuff that should be in the background appears to be closest to you)"

EDIT

I have found the file however im not sure the core supports the edits. the file is in data/android/.com.retroarch and is name retroarch.cores.cfg

it only has 2 options with underscores instead of underslash, im going to para phrase vb_anaglyph_mode = “red and blue” vb_Palatte_mode = " Black and white"

i add what she says bi\ut with under slashes to no effect

Unfortunately, the libretro vb-mednafen core doesn’t have the other 3D options hooked up, only the anaglyph :frowning:

I was looking into it recently, myself, and if you look in libretro.cpp from that repo, you’ll see that the other 3D options are stubbed out as “todo” because they would be complicated to add. I’ve mentioned it to Twinaphex and will see if he knows what would be involved in adding them in, presumably tearing down the context and then re-making it with different geometry to accommodate the additional images.

However, I did just whip up a quick shader that will take the anaglyph image and convert it to side-by-side, if you want to try that (I tested it with the ol’ cross-eyed 3D method and it seemed to work…). I couldn’t test the glsl version on my current machine because glsl shaders always crash here, but maybe it’ll work for you:

#pragma parameter eye_sep "Eye Separation" 0.45 0.0 5.0 0.05
#pragma parameter y_loc "Vertical Placement" 0.0 -1.0 1.0 0.05
#pragma parameter ana_zoom "Zoom" 0.4 -2.0 2.0 0.05
#ifdef PARAMETER_UNIFORM
uniform float eye_sep;
uniform float y_loc;
uniform float ana_zoom;
#else
#define eye_sep 0.5
#define y_loc 0.5
#define ana_zoom 0.13
#endif

#if defined(VERTEX)

#if __VERSION__ >= 130
#define COMPAT_VARYING out
#define COMPAT_ATTRIBUTE in
#define COMPAT_TEXTURE texture
#else
#define COMPAT_VARYING varying 
#define COMPAT_ATTRIBUTE attribute 
#define COMPAT_TEXTURE texture2D
#endif

#ifdef GL_ES
#define COMPAT_PRECISION mediump
#else
#define COMPAT_PRECISION
#endif

COMPAT_ATTRIBUTE vec4 VertexCoord;
COMPAT_ATTRIBUTE vec4 COLOR;
COMPAT_ATTRIBUTE vec4 TexCoord;
COMPAT_VARYING vec4 COL0;
COMPAT_VARYING vec4 TEX0;

vec4 _oPosition1; 
uniform mat4 MVPMatrix;
uniform int FrameDirection;
uniform int FrameCount;
uniform COMPAT_PRECISION vec2 OutputSize;
uniform COMPAT_PRECISION vec2 TextureSize;
uniform COMPAT_PRECISION vec2 InputSize;

void main()
{
    vec4 _oColor;
    vec2 _otexCoord;
	vec2 shift = vec2(0.5) * OutputSize / TextureSize;
    gl_Position = VertexCoord.x * MVPMatrix[0] + VertexCoord.y * MVPMatrix[1] + VertexCoord.z * MVPMatrix[2] + VertexCoord.w * MVPMatrix[3];
    _oPosition1 = gl_Position;
    _oColor = COLOR;
    _otexCoord = TexCoord.xy;
    COL0 = COLOR;
    TEX0.xy = (TexCoord.xy - shift) / vec2(ana_zoom) + shift;
}

#elif defined(FRAGMENT)

#if __VERSION__ >= 130
#define COMPAT_VARYING in
#define COMPAT_TEXTURE texture
out vec4 FragColor;
#else
#define COMPAT_VARYING varying
#define FragColor gl_FragColor
#define COMPAT_TEXTURE texture2D
#endif

#ifdef GL_ES
#ifdef GL_FRAGMENT_PRECISION_HIGH
precision highp float;
#else
precision mediump float;
#endif
#define COMPAT_PRECISION mediump
#else
#define COMPAT_PRECISION
#endif

struct output_dummy {
    vec4 _color;
};

uniform int FrameDirection;
uniform int FrameCount;
uniform COMPAT_PRECISION vec2 OutputSize;
uniform COMPAT_PRECISION vec2 TextureSize;
uniform COMPAT_PRECISION vec2 InputSize;
uniform sampler2D Texture;
COMPAT_VARYING vec4 TEX0;
//standard texture sample looks like this: COMPAT_TEXTURE(Texture, TEX0.xy);

void main()
{
    output_dummy _OUT;
vec4 frame1 = COMPAT_TEXTURE(Texture, TEX0.xy - vec2(eye_sep, y_loc));
vec4 frame2 = COMPAT_TEXTURE(Texture, TEX0.xy + vec2(eye_sep, -y_loc));
frame1.gb = vec2(frame1.r);
frame2.r = frame2.g;
    _OUT._color = vec4(frame1.r + frame2.r, 0.0, 0.0, 1.0);
    FragColor = _OUT._color;
    return;
} 
#endif

And here it is in Cg, if you want to try it on PC. When I get home, I can test/debug the GLSL version on a more cooperative machine:

#pragma parameter eye_sep "Eye Separation" 0.45 0.0 5.0 0.05
#pragma parameter y_loc "Vertical Placement" 0.0 -1.0 1.0 0.05
#pragma parameter ana_zoom "Zoom" 0.4 -2.0 2.0 0.05
#ifdef PARAMETER_UNIFORM
uniform float eye_sep;
uniform float y_loc;
uniform float ana_zoom;
#else
#define eye_sep 0.5
#define y_loc 0.5
#define ana_zoom 0.13
#endif

/* COMPATIBILITY 
   - HLSL compilers
   - Cg   compilers
*/

struct input
{
  float2 video_size;
  float2 texture_size;
  float2 output_size;
  float  frame_count;
  float  frame_direction;
  float frame_rotation;
};

void main_vertex
(
	float4 position	: POSITION,
	float4 color	: COLOR,
	float2 texCoord : TEXCOORD0,

    uniform float4x4 modelViewProj,
	uniform input IN,

	out float4 oPosition : POSITION,
	out float4 oColor    : COLOR,
	out float2 otexCoord : TEXCOORD
)
{
	float2 shift = 0.5 * IN.video_size / IN.texture_size;
	oPosition = mul(modelViewProj, position);
	oColor = color;
	otexCoord = (texCoord - shift) / ana_zoom + shift;
}

struct output 
{
  float4 color    : COLOR;
};

output main_fragment(float2 texCoord : TEXCOORD0, uniform sampler2D decal : TEXUNIT0, uniform input IN) 
{
float4 frame1 = tex2D(decal, texCoord - float2(eye_sep, y_loc));
float4 frame2 = tex2D(decal, texCoord + float2(eye_sep, -y_loc));
frame1.gb = float2(frame1.r);
frame2.r = frame2.g;

   output OUT;
   OUT.color = float4(frame1.r + frame2.r, 0.0, 0.0, 1.0);
   return OUT;
}

Nice, thanks a lot

Pasted the code each with no line break and one at the end of the .glsl

I’m getting no effect, not even a black screen. But perhaps I’ve mistaken something…

Here is sidebyside.glsl working

I’ve pasted the code correctly making sure [back] didn’t sneak it’s way in. Saved as .glsl

Ok, it’s probably just a dumb syntax issue somewhere. I’ll debug it when I get home and post a fix.

Ok, try this one (some of the options are redundant/nonfunctional; I’ll clean it up if/when we get it working):

#pragma parameter eye_sep "Eye Separation" 0.35 -1.0 5.0 0.05
#pragma parameter y_loc "Vertical Placement" 0.0 -1.0 1.0 0.05
#pragma parameter ana_zoom "Zoom" 0.4 -2.0 2.0 0.05
#pragma parameter WIDTH "Side-by-Side Image Width" 2.5 1.0 5.0 0.05
#pragma parameter HEIGHT "Side-by-Side Image Height" 2.0 1.0 5.0 0.1
#pragma parameter HORIZ "Right Eye X" 0.5 -2.0 2.0 0.005
#pragma parameter BOTH "Both Eye X" 0.47 -1.0 1.0 0.005
#pragma parameter VERT "Both Eye Y" 0.12 0.0 0.5 0.005
#ifdef PARAMETER_UNIFORM
uniform float eye_sep;
uniform float y_loc;
uniform float ana_zoom;
uniform float WIDTH;
uniform float HORIZ;
uniform float BOTH;
uniform float VERT;
uniform float HEIGHT;
#else
#define eye_sep 0.5
#define y_loc 0.5
#define ana_zoom 0.13
#define WIDTH 2.5
#define HORIZ 0.5
#define BOTH 0.13
#define VERT 0.055
#define HEIGHT 1.25

#endif

#if defined(VERTEX)

#if __VERSION__ >= 130
#define COMPAT_VARYING out
#define COMPAT_ATTRIBUTE in
#define COMPAT_TEXTURE texture
#else
#define COMPAT_VARYING varying 
#define COMPAT_ATTRIBUTE attribute 
#define COMPAT_TEXTURE texture2D
#endif

#ifdef GL_ES
#define COMPAT_PRECISION mediump
#else
#define COMPAT_PRECISION
#endif

COMPAT_ATTRIBUTE vec4 VertexCoord;
COMPAT_ATTRIBUTE vec4 COLOR;
COMPAT_ATTRIBUTE vec4 TexCoord;
COMPAT_VARYING vec4 COL0;
COMPAT_VARYING vec4 TEX0;

vec4 _oPosition1; 
uniform mat4 MVPMatrix;
uniform int FrameDirection;
uniform int FrameCount;
uniform COMPAT_PRECISION vec2 OutputSize;
uniform COMPAT_PRECISION vec2 TextureSize;
uniform COMPAT_PRECISION vec2 InputSize;

void main()
{
    vec4 _oColor;
    vec2 _otexCoord;
    gl_Position = VertexCoord.x * MVPMatrix[0] + VertexCoord.y * MVPMatrix[1] + VertexCoord.z * MVPMatrix[2] + VertexCoord.w * MVPMatrix[3];
    _oPosition1 = gl_Position;
    _oColor = COLOR;
    _otexCoord = TexCoord.xy;
    COL0 = COLOR;
    TEX0.xy = TexCoord.xy * vec2(WIDTH, HEIGHT) - vec2(BOTH, VERT);
}

#elif defined(FRAGMENT)

#if __VERSION__ >= 130
#define COMPAT_VARYING in
#define COMPAT_TEXTURE texture
out vec4 FragColor;
#else
#define COMPAT_VARYING varying
#define FragColor gl_FragColor
#define COMPAT_TEXTURE texture2D
#endif

#ifdef GL_ES
#ifdef GL_FRAGMENT_PRECISION_HIGH
precision highp float;
#else
precision mediump float;
#endif
#define COMPAT_PRECISION mediump
#else
#define COMPAT_PRECISION
#endif

struct output_dummy {
    vec4 _color;
};

uniform int FrameDirection;
uniform int FrameCount;
uniform COMPAT_PRECISION vec2 OutputSize;
uniform COMPAT_PRECISION vec2 TextureSize;
uniform COMPAT_PRECISION vec2 InputSize;
uniform sampler2D Texture;
COMPAT_VARYING vec4 TEX0;
//standard texture sample looks like this: COMPAT_TEXTURE(Texture, TEX0.xy);

void main()
{
    output_dummy _OUT;
vec4 frame1 = COMPAT_TEXTURE(Texture, TEX0.xy - vec2(eye_sep, y_loc));
vec4 frame2 = COMPAT_TEXTURE(Texture, TEX0.xy + vec2(eye_sep, -y_loc));
frame1.gb = vec2(frame1.r);
frame2.r = frame2.g;
    _OUT._color = vec4(frame1.r + frame2.r, 0.0, 0.0, 1.0);
    FragColor = _OUT._color;
    return;
} 
#endif

Nice work, got it running

Seems to render small is the only issue and it overrides the black and white palette…

I can’t get the gameboy pocket shader to work, but I did get mcgreen from the /misc to work, I ran it as only 1 pass, I think is the resolution problem.

http://imgur.com/HUBY0Zj

Anyway seems some shader do work, some do not. Will be nice fullsize and black/green or Black/White. I hope the lenses of Google cardboard work well

Alright, try this one. Set the anaglyph mode to red/cyan and your video aspect ratio setting to 16:9 so it’ll use the entire screen. It defaults to the red palette, but you can change it to black and white using the runtime toggle:

#pragma parameter eye_sep "Eye Separation" 0.35 -1.0 5.0 0.05
#pragma parameter y_loc "Vertical Placement" 0.30 -1.0 1.0 0.05
#pragma parameter ana_zoom "Zoom" 0.75 -2.0 2.0 0.05
#pragma parameter WIDTH "Side-by-Side Image Width" 3.05 1.0 7.0 0.05
#pragma parameter HEIGHT "Side-by-Side Image Height" 2.0 1.0 5.0 0.1
#pragma parameter BOTH "Horizontal Placement" 0.64 -2.0 2.0 0.005
#pragma parameter palette "Red Palette Toggle" 0.0 0.0 1.0 1.0
#ifdef PARAMETER_UNIFORM
uniform float eye_sep;
uniform float y_loc;
uniform float ana_zoom;
uniform float WIDTH;
uniform float BOTH;
uniform float HEIGHT;
uniform float palette;
#else
#define eye_sep 0.35
#define y_loc 0.30
#define ana_zoom 0.75
#define WIDTH 3.05
#define BOTH 0.64
#define HEIGHT 2.0
#define palette 0.0
#endif

#if defined(VERTEX)

#if __VERSION__ >= 130
#define COMPAT_VARYING out
#define COMPAT_ATTRIBUTE in
#define COMPAT_TEXTURE texture
#else
#define COMPAT_VARYING varying 
#define COMPAT_ATTRIBUTE attribute 
#define COMPAT_TEXTURE texture2D
#endif

#ifdef GL_ES
#define COMPAT_PRECISION mediump
#else
#define COMPAT_PRECISION
#endif

COMPAT_ATTRIBUTE vec4 VertexCoord;
COMPAT_ATTRIBUTE vec4 COLOR;
COMPAT_ATTRIBUTE vec4 TexCoord;
COMPAT_VARYING vec4 COL0;
COMPAT_VARYING vec4 TEX0;

vec4 _oPosition1; 
uniform mat4 MVPMatrix;
uniform int FrameDirection;
uniform int FrameCount;
uniform COMPAT_PRECISION vec2 OutputSize;
uniform COMPAT_PRECISION vec2 TextureSize;
uniform COMPAT_PRECISION vec2 InputSize;

void main()
{
    vec4 _oColor;
    vec2 _otexCoord;
    gl_Position = VertexCoord.x * MVPMatrix[0] + VertexCoord.y * MVPMatrix[1] + VertexCoord.z * MVPMatrix[2] + VertexCoord.w * MVPMatrix[3];
    _oPosition1 = gl_Position;
    _oColor = COLOR;
    _otexCoord = TexCoord.xy;
    COL0 = COLOR;
    vec2 shift = 0.5 * InputSize / TextureSize;
    TEX0.xy = ((TexCoord.xy - shift) * ana_zoom + shift) * vec2(WIDTH, HEIGHT) - vec2(BOTH, 0.0);
}

#elif defined(FRAGMENT)

#if __VERSION__ >= 130
#define COMPAT_VARYING in
#define COMPAT_TEXTURE texture
out vec4 FragColor;
#else
#define COMPAT_VARYING varying
#define FragColor gl_FragColor
#define COMPAT_TEXTURE texture2D
#endif

#ifdef GL_ES
#ifdef GL_FRAGMENT_PRECISION_HIGH
precision highp float;
#else
precision mediump float;
#endif
#define COMPAT_PRECISION mediump
#else
#define COMPAT_PRECISION
#endif

struct output_dummy {
    vec4 _color;
};

uniform int FrameDirection;
uniform int FrameCount;
uniform COMPAT_PRECISION vec2 OutputSize;
uniform COMPAT_PRECISION vec2 TextureSize;
uniform COMPAT_PRECISION vec2 InputSize;
uniform sampler2D Texture;
COMPAT_VARYING vec4 TEX0;
//standard texture sample looks like this: COMPAT_TEXTURE(Texture, TEX0.xy);

void main()
{
    output_dummy _OUT;
vec4 frame1 = COMPAT_TEXTURE(Texture, TEX0.xy - vec2(eye_sep, y_loc));
vec4 frame2 = COMPAT_TEXTURE(Texture, TEX0.xy + vec2(eye_sep, -y_loc));
frame1.gb = vec2(frame1.r);
frame2.r = frame2.g;
vec4 final = vec4(0.0);
if (palette > 0.5)
final = frame1 + frame2;
else
final = vec4(frame1.r + frame2.r, 0.0, 0.0, 1.0);
    _OUT._color = final;
    FragColor = _OUT._color;
    return;
} 
#endif

Works, but the left screen has mild to severe horizontal lines only on the left eye. Currently game breaking with some games http://imgur.com/5BhELc1

Ok, I tracked down the issue here, but I don’t know if I’ll be able to do anything about it.

On GLES (mobile OpenGL), it looks like it’s always using CLAMP_TO_EDGE instead of CLAMP_TO_BORDER. This makes it extend edge pixels out forever, covering the other image, like in this example: I’ll look to see if this is something I can fix or if it’s out of my league.

EDIT: nvm. Rather than trying to fix it in RetroArch, I just added some messy checks to the shader. Try it now:

#pragma parameter eye_sep "Eye Separation" 0.35 -1.0 5.0 0.05
#pragma parameter y_loc "Vertical Placement" 0.30 -1.0 1.0 0.05
#pragma parameter ana_zoom "Zoom" 0.75 -2.0 2.0 0.05
#pragma parameter WIDTH "Side-by-Side Image Width" 3.05 1.0 7.0 0.05
#pragma parameter HEIGHT "Side-by-Side Image Height" 2.0 1.0 5.0 0.1
#pragma parameter BOTH "Horizontal Placement" 0.64 -2.0 2.0 0.005
#pragma parameter palette "Red Palette Toggle" 0.0 0.0 1.0 1.0
#ifdef PARAMETER_UNIFORM
uniform float eye_sep;
uniform float y_loc;
uniform float ana_zoom;
uniform float WIDTH;
uniform float BOTH;
uniform float HEIGHT;
uniform float palette;
#else
#define eye_sep 0.35
#define y_loc 0.30
#define ana_zoom 0.75
#define WIDTH 3.05
#define BOTH 0.64
#define HEIGHT 2.0
#define palette 0.0
#endif

#if defined(VERTEX)

#if __VERSION__ >= 130
#define COMPAT_VARYING out
#define COMPAT_ATTRIBUTE in
#define COMPAT_TEXTURE texture
#else
#define COMPAT_VARYING varying 
#define COMPAT_ATTRIBUTE attribute 
#define COMPAT_TEXTURE texture2D
#endif

#ifdef GL_ES
#define COMPAT_PRECISION mediump
#else
#define COMPAT_PRECISION
#endif

COMPAT_ATTRIBUTE vec4 VertexCoord;
COMPAT_ATTRIBUTE vec4 COLOR;
COMPAT_ATTRIBUTE vec4 TexCoord;
COMPAT_VARYING vec4 COL0;
COMPAT_VARYING vec4 TEX0;

vec4 _oPosition1; 
uniform mat4 MVPMatrix;
uniform int FrameDirection;
uniform int FrameCount;
uniform COMPAT_PRECISION vec2 OutputSize;
uniform COMPAT_PRECISION vec2 TextureSize;
uniform COMPAT_PRECISION vec2 InputSize;

void main()
{
    vec4 _oColor;
    vec2 _otexCoord;
    gl_Position = VertexCoord.x * MVPMatrix[0] + VertexCoord.y * MVPMatrix[1] + VertexCoord.z * MVPMatrix[2] + VertexCoord.w * MVPMatrix[3];
    _oPosition1 = gl_Position;
    _oColor = COLOR;
    _otexCoord = TexCoord.xy;
    COL0 = COLOR;
    vec2 shift = 0.5 * InputSize / TextureSize;
    TEX0.xy = ((TexCoord.xy - shift) * ana_zoom + shift) * vec2(WIDTH, HEIGHT) - vec2(BOTH, 0.0);
}

#elif defined(FRAGMENT)

#if __VERSION__ >= 130
#define COMPAT_VARYING in
#define COMPAT_TEXTURE texture
out vec4 FragColor;
#else
#define COMPAT_VARYING varying
#define FragColor gl_FragColor
#define COMPAT_TEXTURE texture2D
#endif

#ifdef GL_ES
#ifdef GL_FRAGMENT_PRECISION_HIGH
precision highp float;
#else
precision mediump float;
#endif
#define COMPAT_PRECISION mediump
#else
#define COMPAT_PRECISION
#endif

struct output_dummy {
    vec4 _color;
};

uniform int FrameDirection;
uniform int FrameCount;
uniform COMPAT_PRECISION vec2 OutputSize;
uniform COMPAT_PRECISION vec2 TextureSize;
uniform COMPAT_PRECISION vec2 InputSize;
uniform sampler2D Texture;
COMPAT_VARYING vec4 TEX0;
//standard texture sample looks like this: COMPAT_TEXTURE(Texture, TEX0.xy);

void main()
{
    output_dummy _OUT;
vec2 fragCoord1 = (TEX0.xy - vec2(eye_sep, y_loc)) * InputSize / TextureSize;
vec2 fragCoord2 = (TEX0.xy + vec2(eye_sep, -y_loc)) * InputSize / TextureSize;
vec4 frame1 = vec4(0.0);
if ( fragCoord1.x < 1.0 && fragCoord1.x > 0.0 && fragCoord1.y < 1.0 && fragCoord1.y > 0.0 )
frame1 = COMPAT_TEXTURE(Texture, TEX0.xy - vec2(eye_sep, y_loc));
vec4 frame2 = vec4(0.0);
if ( fragCoord2.x < 1.0 && fragCoord2.x > 0.0 && fragCoord2.y < 1.0 && fragCoord2.y > 0.0 )
frame2 = COMPAT_TEXTURE(Texture, TEX0.xy + vec2(eye_sep, -y_loc));
frame1.gb = vec2(frame1.r);
frame2.r = frame2.g;
vec4 final = vec4(0.0);
if (palette > 0.5)
final = frame1 + frame2;
else
final = vec4(frame1.r + frame2.r, 0.0, 0.0, 1.0);
    _OUT._color = final;
    FragColor = _OUT._color;
    return;
} 
#endif

Thanks again, this time is working very cleanly http://imgur.com/7tl7bq2

Should be getting my Google Cardboard today, and work pretty well! Some correction for the lens distortion, a whole other issue would really add to the effect I think. Imgur

Edit:Got my lenses and this is awesome! Just a bit of distortion from lenses, but nothing bad at all, recommended

Actually I’m not sure but scaling the side by side height and width seems to change things. Check this out

http://imgur.com/KGlWsDu

It’s still 3d but has crazy artifacts from only seeing the hills in one eye. Like a transparency

///Edit: It is just scaling down the right eye is the problem. Also there is no distortion it’s just for focus///

Also you pretty much see right down to how your pixels are being made. My oled gives a nice hint of red and blue in the pattern oled gives.

I think I can get some lens distortion compensation in there. Does the lens distortion from the side-by-side shader work well enough? If so, I’ll just copy it.

Btw, did you set your RetroArch aspect ratio to 16x9? That will let you use the entire screen.

Oh didn’t realize that, it looks pretty good is actually looks the same through the lense. But the angle let’s you see more of the screen, maybe maybe that would be a nice option. I can’t set my eye separation to fully test

Mario tennis seems fine, but panic bomber the puzzle fighter like game shows you can not see the 4 corners or bottom of the screen well. I did manage 16:9

and would not scale down for me without some clipping. But that distortion might do the trick

Try this one:

#pragma parameter eye_sep "Eye Separation" 0.35 -1.0 5.0 0.05
#pragma parameter y_loc "Vertical Placement" 0.30 -1.0 1.0 0.05
#pragma parameter ana_zoom "Zoom" 0.75 -2.0 2.0 0.05
#pragma parameter WIDTH "Side-by-Side Image Width" 3.05 1.0 7.0 0.05
#pragma parameter HEIGHT "Side-by-Side Image Height" 2.0 1.0 5.0 0.1
#pragma parameter BOTH "Horizontal Placement" 0.64 -2.0 2.0 0.005
#pragma parameter palette "Red Palette Toggle" 0.0 0.0 1.0 1.0
#pragma parameter warpX "warpX" 0.031 0.0 0.125 0.01
#pragma parameter warpY "warpY" 0.041 0.0 0.125 0.01
#ifdef PARAMETER_UNIFORM
uniform float eye_sep;
uniform float y_loc;
uniform float ana_zoom;
uniform float WIDTH;
uniform float BOTH;
uniform float HEIGHT;
uniform float palette;
uniform float warpX;
uniform float warpY;
#else
#define eye_sep 0.35
#define y_loc 0.30
#define ana_zoom 0.75
#define WIDTH 3.05
#define BOTH 0.64
#define HEIGHT 2.0
#define palette 0.0
#define warpX 0.031
#define warpY 0.041
#endif

#if defined(VERTEX)

#if __VERSION__ >= 130
#define COMPAT_VARYING out
#define COMPAT_ATTRIBUTE in
#define COMPAT_TEXTURE texture
#else
#define COMPAT_VARYING varying 
#define COMPAT_ATTRIBUTE attribute 
#define COMPAT_TEXTURE texture2D
#endif

#ifdef GL_ES
#define COMPAT_PRECISION mediump
#else
#define COMPAT_PRECISION
#endif

COMPAT_ATTRIBUTE vec4 VertexCoord;
COMPAT_ATTRIBUTE vec4 COLOR;
COMPAT_ATTRIBUTE vec4 TexCoord;
COMPAT_VARYING vec4 COL0;
COMPAT_VARYING vec4 TEX0;

vec4 _oPosition1; 
uniform mat4 MVPMatrix;
uniform int FrameDirection;
uniform int FrameCount;
uniform COMPAT_PRECISION vec2 OutputSize;
uniform COMPAT_PRECISION vec2 TextureSize;
uniform COMPAT_PRECISION vec2 InputSize;

void main()
{
    vec4 _oColor;
    vec2 _otexCoord;
    gl_Position = VertexCoord.x * MVPMatrix[0] + VertexCoord.y * MVPMatrix[1] + VertexCoord.z * MVPMatrix[2] + VertexCoord.w * MVPMatrix[3];
    _oPosition1 = gl_Position;
    _oColor = COLOR;
    _otexCoord = TexCoord.xy;
    COL0 = COLOR;
    vec2 shift = 0.5 * InputSize / TextureSize;
    TEX0.xy = ((TexCoord.xy - shift) * ana_zoom + shift) * vec2(WIDTH, HEIGHT) - vec2(BOTH, 0.0);
}

#elif defined(FRAGMENT)

#if __VERSION__ >= 130
#define COMPAT_VARYING in
#define COMPAT_TEXTURE texture
out vec4 FragColor;
#else
#define COMPAT_VARYING varying
#define FragColor gl_FragColor
#define COMPAT_TEXTURE texture2D
#endif

#ifdef GL_ES
#ifdef GL_FRAGMENT_PRECISION_HIGH
precision highp float;
#else
precision mediump float;
#endif
#define COMPAT_PRECISION mediump
#else
#define COMPAT_PRECISION
#endif

struct output_dummy {
    vec4 _color;
};

uniform int FrameDirection;
uniform int FrameCount;
uniform COMPAT_PRECISION vec2 OutputSize;
uniform COMPAT_PRECISION vec2 TextureSize;
uniform COMPAT_PRECISION vec2 InputSize;
uniform sampler2D Texture;
COMPAT_VARYING vec4 TEX0;
//standard texture sample looks like this: COMPAT_TEXTURE(Texture, TEX0.xy);

//distortion
vec2 Warp(float2 pos){
  pos=pos*2.0-1.0;    
  pos*=float2(1.0+(pos.y*pos.y)*warpX,1.0+(pos.x*pos.x)*warpY);
  return pos*0.5+0.5;}

void main()
{
    output_dummy _OUT;
	vec2 warpCoord = Warp(TEX0.xy);
vec2 fragCoord1 = (warpCoord - vec2(eye_sep, y_loc)) * InputSize / TextureSize;
vec2 fragCoord2 = (warpCoord + vec2(eye_sep, -y_loc)) * InputSize / TextureSize;
vec4 frame1 = vec4(0.0);
if ( fragCoord1.x < 1.0 && fragCoord1.x > 0.0 && fragCoord1.y < 1.0 && fragCoord1.y > 0.0 )
frame1 = COMPAT_TEXTURE(Texture, warpCoord - vec2(eye_sep, y_loc));
vec4 frame2 = vec4(0.0);
if ( fragCoord2.x < 1.0 && fragCoord2.x > 0.0 && fragCoord2.y < 1.0 && fragCoord2.y > 0.0 )
frame2 = COMPAT_TEXTURE(Texture, warpCoord + vec2(eye_sep, -y_loc));
frame1.gb = vec2(frame1.r);
frame2.r = frame2.g;
vec4 final = vec4(0.0);
if (palette > 0.5)
final = frame1 + frame2;
else
final = vec4(frame1.r + frame2.r, 0.0, 0.0, 1.0);
    _OUT._color = final;
    FragColor = _OUT._color;
    return;
} 
#endif

It’s not the same distortion code as the other one, but maybe it will help. The code from the side-by-side shader is a mess, so hopefully this one will be good enough.

I’m loaded this one up but am getting no effect on this one. Thanks for the continue work though

Ah, yeah, that was a dumb typo on my part. Try this one (fixed typo and did some more tweaking):

#pragma parameter eye_sep "Eye Separation" 0.35 -1.0 5.0 0.05
#pragma parameter y_loc "Vertical Placement" 0.30 -1.0 1.0 0.05
#pragma parameter ana_zoom "Zoom" 0.75 -2.0 2.0 0.05
#pragma parameter WIDTH "Side-by-Side Image Width" 3.05 1.0 7.0 0.05
#pragma parameter HEIGHT "Side-by-Side Image Height" 2.0 1.0 5.0 0.1
#pragma parameter BOTH "Horizontal Placement" 0.64 -2.0 2.0 0.005
#pragma parameter palette "Red Palette Toggle" 0.0 0.0 1.0 1.0
#pragma parameter warpX "warpX" 0.3 0.0 0.5 0.05
#pragma parameter warpY "warpY" 0.3 0.0 0.5 0.05
#ifdef PARAMETER_UNIFORM
uniform float eye_sep;
uniform float y_loc;
uniform float ana_zoom;
uniform float WIDTH;
uniform float BOTH;
uniform float HEIGHT;
uniform float palette;
uniform float warpX;
uniform float warpY;
#else
#define eye_sep 0.35
#define y_loc 0.30
#define ana_zoom 0.75
#define WIDTH 3.05
#define BOTH 0.64
#define HEIGHT 2.0
#define palette 0.0
#define warpX 0.3
#define warpY 0.3
#endif

#if defined(VERTEX)

#if __VERSION__ >= 130
#define COMPAT_VARYING out
#define COMPAT_ATTRIBUTE in
#define COMPAT_TEXTURE texture
#else
#define COMPAT_VARYING varying 
#define COMPAT_ATTRIBUTE attribute 
#define COMPAT_TEXTURE texture2D
#endif

#ifdef GL_ES
#define COMPAT_PRECISION mediump
#else
#define COMPAT_PRECISION
#endif

COMPAT_ATTRIBUTE vec4 VertexCoord;
COMPAT_ATTRIBUTE vec4 COLOR;
COMPAT_ATTRIBUTE vec4 TexCoord;
COMPAT_VARYING vec4 COL0;
COMPAT_VARYING vec4 TEX0;

vec4 _oPosition1; 
uniform mat4 MVPMatrix;
uniform int FrameDirection;
uniform int FrameCount;
uniform COMPAT_PRECISION vec2 OutputSize;
uniform COMPAT_PRECISION vec2 TextureSize;
uniform COMPAT_PRECISION vec2 InputSize;

void main()
{
    vec4 _oColor;
    vec2 _otexCoord;
    gl_Position = VertexCoord.x * MVPMatrix[0] + VertexCoord.y * MVPMatrix[1] + VertexCoord.z * MVPMatrix[2] + VertexCoord.w * MVPMatrix[3];
    _oPosition1 = gl_Position;
    _oColor = COLOR;
    _otexCoord = TexCoord.xy;
    COL0 = COLOR;
    vec2 shift = 0.5 * InputSize / TextureSize;
    TEX0.xy = ((TexCoord.xy - shift) * ana_zoom + shift) * vec2(WIDTH, HEIGHT) - vec2(BOTH, 0.0);
}

#elif defined(FRAGMENT)

#if __VERSION__ >= 130
#define COMPAT_VARYING in
#define COMPAT_TEXTURE texture
out vec4 FragColor;
#else
#define COMPAT_VARYING varying
#define FragColor gl_FragColor
#define COMPAT_TEXTURE texture2D
#endif

#ifdef GL_ES
#ifdef GL_FRAGMENT_PRECISION_HIGH
precision highp float;
#else
precision mediump float;
#endif
#define COMPAT_PRECISION mediump
#else
#define COMPAT_PRECISION
#endif

struct output_dummy {
    vec4 _color;
};

uniform int FrameDirection;
uniform int FrameCount;
uniform COMPAT_PRECISION vec2 OutputSize;
uniform COMPAT_PRECISION vec2 TextureSize;
uniform COMPAT_PRECISION vec2 InputSize;
uniform sampler2D Texture;
COMPAT_VARYING vec4 TEX0;
//standard texture sample looks like this: COMPAT_TEXTURE(Texture, TEX0.xy);

//distortion
vec2 Warp(vec2 pos){
  pos.xy = pos.xy * 2.0-1.0;    
  pos.xy *= vec2(1.0+(pos.y*pos.y)*warpX,1.0+(pos.x*pos.x)*warpY);
  return pos*0.5+0.5;}

void main()
{
    output_dummy _OUT;
	vec2 warpCoord1 = Warp((TEX0.xy - vec2(eye_sep,  y_loc))*(TextureSize.xy/InputSize.xy))*(InputSize.xy/TextureSize.xy);
	vec2 warpCoord2 = Warp((TEX0.xy + vec2(eye_sep, -y_loc))*(TextureSize.xy/InputSize.xy))*(InputSize.xy/TextureSize.xy);
vec2 fragCoord1 = warpCoord1 * InputSize / TextureSize;
vec2 fragCoord2 = warpCoord2 * InputSize / TextureSize;
vec4 frame1 = vec4(0.0);
if ( fragCoord1.x < 1.0 && fragCoord1.x > 0.0 && fragCoord1.y < 1.0 && fragCoord1.y > 0.0 )
frame1 = COMPAT_TEXTURE(Texture, warpCoord1);
vec4 frame2 = vec4(0.0);
if ( fragCoord2.x < 1.0 && fragCoord2.x > 0.0 && fragCoord2.y < 1.0 && fragCoord2.y > 0.0 )
frame2 = COMPAT_TEXTURE(Texture, warpCoord2);
frame1.gb = vec2(frame1.r);
frame2.r = frame2.g;
vec4 final = vec4(0.0);
if (palette > 0.5)
final = frame1 + frame2;
else
final = vec4(frame1.r + frame2.r, 0.0, 0.0, 1.0);
    _OUT._color = final;
    FragColor = _OUT._color;
    return;
} 
#endif

Hey sorry it’s been a bit, but I’m getting no effect on this one as well. And no shader parameters

Hmm. Are you sure you copied/pasted correctly? I just tried it on a different machine and it works fine for me there, too.

Okay working now. Had to make the glsl on my computer instead of mobile

It seems to be scaling down evenly and I’ve got the whole picture in there. The curve distortion really helps to keep the screen a bit bigger but see the corners.

Awesome :slight_smile: Should we call it a success, then? If so, I’ll put it in my glsl repo and get a Cg version in the common-shaders repo.

Yeah I can say everything is adjusting fine. Got everything on screen and the curvature is a nice option to have