(x,y,t,&r,&g,&b) // Fake sphere mapping. // Get distance squared from centre. d = x * x + y * y; if (d < 1) { // Calculate texture coordinates. u = +(sin(x) / cos(d)) / pi + (t / 10); v = -(sin(y) / cos(d)) / pi + 0.5; // Get picture dimensions. t_w = 0; t_h = 0; getpicsiz(t_w, t_h); // Look up pixel from texture. pic( u * t_w, v * t_h, r, g, b ); // Apply crude shading. shading = sin(x + t / 2) * 64; r -= shading; g -= shading; b -= shading; } else { // We're outside the bounds of the // sphere, so return black. r = 0; g = 0; b = 0; }