guest  Real addict
  

Status:Offline Date registered: 30.07.2004 Post:856 Send Message | Created on 13.07.2006 - 11:30 |  |
With some changes...
//\xgs2gl1.0
const float threshold = 0.10; // effects dark lines
uniform sampler2D tex0;
uniform vec4 tex_attribs;
void main (void)
{
vec3 c11 = texture2D(tex0, gl_TexCoord[0].xy).rgb;
vec3 c12 = texture2D(tex0, gl_TexCoord[1].xy).rgb;
vec3 c02 = texture2D(tex0, gl_TexCoord[2].xy).rgb;
vec3 c01 = texture2D(tex0, gl_TexCoord[3].xy).rgb;
vec3 c00 = texture2D(tex0, gl_TexCoord[4].xy).rgb;
vec3 c10 = texture2D(tex0, gl_TexCoord[5].xy).rgb;
vec3 c20 = texture2D(tex0, gl_TexCoord[6].xy).rgb;
vec3 c21 = texture2D(tex0, gl_TexCoord[7].xy).rgb;
vec3 c22 = texture2D(tex0, vec2(gl_TexCoord[0] + tex_attribs));
vec3 dt = vec3(1.0,1.0,1.0);
float d1=dot(abs(c00-c22),dt);
float d2=dot(abs(c20-c02),dt);
float hl=dot(abs(c01-c21),dt);
float vl=dot(abs(c10-c12),dt);
float d = 0.6*(d1+d2+hl+vl)/(dot(c11,dt)+0.15);
d = pow(max(d-threshold,0.0),1.5);
gl_FragColor.xyz = (1.15-d)*c11;
}
I think there is a default vertex file built in the main executable (or a default vertex file in a dir) for fragmet files. Adding your own vertex file replaces the default one.
|
Z Strong supporter
 

Status:Offline Date registered: 03.08.2005 Post:72 Send Message | Created on 13.07.2006 - 23:01 |  |
Thanks for your reply. 
This version works (if you fill in the missing ".rgb" in line 19).
Now we only need the vertex file and we're complete.

How do I have to change this one?
uniform vec4 OGL2Param;
uniform vec4 OGL2Size;
void main()
{
float x = (OGL2Size.x/2048.0)*OGL2Param.x;
float y = (OGL2Size.y/1024.0)*OGL2Param.y;
vec2 dg1 = vec2( x,y);
vec2 dg2 = vec2(-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;
gl_TexCoord[1].zw = gl_TexCoord[0].xy - dg2;
gl_TexCoord[2].zw = gl_TexCoord[0].xy + dg2;
}
Unfortunately I don't know which uniforms I have to use for OGL2Param and OGL2Size etc. ... 
|
guest  Real addict
  

Status:Offline Date registered: 30.07.2004 Post:856 Send Message | Created on 14.07.2006 - 01:42 |  |
Btw. switched to nVidia.
Their GLSL parser knows how to convert vec4 to vec3. :P (did't notice the bug therefore)
the modified vertex file:
uniform vec4 tex_attribs;
uniform vec4 img_attribs1;
void main()
{
float x = tex_attribs.x;
float y = tex_attribs.y;
vec2 dg1 = vec2( x,y);
vec2 dg2 = vec2(-x,y);
vec2 dx = vec2(x,0.0);
vec2 dy = vec2(0.0,y);
gl_Position = ftransform();
gl_TexCoord[0] = gl_Vertex * img_attribs1;
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;
gl_TexCoord[1].zw = gl_TexCoord[0].xy - dg2;
gl_TexCoord[2].zw = gl_TexCoord[0].xy + dg2;
}
|