guest  Real addict
  

Status:Offline Date registered: 30.07.2004 Post:856 Send Message | Created on 25.09.2005 - 20:29 |  |
A fast AA shader.
vertex file
uniform vec4 OGL2Param; uniform vec4 OGL2Size; void main()
{ float x = (OGL2Size.x/2048.0)*OGL2Param.x; float y = (OGL2Size.y/1024.0)*OGL2Param.y; gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; gl_TexCoord[0] = gl_MultiTexCoord0; gl_TexCoord[1] = gl_TexCoord[0]; gl_TexCoord[2] = gl_TexCoord[0]; gl_TexCoord[4] = gl_TexCoord[0]; gl_TexCoord[5] = gl_TexCoord[0]; gl_TexCoord[1].y-=y; gl_TexCoord[2].y+=y; gl_TexCoord[4].x-=x; gl_TexCoord[5].x+=x; }
fragment file
// SaL shader // by guest(r) (guest.r@gmail.com) // License: GNU-GPL
uniform vec4 OGL2Param; uniform vec4 OGL2Size; uniform sampler2D OGL2Texture;
void main() { vec3 c10 = texture2D(OGL2Texture, gl_TexCoord[1].xy).xyz; vec3 c01 = texture2D(OGL2Texture, gl_TexCoord[4].xy).xyz; vec3 c11 = texture2D(OGL2Texture, gl_TexCoord[0].xy).xyz; vec3 c21 = texture2D(OGL2Texture, gl_TexCoord[5].xy).xyz; vec3 c12 = texture2D(OGL2Texture, gl_TexCoord[2].xy).xyz;
vec3 dottie = vec3(1.0,1.0,1.0); float k10=dot(abs(c10-c11),dottie); float k21=dot(abs(c21-c11),dottie); float k12=dot(abs(c12-c11),dottie); float k01=dot(abs(c01-c11),dottie);
float m1 = max(k01,k21); float m2 = max(k10,k12);
float w10 = max(m1,k12); float w21 = max(m2,k01); float w12 = max(m1,k10); float w01 = max(m2,k21);
gl_FragColor.xyz = (w10*c10+w21*c21+w12*c12+w01*c01+0.01*c11)/(w10+w21+w12+w01+0.01); }
[Dieser Beitrag wurde am 08.11.2005 - 13:53 von guest aktualisiert]
|
guest  Real addict
  

Status:Offline Date registered: 30.07.2004 Post:856 Send Message | Created on 26.10.2005 - 14:53 |  |
A much faster version. Vertex file stays the same.
fragment file
// SaL shader // by guest(r) // license: GNU-GPL
uniform sampler2D OGL2Texture;
void main() { vec3 c10 = texture2D(OGL2Texture, gl_TexCoord[1].xy).xyz; vec3 c01 = texture2D(OGL2Texture, gl_TexCoord[4].xy).xyz; vec3 c11 = texture2D(OGL2Texture, gl_TexCoord[0].xy).xyz; vec3 c21 = texture2D(OGL2Texture, gl_TexCoord[5].xy).xyz; vec3 c12 = texture2D(OGL2Texture, gl_TexCoord[2].xy).xyz;
vec3 dt = vec3(1.0,1.0,1.0); float k1=dot(abs(c01-c21),dt); float k2=dot(abs(c10-c12),dt);
gl_FragColor.xyz = (k1*(c10+c12)+k2*(c01+c21)+0.001*c11)/(2.0*(k1+k2)+0.001); }
[Dieser Beitrag wurde am 08.11.2005 - 13:54 von guest aktualisiert]
|