Using the fundamental system for representing the colors to be used on a computer display, RGB, our aim is to create a program(with C#) where the user can input their image, and the result is a spherical polygon-cloud which projects individual RGB extracted shadows from specific views.
The initial prototyping of RGB processing was done in p5.js and grasshopper.
The core process of SHADOW RGB including creating rotational point cloud with x, y, z and remapping image color information(hue and brightness) to three faces. The faces are grouped with red, green, blue in three direction with three group of triangular faces that perpendicular to each other. Higher brightness will result in bigger triangles.
private void RunScript (
string imageFile, // original image file
int d, // size per triangulation
double distan, // cube to sphere
ref object A, // output geometry
ef object B // rotation center
) {
System.Drawing.Bitmap mybmp = new System.Drawing.Bitmap(imageFile);
int z = 20; // offset from origin
int rx = (mybmp.Width - 1); // image width
int ry = (mybmp.Height - 1); // image height
List<system.drawing.color> colors = new List<system.drawing.color>();</system.drawing.color></system.drawing.color>
List<mesh> mee = new List<mesh>(); </mesh></mesh>// start list of mesh
Point3d center = new Point3d(rx / 2, ry / 2, rx / 2); // center point of output geometry
Point3d origin = new Point3d(rx / 2, ry / 2, rx / 2 + z);
for (int i = 0; i < rx; i++) { // loop system for x, y, z faces
for (int j = 0; j < ry; j++) {
for (int k = 0; k < rx; k++) {
System.Drawing.Color a = mybmp.GetPixel( j, rx - k); // corresponding color system for each face
System.Drawing.Color b = mybmp.GetPixel(i, ry - j);
System.Drawing.Color c = mybmp.GetPixel(i, rx - k);
double valR = a.R;
double valG = b.G;
double valB = c.B;
Mesh m = new Mesh(); // create new mesh
Point3d current = new Point3d(i, j, k); // setting spherical boundary through condition
double centertocurrent = center.DistanceTo(current);
if(centertocurrent < distan){
Point3d p1 = new Point3d(i, j, z + valR / d + k); // setting vertices
Point3d p2 = new Point3d(i + valG / d, j, z + k);
Point3d p3 = new Point3d(i, j + valB / d, z + k);
Point3d p0 = new Point3d(i, j, z + k);
m.Vertices.Add(p0); // vertices for Green
m.Vertices.Add(p1);
m.Vertices.Add(p2);
m.Vertices.Add(p0); // vertices for Blue
m.Vertices.Add(p2);
m.Vertices.Add(p3);
m.Vertices.Add(p0); // vertices for Red
m.Vertices.Add(p3);
m.Vertices.Add(p1);
m.VertexColors.Add(0, 255, 0); // coloration (Green)
m.VertexColors.Add(0, 255, 0);
m.VertexColors.Add(0, 255, 0);
m.VertexColors.Add(0, 0, 255); // coloration (Blue)
m.VertexColors.Add(0, 0, 255);
m.VertexColors.Add(0, 0, 255);
m.VertexColors.Add(255, 0, 0); // coloration (Red)
m.VertexColors.Add(255, 0, 0);
m.VertexColors.Add(255, 0, 0);
m.Faces.AddFace(0, 1, 2); // G // create face from vertices
m.Faces.AddFace(3, 4, 5); // B // create face from vertices
m.Faces.AddFace(6, 7, 8); // R // create face from vertices
mee.Add(m); // add per triangle to mesh
}
}
}
}
A = mee; // export meshes
B = origin; // export rotational origin
}
Final example is generated from Peppa Pig. The shadow outcome of the sculpture is tested with real-time lights in vray.