add upper spheres

This commit is contained in:
Cat Flynn 2023-02-26 03:26:42 +00:00
parent 1c672e0f42
commit 55d9620983
3 changed files with 31 additions and 3 deletions

View File

@ -11,6 +11,34 @@ RayHit trace(inout Ray ray)
intersectSphere(ray, hit, _spheres[i]); intersectSphere(ray, hit, _spheres[i]);
} }
int sphereCount = 10;
for (int i = 0; i < sphereCount; i++)
{
Sphere s;
float a = i/float(sphereCount)*2.0*PI;
float d = 17.0 + cos((1.3+a)*3.0) * 3.0;
float r = 4.0 + sin(a*3.0)*2.0;
s.cr = vec4(sin(a)*d,2.0*r+cos(a*5.0),cos(a)*d, r);
s.albedo = vec3(.2);
s.material = i % 3 == 0 ? MAT_CHROME : MAT_LAMBERT;
intersectSphere(ray, hit, s);
}
sphereCount = 3;
for (int i = 0; i < sphereCount; i++)
{
Sphere s;
float a = i/float(sphereCount)*2.0*PI;
float d = 5.0 + cos((5.34+a)*5.0) * 3.0;
float r = 3.0 + sin(a*2.0)*1.5;
s.cr = vec4(sin(a)*d,4.0*r+cos(a*5.0),cos(a)*d, r);
s.albedo = vec3(.2);
s.material = i % 3 == 0 ? MAT_CHROME : MAT_LAMBERT;
intersectSphere(ray, hit, s);
}
ray.distance += hit.distance * float(hit.distance < INF); ray.distance += hit.distance * float(hit.distance < INF);
return hit; return hit;

View File

@ -135,7 +135,7 @@ void updateUniforms(GLuint shaderProgram, float t)
updateCameraUniforms(shaderProgram, aspect, t); updateCameraUniforms(shaderProgram, aspect, t);
// make and update spheres // make and update spheres
const int sphereCount = 41; const int sphereCount = 25;
struct Sphere spheres[sphereCount]; struct Sphere spheres[sphereCount];
makeSpheres(spheres, sphereCount, t); makeSpheres(spheres, sphereCount, t);
updateSphereUniforms(shaderProgram, spheres, sphereCount); updateSphereUniforms(shaderProgram, spheres, sphereCount);

View File

@ -30,13 +30,13 @@ void makeSpheres(struct Sphere *spheres, int count, float t)
int rainbowSpheres = count - middleSpheres; int rainbowSpheres = count - middleSpheres;
// distance from center // distance from center
float d = 6.0; float d = 6.0;
radius = 0.5; radius = 0.7;
float x; float x;
for (int i = 0; i < rainbowSpheres; i++) for (int i = 0; i < rainbowSpheres; i++)
{ {
x = 2.0*CGLM_PI * (float)i/(float)rainbowSpheres; x = 2.0*CGLM_PI * (float)i/(float)rainbowSpheres;
sc[0] = sin(x)*d; sc[0] = sin(x)*d;
sc[1] = sin(x*3.0-5.0*sin(t)); sc[1] = radius*sin(x*3.0-5.0*sin(t));
sc[2] = cos(x)*d; sc[2] = cos(x)*d;
float ic = i/(float)rainbowSpheres*CGLM_PI*2.0; float ic = i/(float)rainbowSpheres*CGLM_PI*2.0;