guest  Real addict
  

Status:Offline Date registered: 30.07.2004 Post:856 Send Message | Created on 06.05.2005 - 10:48 |  |
A bit faster.
vertex file:
uniform vec4 OGL2Param; uniform vec4 OGL2Size; varying vec2 dg2; void main()
{ float z = 2.0*(OGL2Size.y/OGL2Size.x); float x = OGL2Param.x; float y = OGL2Param.y*z; vec2 dg1 = vec2( OGL2Param.x,y); dg2 = vec2(-OGL2Param.x,y); vec2 dx = vec2(x,0.0); vec2 dy = vec2(0.0,y); gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; gl_TexCoord[0] = gl_MultiTexCoord0; gl_TexCoord[1].xy = gl_TexCoord[0].xy - dy; gl_TexCoord[2].xy = gl_TexCoord[0].xy + dy; gl_TexCoord[3].xy = gl_TexCoord[0].xy - dx; gl_TexCoord[4].xy = gl_TexCoord[0].xy + dx; gl_TexCoord[5].xy = gl_TexCoord[0].xy - dg1; gl_TexCoord[6].xy = gl_TexCoord[0].xy + dg1; }
fragment file
// 3x3 Gaussian blur shader
uniform sampler2D OGL2Texture; uniform vec4 OGL2Param; varying vec2 dg2;
void main() { vec2 c1 = gl_TexCoord[0].xy - dg2; vec2 c2 = gl_TexCoord[0].xy + dg2;
vec3 c00 = texture2D(OGL2Texture, gl_TexCoord[5].xy).xyz; vec3 c10 = texture2D(OGL2Texture, gl_TexCoord[1].xy).xyz; vec3 c20 = texture2D(OGL2Texture, c1).xyz; vec3 c01 = texture2D(OGL2Texture, gl_TexCoord[3].xy).xyz; vec3 c11 = texture2D(OGL2Texture, gl_TexCoord[0].xy).xyz; vec3 c21 = texture2D(OGL2Texture, gl_TexCoord[4].xy).xyz; vec3 c02 = texture2D(OGL2Texture, c2).xyz; vec3 c12 = texture2D(OGL2Texture, gl_TexCoord[2].xy).xyz; vec3 c22 = texture2D(OGL2Texture, gl_TexCoord[6].xy).xyz;
gl_FragColor.xyz = (c00+c20+c20+c22+2.0*(c10+c01+c21+c12)+4.0*c11)*0.0625; }
[Dieser Beitrag wurde am 08.11.2005 - 13:51 von guest aktualisiert]
|
<Gundam> unregistried
| Created on 11.10.2005 - 19:12 |  |
test this: !!ARBfp1.0
TEMP c11, c10, c21, c12, c01, t1, d, m, w;
PARAM dt = { 1.0, 1.0, 1.0, 1.0}; PARAM t = { 0.1, 0.1, 0.1, 0.1}; PARAM zero = {0.0, 0.0, 0.0, 0.0};
TEX c11, fragment.texcoord[ 0 ], texture[ 0 ], 2D; TEX c10, fragment.texcoord[ 1 ], texture[ 0 ], 2D; TEX c21, fragment.texcoord[ 2 ], texture[ 0 ], 2D; TEX c12, fragment.texcoord[ 3 ], texture[ 0 ], 2D; TEX c01, fragment.texcoord[ 4 ], texture[ 0 ], 2D;
# compute SaL rule application SUB t1, c10, c11; ABS t1, t1; DP4 d.x, t1, dt;
SUB t1, c21, c11; ABS t1, t1; DP4 d.y, t2, dt;
SUB t1, c12, c11; ABS t1, t1; DP4 d.z, t3, dt;
SUB t1, c01, c11; ABS t1, t1; DP4 d.w, t1, dt;
# compute & apply weights
MAX m.x, d.x, d.z; MAX m.y, d.y, d.w;
MAX w.x, m.y, d.z; MAX w.y, m.x, d.w; MAX w.z, m.y, d.x; MAX w.w, m.x, d.y;
MUL t1, C11, t; MAD t1, c10, w.xxxx, t1; MAD t1, c21, w.yyyy, t1; MAD t1, c12, w.zzzz, t1; MAD t1, c01, w.wwww, t1;
DP4 w.x, w, dt; ADD w.x, w.x, 0.1; RCP w, w.x;
MUL result.color, t1, w;
END
Bye ...
|