Skip to content

Architecture

Valtteri Koskivuori edited this page Jul 3, 2022 · 5 revisions

A few notes on some details on how C-ray works

Shared scene data

C-ray uses shared, global arrays for polygons, vertices, texture coordinates and normals. You don't have to worry about this, as all the management is already complete and (somewhat) tested. This choice was made to simplify memory management. Thus, the mesh data structure only has to keep track of an offset, and amount of a given element belonging to it, like so:

> int vertexCount;

> int firstVectorIndex;

Fixed in 472be4e7ef2d3c0db12793041dcc00c646d318f5!

Single, global coordinate system

C-ray doesn't use local coordinates for vertex data. All objects are transformed within the global coordinate system.

Fixed in 576d3085ab8bce5f03f7be3d2c55421754e5e749!

Object instances have their own local coordinate systems.

Left-hand coordinate system (Y up world)

This is something that I'm looking to change, since any models you export from, say, Blender, will be mirrored on one axis.

In C-ray, X is right, Y is up, and Z is forward by default.

Fixed in a825b1c9e6342fc99920c16915a8b4ffd7da58e4!

No instancing, simple transforms~

C-ray does not support object instancing at this time. Meaning if you want multiple instances of the same mesh, you just have to load it in multiple times (thus consuming more memory)~ This is just to keep things simple, but I'm open to improvements on this regard.~

The transform system, again, is very simple.~ You can rotate models, scale them and move them around using numeric coordinates and degrees.~ Transforms are computed and applied on the actual source coordinates, before rendering.~

Fixed in 576d3085ab8bce5f03f7be3d2c55421754e5e749!

c-ray has a fairly robust instancing system now, and the transforms system is also pretty capable now.

Primitive material system

The material system is still very limited. You can't mix shaders, and there's only a few shaders that aren't very realistic. Something to work on!

Fixed, we now have a basic node-based material system. It still needs work, but is infinitely more powerful than the old one.