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

Homepage Members Register Login Search Old board


Neuer Thread ...


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 31.07.2009 - 12:00Jump to top Quote this post Report this post Edit Delete


I think this might be a great idea since point and linear samplers (in general) give a blurry/distorted results. This can be compensated by using an alternative interpolation method. The end image can look like linear or point interpolated - or anything in between.
In the shader posted below this can be managed by the *p* value (p like power of...).

p = 1.0 - linear interpolation
p = 10.0 - almost point interpolation.

Code (2xSaL smart - is a fine example):

vertex shader:

Code:
1:
2:
3:
4:
5:
6:
7:
8:
 

void main()

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


fragment shader:
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:
 

/*

  2xSaL Smart shader (pow-metric)

           - Copyright (C) 2007 guest(r) - guest.r@gmail.com

           - License: GNU-GPL  
*/



uniform sampler2D OGL2Texture;

const float p = 1.5;  // value to be played with

const vec3 dt = vec3(1.0,1.0,1.0);

vec3 mux (vec3 a, vec3 b, float x, float p)
{    
    float xa = pow(x,p);
    float xb = pow(1-x,p);
    return (a*xa + b*xb)/(xa+xb);
}


void main()
{

    // Calculating texel coordinates
    
    vec2 size     = vec2(2048.0,1024.0);
    vec2 inv_size = vec2(1.0/2048.0, 1.0/1024.0);

    vec2 OGL2Pos = gl_TexCoord[0].xy*size;
    vec2 fp  = fract(OGL2Pos);
    vec2 dx  = vec2(inv_size.x,0.0);
    vec2 dy  = vec2(0.0,inv_size.y);
    vec2 g1  = vec2( inv_size.x,inv_size.y);
    vec2 g2  = vec2(-inv_size.x,inv_size.y);

    vec2 pC4 = floor(OGL2Pos)*inv_size;
   

    // Reading the texels

    vec3 C0 = texture2D(OGL2Texture,pC4-g1).xyz; 
    vec3 C1 = texture2D(OGL2Texture,pC4-dy).xyz;
    vec3 C2 = texture2D(OGL2Texture,pC4-g2).xyz;
    vec3 C3 = texture2D(OGL2Texture,pC4-dx).xyz;
    vec3 C4 = texture2D(OGL2Texture,pC4   ).xyz;
    vec3 C5 = texture2D(OGL2Texture,pC4+dx).xyz;
    vec3 C6 = texture2D(OGL2Texture,pC4+g2).xyz;
    vec3 C7 = texture2D(OGL2Texture,pC4+dy).xyz;
    vec3 C8 = texture2D(OGL2Texture,pC4+g1).xyz;

    vec3 ul,ur,dl,dr; float m1,m2;

    m1=dot(abs(C0-C4),dt)+0.001;
    m2=dot(abs(C1-C3),dt)+0.001;
    ul=(m2*(C0+C4)+m1*(C1+C3))/(m1+m2);

    m1=dot(abs(C1-C5),dt)+0.001;
    m2=dot(abs(C2-C4),dt)+0.001;
    ur=(m2*(C1+C5)+m1*(C2+C4))/(m1+m2);

    m1=dot(abs(C3-C7),dt)+0.001;
    m2=dot(abs(C6-C4),dt)+0.001;
    dl=(m2*(C3+C7)+m1*(C6+C4))/(m1+m2);

    m1=dot(abs(C4-C8),dt)+0.001;
    m2=dot(abs(C5-C7),dt)+0.001;
    dr=(m2*(C4+C8)+m1*(C5+C7))/(m1+m2);

    gl_FragColor.xyz = 0.5*(mux(mux(dr,dl,fp.x,p),mux(ur,ul,fp.x,p),fp.y,p));    
}





Similarly threads:
Topics Created by Replies Boardname
Pixel Plaza Horst_RPG 8 horst_rpg
Pixel Piraten Borussia 0 ballspielverein_borussia
PIXEL MIST waldi 1 medientechnologie
Pixel ist 18 Mietze 21 turbohanes
Pixel-Wettbewerb Bianca 0 legendary_forum
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!



blank