I'm writing a pixel shader for a class, and the final step is to use a 1D texture to map whatever color the fragment would be under phong shading to another color to produce a banding effect. When I run the program the object appears completely black, so I think that I am creating the texture wrong. Here is the code to generate the texture
It's a 1D, RGB texture with no border, so I think I have the glTexImage1D parameters right. When the object is drawn, I pass color_map_id to it as a sampler1D and perform a texture1D lookup with it. Am I setting it up wrong? Am I doing the lookup/id passing wrong? Why is the texture not loading? Thanks in advance for any help you can giveCode:// definitions actually located in a header file
#define COLOR_MAP_WIDTH 256
unsigned char color_map[COLOR_MAP_WIDTH][3];
#define RED_STEP 13
#define BLUE_STEP 27
#define GREEN_STEP 33
unsigned int color_map_id;
void gen_texture_map(void){
int i;
for(i = 0; i < 256; ++i){
color_map[i][0] = (i/RED_STEP)*RED_STEP;
color_map[i][1] = (i/GREEN_STEP)*GREEN_STEP;
color_map[i][2] = (i/BLUE_STEP)*BLUE_STEP;
}
glGenTextures(1, &color_map_id);
glBindTexture(GL_TEXTURE_1D, color_map_id);
glTexImage1D(GL_TEXTURE_1D, 0, 3, COLOR_MAP_WIDTH, 0, GL_RGB, GL_UNSIGNED_BYTE, color_map);
}