Pete´s Messageboard... No ISO/BIOS requests!

Homepage Members Register Login Search Old board


Neuer Thread ...
More : [1] [2] [3]


AuthorTopics » Book an abo for this threadClose Thread Move Thread Fix the thread Print view Delete this thread

Z 
Real addict
.........

...

Status:Offline
Date registered: 03.08.2005
Post:103
Send Message
...   Created on 14.03.2012 - 20:49Jump to top Quote this post Report this post Edit Delete


Nice work guys!

Glad to see some life ins this board and the posted shaders look great.




Hyllian 
Frequent poster
...

...

Status:Offline
Date registered: 12.03.2012
Post:11
Send Message
...   Created on 15.03.2012 - 12:42Jump to top Quote this post Report this post Edit Delete


Hi Guest,

Your latest version improved a bit on speed. Though not as fast as the matrix original version. (151 cycles vs 125 cycles)

There isn't a way to use matrix operations in GLSL?




Z 
Real addict
.........

...

Status:Offline
Date registered: 03.08.2005
Post:103
Send Message
...   Created on 16.03.2012 - 03:21Jump to top Quote this post Report this post Edit Delete


Does that even matter with today's graphic cards?




Hyllian 
Frequent poster
...

...

Status:Offline
Date registered: 12.03.2012
Post:11
Send Message
...   Created on 16.03.2012 - 18:08Jump to top Quote this post Report this post Edit Delete


Z schrieb

    Does that even matter with today's graphic cards?


Maybe. Not everybody have the latest hardware, so we have to think about them, sometimes. Besides, there are emulators which can combine two shaders to enhance image, and if one of those is too slow, it won't run well combined with another shader. xBR is specially good when combined with lanczos or bicubic shaders.

When I think about optimizing code, I'm thinking about the hardware I'm used to code that is the PS3. For PS3, the tip to optimize is to get rid of branches and vectorize the most I can. I don't know if that tip can work on GPUs made for PCs out there.




Hyllian 
Frequent poster
...

...

Status:Offline
Date registered: 12.03.2012
Post:11
Send Message
...   Created on 17.03.2012 - 11:44Jump to top Quote this post Report this post Edit Delete


Using swizzle operators I've managed to speed my Cg shader by 27%. It allowed me to create three variants of xBR, each distinct by how corners are treated: rounded, semi-rounded or squared.

The variants are here: xBR 3.6




Hyllian 
Frequent poster
...

...

Status:Offline
Date registered: 12.03.2012
Post:11
Send Message
...   Created on 18.03.2012 - 11:54Jump to top Quote this post Report this post Edit Delete


Improved corner detection.

5xBR-v3.7 Cg shaders




Z 
Real addict
.........

...

Status:Offline
Date registered: 03.08.2005
Post:103
Send Message
...   Created on 21.03.2012 - 16:12Jump to top Quote this post Report this post Edit Delete


Hyllian schrieb
    Besides, there are emulators which can combine two shaders to enhance image


What emulators are you referring to?


Well anyway, what I'm trying to say is that I prefer the approach in a long way, which means:

If a compromise has to be made, set the priority to quality.
Speed is good as long as quality doesn't suffer from this.

A few months later, when he has got a new graphics card, even the one with a weak card today will be glad to have the best quality.




guest ...
Real addict
.........

...

Status:Offline
Date registered: 30.07.2004
Post:854
Send Message
...   Created on 02.04.2012 - 14:52Jump to top Quote this post Report this post Edit Delete


Decent speedup. Works nice with AMD cards.

fragment file:

Code:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
 
/*
   Hyllian's 5xBR v3.7a Shader
   
   Copyright (C) 2011 Hyllian/Jararaca - sergiogdb@gmail.com
  
   This program is free software; you can redistribute it and/or
   modify it under the terms of the GNU General Public License
   as published by the Free Software Foundation; either version 2
   of the License, or (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.

*/

const float coef        = 2.0;
const vec3  rgbw        = vec3(14.352, 28.176, 5.472);

const   vec2 OGLSize    = vec2( 1024.0, 512.0);
const   vec2 OGLInvSize = vec2( 0.0009765625, 0.001953125); 
const   vec2 dx         = vec2( 0.0009765625, 0.0);
const   vec2 dy         = vec2( 0.0, 0.001953125 );
const   vec2 x2         = vec2( 0.001953125 , 0.0);
const   vec2 y2         = vec2( 0.0 , 0.00390625 );
const   vec4 xy         = vec4( 0.0009765625, 0.001953125,-0.0009765625,-0.001953125);  
const   vec4 zw         = vec4( 0.001953125 , 0.001953125,-0.001953125 ,-0.00390625 );  
const   vec4 wz         = vec4( 0.0009765625, 0.00390625 ,-0.0009765625,-0.00390625 );  


vec4 df(vec4 A, vec4 B)
{
    return abs(A-B);
}

vec4 weighted_distance(vec4 a, vec4 b, vec4 c, vec4 d, vec4 e, vec4 f, vec4 g, vec4 h)
{
    return (df(a,b) + df(a,c) + df(d,e) + df(d,f) + 4.0*df(g,h));
}


uniform sampler2D OGL2Texture;

void main()
{
    vec4  edr, edr_left, edr_up; bvec4 px; // px = pixel, edr = edge detection rule
    vec4  interp_restriction_lv1, interp_restriction_lv2_left, interp_restriction_lv2_up;
    bvec4 nc; // new_color
    vec4  fx, fx_left, fx_up; // inequations of straight lines.
    
    vec2 fp  = fract(gl_TexCoord[0].xy*OGLSize);
    vec2 TexCoord_0 = gl_TexCoord[0].xy-fp*OGLInvSize;

    vec3 A  = texture2D(OGL2Texture, TexCoord_0 + xy.zw ).xyz;
    vec3 B  = texture2D(OGL2Texture, TexCoord_0     -dy ).xyz;
    vec3 C  = texture2D(OGL2Texture, TexCoord_0 + xy.xw ).xyz;
    vec3 D  = texture2D(OGL2Texture, TexCoord_0 - dx    ).xyz;
    vec3 E  = texture2D(OGL2Texture, TexCoord_0         ).xyz;
    vec3 F  = texture2D(OGL2Texture, TexCoord_0 + dx    ).xyz;
    vec3 G  = texture2D(OGL2Texture, TexCoord_0 + xy.zy ).xyz;
    vec3 H  = texture2D(OGL2Texture, TexCoord_0     +dy ).xyz;
    vec3 I  = texture2D(OGL2Texture, TexCoord_0 + xy.xy ).xyz;
    vec3 A1 = texture2D(OGL2Texture, TexCoord_0 + wz.zw ).xyz;
    vec3 C1 = texture2D(OGL2Texture, TexCoord_0 + wz.xw ).xyz;
    vec3 A0 = texture2D(OGL2Texture, TexCoord_0 + zw.zw ).xyz;
    vec3 G0 = texture2D(OGL2Texture, TexCoord_0 + zw.zy ).xyz;
    vec3 C4 = texture2D(OGL2Texture, TexCoord_0 + zw.xw ).xyz;
    vec3 I4 = texture2D(OGL2Texture, TexCoord_0 + zw.xy ).xyz;
    vec3 G5 = texture2D(OGL2Texture, TexCoord_0 + wz.zy ).xyz;
    vec3 I5 = texture2D(OGL2Texture, TexCoord_0 + wz.xy ).xyz;
    vec3 B1 = texture2D(OGL2Texture, TexCoord_0 - y2    ).xyz;
    vec3 D0 = texture2D(OGL2Texture, TexCoord_0 - x2    ).xyz;
    vec3 H5 = texture2D(OGL2Texture, TexCoord_0 + y2    ).xyz;
    vec3 F4 = texture2D(OGL2Texture, TexCoord_0 + x2    ).xyz;

    vec4 b  = vec4(dot(B ,rgbw), dot(D ,rgbw), dot(H ,rgbw), dot(F ,rgbw));
    vec4 c  = vec4(dot(C ,rgbw), dot(A ,rgbw), dot(G ,rgbw), dot(I ,rgbw));
    vec4 d  = b.yzwx;
    vec4 e  = vec4(dot(E,rgbw));
    vec4 f  = b.wxyz;
    vec4 g  = c.zwxy;
    vec4 h  = b.zwxy;
    vec4 i  = c.wxyz;
    vec4 i4 = vec4(dot(I4,rgbw), dot(C1,rgbw), dot(A0,rgbw), dot(G5,rgbw));
    vec4 i5 = vec4(dot(I5,rgbw), dot(C4,rgbw), dot(A1,rgbw), dot(G0,rgbw));
    vec4 h5 = vec4(dot(H5,rgbw), dot(F4,rgbw), dot(B1,rgbw), dot(D0,rgbw));
    vec4 f4 = h5.yzwx;
    
    vec4 Ao = vec4( 1.0, -1.0, -1.0, 1.0 );
    vec4 Bo = vec4( 1.0,  1.0, -1.0,-1.0 );
    vec4 Co = vec4( 1.5,  0.5, -0.5, 0.5 );
    vec4 Ax = vec4( 1.0, -1.0, -1.0, 1.0 );
    vec4 Bx = vec4( 0.5,  2.0, -0.5,-2.0 );
    vec4 Cx = vec4( 1.0,  1.0, -0.5, 0.0 );
    vec4 Ay = vec4( 1.0, -1.0, -1.0, 1.0 );
    vec4 By = vec4( 2.0,  0.5, -2.0,-0.5 );
    vec4 Cy = vec4( 2.0,  0.0, -1.0, 0.5 );
    
    // These inequations define the line below which interpolation occurs.
    fx      = vec4(greaterThan(Ao*fp.y+Bo*fp.x,Co));
    fx_left = vec4(greaterThan(Ax*fp.y+Bx*fp.x,Cx)); 
    fx_up   = vec4(greaterThan(Ay*fp.y+By*fp.x,Cy)); 

    interp_restriction_lv1      = vec4(notEqual(e,f))*vec4(notEqual(e,h));
    interp_restriction_lv2_left = vec4(notEqual(e,g))*vec4(notEqual(d,g));
    interp_restriction_lv2_up   = vec4(notEqual(e,c))*vec4(notEqual(b,c));

    edr      = vec4(lessThan(weighted_distance( e, c, g, i, h5, f4, h, f), weighted_distance( h, d, i5, f, i4, b, e, i)))*interp_restriction_lv1;
    edr_left = vec4(lessThanEqual(coef*df(f,g),df(h,c)))*interp_restriction_lv2_left; 
    edr_up   = vec4(greaterThanEqual(df(f,g),coef*df(h,c)))*interp_restriction_lv2_up;
    
    nc = bvec4 (edr*(max(max(fx, edr_left*fx_left), edr_up*fx_up)));

    px = lessThanEqual(df(e,f),df(e,h));

    vec3 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;    
    gl_FragColor.xyz = res;    
}


