Links and Guides to Custom Shaders for Pete's OpenGL2 plugin

Discussion in 'PSX Plugin Questions & Troubleshooting' started by ViperXtreme, Aug 11, 2006.

  1. SimoneT

    SimoneT Not so likeable!

    Messages:
    162
    Likes Received:
    0
    New 5xBR v3.7a GLSL and ARB (for NVIDIA cards only)...
    Big speedup... and no code obfuscation (so Guest.r can copy without problems)!
    Remember to disable "Screen filtering" and set "Internal X/Y resolution to 0:low"
    Ciao.
  2. Hyllian

    Hyllian New Member

    Messages:
    84
    Likes Received:
    0
    Are you planning "b" and "c" versions?
  3. SimoneT

    SimoneT Not so likeable!

    Messages:
    162
    Likes Received:
    0
    Yes, but I think the "a" version is enough good for most PSX games (and gamers). I'm working on a version that permit the use of the internal screen filtering. When I think is ready I sent you a PM.
    Ciao.
    P.S.: have you tested my "vertex calculation" trick?
  4. Hyllian

    Hyllian New Member

    Messages:
    84
    Likes Received:
    0
    Ok. Does the 'internal screen filtering' work over textures?

    Not yet. But I've passed my eyes a bit over it. It seems you know some clever shader tricks. :wub:

    I'll try to translate to Cg later and see what happens. :thumb:
  5. Hyllian

    Hyllian New Member

    Messages:
    84
    Likes Received:
    0
    That I4 texture lookup should be "xw" instead "xy", or Am I mistaken?
  6. SimoneT

    SimoneT Not so likeable!

    Messages:
    162
    Likes Received:
    0
    You are right!
    Ciao.
  7. Hyllian

    Hyllian New Member

    Messages:
    84
    Likes Received:
    0
    SimoneT, why don't you use variables instead assuming resolution of 1024x512?

    I'll use something like this in my code (not tested yet):

    Code:
    	half2 ps = half2(1.0/IN.texture_size.x, 1.0/IN.texture_size.y);
    	half dx  = ps.x;
    	half dy  = ps.y;
    
    //    A1 B1 C1
    // A0  A  B  C C4
    // D0  D  E  F F4
    // G0  G  H  I I4
    //    G5 H5 I5
    
    	OUT.texCoord = texCoord;
    	OUT.t1 = texCoord.xxxy + half4( -dx, 0, dx,-2.0*dy); // A1 B1 C1
    	OUT.t2 = texCoord.xxxy + half4( -dx, 0, dx,    -dy); //  A  B  C 
    	OUT.t3 = texCoord.xxxy + half4( -dx, 0, dx,      0); //  D  E  F 
    	OUT.t4 = texCoord.xxxy + half4( -dx, 0, dx,     dy); //  G  H  I 
    	OUT.t5 = texCoord.xxxy + half4( -dx, 0, dx, 2.0*dy); // G5 H5 I5
    	OUT.t6 = texCoord.xyyy + half4(-2.0*dx,-dy, 0,  dy); // A0 D0 G0
    	OUT.t7 = texCoord.xyyy + half4( 2.0*dx,-dy, 0,  dy); // C4 F4 I4
    
  8. SimoneT

    SimoneT Not so likeable!

    Messages:
    162
    Likes Received:
    0
    Your code is right. 1024x512 is the psx buffer resolution at low X/Y, used as a input texture (pbuffer) by the Pete OGL2 plugin. If you have a fixed input resolution, is better that you force it into your vertex program.
    ...and x+x is little bit faster than 2.0*x...
  9. Hyllian

    Hyllian New Member

    Messages:
    84
    Likes Received:
    0
    Ok, tks. And I've seen you used x*x instead abs(x) on the d function. Is it always faster?
  10. SimoneT

    SimoneT Not so likeable!

    Messages:
    162
    Likes Received:
    0
    Yes, is a little bit faster. Please use PM if you can, is better to no fill this tread with personal conversations...
    Ciao.
  11. RyuRanX

    RyuRanX New Member

    Messages:
    51
    Likes Received:
    0
    Can someone port bsnes' CRT shaders to the openGL2 plugin format? I love the way it looks with the curvature and all. :wub:

    [​IMG]
  12. KrossX

    KrossX クロスエックス

    Messages:
    4,199
    Likes Received:
    27
    I tried, but the curve didn't work. It kept flickering. =S
  13. SimoneT

    SimoneT Not so likeable!

    Messages:
    162
    Likes Received:
    0
    Small update. In my system, the ARB(fp/vp) version is a little bit faster than the GLSL(slf/slv). Ciao.
  14. Hyllian

    Hyllian New Member

    Messages:
    84
    Likes Received:
    0
    SimoneT, I've seen you changed this code:

    Code:
    	half3 res = nc.x ? px.x ? F : H : nc.y ? px.y ? B : F : nc.z ? px.z ? D : B : nc.w ? px.w ? H : D : E;
    
    By this:

    Code:
    if ((nc.x && px.x) || (nc.y && !px.y)) 
    {
    	E = F;
    } 
    else
    if ((nc.y && px.y) || (nc.z && !px.z)) 
    {
    	E = B;
    } 
    else
    if ((nc.z && px.z) || (nc.w && !px.w)) 
    {
    	E = D;
    } 
    else
    if ((nc.w && px.w) || (nc.x && !px.x)) 
    {
    	E = H;
    } 
    
    This is wrong, because you changed priorities. I expect some small artifacts to appear now.
  15. SimoneT

    SimoneT Not so likeable!

    Messages:
    162
    Likes Received:
    0
    Here your code in c++ notation:
    Code:
        if (nc.x) { // if nc.x begin
            if (px.x) { 
                TMP2 = F;
            } else {
                TMP2 = H;
            } 
            TMP1 = TMP2;
        } else {
            if (nc.y) { // if nc.y begin
                if (px.y) { 
                    TMP4 = B;
                } else {
                    TMP4 = F;
                } 
                TMP3 = TMP4;
            } else {
                if (nc.z) { // if nc.z begin
                    if (px.z) { 
                        TMP6 = D;
                    } else {
                        TMP6 = B;
                    } 
                    TMP5 = TMP6;
                } else {
                    if (nc.w) { // if nc.w begin
                        if (px.w) { 
                            TMP8 = H;
                        } else {
                            TMP8 = D;
                        } 
                        TMP7 = TMP8;
                    } else {
                        TMP7 = E;
                    } // end if nc.w
                    TMP5 = TMP7;
                } // end if nc.z
                TMP3 = TMP5;
            } // end if nc.y 
            TMP1 = TMP3;
        } // end if nc.x 
        gl_FragColor = TMP1;
    
    My code is only an optimization, try all 16 cases of nc and px...
    Ciao.
    Last edited: Apr 4, 2012
  16. Hyllian

    Hyllian New Member

    Messages:
    84
    Likes Received:
    0
    In my code, if (nc.x==1 && px.x==0) then it ALWAYS return H.

    In your code, if (nc.x==1 && px.x==0), then it MAY return F, for example.
  17. SimoneT

    SimoneT Not so likeable!

    Messages:
    162
    Likes Received:
    0
    I have tested your assumption and... I discovered that my code, compared to yours, is able to better discriminate the ambiguities of the edges (see the screenshots). But, if you wants, I will rewrite the shader code as the original.
    Ciao:D
    P.S.: the original.jpg was at 128x64 scaled to 1280x640 (10x)
    Last edited: Apr 5, 2012
  18. Hyllian

    Hyllian New Member

    Messages:
    84
    Likes Received:
    0
    I don't know if we can assume it always happen based only in one example picture.

    The fact I was trying to demonstrate is that those pieces of codes weren't equivalent anymore. We can test more and if it becomes clear your optimizations fix some defects, then I will incorporate to the cg codes. Improvements are always welcomed!
  19. SimoneT

    SimoneT Not so likeable!

    Messages:
    162
    Likes Received:
    0
    Ok. I will test with more games and emulators (I have ported yours shader to bsnes but I haven't released it...) and i will post some more screenshots.
  20. Hyllian

    Hyllian New Member

    Messages:
    84
    Likes Received:
    0
    Great. This code is so tight I always expect artifacts when something is changed. :D:D


    Bsnes? Someone else already made it in this thread: xml shader

    Maybe you wanna contribute there.

    EDIT: Your implementation seems a bit different from mine. This is what I'm getting with my Cg shader on PS3:
    Last edited: Apr 5, 2012

Share This Page