Lukas Jiriste [Thu, 28 Nov 2024 22:03:25 +0000 (23:03 +0100)]
Fix cylinder rendering
I thought that the ray forms and acute angle with a vector from
point of entry to cylinder center, but that was not true.
Instead the projections to the plane orthogonal the rotational axis have
this property. So in this commit I implement the test for it.
Lukas Jiriste [Thu, 28 Nov 2024 16:58:18 +0000 (17:58 +0100)]
Implement .rt and args parsing, move test scene
Add rt_grammar and rt_parsing_table as they describe the grammar used to
parse the .rt file. Their contents are available to he program through
the file parsing_info.h where they are encoded (using xxd -i).
The test_scene is added for testing as the "default scene" had to be
erased from main for parsing to be enabled.
Other changes involve the parsing implementation directly.
Lukáš Jiřiště [Wed, 27 Nov 2024 09:08:03 +0000 (10:08 +0100)]
Fix shadow casting
The shadows did not work because the obstruction detection used a
function that expects ray with normalized direction vector. But the
obstruction detection did not normalize its ray because the check for
whether the obstruction is between the object and the light was easier.
The fix is normalizing the ray vector and using distance.
Lukas Jiriste [Tue, 26 Nov 2024 19:10:26 +0000 (20:10 +0100)]
Change plane light diffusion
In the previous commit I noted that plane may not interact with light,
if the normal has the wrong sign. This commit changes but now a plane is
illuminated through itself - it diffuses light that is on the other side
than the camera.
This could be excused arguing that it is an infinitely thin piece so it
should emit light on both sides, but I would rather it would only
emit light on the side it is illuminated on.
Lukas Jiriste [Tue, 26 Nov 2024 18:55:06 +0000 (19:55 +0100)]
Implement Lambertian diffuse lighting (kind of)
This implementation has its problems. The one I can think of now is that
planes are only reflecting, when their normal points in the direction of
the light.
Lukas Jiriste [Fri, 22 Nov 2024 11:55:04 +0000 (12:55 +0100)]
Bring the project closer to compileability
Fix Makefile includes and links.
Comment line prototypes out of main.c.
Rearrange the functions in main.c (I really should just write the
declarations into the header file...).
Lukas Jiriste [Thu, 21 Nov 2024 21:47:22 +0000 (22:47 +0100)]
Implement the color calculation
Also reimplement the t_color as typedef of t_vec3 so that I can use the
vec* operations on color. The t_color now signifies the linear RGB and
needs to be converted to (and from) sRGB upon printing (reading).
Lukas Jiriste [Thu, 21 Nov 2024 16:00:49 +0000 (17:00 +0100)]
Implement most of ray intersection detection
Implement finding the intersection of ray with plane and sphere and use
the intersection closest intersection to camera for color finding.
Cylinder will be implemented at another time.
Also change what qualifies as an object; Now objects have to interact
with light. Light sources and cameras are not objects anymore.