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

Homepage Members Register Login Search Old board


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


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

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

...

Status:Offline
Date registered: 30.07.2004
Post:856
Send Message
...   Created on 25.07.2009 - 18:10Jump to top Quote this post Report this post Edit Delete


All good things come in three...

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:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
188:
189:
190:
191:
192:
193:
194:
195:
196:
197:
198:
199:
200:
201:
202:
203:
204:
 
/* ############################################################################################

   Copyright (C) 2009 guest(r) - guest.r@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.

   ############################################################################################

   This Gs2xSmartFilter shader is well used to scale a gfx. buffer to a custom size.

   Note: set scaler to normal2x or advmame2x...

   Note: If playing a hi-res game set scaler to forced mode (i.e. scaler = normal2x forced)

   ############################################################################################*/



#include "shader.code"

float scaling   : SCALING = 0.1;
float3 dtt = float3(0.005,0.005,0.005);

string preprocessTechique : PREPROCESSTECHNIQUE = "Gs2x";
string combineTechique : COMBINETECHNIQUE =  "SmartFilter";


/*********************************************************************************************/

VERTEX_STUFF0 S_VERTEX (float3 p : POSITION, float2 tc : TEXCOORD0)
{
  VERTEX_STUFF0 OUT = (VERTEX_STUFF0)0;
  
  float dx = ps.x;
  float dy = ps.y;

  OUT.coord = mul(float4(p,1),WorldViewProjection);
  OUT.CT = tc;
  OUT.t1.xy = tc + float2(-dx, 0);
  OUT.t2.xy = tc + float2( dx, 0);
  OUT.t3.xy = tc + float2( 0,-dy);
  OUT.t4.xy = tc + float2( 0, dy);
  OUT.t1.zw = tc + float2(-dx,-dy);
  OUT.t2.zw = tc + float2(-dx, dy);
  OUT.t3.zw = tc + float2( dx,-dy);
  OUT.t4.zw = tc + float2( dx, dy);

  return OUT;
}

/*********************************************************************************************/

float4 S_FRAGMENT ( in VERTEX_STUFF0 VAR ) : COLOR
{
   half3 c00 = tex2D(s_l, VAR.t1.zw).xyz; 
   half3 c10 = tex2D(s_l, VAR.t3.xy).xyz; 
   half3 c20 = tex2D(s_l, VAR.t3.zw).xyz; 
   half3 c01 = tex2D(s_l, VAR.t1.xy).xyz; 
   half3 c11 = tex2D(s_l, VAR.CT).xyz; 
   half3 c21 = tex2D(s_l, VAR.t2.xy).xyz; 
   half3 c02 = tex2D(s_l, VAR.t2.zw).xyz; 
   half3 c12 = tex2D(s_l, VAR.t4.xy).xyz; 
   half3 c22 = tex2D(s_l, VAR.t4.zw).xyz;

   float d1 = dot(abs(c00-c22),dt)+0.001;
   float d2 = dot(abs(c20-c02),dt)+0.001;
   float hl = dot(abs(c01-c21),dt)+0.001;
   float vl = dot(abs(c10-c12),dt)+0.001;

   float k1=hl+vl; float k2=d1+d2;
    
   float3 t1=(hl*(c10+c12)+vl*(c01+c21)+k1*c11)/(3.0*(hl+vl));
   float3 t2=(d1*(c20+c02)+d2*(c00+c22)+k2*c11)/(3.0*(d1+d2));

   k1=dot(abs(t1-c11),dt)+0.001;
   k2=dot(abs(t2-0.5*(c11+t1)),dt)+0.001;

   return float4((k1*t2+k2*t1)/(k1+k2),1);
}

/*********************************************************************************************/
/*********************************************************************************************/


VERTEX_STUFF4 S_VERTEX0 (float3 p : POSITION, float2 tc : TEXCOORD0)
{
  VERTEX_STUFF4 OUT = (VERTEX_STUFF4)0;
  
  float dx = ps.x*0.50;
  float dy = ps.y*0.50;
  float sx = ps.x*0.25;
  float sy = ps.y*0.25;

  OUT.coord = mul(float4(p,1),WorldViewProjection);
  OUT.CT = tc;

  OUT.t1 = float4(tc,tc) + float4(-dx,-dy, dx,-dy); // outer diag. texels
  OUT.t2 = float4(tc,tc) + float4( dx, dy,-dx, dy);
  OUT.t3 = float4(tc,tc) + float4(-sx,-sy, sx,-sy); // inner diag. texels
  OUT.t4 = float4(tc,tc) + float4( sx, sy,-sx, sy);
  OUT.t5 = float4(tc,tc) + float4(-dx,  0, dx,  0); // outer hor/vert texels
  OUT.t6 = float4(tc,tc) + float4(  0,-dy,  0, dy);

  return OUT;
}

/*********************************************************************************************/

float4 S_FRAGMENT0 ( in VERTEX_STUFF4 VAR ) : COLOR

