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

CRT-Geom with thinner scanlines #114

Open Faberman opened 7 years ago

Faberman commented 7 years ago

Is it possible to modify the current version of crt-geom.cg to get thinner scanlines as shown on Game Tech Wiki?

With CURVATURE = "0.0" and SHARPER = "2.0" I get regular scanlines like this. But the goal is this - a fine mesh which contributes to a nice blending without an excessive amount of blur.

I guess it's all about this line: <fragment filter="nearest" outscale_x="1" outscale_y="2">. Is it possible to set outscale_x and outscale_y attributes in Cg shader? @Themaister, any help here?

Here is the full quote from GTW:

To obtain thinner, 480p-esque scanlines, first tweak the shader to apply greater sharpness, but only apply it to the TextureSize. The code should look like this: uniform vec2 rubyTextureSize; vec2 TextureSize = vec2(2*rubyTextureSize.x, 2*rubyTextureSize.y); Again, this is for both the vertex and fragment portions. Don't forget to seek out any other instances of rubyTextureSize, and replace them with simply TextureSize.

Now, go to the beginning of the fragment portion, and modify it as such: <fragment filter="nearest" outscale_x="1" outscale_y="2"><![CDATA[ This will only yield satisfactory results at 4x integer scale. Anything else will likely cause problems. It might also be wise to disable the phosphor emulation, as leaving it on produces a "grid"-like effect, which may or may not be desirable.

hizzlekizzle commented 7 years ago

The way to do it is to add a first pass of the stock shader at 2x scale and then add crt-geom as a second pass. You'll want to disable the interlacing detection using the "CRTGeom Interlacing" option.

Faberman commented 7 years ago

@hizzlekizzle, unfortunately, there are no scanlines at all with these settings. Left - reference, right - current result: http://i.imgur.com/hSpOUZ3.png

hizzlekizzle commented 7 years ago

It's still showing scanlines for me but it's not looking like it's supposed to. I'll try to work on it some soon.