vertex file:
Code:
1:
2:
3:
4:
5:
6:
 
void main()

{
    gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
    gl_TexCoord[0] = gl_MultiTexCoord0;
}


[Dieser Beitrag wurde am 07.04.2012 - 12:23 von guest aktualisiert]




guest ...
Real addict
.........

...

Status:Offline
Date registered: 30.07.2004
Post:854
Send Message
...   Created on 06.04.2012 - 12:52Jump to top Quote this post Report this post Edit Delete


Scanlines added. They can be tweaked a bit also.

fragment file:

Code:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
 
/*
   Hyllian's 5xBR v3.7a shader w. scanlines
   
   Copyright (C) 2011 Hyllian/Jararaca - sergiogdb@gmail.com
  
   This program is free software; you can redistribute it and/or
   modify it under the terms of the GNU General Public License
   as published by the Free Software Foundation; either version 2
   of the License, or (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.

*/

const   float n_scan    = 3;
const   float s_divid   = 2;
const   float bright    = 1.1;  
const   float dark      = 0.5;
const   float coef      = 2.0;
const   vec3  rgbw      = vec3(14.352, 28.176, 5.472);
const   vec2 OGLSize    = vec2( 1024.0, 512.0);
const   vec2 OGLInvSize = vec2( 0.0009765625, 0.001953125); 
const   vec2 dx         = vec2( 0.0009765625, 0.0);
const   vec2 dy         = vec2( 0.0, 0.001953125 );
const   vec2 x2         = vec2( 0.001953125 , 0.0);
const   vec2 y2         = vec2( 0.0 , 0.00390625 );
const   vec4 xy         = vec4( 0.0009765625, 0.001953125,-0.0009765625,-0.001953125);  
const   vec4 zw         = vec4( 0.001953125 , 0.001953125,-0.001953125 ,-0.00390625 );  
const   vec4 wz         = vec4( 0.0009765625, 0.00390625 ,-0.0009765625,-0.00390625 );  


