Original Post
//Vertex Shader: ////////////// varying vec3 normal; varying vec4 pos; uniform vec3 MyPoint[2]; uniform float activationSize; varying float dist; float distancefinder(vec3 Point[2]) { int i; //float tempDist = distance(Point,gl_Vertex); float tempDist; for (i=0;i<2;i++) { tempDist = distance(Point,gl_Vertex); tempDist /= 15; if (tempDist <= 1.0) { i=3; } } return (tempDist*activationSize); } void main() { normal = gl_NormalMatrix * gl_Normal; gl_Position = ftransform(); pos = gl_ModelViewMatrix * gl_Vertex; dist = distancefinder(MyPoint); //dist = distancefinder(MyPoint[0]); //dist = distance(MyPoint[1],gl_Vertex); //dist /= (45-(40)); // Change Value to Change Distance of Electrode // activationSize } ///////////// ///Fragment Shader /////////////// varying vec3 normal; varying vec4 pos; varying float dist; uniform float activation; uniform sampler1D texturecolors; void main() { vec4 color; bool flag = false; if (dist <= 1.0) { vec4 colormap = tex1D(texturecolors, 1-(dist)); // Distance from Vertex // dist*activation color[0] = colormap[0]; color[1] = colormap[1]; color[2] = colormap[2]; color[3] = 0.0; } else { color = gl_FrontMaterial.diffuse; } 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; } The Two shaders will produce two activation points given the input of MyPoint[2] is located on a model in XYZ Coordinates. For Some reason when I produce two of these using the distance function, the second activation is not drawn as smoothly. The edges of all polygons are shown. Does anyone know of a way to get around this? Or fixes in my code to try? Much appreciated