Posted Below are my two shaders that encompass all the coloring. The UV Tex Coords contain a color value that I use to pull out from a 1D Texture. If anyone can help me understand why I am getting rainbow edging around my drawing it would greatly appreciated.
My radius of involvement is 10.0, the “rainbow edging” means that at the edge of these vertices there is a stripe of rainbow coloring that I cannot seem to get rid of.
Thanks to anyone and everyone who lends a hand to help out on these forums.
http://s592.photobucket.com/albums/tt8/lacabos/?action=view¤t=phantomline.png
Vertex Shader//
/////////////
varying vec3 normal;
varying vec4 pos;
uniform vec3 MyPoint[5]; // ** CHANGE ARRAY SIZE TO ELECTRODES ** //
uniform float activationSize; // Activation Modulation from 0.0 being no Activity 1.0 being full radial distance
varying float dist; // Compute Distance from Electrode point and Pass Value to Fragment Shader
varying float radialdistance;
attribute short nodelocations[5];
float distancefinder(vec3 Point[5]) // ** CHANGE ARRAY SIZE TO ELECTRODES ** // change to float return type
{
int i;
float tempDist;
for (i=0;i<5;i++) // Change < to the Size of Electrodes //
{
tempDist = (distance(Point[i],gl_Vertex));
tempDist /= radialdistance;
if(tempDist <= 1.0)
{
return(tempDist);} // works
}
return (radialdistance);
}
void main()
{
radialdistance = 45.5; // Change to Determine Removal of Small Spotting keep consitent with Model.cpp contribution Var
normal = gl_NormalMatrix * gl_Normal;
gl_Position = ftransform();
pos = gl_ModelViewMatrix * gl_Vertex;
gl_TexCoord[0].x = gl_MultiTexCoord0;
if (gl_TexCoord[0].x <= 1.0)
{
if (distancefinder(MyPoint) >= 1.0)
{
gl_TexCoord[0].x = radialdistance;
} // Works
}
}
Frag Shade
////
varying vec3 normal;
varying vec4 pos;
varying float dist;
uniform float activation; // color range between 0 - 1
uniform sampler1D texturecolors;
varying float radialdistance;
void main() {
vec4 color;
if (gl_TexCoord[0].x > 1.0 && gl_TexCoord[0].x <= 5) // To Fade to White
{
color[0] = 1.0;
color[1] = 1.0;
color[2] = 1.0;
color[3] = 0.0;
}
else if (gl_TexCoord[0].x <= 1.0) // gl_TexCoord[0].x @ 1.0 is 100%,
{
vec4 colormap = tex1D(texturecolors, ((gl_TexCoord[0].x)*activation));
color[0] = colormap[0];
color[1] = colormap[1];
color[2] = colormap[2];
color[3] = 0.0;
}
// ABOVE IF STATE gl_TexCoord[0].x >= 0.280 && gl_TexCoord[0].x <= 1.0
else
{ color = gl_FrontMaterial.diffuse; } // Comment to Make Brain Black
vec4 matspec = gl_FrontMaterial.specular;
float shininess = gl_FrontMaterial.shininess;
vec4 lightspec = gl_LightSource[0].specular;
vec4 lpos = gl_LightSource[0].position;
vec4 s = -normalize(pos-lpos);
vec3 light = s.xyz;
vec3 n = normalize(normal);
vec3 r = -reflect(light, n);
r = normalize(r);
vec3 v = -pos.xyz;
v = normalize(v);
vec4 diffuse = color * max(0.0, dot(n, s.xyz)) * gl_LightSource[0].diffuse;
vec4 specular;
if (shininess != 0.0) {
specular = lightspec * matspec * pow(max(0.0, dot(r, v)), shininess);
} else {
specular = vec4(0.250, 0.250, 0.250, 0.0);
}
gl_FragColor = diffuse + specular;
}