{
  half3 c11 = tex2D(w_l, VAR.CT   ).xyz;
  half3 c00 = tex2D(w_l, VAR.t1.xy).xyz;
  half3 c20 = tex2D(w_l, VAR.t1.zw).xyz;
  half3 c22 = tex2D(w_l, VAR.t2.xy).xyz;
  half3 c02 = tex2D(w_l, VAR.t2.zw).xyz;
  half3 s00 = tex2D(s_l, VAR.t1.xy).xyz;
  half3 s20 = tex2D(s_l, VAR.t1.zw).xyz;
  half3 s22 = tex2D(s_l, VAR.t2.xy).xyz;
  half3 s02 = tex2D(s_l, VAR.t2.zw).xyz;
  half3 c01 = tex2D(w_l, VAR.t5.xy).xyz;
  half3 c21 = tex2D(w_l, VAR.t5.zw).xyz;
  half3 c10 = tex2D(w_l, VAR.t6.xy).xyz;
  half3 c12 = tex2D(w_l, VAR.t6.zw).xyz;

  float d1=dot(abs(c00-c22),dt)+0.001;
  float d2=dot(abs(c20-c02),dt)+0.001;
  float hl=dot(abs(c01-c21),dt)+0.001;
  float vl=dot(abs(c10-c12),dt)+0.001;
  float m1=dot(abs(s00-s22),dt)+0.001;
  float m2=dot(abs(s02-s20),dt)+0.001;

  float3 s11 = 0.5*(m2*(s00+s22)+m1*(s02+s20))/(m1+m2);

  float3 mn1 = min(min(c00,c01),c02);
  float3 mn2 = min(min(c10,min(s11,c11)),c12);
  float3 mn3 = min(min(c20,c21),c22);
  float3 mx1 = max(max(c00,c01),c02);
  float3 mx2 = max(max(c10,max(c11,s11)),c12);
  float3 mx3 = max(max(c20,c21),c22);

  mn1 = min(min(mn1,mn2),mn3);
  mx1 = max(max(mx1,mx2),mx3);

 c11=(hl*(c10+c12)+vl*(c01+c21)+(hl+vl)*c11)/(12.0*(hl+vl))+
     (d1*(c20+c02)+d2*(c00+c22)+(d1+d2)*c11)/(12.0*(d1+d2))+0.5*s11;

  float3 dif1 = abs(c11-mn1) + dtt;
  float3 dif2 = abs(c11-mx1) + dtt;



  float filterparam = 9.5;  // filtering OFF
  //  float filterparam = clamp(3*length(mn1-mx1)+ 4*dot(abs(mn1-mx1),dt)+0.90,1,7);  // filtering ON


  dif1=float3(pow(dif1.x,filterparam),pow(dif1.y,filterparam),pow(dif1.z,filterparam));
  dif2=float3(pow(dif2.x,filterparam),pow(dif2.y,filterparam),pow(dif2.z,filterparam));

  c11 = float3((dif1.x*mx1.x + dif2.x*mn1.x)/(dif1.x + dif2.x),
               (dif1.y*mx1.y + dif2.y*mn1.y)/(dif1.y + dif2.y),
               (dif1.z*mx1.z + dif2.z*mn1.z)/(dif1.z + dif2.z));

  return float4(c11,1);
}


/*********************************************************************************************/
/*********************************************************************************************/


technique Gs2x
{
   pass P0
   {
     VertexShader = compile vs_2_0 S_VERTEX();
     PixelShader  = compile ps_2_0 S_FRAGMENT();
   }  
}


technique SmartFilter
{
   pass P0
   {
     VertexShader = compile vs_3_0 S_VERTEX0();
     PixelShader  = compile ps_3_0 S_FRAGMENT0();
   }  
}




KrossX 
Strong supporter
......

...

Status:Offline
Date registered: 16.06.2008
Post:90
Send Message
...   Created on 14.11.2009 - 12:40Jump to top Quote this post Report this post Edit Delete


Cheap (or LQ) version of your OGL2 Smart Shader. Now is not so smart. >_<

Basicly, I just tried to get a better performance with this IGP I'm now using. It needed to reach stable 120FPS with vsync for a "smooth" image and was giving around 95FPS. Now is able to have stable 120FPS most of the time.

Screenies for comparison, without color correction.
SmartShader | NotSmartOne

gpuPeteOGL2.slf

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:
 
/*
   The GLSmartTexMag filter shader
   
   Copyright (C) 2009 guest(r) - guest.r@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.

*/


uniform sampler2D OGL2Texture;

