More Lua based shenanigans

I did some more work this week, on my ray tracer. Prior to this, the scene that would be rendered was static data compiled into the executable. This is understandably a bad idea because it requires the entire program to be recompiled every time I wish to change the scene. I decided to place the configuration in Lua, being one of my favourite languages. This gives me flexibility in many ways. I have plans to alter the program such that it will generate a continuous animation rather than static images. By using Lua, I can have a callback function that will move the camera or the objects between frames.

Thanks to my learning experience dealing with Lua tables through my Asteroids game, I decided to be a bit brave and allow more of the functions the executable exports to the Lua scripts. So far I have only 4 functions, very simple ones.

create_pointLight, create_sphere, create_plane, create_material.

The create_material function takes a Lua table as an argument. My function parses the table for the reflective, refractive (even though I have yet to implement it in the ray tracer itself) and colour components and stores them in a material instance from my program. The other functions take a material, position, in addition to the other pieces of information the function needs (sphere needs a radius, plane needs a normal and a scalar argument, etc).

Plans for the future are to expand on the number of shapes I can create, and to implement the callback function. Then I can implement functions to move objects and alter their position, size, colour etc to create interesting videos when the rendered images are played back continuously.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: