Яндекс

Friday, November 21, 2014

Problem with CRT shader

I need help with CRT shader. The problem is following: scanlines are vertical (click on image to see it in full size )

I tried various versions of CRT shaders, they all work like this.The problem is especially bad when screen curvature is enabled:


I started to experiment with simplest CRT shader I found, author: Themaister
By default it also renders vertical scanlines.
I found that if I replace calculation of omega variable:
omega = vec2(3.1415 * rubyOutputSize.x * rubyTextureSize.x / rubyInputSize.x, 2.0 * 3.1415 * rubyTextureSize.y);
by
omega = vec2(2.0 * 3.1415 * rubyOutputSize.x * rubyTextureSize.x / rubyInputSize.x, 3.1415 * rubyTextureSize.y);
it fixes scanlines:


It's good, but I want to use more advanced shader,  like cgwg, Themaister and DOLLS CRT shader.
However, it uses more complex mathematics, and I can't find where to tune it to get needed result.

Other question: why these filters work for  bsnes? What did I wrong with OpenGL parameters to get this curse? The OpenGL code is very basic - just draw textured rectangle with CRT shader enabled.

4 comments:

  1. For the vertical scanlines in the first picture, it looks like its emulating vertical subpixel pattern there, not the scanline effect.

    The second picture, it looks like you are getting a moiré pattern, while I have no experience with shaders or anything 3D rendering, I think you'll need bilinear or anisotropic filtering to prevent the effect.

    ReplyDelete
    Replies
    1. No, I use exactly CRT shaders, which emulates scanlines. Check this article for screen shots and explanations: http://filthypants.blogspot.ru/2010/12/crt-pixel-shader-filter-for-snes.html

      Delete
  2. From what I see, it seems that bending is apply after scanline. This make sense but as scanline seems to have thin lines (1 pixel for 2), I wonder if, once a curvature applied, you didn't have a moiré pattern.

    Have you anti aliasing applied?

    Try to increase the scanline size, just to see if the pattern still appear.

    Not sure it help. :(

    Keep the (amazing) work! :)

    ReplyDelete
  3. As I see from screen shots from this article (http://filthypants.blogspot.ru/2010/12/crt-pixel-shader-filter-for-snes.html) moiré pattern is an expected part of shader's work.

    Enabling/disabling anti-aliasing does not affect shader work.

    I don't know how to increase the scanline size, I don't see such parameter in the shader.

    ReplyDelete