void main()
{
    vec3 c11 = texture(OGL2Texture, gl_TexCoord[0].xy).xyz;
    vec3 s00 = texture(OGL2Texture, gl_TexCoord[1].xy).xyz; 
    vec3 s20 = texture(OGL2Texture, gl_TexCoord[2].xy).xyz; 
    vec3 s22 = texture(OGL2Texture, gl_TexCoord[3].xy).xyz; 
    vec3 s02 = texture(OGL2Texture, gl_TexCoord[4].xy).xyz;     
    vec3 c01 = texture(OGL2Texture, gl_TexCoord[1].zw).xyz; 
    vec3 c21 = texture(OGL2Texture, gl_TexCoord[2].zw).xyz; 
    vec3 c10 = texture(OGL2Texture, gl_TexCoord[3].zw).xyz; 
    vec3 c12 = texture(OGL2Texture, gl_TexCoord[4].zw).xyz;  
    vec3 dt = vec3(1.0,1.0,1.0);

    float hl=dot(abs(c01-c21),dt)+0.0001;
    float vl=dot(abs(c10-c12),dt)+0.0001;
    float m1=dot(abs(s00-s22),dt)+0.0001;
    float m2=dot(abs(s02-s20),dt)+0.0001;            
    
    vec3 temp1 = m2*(s00 + s22) + m1*(s02 + s20);
    vec3 temp2 = hl*(c10 + c12) + vl*(c01 + c21);
    
    c11 = (temp2/(hl+vl) + c11 + c11) * 0.083333 + (temp1/(m1+m2)) * 0.333333;

    vec3 mn1 = min(min(s00,c01),s02);
    vec3 mn2 = min(min(c10,c11),c12);
    vec3 mn3 = min(min(s20,c21),s22);

    vec3 mx1 = max(max(s00,c01),s02);
    vec3 mx2 = max(max(c10,c11),c12);
    vec3 mx3 = max(max(s20,c21),s22);

    mn1 = min(min(mn1,mn2),mn3);
    mx1 = max(max(mx1,mx2),mx3);

    // float filterparam = 3.0;     

    vec3 dif1 = 0.0001*dt + abs(c11-mn1);
    vec3 dif2 = 0.0001*dt + abs(c11-mx1);

    // dif = pow(dif, filterparam)
    dif1 = dif1 * dif1 * dif1;
    dif2 = dif2 * dif2 * dif2;

    c11 = (dif1 * mx1 + dif2 * mn1) / (dif1 + dif2);
        
    // 16-255    
    // gl_FragColor.xyz = c11 * 1.0669456 - 0.0669456;    
    // 16-235
    gl_FragColor.xyz = c11 * 1.16438356 - 0.07305936;    
    
}


gpuPeteOGL2.slv
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:
 
/*
   
   Copyright (C) 2005 guest(r) - guest.r@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.
        
*/


uniform vec4 OGL2Param;
uniform vec4 OGL2Size;

void main()
{
// 1.0/2048.0 = 0.00048828125
// 1.0/1024.0 = 0.0009765625
float x = OGL2Size.x * 0.0004883 * OGL2Param.x;
float y = OGL2Size.y * 0.0009766 * OGL2Param.y;

vec2 sd1 = vec2( x,y) * 0.5; 
vec2 sd2 = vec2(-x,y) * 0.5;

vec2 ddx = vec2(  x, 0.0); 
vec2 ddy = vec2(0.0,   y);

gl_Position = ftransform();
gl_TexCoord[0] = gl_MultiTexCoord0;
gl_TexCoord[1].xy = gl_TexCoord[0].xy - sd1;
gl_TexCoord[2].xy = gl_TexCoord[0].xy - sd2;
gl_TexCoord[3].xy = gl_TexCoord[0].xy + sd1;
gl_TexCoord[4].xy = gl_TexCoord[0].xy + sd2;
gl_TexCoord[1].zw = gl_TexCoord[0].xy - ddy;
gl_TexCoord[2].zw = gl_TexCoord[0].xy + ddx;
gl_TexCoord[3].zw = gl_TexCoord[0].xy + ddy;
gl_TexCoord[4].zw = gl_TexCoord[0].xy - ddx;
}


[Dieser Beitrag wurde am 14.11.2009 - 12:40 von KrossX aktualisiert]





Signature

More : [1] [2]

Similarly threads:
Topics Created by Replies Boardname
Smart Texture Filtering GLSL shader (Copyright (c) 2004 Jaewon Jung) ShadX 7 pete_bernert
DOSBox - Probleme Myro 213 slydos
Wie findet ihr MoFi (Modified Filter) - AIM Crash Filter TsunamiDT 0 tsunamidt
DOSBox 0.70 erschienen Egidius 2 slydos
Does anyone have a link to a Smart Texture Filtering shader? FM 1 pete_bernert
Neuer Thread ...





Masthead

This forum is a free service of razyboard.com powered by:
Geizkragen Price Comparison. Top product in the price comparison: Krups Nespresso Essenza (XN2001)
Do you want a free forum in less than two minutes? Then click here!



Verwandte Suchbegriffe:
smart texture filtering | dosbox texture filtering | texturemagfilter | pete ogl2 no buffer available | ogl2 hi-res texture | smart texture ogl2
blank