void cast_aa_ray(int x, int y)
{

    double color[3],color1[3],color2[3],color3[3],color4[3];


    /*Anti-Aliasing by super sampling for each pixel using grid algorithm method
    ---------
    | . . . |
    | . . . |
    | . . . |
    ---------
    */

    cast_ray(x+.25f, y+.5f, color1);
    cast_ray(x+.5f, y+.75f, color2);
    cast_ray(x+.5f, y+.25f, color3);
    cast_ray(x+.75f, y+.5f, color4);

    /* I am using only 4 grids i.e averaging by 4 per pixel */
    color[0] = (color1[0]+color2[0]+color3[0]+color4[0]) / 4;
    color[1] = (color1[1]+color2[1]+color3[1]+color4[1]) / 4;
    color[2] = (color1[2]+color2[2]+color3[2]+color4[2]) / 4;


    if(color[0] > 1)
        color[0] = 1;
    else if (color[0] < 0)
        color[0] = 0;
    color[0] *= 255;

    if(color[1] > 1)
        color[1] = 1;
    else if (color[1] < 0)
        color[1] = 0;
    color[1] *= 255;

    if(color[2] > 1)
        color[2] = 1;
    else if (color[2] < 0)
        color[2] = 0;
    color[2] *= 255;

    plot_pixel_jpeg(x,y,color[0],color[1],color[2]);

}
Example #2
0
void plot_pixel(int x,int y,double r,double g,double b)
{
	while(r >= 256.0)
	{
		r -= 256.0;
	}
	while(g >= 256.0)
	{
		g -= 256.0;
	}
	while(b >= 256.0)
	{
		b -= 256.0;
	}
  plot_pixel_display(x,y,r,g,b);
  if(mode == MODE_JPEG)
      plot_pixel_jpeg(x,y,r,g,b);
}
Example #3
0
void plot_pixel(int x,int y,unsigned char r,unsigned char g, unsigned char b)
{
  plot_pixel_display(x,y,r,g,b);
  if(mode == MODE_JPEG)
      plot_pixel_jpeg(x,y,r,g,b);
}