First, please sorry for my poor english but i’m french.
Here is my first raytracer in java. With low parameters, i’m close to realtime. On my computer - core
i5 2500K 4 cores at 4.2ghz - the demo’s scene - 17762 triangles - is about 3 fps with a screen at 600x400.
With higher parameters (anti-alliasing, smooth shadows, higher recursion), it can be very, very slow.
You can configure the raytracer with the « Param.txt » configuration file in "_Param" directory. All the
parameters are explained and easy to understand.
Some coding tips :
I’m using 2 kdtree for this demo.
- 1 for static objects that use SAH optimisation.
- 1 for dynamic objects, that must be rebuilt on each frame, with middle splitting axe. With « symetric »
objects, it’s not very much slower than SAH.
The KDTree build is multithreaded. At level 2, 4 threads are created. After, for the SAH version only,
if there are enough faces, 3 threads are created, one for each plane to check.
I use another optimization : as the triangles coordinate are sorted on the current axe, we don’t just use
left and right child, but i introduce a middle child, that was copied to the right child.
When turn on, the rendering is made twice :
- The standart one
- One the second pass, each pixel is compared to the 4 around. A delta is computed. If this delta
is higher the a value (AA_DELTA_COLOR in parameter’s file) then AA_LEVEL rays are fired.
For smooth shadow, i’m using a poisson distribution on light area (each light have is own rectangular
area) to avoid banding.
I’m a developper, not a graphist, so sorry for the demo’s scene that I know to be awful. All the
algorithms used come from the web. I’m just tried to use the best. I'm not a great programmer, as
i can see in this forum, so, please, be gentle with me and thank’s for reading my code and give
me you’re feedback and what can be improved. In particular, the normal mapping part, that i'm pretty
sure to be false. The most important classes are RT_SCENE.java and RT_KDTREE.java
Java 7 is required (i think)
The executable jar: https://mega.co.nz/#!mdhx0b6A!Dm1Gny3WNBAh-rIAEeU_LlLJaltU1bqjbCFiIRGuito
The eclipse jar (kepler) : https://mega.co.nz/#!KYAg0CDD!HWw1UBjmrKvE2oECrgQC_TkkgdtZHwu_7UDd4_yAU3c
Show-off, reference material & tools.
1 post • Page 1 of 1
Who is online
Users browsing this forum: No registered users and 4 guests