I don’t know much about how people program 3D material, so I’ll just give you clean math and hope it will be useful.
A sphere of radius 1 centered on origin is a set of points satisfying:
x 2 + y 2 + z 2 = 1
3D- , . , z:
z = ± sqrt (1 - x 2 - y 2).
, . , (x, y, z), , , < x, y, z > .
, , (x, y, z), x, y z, at (x 0, y 0, z 0). :
x 0 x + y 0 y + z 0 z = 1
, .
():
- :
const int R = 31, SZ = power_of_two(R*2);
std::vector<vec4_t> p;
for(int y=0; y<SZ; y++) {
for(int x=0; x<SZ; x++) {
const float rx = (float)(x-R)/R, ry = (float)(y-R)/R;
if(rx*rx+ry*ry > 1) {
p.push_back(vec4_t(0,0,0,0));
} else {
vec3_t normal(rx,sqrt(1.-rx*rx-ry*ry),ry);
p.push_back(vec4_t(normal,1));
}
}
}
, , blit; ?
(TZ)
, ++. , .