Commit c95e8d19 authored by Sabrina Templeton's avatar Sabrina Templeton
Browse files

code cleanup in fragment shader

parent f4f7db17
......@@ -9,33 +9,25 @@ in vec3 v_Normal;
in vec3 v_Parameter;
in float v_Index;
const int ncolor = 256;
uniform float u_umin;
uniform float u_umax;
uniform int u_nb_points;
uniform samplerBuffer colormap;
//uniform samplerBuffer nn;
#define DEBUG 0
float random (vec2 uv) {
return fract(sin(dot(uv,vec2(12.9898,78.233)))*43758.5453123);
}
void
get_color( float u , out vec3 color ) {
// This line turns on the random shading (for structured points)
//u = random( vec2(v_Index,v_Index) ) * (u_nb_points+1);
float umin = 0.;//u_umin;
float umax = u_nb_points +1;//u_umax;
float umin = 0.;
float umax = u_nb_points +1;
// int indx = int(ncolor*(u - umin)/(umax - umin));
int indx = int(ncolor*(u - umin)/(umax - umin));
......@@ -48,38 +40,15 @@ int indx = int(ncolor*(u - umin)/(umax - umin));
float b0 = texelFetch( colormap , 3*(indx) + 2 ).x;
color = vec3(r0,g0,b0);
//if (indx == 36) color = vec3(1,0,1);
}
void main() {
vec3 color = vec3(.2, .2, .2);//vec3(0.8,0.8,0.2);
vec3 color = vec3(.2, .2, .2);
float idx = v_Index;//gl_PrimitiveID;
float f = idx;
//float t = texelFetch( nn, 1 * idx ).x;
#if DEBUG
if (idx == 0) color = vec3(1,0,0);
if (idx == 1) color = vec3(0,1,0);
if (idx == 2) color = vec3(0,0,1);
if (idx == 3) color = vec3(1,1,0);
if (idx == 4) color = vec3(0,1,1);
if (idx == 5) color = vec3(1,0,1);
if (idx == 6) color = vec3(.5,.5,.5);
#else
float idx = v_Index; //gl_PrimitiveID;
get_color(idx, color);
#endif
//if (t == idx) color = vec3(0, 1, 0);
fragColor = vec4(color, 1);
}
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment