PeteOpenGL2Tweak - Tweaker for PeteOpenGL2 plugin w/ GTE Accuracy Hack!

Discussion in 'PSX Plugin Questions & Troubleshooting' started by tapeq, Mar 26, 2014.

  1. unreal676

    unreal676 New Member

    Messages:
    39
    Likes Received:
    12
    Yeah I'm using 2.4 version of Tweaks, it seems that disabling FastFBE helped me regain the xBRZ effect, thank you very much, Dimensioner. Does FastFBE work fine for you enabled with 2.4 of Tweaks in the game? It seems to disable xBRZ for me :3.

    I use small amounts of xBRZ anyhow, I'm not sure, but smaller numbers make it more subtle, right? Currently using a value of 2. Does changing the BatchSize do anything visibly to xBRZ? I'll extend the question to SlicesCount as well. I did change the TextureCacheSize to 256.

    Thanks though, with FastFBE disabled, I get a really nice xBRZ look for this game which I feel absolutely improves it. With PGXP, it's gorgeous.


    Pre Edit : I use this website to find configurations of games that I play (http://psxdatacenter.com/ntsc-u_list.html)..... it recommended 1/3/2 for the graphics settings.... I forgot xBRZ needs it to be x/2/x, ahaha, changing it back to Standard fixed the problem. Sorry about that.
  2. TheDimensioner

    TheDimensioner New Member

    Messages:
    258
    Likes Received:
    68
    @unreal676 You're welcome! And yes, "Framebuffer effects" mode "3" seems to enable the framebuffer at all times, as it can be seen on the GUI (press DEL in-game) by that small square at the end of the bar that appears when there's a FBE happening. Since "FastFBE" tracks framebuffer effects and turn the image into nearest neighbor, with a FBE happening all the time, the whole image would be pixelated XD. And like I said, "FastFBE" does not work for me anymore with 2.4 when using "framebuffer effects 2", as it's intended. If there's a FBE transition, or a spell or something that uses FBE, there will be slowdown for me with xBRZ enabled, even if it's x2 or x3 (Final Fantasy PSX Trilogy FBE transition nightmare XD). Look at my Crash 3 video, when entering the first level, there's a FBE, and that slowdown is what I bare with sometimes XD. But version 2.3 of the TWEAK works well for that, even if not all textures will be xBRZ after a FBE.

    I generally leave my xBRZ setting at x3, and I also enable "deposterize". That last option also decreases performance a bit in some games, but it can give a nicer look. 2D games can have xBRZ set to x4 or even x5 (x6 is just overkill for 1080p XD) and they'll look incredible (I discovered that many actually think otherwise, but oh well). I've really come to like the look in some full 3D games with xBRZ as well, if it had a "sharp" filter (like the one available in GlideN64) to combine with a high xBRZ setting, games would look amazing, like a painting or something.

    About "BatchSize", "SlicesCount" or even "TextureCacheSize", it's better to ask @tapeq (author of the Tweaks) about those, because I really don't know how to use those options XD. Although I did perceive that increasing "TextureCacheSize" does improve performance a bit.
    Last edited: Aug 13, 2016
    unreal676 likes this.
  3. unreal676

    unreal676 New Member

    Messages:
    39
    Likes Received:
    12
    @TheDimensioner Thanks very much, really helpful of you to check into it initially =) I do also remember about the icon that should show up with fastFBE, I tend to use that Del menu with Ins for explanations often for quick adjusting of settings =).

    Hopefully @tapeq get's notified and can answer the questions then. I'll check the thread for answers just in-case they've been answered before.
    TheDimensioner likes this.
  4. Thirteen1355

    Thirteen1355 The Incinerator

    Messages:
    79
    Likes Received:
    4
  5. TheDimensioner

    TheDimensioner New Member

    Messages:
    258
    Likes Received:
    68
    Well, this thread is still helpful for whom wants to know about xBRZ, one of the great enhancements the TWEAK provides. Like @unreal676 did, by putting his issue with Xenogears.
  6. unreal676

    unreal676 New Member

    Messages:
    39
    Likes Received:
    12
    Here's another question, what stretching mode is the most accurate? Keep Aspect Ratio, Stretch on small Heights or Pixel Ratio?

    Pixel looks better to me, and I only play games in a 4:3 aspect ratio, but they do give off different looks in the same screen space.
  7. superjupi

    superjupi New Member

    Messages:
    117
    Likes Received:
    16
    Pixel ratio only works on games that have a 4:3 ratio when pixels are of equal height and width. Lots of games change screen resolutions (FFVII is slightly vertically squished for menus, all of FFT is horizontally squished to near 1:1, Ridge Racer Turbo is 2:3, etc), and pixel ratio will not show those games in 4:3. Keep Aspect is ostensibly the most accurate. I use Stretch to Full Window Size, and force a 4:3 resolution in the fields above.
    Last edited: Aug 18, 2016
    unreal676 likes this.
  8. TheDimensioner

    TheDimensioner New Member

    Messages:
    258
    Likes Received:
    68
    @unreal676 I think stretching mode 2 is better, because most of the time, it actually keeps the true aspect ratio of the game. Example is Symphony of the Night, in the original 4:3, it looks very stretched for me, besides the black bars on top and bottom. But in stretching mode 2, nothing is stretched, and other screens (start screen for example) is set to its correct aspect as well, when entered. Although, I think mode 2 and mode 3 are inverted, because mode 2 should be the pixel ratio, while mode 3 is the one that "stretch on small heights", but their descriptions are different.

    If you want to play at a "true" 4:3 aspect always, than set stretching mode to "0: Stretch to full window size (standard)", and then check "Use Window size in Fullscreen mode (Widescreen fix)". On window size, set to the 4:3 equivalent of the fullscreen resolution you use, for example, if your resolution is 1920x1080, set the window size to 1440x1080. If it's 1366x768, set to 1024x768; 1280x720 > 960x720; 1600x900 > 1200x900, etc. You can set a custom aspect ratio if you want, using this method, but only if the number you set is smaller than the width/height (it's not possible to crop the image by setting bigger numbers, I just tried that and got sad :(). For example, if you want to set a similar aspect ratio to the SNES for SNES game ports (Final Fantasy III, Chrono Trigger, don't know if there are other ports for PSX) which is 8:7, set the width a little less than the 4:3 number (if it's 1440x1080, set to 1215x1080). I got those numbers around the web, they could be terribly wrong, but most of them work for me when I want to play games in 4:3, or 8:7.

    Also, a feature request for the Tweaks, @tapeq, is it possible to add a crop function? Or to set custom aspect ratios or custom resolutions to allow cropping? That would be awesome.
    unreal676 likes this.
  9. unreal676

    unreal676 New Member

    Messages:
    39
    Likes Received:
    12
    @superjupi and @TheDimensioner Thanks to both of you. I realized Pixel Aspect was being a little funky, so I'm back at keep aspect ratio. I play on a 1080 monitor, but keep the window sized at a custom 1360*1020, which keeps the 4:3 size.

    Very nice explanation as well, Jupi, so thanks for that.
    superjupi likes this.
  10. pepodmc2

    pepodmc2 New Member

    Messages:
    4
    Likes Received:
    0
    hello, pgxp works with pete opengl 2.9 or it only works with pete opengl 1.78?
  11. TheDimensioner

    TheDimensioner New Member

    Messages:
    258
    Likes Received:
    68
    @pepodmc2 To use Pete'sOGL2 2.9 with PGXP, you need the Tweaks 2.4 (included with PGXP), or you can use OpenGL 1.78, but it has no major enhancements, besides PGXP mode (F11), where you can see directly if a game is high precision or not.

    Go to the new thread exclusive for PGXP, if you want more info about it:

    http://ngemu.com/threads/pcsxr-pgxp.186369/
    Last edited: Aug 20, 2016
    pepodmc2 likes this.
  12. papermanzero

    papermanzero New Member

    Messages:
    59
    Likes Received:
    7
    It's amazing to see the progress on PGXP.
    The remaining topic is about textures.
    xBRZ is ok, but the main issue is the posterize effect.
    Meanwhile Super xBR surpassed the quality of xBRZ. Especially the posterize effect is much less.
    Combined with Fast Bilateral it is almost gone.

    Would it be possible to create a Super xBR and Smart Blur Shader for texture filtering?

    Super xBR Shader:
    https://github.com/libretro/common-shaders/tree/master/xbr/shaders/super-xbr

    Fast Bilateral for Super xBR:
    https://github.com/libretro/common-shaders/tree/0c9ae63f09fad8687d21ec9599261d89766817c5/denoisers


    Screenshots:
    Super xBR:
    [​IMG]

    Super xBR with fast Bilateral
    [​IMG]
    Super xBR:
    [​IMG]

    Super xBR with fast Bilateral
    [​IMG]

    Super xBR:
    [​IMG]

    Super xBR with fast Bilateral
    [​IMG]

    Super xBR
    [​IMG]

    Super xBR with fast Bilateral
    [​IMG]
    Last edited: Aug 24, 2016
  13. tapeq

    tapeq Member

    Messages:
    538
    Likes Received:
    74
    SuperXBRZ is postprocesing shader and is useless for texture scaling filter. Deposterzie pre-filter is good enough.
  14. papermanzero

    papermanzero New Member

    Messages:
    59
    Likes Received:
    7
    1. It is Super xBR not SuperXBRZ.
    2. xBRZ is also a shader
    3. Super xBR is used as scaling filter.
    4. Deposterize is not as effective as Super xBR algorithm to detect edges and gradiants.
    5. Super xBR is much more effective than xBRZ.
  15. tapeq

    tapeq Member

    Messages:
    538
    Likes Received:
    74
    Do feel free to fork on githubie and add it, because I have not see any C++ implemantation of Super xBR which is reqired for texture scaling in this plugin.

    Wysłane z mojego MotoG3 przy użyciu Tapatalka
  16. papermanzero

    papermanzero New Member

    Messages:
    59
    Likes Received:
    7
    Btw. I did not want to be rude.

    Here we go. ^^
    It is not finished, but at least it is a starting point.
    Furthermore it can be used to do some prototyping (to see how it behaves compared to xBRZ for example)

    Code:
    /*
    
    *******  Super XBR Scaler  *******
    
    Copyright (c) 2016 Hyllian - sergiogdb@gmail.com
    
    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files (the "Software"), to deal
    in the Software without restriction, including without limitation the rights
    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    copies of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions:
    
    The above copyright notice and this permission notice shall be included in
    all copies or substantial portions of the Software.
    
    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
    THE SOFTWARE.
    
    */
    
    #define R(_col) ((_col>> 0)&0xFF)
    #define G(_col) ((_col>> 8)&0xFF)
    #define B(_col) ((_col>>16)&0xFF)
    #define A(_col) ((_col>>24)&0xFF)
    
    
    #define wgt1 0.129633f
    #define wgt2 0.175068f
    #define w1  (-wgt1)
    #define w2  (wgt1+0.5f)
    #define w3  (-wgt2)
    #define w4  (wgt2+0.5f)
    
    
    
    float df(float A, float B)
    {
        return abs(A - B);
    }
    
    float min4(float a, float b, float c, float d)
    {
        return std::min(std::min(a,b),std::min(c, d));
    }
    
    float max4(float a, float b, float c, float d)
    {
        return std::max(std::max(a, b), std::max(c, d));
    }
    
    template<class T>
    T clamp(T x, T floor, T ceil)
    {
        return std::max(std::min(x, ceil), floor);
    }
    
    /*
                            P1
    |P0|B |C |P1|        C    F4          |a0|b1|c2|d3|
    |D |E |F |F4|      B    F    I4      |b0|c1|d2|e3|  |e1|i1|i2|e2|
    |G |H |I |I4|  P0    E  A  I    P3    |c0|d1|e2|f3|  |e3|i3|i4|e4|
    |P2|H5|I5|P3|      D    H    I5      |d0|e1|f2|g3|
                          G    H5
                            P2
    
    sx, sy
    -1  -1 | -2  0  (x+y) (x-y)    -3  1  (x+y-1)  (x-y+1)
    -1  0 | -1 -1                  -2  0
    -1  1 |  0 -2                  -1 -1
    -1  2 |  1 -3                  0 -2
    
    0  -1 | -1  1  (x+y) (x-y)      ...    ...    ...
    0  0 |  0  0
    0  1 |  1 -1
    0  2 |  2 -2
    1  -1 |  0  2  ...
    1  0 |  1  1
    1  1 |  2  0
    1  2 |  3 -1
    2  -1 |  1  3  ...
    2  0 |  2  2
    2  1 |  3  1
    2  2 |  4  0
    
                          
    */
    
    float diagonal_edge(float mat[][4], float *wp) {
        float dw1 = wp[0]*(df(mat[0][2], mat[1][1]) + df(mat[1][1], mat[2][0]) + df(mat[1][3], mat[2][2]) + df(mat[2][2], mat[3][1])) +\
                    wp[1]*(df(mat[0][3], mat[1][2]) + df(mat[2][1], mat[3][0])) + \
                    wp[2]*(df(mat[0][3], mat[2][1]) + df(mat[1][2], mat[3][0])) +\
                    wp[3]*df(mat[1][2], mat[2][1]) +\
                    wp[4]*(df(mat[0][2], mat[2][0]) + df(mat[1][3], mat[3][1])) +\
                    wp[5]*(df(mat[0][1], mat[1][0]) + df(mat[2][3], mat[3][2]));
    
        float dw2 = wp[0]*(df(mat[0][1], mat[1][2]) + df(mat[1][2], mat[2][3]) + df(mat[1][0], mat[2][1]) + df(mat[2][1], mat[3][2])) +\
                    wp[1]*(df(mat[0][0], mat[1][1]) + df(mat[2][2], mat[3][3])) +\
                    wp[2]*(df(mat[0][0], mat[2][2]) + df(mat[1][1], mat[3][3])) +\
                    wp[3]*df(mat[1][1], mat[2][2]) +\
                    wp[4]*(df(mat[1][0], mat[3][2]) + df(mat[0][1], mat[2][3])) +\
                    wp[5]*(df(mat[0][2], mat[1][3]) + df(mat[2][0], mat[3][1]));
    
        return (dw1 - dw2);
    }
    
    // Not used yet...
    float cross_edge(float mat[][4], float *wp) {
        float hvw1 = wp[3] * (df(mat[1][1], mat[2][1]) + df(mat[1][2], mat[2][2])) + \
                    wp[0] * (df(mat[0][1], mat[1][1]) + df(mat[2][1], mat[3][1]) + df(mat[0][2], mat[1][2]) + df(mat[2][2], mat[3][2])) + \
                    wp[2] * (df(mat[0][1], mat[2][1]) + df(mat[1][1], mat[3][1]) + df(mat[0][2], mat[2][2]) + df(mat[1][2], mat[3][2]));
    
        float hvw2 = wp[3] * (df(mat[1][1], mat[1][2]) + df(mat[2][1], mat[2][2])) + \
                    wp[0] * (df(mat[1][0], mat[1][1]) + df(mat[2][0], mat[2][1]) + df(mat[1][2], mat[1][3]) + df(mat[2][2], mat[2][3])) + \
                    wp[2] * (df(mat[1][0], mat[1][2]) + df(mat[1][1], mat[1][3]) + df(mat[2][0], mat[2][2]) + df(mat[2][1], mat[2][3]));
    
        return (hvw1 - hvw2);
    }
    
    
    
    
    
    ///////////////////////// Super-xBR scaling
    // perform super-xbr (fast shader version) scaling by factor f=2 only.
    template<int f>
    void scaleSuperXBRT(u32* data, u32* out, int w, int h) {
        int outw = w*f, outh = h*f;
    
        float wp[6] = { 2.0f, 1.0f, -1.0f, 4.0f, -1.0f, 1.0f };
    
        // First Pass
        for (int y = 0; y < outh; ++y) {
            for (int x = 0; x < outw; ++x) {
                float r[4][4], g[4][4], b[4][4], a[4][4], Y[4][4];
                int cx = x / f, cy = y / f; // central pixels on original images
                // sample supporting pixels in original image
                for (int sx = -1; sx <= 2; ++sx) {
                    for (int sy = -1; sy <= 2; ++sy) {
                        // clamp pixel locations
                        int csy = clamp(sy + cy, 0, h - 1);
                        int csx = clamp(sx + cx, 0, w - 1);
                        // sample & add weighted components
                        u32 sample = data[csy*w + csx];
                        r[sx + 1][sy + 1] = (float)R(sample);
                        g[sx + 1][sy + 1] = (float)G(sample);
                        b[sx + 1][sy + 1] = (float)B(sample);
                        a[sx + 1][sy + 1] = (float)A(sample);
                        Y[sx + 1][sy + 1] = (float)(0.2126*r[sx + 1][sy + 1] + 0.7152*g[sx + 1][sy + 1] + 0.0722*b[sx + 1][sy + 1]);
                    }
                }
                float min_r_sample = min4(r[1][1], r[2][1], r[1][2], r[2][2]);
                float min_g_sample = min4(g[1][1], g[2][1], g[1][2], g[2][2]);
                float min_b_sample = min4(b[1][1], b[2][1], b[1][2], b[2][2]);
                float min_a_sample = min4(a[1][1], a[2][1], a[1][2], a[2][2]);
                float max_r_sample = max4(r[1][1], r[2][1], r[1][2], r[2][2]);
                float max_g_sample = max4(g[1][1], g[2][1], g[1][2], g[2][2]);
                float max_b_sample = max4(b[1][1], b[2][1], b[1][2], b[2][2]);
                float max_a_sample = max4(a[1][1], a[2][1], a[1][2], a[2][2]);
                float d_edge = diagonal_edge(Y, &wp[0]);
                float r1, g1, b1, a1, r2, g2, b2, a2, rf, gf, bf, af;
                r1 = (float)w1*(r[0][3] + r[3][0]) + (float)w2*(r[1][2] + r[2][1]);
                g1 = (float)w1*(g[0][3] + g[3][0]) + (float)w2*(g[1][2] + g[2][1]);
                b1 = (float)w1*(b[0][3] + b[3][0]) + (float)w2*(b[1][2] + b[2][1]);
                a1 = (float)w1*(a[0][3] + a[3][0]) + (float)w2*(a[1][2] + a[2][1]);
                r2 = (float)w1*(r[0][0] + r[3][3]) + (float)w2*(r[1][1] + r[2][2]);
                g2 = (float)w1*(g[0][0] + g[3][3]) + (float)w2*(g[1][1] + g[2][2]);
                b2 = (float)w1*(b[0][0] + b[3][3]) + (float)w2*(b[1][1] + b[2][2]);
                a2 = (float)w1*(a[0][0] + a[3][3]) + (float)w2*(a[1][1] + a[2][2]);
                // generate and write result
                if (d_edge <= 0.0f) { rf = r1; gf = g1; bf = b1; af = a1; }
                else { rf = r2; gf = g2; bf = b2; af = a2; }
                // anti-ringing, clamp.
                rf = clamp(rf, min_r_sample, max_r_sample);
                gf = clamp(gf, min_g_sample, max_g_sample);
                bf = clamp(bf, min_b_sample, max_b_sample);
                af = clamp(af, min_a_sample, max_a_sample);
                int ri = clamp(static_cast<int>(ceilf(rf)), 0, 255);
                int gi = clamp(static_cast<int>(ceilf(gf)), 0, 255);
                int bi = clamp(static_cast<int>(ceilf(bf)), 0, 255);
                int ai = clamp(static_cast<int>(ceilf(af)), 0, 255);
                out[y*outw + x] = out[y*outw + x + 1] = out[(y + 1)*outw + x] = data[cy*w + cx];
                out[(y+1)*outw + x+1] = (ai << 24) | (bi << 16) | (gi << 8) | ri;
                ++x;
            }
            ++y;
        }
      
    
    
        // Second Pass
        wp[0] = 2.0f;
        wp[1] = 0.0f;
        wp[2] = 0.0f;
        wp[3] = 0.0f;
        wp[4] = 0.0f;
        wp[5] = 0.0f;
    
        for (int y = 0; y < outh; ++y) {
            for (int x = 0; x < outw; ++x) {
                float r[4][4], g[4][4], b[4][4], a[4][4], Y[4][4];
                // sample supporting pixels in original image
                for (int sx = -1; sx <= 2; ++sx) {
                    for (int sy = -1; sy <= 2; ++sy) {
                        // clamp pixel locations
                        int csy = clamp(sx - sy + y, 0, f*h - 1);
                        int csx = clamp(sx + sy + x, 0, f*w - 1);
                        // sample & add weighted components
                        u32 sample = out[csy*outw + csx];
                        r[sx + 1][sy + 1] = (float)R(sample);
                        g[sx + 1][sy + 1] = (float)G(sample);
                        b[sx + 1][sy + 1] = (float)B(sample);
                        a[sx + 1][sy + 1] = (float)A(sample);
                        Y[sx + 1][sy + 1] = (float)(0.2126*r[sx + 1][sy + 1] + 0.7152*g[sx + 1][sy + 1] + 0.0722*b[sx + 1][sy + 1]);
                    }
                }
                float min_r_sample = min4(r[1][1], r[2][1], r[1][2], r[2][2]);
                float min_g_sample = min4(g[1][1], g[2][1], g[1][2], g[2][2]);
                float min_b_sample = min4(b[1][1], b[2][1], b[1][2], b[2][2]);
                float min_a_sample = min4(a[1][1], a[2][1], a[1][2], a[2][2]);
                float max_r_sample = max4(r[1][1], r[2][1], r[1][2], r[2][2]);
                float max_g_sample = max4(g[1][1], g[2][1], g[1][2], g[2][2]);
                float max_b_sample = max4(b[1][1], b[2][1], b[1][2], b[2][2]);
                float max_a_sample = max4(a[1][1], a[2][1], a[1][2], a[2][2]);
                float d_edge = diagonal_edge(Y, &wp[0]);
                float r1, g1, b1, a1, r2, g2, b2, a2, rf, gf, bf, af;
                r1 = (float)w3*(r[0][3] + r[3][0]) + (float)w4*(r[1][2] + r[2][1]);
                g1 = (float)w3*(g[0][3] + g[3][0]) + (float)w4*(g[1][2] + g[2][1]);
                b1 = (float)w3*(b[0][3] + b[3][0]) + (float)w4*(b[1][2] + b[2][1]);
                a1 = (float)w3*(a[0][3] + a[3][0]) + (float)w4*(a[1][2] + a[2][1]);
                r2 = (float)w3*(r[0][0] + r[3][3]) + (float)w4*(r[1][1] + r[2][2]);
                g2 = (float)w3*(g[0][0] + g[3][3]) + (float)w4*(g[1][1] + g[2][2]);
                b2 = (float)w3*(b[0][0] + b[3][3]) + (float)w4*(b[1][1] + b[2][2]);
                a2 = (float)w3*(a[0][0] + a[3][3]) + (float)w4*(a[1][1] + a[2][2]);
                // generate and write result
                if (d_edge <= 0.0f) { rf = r1; gf = g1; bf = b1; af = a1; }
                else { rf = r2; gf = g2; bf = b2; af = a2; }
                // anti-ringing, clamp.
                rf = clamp(rf, min_r_sample, max_r_sample);
                gf = clamp(gf, min_g_sample, max_g_sample);
                bf = clamp(bf, min_b_sample, max_b_sample);
                af = clamp(af, min_a_sample, max_a_sample);
                int ri = clamp(static_cast<int>(ceilf(rf)), 0, 255);
                int gi = clamp(static_cast<int>(ceilf(gf)), 0, 255);
                int bi = clamp(static_cast<int>(ceilf(bf)), 0, 255);
                int ai = clamp(static_cast<int>(ceilf(af)), 0, 255);
                out[y*outw + x + 1] = (ai << 24) | (bi << 16) | (gi << 8) | ri;
    
                for (int sx = -1; sx <= 2; ++sx) {
                    for (int sy = -1; sy <= 2; ++sy) {
                        // clamp pixel locations
                        int csy = clamp(sx - sy + 1 + y, 0, f*h - 1);
                        int csx = clamp(sx + sy - 1 + x, 0, f*w - 1);
                        // sample & add weighted components
                        u32 sample = out[csy*outw + csx];
                        r[sx + 1][sy + 1] = (float)R(sample);
                        g[sx + 1][sy + 1] = (float)G(sample);
                        b[sx + 1][sy + 1] = (float)B(sample);
                        a[sx + 1][sy + 1] = (float)A(sample);
                        Y[sx + 1][sy + 1] = (float)(0.2126*r[sx + 1][sy + 1] + 0.7152*g[sx + 1][sy + 1] + 0.0722*b[sx + 1][sy + 1]);
                    }
                }
                d_edge = diagonal_edge(Y, &wp[0]);
                r1 = (float)w3*(r[0][3] + r[3][0]) + (float)w4*(r[1][2] + r[2][1]);
                g1 = (float)w3*(g[0][3] + g[3][0]) + (float)w4*(g[1][2] + g[2][1]);
                b1 = (float)w3*(b[0][3] + b[3][0]) + (float)w4*(b[1][2] + b[2][1]);
                a1 = (float)w3*(a[0][3] + a[3][0]) + (float)w4*(a[1][2] + a[2][1]);
                r2 = (float)w3*(r[0][0] + r[3][3]) + (float)w4*(r[1][1] + r[2][2]);
                g2 = (float)w3*(g[0][0] + g[3][3]) + (float)w4*(g[1][1] + g[2][2]);
                b2 = (float)w3*(b[0][0] + b[3][3]) + (float)w4*(b[1][1] + b[2][2]);
                a2 = (float)w3*(a[0][0] + a[3][3]) + (float)w4*(a[1][1] + a[2][2]);
                // generate and write result
                if (d_edge <= 0.0f) { rf = r1; gf = g1; bf = b1; af = a1; }
                else { rf = r2; gf = g2; bf = b2; af = a2; }
                // anti-ringing, clamp.
                rf = clamp(rf, min_r_sample, max_r_sample);
                gf = clamp(gf, min_g_sample, max_g_sample);
                bf = clamp(bf, min_b_sample, max_b_sample);
                af = clamp(af, min_a_sample, max_a_sample);
                ri = clamp(static_cast<int>(ceilf(rf)), 0, 255);
                gi = clamp(static_cast<int>(ceilf(gf)), 0, 255);
                bi = clamp(static_cast<int>(ceilf(bf)), 0, 255);
                ai = clamp(static_cast<int>(ceilf(af)), 0, 255);
                out[(y+1)*outw + x] = (ai << 24) | (bi << 16) | (gi << 8) | ri;
                ++x;
            }
            ++y;
        }
    
        // Third Pass
        wp[0] =  2.0f;
        wp[1] =  1.0f;
        wp[2] = -1.0f;
        wp[3] =  4.0f;
        wp[4] = -1.0f;
        wp[5] =  1.0f;
    
        for (int y = outh - 1; y >= 0; --y) {
            for (int x = outw - 1; x >= 0; --x) {
                float r[4][4], g[4][4], b[4][4], a[4][4], Y[4][4];
                for (int sx = -2; sx <= 1; ++sx) {
                    for (int sy = -2; sy <= 1; ++sy) {
                        // clamp pixel locations
                        int csy = clamp(sy + y, 0, f*h - 1);
                        int csx = clamp(sx + x, 0, f*w - 1);
                        // sample & add weighted components
                        u32 sample = out[csy*outw + csx];
                        r[sx + 2][sy + 2] = (float)R(sample);
                        g[sx + 2][sy + 2] = (float)G(sample);
                        b[sx + 2][sy + 2] = (float)B(sample);
                        a[sx + 2][sy + 2] = (float)A(sample);
                        Y[sx + 2][sy + 2] = (float)(0.2126*r[sx + 2][sy + 2] + 0.7152*g[sx + 2][sy + 2] + 0.0722*b[sx + 2][sy + 2]);
                    }
                }
                float min_r_sample = min4(r[1][1], r[2][1], r[1][2], r[2][2]);
                float min_g_sample = min4(g[1][1], g[2][1], g[1][2], g[2][2]);
                float min_b_sample = min4(b[1][1], b[2][1], b[1][2], b[2][2]);
                float min_a_sample = min4(a[1][1], a[2][1], a[1][2], a[2][2]);
                float max_r_sample = max4(r[1][1], r[2][1], r[1][2], r[2][2]);
                float max_g_sample = max4(g[1][1], g[2][1], g[1][2], g[2][2]);
                float max_b_sample = max4(b[1][1], b[2][1], b[1][2], b[2][2]);
                float max_a_sample = max4(a[1][1], a[2][1], a[1][2], a[2][2]);
                float d_edge = diagonal_edge(Y, &wp[0]);
                float r1, g1, b1, a1, r2, g2, b2, a2, rf, gf, bf, af;
                r1 = (float)w1*(r[0][3] + r[3][0]) + (float)w2*(r[1][2] + r[2][1]);
                g1 = (float)w1*(g[0][3] + g[3][0]) + (float)w2*(g[1][2] + g[2][1]);
                b1 = (float)w1*(b[0][3] + b[3][0]) + (float)w2*(b[1][2] + b[2][1]);
                a1 = (float)w1*(a[0][3] + a[3][0]) + (float)w2*(a[1][2] + a[2][1]);
                r2 = (float)w1*(r[0][0] + r[3][3]) + (float)w2*(r[1][1] + r[2][2]);
                g2 = (float)w1*(g[0][0] + g[3][3]) + (float)w2*(g[1][1] + g[2][2]);
                b2 = (float)w1*(b[0][0] + b[3][3]) + (float)w2*(b[1][1] + b[2][2]);
                a2 = (float)w1*(a[0][0] + a[3][3]) + (float)w2*(a[1][1] + a[2][2]);
                // generate and write result
                if (d_edge <= 0.0f) { rf = r1; gf = g1; bf = b1; af = a1; }
                else { rf = r2; gf = g2; bf = b2; af = a2; }
                // anti-ringing, clamp.
                rf = clamp(rf, min_r_sample, max_r_sample);
                gf = clamp(gf, min_g_sample, max_g_sample);
                bf = clamp(bf, min_b_sample, max_b_sample);
                af = clamp(af, min_a_sample, max_a_sample);
                int ri = clamp(static_cast<int>(ceilf(rf)), 0, 255);
                int gi = clamp(static_cast<int>(ceilf(gf)), 0, 255);
                int bi = clamp(static_cast<int>(ceilf(bf)), 0, 255);
                int ai = clamp(static_cast<int>(ceilf(af)), 0, 255);
                out[y*outw + x] = (ai << 24) | (bi << 16) | (gi << 8) | ri;
            }
        }
    
    }
    
    
    //// *** Super-xBR code ends here ///
    
    
    void scaleSuperXBR(int factor, u32* data, u32* out, int w, int h) {
    /* Needs implementation.*/
        switch (factor) {
        case 2: scaleSuperXBRT<2>(data, out, w, h); break;
        default: ERROR_LOG(VIDEO, "Super-xBR upsampling only implemented for factor 2");
        }
    
    }
    Last edited: Aug 26, 2016
  17. pepodmc2

    pepodmc2 New Member

    Messages:
    4
    Likes Received:
    0
    but when i use tweaks 2.4 the game textures looks bugged:


    [​IMG]

    how can i fix this?


    EDIT: I fixed the problem with "high res texture" set to "0=none" XD

    EDIT 2: If you disable xbrz in the "gpuPeteOpenGL2Tweak ini" you can use "2xsai" XD

    ---------------------------------------------------------------------------------------------------------

    From a youtube response:

    "But in other games, vertex caching will make things jittery, or cause texture warping "

    Does that happens with crash team racing and tony hawk pro skater 3? Whats the best config for those games? (in your opinion)
    Last edited: Aug 28, 2016
  18. Pogo _SoM

    Pogo _SoM New Member

    Messages:
    3
    Likes Received:
    0
    Hey Guys,
    I'm a little bit helples here. Its unfortunately a bit confusing. Im playing Tales of Phantasia PSX at the moment. And its working good so far with the old Petes Plugin. But I would really want to use xBRZ, since I like it with 2D games. But I cant get the Petes PLugin Tweak to work. And I dont know what Im doing wrong.

    Im using Win10 with the latest epsxe 2.05 release. Also Petes OpenGL Driver 2.9 and the tweak 2.4

    Res: 2,2,1,1
    Textures: 0,0 (because I read it works better with xbrz...well doesnt help so far)
    Compi: 1,2,2
    Screen filter and shader 1.

    When I start tales of Phantasia it just stays black, but the game runs, because I can hear the sound.
    So, what I'm supposed to do, what setting does the .ini needs to work?

    Thanks for the help.
  19. TheDimensioner

    TheDimensioner New Member

    Messages:
    258
    Likes Received:
    68
    @pepodmc2 "Vertex caching" does make some things jittery in CTR, but it's mainly 2D text. It mostly happens when there's 2D over moving 3D elements, like characters, or maybe when credits roll over an internal rendered cutscene. In the beginning of this "Mega Man Legends" video by @curryking3 you can see the "Press Start Button" text shake a bit when the first "Servbot" passes behind it. The game's name also shakes. But when the "new game - continue - option" window appears and all the other "servbots" start running, that rectangle will shake like crazy. That does not happen if "vertex caching" is disabled.

    Not all games have that, though. "Vertex caching" does help PGXP, so if you see a game that doesn't get the "high precision treatment", try enabling "vertex caching".

    EDIT: @Pogo _SoM I saw your post after posting mine, so I'm answering you here XD. If you're using Tweaks 2.4 (the version that comes with PGXP), it doesn't work with ePSXe, because things were done to it to work specifically with PGXP. Use version 2.3, the one in the first post, it works very well with ePSXe. Make sure you disable "FastFBE" in the .ini, because that will make some textures "not xBRZ". But I remember that game has many framebuffer effects, which get slow with xBRZ, so if there's slowdown, enable "FastFBE", or use a lower xBRZ setting.

    There is a 2.4 version of the TWEAK that works with ePSXe, but it's not as good as 2.3. Some of the Tweaks present in the PGXP version are there, and there's also some options that helped the old GTE hack that ePSXe still uses, but PGXP is still superior, so try using PCSXR-PGXP:

    http://ngemu.com/threads/pcsxr-pgxp.186369/

    If you see that it's more difficult than ePSXe, than try this 2.4 version of the Tweaks:

    http://dev.tapek.shst.pl/ePSXe/wip.zip
    Last edited: Aug 28, 2016
    Pogo _SoM and pepodmc2 like this.
  20. Pogo _SoM

    Pogo _SoM New Member

    Messages:
    3
    Likes Received:
    0
    Thanks for the reply. I tried the 2.3 version before and its just the same. I switched back to 2.3 and I get a blackscreen with the music intro playing, like before. I disbabled fast FBE, but is stays black.
    Yes, in Phantasia there are some cities and areas that have an immense slowdown, but good to know that I could try to use the fastFBE for that.
    In the End I cant get it to work, which is shitty, because I think it could be revolved with some config tweaks. But maybe Im wrong.

    Maybe Im gonna try PCSXR-PGXP.

    Edit: Well, I tried the other Emu. Its also not working. Its basically the same. Evething works, just not with the tweak plugin. Which tells me that its one or more of the settings in the ini or its incompatable. Is it possible that it just works with NVIDIA or AMD cards?

    Edit2: Okay. I sorted it out. It was the res hack lines that caused it to not display. I never changed them, so the default options were bad for me. Not so good. Now it works, but I dont really know what the res hack does.
    Last edited: Aug 28, 2016

Share This Page