To fill a particular cell with color, you need to draw a "cube" (in fact, a cube face), for example:
\fill[cube, yourcolor] (\x,\y) -- +(0, .25) -- +(.25, .25) -- +(.25,0) -- cycle;
To draw arbitrary "bitmaps" on in your grid, I think the best approach is to have the bitmap defined in a bidimensional array, and use pgfmath
to access the elements of that array. For example:
\documentclass{standalone}
\usepackage{tikz}
\usepackage{tikz-3dplot}
\def\pixelmap{{%
{0,0,1,1,1,1,0,0,0},
{0,1,0,0,0,0,1,0,0},
{1,0,1,0,1,0,0,1,0},
{1,0,1,0,1,0,0,1,0},
{1,0,0,0,0,1,0,1,0},
{1,0,1,1,1,0,0,1,0},
{0,1,0,0,0,0,1,0,0},
{0,0,1,1,1,1,0,0,0},
{0,0,0,0,0,0,0,0,0}
}}
\colorlet{color0}{yellow!40}
\colorlet{color1}{red}
\begin{document}
\tdplotsetmaincoords{60}{125}
\begin{tikzpicture}
[tdplot_main_coords,
grid/.style={very thin,gray},
]
\foreach \x [count=\i from 0] in {-2.5,-2.25,...,2.5}
\foreach \y [count=\j from 0] in {-2.5,-2.25,...,2.5}
{
\def\bit{0}
\pgfmathsetmacro{\bit}{\pixelmap[mod(\i,9)][mod(\j,9)]}
\draw[grid] (\x,-2.5) -- (\x,2.5);
\draw[grid] (-2.5,\y) -- (2.5,\y);
\fill[cube, color\bit] (\x,\y) -- +(0, 0.25) -- +(.25, .25) -- +(.25,0) -- cycle;
}
\end{tikzpicture}
\end{document}
This produces the result:
(Note that, since my bitmap is only 9x9 while your grid is 20x20, I used mod
function to repeat the pattern)
For example, fill some of the cells with red so that the colored cells form the shape of a circle.
Are you trying to carry out "rasterization"