Previous Thread
Next Thread
Print Thread
Page 1 of 19 1 2 3 18 19
#49774 05/03/09 08:12 PM
Joined: Jul 2007
Posts: 79
C
Member
Member
C Offline
Joined: Jul 2007
Posts: 79
I've noticed a couple issues using GLSL. For reference, I'm running Fedora 10 with a GeForce 8600GT.

1. In certain games -gl_glsl_filter 1 shows artifacts as shown. They depend on the size of the window and are either vertical or horizontal strips. They also interact strangely with fullscreen. In tgmj, for example, they appear when I start the game in fullscreen (1600x1200) but then disappear when I toggle fullscreen off and back on.
[Linked Image from img213.imageshack.us] Click for full size.

2. GLSL bilinear filtering only works on some games. It works on pacman and sf2, but invaders and sfiii3 are unfiltered.

The two problems occur whether I use -gl_glsl_filter 1 or if I use -glsl_shader_mame0 shader/glsl_bilinear.

Joined: Jul 2007
Posts: 79
C
Member
Member
C Offline
Joined: Jul 2007
Posts: 79
As an excuse to bump my thread, I thought I might show my attempt at a scanlines shader. Horizontally I use simple linear interpolation since I don't want to simulate a CRT's video amplifier. Vertically I give the beam a Gaussian profile. I also simulate CRT bloom by increasing the beam width for the brightest colours.

[Linked Image from img104.imageshack.us] Click for full size

[Linked Image from img25.imageshack.us] Click for full size

I based it on the glsl_bilinear shader and it suffers from both of the issues in my first post.

Joined: Jul 2007
Posts: 79
C
Member
Member
C Offline
Joined: Jul 2007
Posts: 79
Looks like I have another excuse to bump this.

[Linked Image from img404.imageshack.us]

The aperture effect used here was designed to work with the RGB subpixel structure of LCDs, so you should see it at full size. I use Lanczos scaling horizontally and give the beam a Gaussian profile (in a linear color space). Scanline width and bloom effects can of course be adjusted.

Joined: Mar 2001
Posts: 17,258
Likes: 267
R
Very Senior Member
Very Senior Member
R Offline
Joined: Mar 2001
Posts: 17,258
Likes: 267
That last one looks really nice. Are your shaders available for download someplace?

Joined: Jul 2007
Posts: 79
C
Member
Member
C Offline
Joined: Jul 2007
Posts: 79
Code
#pragma optimize (on)
#pragma debug (off)

uniform sampler2D     mpass_texture;
uniform sampler2D     color_texture;
uniform vec2          color_texture_pow2_sz; // pow2 tex size
uniform vec4          vid_attributes;        // gamma, contrast, brightness

#define TEX2D(c) texture2D(mpass_texture,(c))
#define PI 3.141592653589

void main()
{
	vec2 xy = gl_TexCoord[0].st;

	vec2 uv_ratio     = fract(xy*color_texture_pow2_sz);
	vec2 one          = 1.0/color_texture_pow2_sz;

	vec4 col, col2;

	vec4 coeffs = vec4(1.0 + uv_ratio.x, uv_ratio.x, 1.0 - uv_ratio.x, 2.0 - uv_ratio.x);
	coeffs = sin(PI * coeffs) * sin(PI * coeffs / 2.0) / (coeffs * coeffs);
	coeffs = coeffs / (coeffs.x+coeffs.y+coeffs.z+coeffs.w);

	col  = clamp(coeffs.x * TEX2D(xy + vec2(-one.x,0.0)) + coeffs.y * TEX2D(xy) + coeffs.z * TEX2D(xy + vec2(one.x, 0.0)) + coeffs.w * TEX2D(xy + vec2(2 * one.x, 0.0)),0.0,1.0);
	col2 = clamp(coeffs.x * TEX2D(xy + vec2(-one.x,one.y)) + coeffs.y * TEX2D(xy + vec2(0.0, one.y)) + coeffs.z * TEX2D(xy + one) + coeffs.w * TEX2D(xy + vec2(2 * one.x, one.y)),0.0,1.0);
	col = pow(col, 2.2);
	col2 = pow(col2, 2.2);
	

	vec4 wid = 0.3 + 0.2 * pow(col, 4.0);
	vec4 weights = uv_ratio.y/wid;
	weights = 0.51*exp(-weights*weights)/wid;
	wid = 0.3 + 0.2 * pow(col2,4.0);
	vec4 weights2 = (1.0-uv_ratio.y)/wid;
	weights2 = 0.51*exp(-weights2*weights2)/wid;

	gl_FragColor = pow(col * weights + col2 * weights2, 1.0/2.2);
}

I took one of the bilinear shaders as a starting point. Here's everything tarred up. Put aperture4x4v2.png in the appropriate place and put the shader files in shader/custom. I produced that screenshot by running this:

Code
sdlmame -gl_glsl -glsl_shader_mame0 shader/glsl_plain -glsl_shader_mame1 shader/custom/scanlines -effect aperture4x4v2 sf2

Joined: Dec 2007
Posts: 107
T
Senior Member
Senior Member
T Offline
Joined: Dec 2007
Posts: 107
Sadly, this package is not available anymore. Could anyone please upload shaders/PNG filters somewhere ?

Joined: Jul 2007
Posts: 79
C
Member
Member
C Offline
Joined: Jul 2007
Posts: 79
Sorry, it looks like I mangled the link. This link should hopefully work.

Joined: Dec 2007
Posts: 107
T
Senior Member
Senior Member
T Offline
Joined: Dec 2007
Posts: 107
Thanks ! Ahem, well, I also wonder where I can find the regular shaders pack (that contains glsl_plain wink

Sorry ! smile

Joined: Dec 2007
Posts: 107
T
Senior Member
Senior Member
T Offline
Joined: Dec 2007
Posts: 107
Okay, finally, I got it working ; it looks really cool !

However, the shader effect leads to a few vertical black lines (<10) over the picture. Any idea ?

Edit : Hmm, I wanted to make a screenshot, however sdlmame (linux) locks the keyboard and the built-in screenshot feature seems to short-circuit the effects. It's not such a bad behaviour, as you don't switch to another virtual desktop when playing smile

Last edited by torturedutopian; 12/10/09 12:09 PM.
Joined: Mar 2001
Posts: 17,258
Likes: 267
R
Very Senior Member
Very Senior Member
R Offline
Joined: Mar 2001
Posts: 17,258
Likes: 267
Eh? You can run in windowed mode and use the mouse to pull up your favorite screenshot utility smile

Page 1 of 19 1 2 3 18 19

Moderated by  R. Belmont 

Link Copied to Clipboard
Who's Online Now
1 members (yugffuts), 177 guests, and 0 robots.
Key: Admin, Global Mod, Mod
ShoutChat
Comment Guidelines: Do post respectful and insightful comments. Don't flame, hate, spam.
Forum Statistics
Forums9
Topics9,355
Posts122,424
Members5,082
Most Online1,283
Dec 21st, 2022
Our Sponsor
These forums are sponsored by Superior Solitaire, an ad-free card game collection for macOS and iOS. Download it today!

Superior Solitaire
Powered by UBB.threads™ PHP Forum Software 8.0.0