vec4 df(vec4 A, vec4 B)
{
    return abs(A-B);
}

vec4 weighted_distance(vec4 a, vec4 b, vec4 c, vec4 d, vec4 e, vec4 f, vec4 g, vec4 h)
{
    return (df(a,b) + df(a,c) + df(d,e) + df(d,f) + 4.0*df(g,h));
}

uniform sampler2D OGL2Texture;

void main()
{
    vec4  edr, edr_left, edr_up; bvec4 px; // px = pixel, edr = edge detection rule
    vec4  interp_restriction_lv1, interp_restriction_lv2_left, interp_restriction_lv2_up;
    bvec4 nc; // new_color
    vec4  fx, fx_left, fx_up; // inequations of straight lines.
    
    vec2 fp  = fract(gl_TexCoord[0].xy*OGLSize);
    vec2 TexCoord_0 = gl_TexCoord[0].xy-fp*OGLInvSize;

    vec3 A  = texture2D(OGL2Texture, TexCoord_0 + xy.zw ).xyz;
    vec3 B  = texture2D(OGL2Texture, TexCoord_0     -dy ).xyz;
    vec3 C  = texture2D(OGL2Texture, TexCoord_0 + xy.xw ).xyz;
    vec3 D  = texture2D(OGL2Texture, TexCoord_0 - dx    ).xyz;
    vec3 E  = texture2D(OGL2Texture, TexCoord_0         ).xyz;
    vec3 F  = texture2D(OGL2Texture, TexCoord_0 + dx    ).xyz;
    vec3 G  = texture2D(OGL2Texture, TexCoord_0 + xy.zy ).xyz;
    vec3 H  = texture2D(OGL2Texture, TexCoord_0     +dy ).xyz;
    vec3 I  = texture2D(OGL2Texture, TexCoord_0 + xy.xy ).xyz;
    vec3 A1 = texture2D(OGL2Texture, TexCoord_0 + wz.zw ).xyz;
    vec3 C1 = texture2D(OGL2Texture, TexCoord_0 + wz.xw ).xyz;
    vec3 A0 = texture2D(OGL2Texture, TexCoord_0 + zw.zw ).xyz;
    vec3 G0 = texture2D(OGL2Texture, TexCoord_0 + zw.zy ).xyz;
    vec3 C4 = texture2D(OGL2Texture, TexCoord_0 + zw.xw ).xyz;
    vec3 I4 = texture2D(OGL2Texture, TexCoord_0 + zw.xy ).xyz;
    vec3 G5 = texture2D(OGL2Texture, TexCoord_0 + wz.zy ).xyz;
    vec3 I5 = texture2D(OGL2Texture, TexCoord_0 + wz.xy ).xyz;
    vec3 B1 = texture2D(OGL2Texture, TexCoord_0 - y2    ).xyz;
    vec3 D0 = texture2D(OGL2Texture, TexCoord_0 - x2    ).xyz;
    vec3 H5 = texture2D(OGL2Texture, TexCoord_0 + y2    ).xyz;
    vec3 F4 = texture2D(OGL2Texture, TexCoord_0 + x2    ).xyz;

    vec4 b  = vec4(dot(B ,rgbw), dot(D ,rgbw), dot(H ,rgbw), dot(F ,rgbw));
    vec4 c  = vec4(dot(C ,rgbw), dot(A ,rgbw), dot(G ,rgbw), dot(I ,rgbw));
    vec4 d  = b.yzwx;
    vec4 e  = vec4(dot(E,rgbw));
    vec4 f  = b.wxyz;
    vec4 g  = c.zwxy;
    vec4 h  = b.zwxy;
    vec4 i  = c.wxyz;
    vec4 i4 = vec4(dot(I4,rgbw), dot(C1,rgbw), dot(A0,rgbw), dot(G5,rgbw));
    vec4 i5 = vec4(dot(I5,rgbw), dot(C4,rgbw), dot(A1,rgbw), dot(G0,rgbw));
    vec4 h5 = vec4(dot(H5,rgbw), dot(F4,rgbw), dot(B1,rgbw), dot(D0,rgbw));
    vec4 f4 = h5.yzwx;
    
    vec4 Ao = vec4( 1.0, -1.0, -1.0, 1.0 );
    vec4 Bo = vec4( 1.0,  1.0, -1.0,-1.0 );
    vec4 Co = vec4( 1.5,  0.5, -0.5, 0.5 );
    vec4 Ax = vec4( 1.0, -1.0, -1.0, 1.0 );
    vec4 Bx = vec4( 0.5,  2.0, -0.5,-2.0 );
    vec4 Cx = vec4( 1.0,  1.0, -0.5, 0.0 );
    vec4 Ay = vec4( 1.0, -1.0, -1.0, 1.0 );
    vec4 By = vec4( 2.0,  0.5, -2.0,-0.5 );
    vec4 Cy = vec4( 2.0,  0.0, -1.0, 0.5 );
    
    // These inequations define the line below which interpolation occurs.
    fx      = vec4(greaterThan(Ao*fp.y+Bo*fp.x,Co));
    fx_left = vec4(greaterThan(Ax*fp.y+Bx*fp.x,Cx)); 
    fx_up   = vec4(greaterThan(Ay*fp.y+By*fp.x,Cy)); 

    interp_restriction_lv1      = vec4(notEqual(e,f))*vec4(notEqual(e,h));
    interp_restriction_lv2_left = vec4(notEqual(e,g))*vec4(notEqual(d,g));
    interp_restriction_lv2_up   = vec4(notEqual(e,c))*vec4(notEqual(b,c));

    edr      = vec4(lessThan(weighted_distance( e, c, g, i, h5, f4, h, f), weighted_distance( h, d, i5, f, i4, b, e, i)))*interp_restriction_lv1;
    edr_left = vec4(lessThanEqual(coef*df(f,g),df(h,c)))*interp_restriction_lv2_left; 
    edr_up   = vec4(greaterThanEqual(df(f,g),coef*df(h,c)))*interp_restriction_lv2_up;
    
    nc = bvec4 (edr*(max(max(fx, edr_left*fx_left), edr_up*fx_up)));

    px = lessThanEqual(df(e,f),df(e,h));

    vec3 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;

    if (mod(gl_FragCoord.y,n_scan) < s_divid) float x=dark; else x = bright;
    gl_FragColor.xyz = x*res;    
}


vertex file:
Code:
1:
2:
3:
4:
5:
6:
 
void main()

{
    gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
    gl_TexCoord[0] = gl_MultiTexCoord0;
}


[Dieser Beitrag wurde am 06.04.2012 - 18:03 von guest aktualisiert]




Hyllian 
Frequent poster
...

...

Status:Offline
Date registered: 12.03.2012
Post:11
Send Message
...   Created on 06.04.2012 - 13:58Jump to top Quote this post Report this post Edit Delete


Hi Guest,

I've seen you're updating this shader lately. Could you update the disclaimer exchanging 3.5a by 3.7a? That's because some speedups were made when I and SimoneT were creating the 3.7a version.

I've seen you incorporated some new ideas to speed up things too. Would you mind if I test some of those ideas and incorporate to the Cg version? Any improvements are welcomed, anyway.

And, before I forget, here a low quality xBR version I was working. It's blazing fast, though quality isn't on par with the hq version. This isn't intended to replace the hq one, it's just for slow hardware.

5xBR-3.7a-lq.cg




More : [1] [2] [3]

Similarly threads:
Topics Created by Replies Boardname
Natural Vision Shader + AA Shader v2.o = Best Shader for 2d !! zaykho 16 pete_bernert
shader guest 2 pete_bernert
MMJ's 4-in-1 Shader MegaManJuno 10 pete_bernert
Shader Aquamarin 0 schaddi
4-in-1 Shader v1.10 MegaManJuno 3 pete_bernert
Neuer Thread ...





Masthead

This forum is a free service of razyboard.com
Do you want a free forum in less than two minutes? Then click here!



Verwandte Suchbegriffe:
5xbr 3.7 fx
blank