Page 1 of 2 1 2 >
Topic Options
#49774 - 03/05/09 09:12 PM A couple GLSL issues
cgwg Offline
Member

Registered: 27/07/07
Posts: 16
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.
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.

Top
#50066 - 11/05/09 08:00 AM Re: A couple GLSL issues [Re: cgwg]
cgwg Offline
Member

Registered: 27/07/07
Posts: 16
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.

Click for full size

Click for full size

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

Top
#51877 - 23/07/09 05:34 PM Re: A couple GLSL issues [Re: cgwg]
cgwg Offline
Member

Registered: 27/07/07
Posts: 16
Looks like I have another excuse to bump this.



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.

Top
#51878 - 23/07/09 05:52 PM Re: A couple GLSL issues [Re: cgwg]
R. Belmont Offline
Senior Member

Registered: 17/03/01
Posts: 12492
Loc: USA
That last one looks really nice. Are your shaders available for download someplace?

Top
#51881 - 23/07/09 06:08 PM Re: A couple GLSL issues [Re: R. Belmont]
cgwg Offline
Member

Registered: 27/07/07
Posts: 16
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

Top
#53192 - 31/08/09 10:43 AM Re: A couple GLSL issues [Re: cgwg]
torturedutopian Offline
Member

Registered: 18/12/07
Posts: 28
Sadly, this package is not available anymore. Could anyone please upload shaders/PNG filters somewhere ?

Top
#53205 - 31/08/09 11:44 PM Re: A couple GLSL issues [Re: torturedutopian]
cgwg Offline
Member

Registered: 27/07/07
Posts: 16
Sorry, it looks like I mangled the link. This link should hopefully work.

Top
#56841 - 07/12/09 11:49 AM Re: A couple GLSL issues [Re: cgwg]
torturedutopian Offline
Member

Registered: 18/12/07
Posts: 28
Thanks ! Ahem, well, I also wonder where I can find the regular shaders pack (that contains glsl_plain wink

Sorry ! smile

Top
#56958 - 10/12/09 11:54 AM Re: A couple GLSL issues [Re: torturedutopian]
torturedutopian Offline
Member

Registered: 18/12/07
Posts: 28
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


Edited by torturedutopian (10/12/09 12:09 PM)

Top
#56960 - 10/12/09 02:21 PM Re: A couple GLSL issues [Re: torturedutopian]
R. Belmont Offline
Senior Member

Registered: 17/03/01
Posts: 12492
Loc: USA
Eh? You can run in windowed mode and use the mouse to pull up your favorite screenshot utility smile

Top
Page 1 of 2 1 2 >


Moderator:  R. Belmont 
Who's Online
4 registered (Micko, judge, couriersud, Richard Bannister), 8 Guests and 3 Spiders online.
Key: Admin, Global Mod, Mod
Shout Box

Forum Stats
4015 Members
9 Forums
6214 Topics
63592 Posts

Max Online: 162 @ 01/05/07 03:28 AM