Author Topic: MySQL Raytracer  (Read 2337 times)

0 Members and 1 Guest are viewing this topic.


  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2490
MySQL Raytracer
« on: October 21, 2019, 01:55:46 PM »
This is a raytracing engine contained in a single Mysql SELECT statement. In the beginning of the code there are a few parameters that can be modified. The scene can be specified using the @triangles and @squares parameters, but everything is explained in the comments. The whole query returns a bitmap file which can be written to the filesystem using the "INTO DUMPFILE" syntax at the end of the query, if mysql has filesystem write permissions.

The raytracer supports shadows and reflections, which makes it, to my knowledge, the most advanced MySQL raytracer on the market right now. However, it is not really polished and kinda slow. Since I didn't really know how to present this work in a demoparty friendly way, I just included two finished renderings.

To run this code, you need a running mysql-server to execute the query. The code is only tested on mysql version 5.7.22 running on Ubuntu 16.04. MySQL also needs file write permissions to write the bmp file to the filesystem.

If you want to render more than a few pixels worth you usually also have to increase mysql's memory and execution time limit settings.


MySQL Raytracer

MySQL Raytracer
« Last Edit: October 21, 2019, 04:05:39 PM by JeGX »