Skip to content

Commit

Permalink
a pattern is mapped to the sphere
Browse files Browse the repository at this point in the history
  • Loading branch information
ssloy committed Jan 27, 2019
1 parent ef22c62 commit 45ea36a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
Binary file modified out.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion tinykaboom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ int main() {
if (sphere_trace(Vec3f(0, 0, 3), Vec3f(dir_x, dir_y, dir_z).normalize(), hit)) { // the camera is placed to (0,0,3) and it looks along the -z axis
Vec3f light_dir = (Vec3f(10, 10, 10) - hit).normalize(); // one light is placed to (10,10,10)
float light_intensity = std::max(0.4f, light_dir*distance_field_normal(hit));
framebuffer[i+j*width] = Vec3f(1, 1, 1)*light_intensity;
float displacement = (sin(16*hit.x)*sin(16*hit.y)*sin(16*hit.z) + 1.)/2.;
framebuffer[i+j*width] = Vec3f(1, 1, 1)*displacement*light_intensity;
} else {
framebuffer[i+j*width] = Vec3f(0.2, 0.7, 0.8); // background color
}
Expand Down

0 comments on commit 45ea36a

Please sign in to comment.