Carnival2
By Martin CalcaterraI used my A6 and A4 implementations for reference, too. A6 for mirror properties and transformations, A4 for pane boundaries.
Feature: Square Object Type
A new type of object used for rendering squares. Primarily used for mirror panes in this project.
Has 3 object-specific properties to be set in .json:
translate: the position of the bottom right corner of the square in 3D space.scale: size of the square (width and height).rotate: rotation around the Y axis in radians (could add more axes, left here for simplicity).mirrortype: id used for normal calculation
Square.h defines this type, and read_json.h has been augmented to read
the format from .json.
As it is a child of Plane, read_json.h uses the first 3 parameters to compute
its Plane parameters as well.
Feature: Fun Mirrors
In order to augument a square with a mirror with fun properties, Square.cpp computes
normals differently based on the square’s mirrortype.
The 3 positional parameters for a square map any point on the square to a canonical unit square:
[0, 0, 0], [1, 0, 0], [1, 1, 0], [0, 1, 0]
This is done with transformation matrices.
Any point on the plane that maps outside this canonical square is not on the square. Much like the A4 box interval checking, but in 2D.
The custom normals are computed by slightly rotating the square’s normal as a function of the xy position of the intersection on the canonical square.
For example, mirrortype==4 uses Perlinn Noise to perturb the normals.
perlinn_noise.cpp, smoothstep.cpp, and randomvec.cpp (as well as their headers) have the logic
for Perlinn Noise (structured very similarly to A6).
Mini Feature: Realistic Mirrors
Mirrors reflect slightly more green light than they do other colours, and I wanted this little feature modelled in my samples, as I find mirror tunnels fun.
I’ve tweaked the km for a mirror in carnival2.json to [0.9, 0.999, 0.9]
In the piece, you can see that reflections turn slightly greener the more nested they are :) .
Acknowledgements
CSC317 Fall 2025 A3, A4, and A6 starter code.
Including Eigen.
Also Vsauce for this mirror explanation.
And thanks to the teaching team! I wouldn’t be able to produce this without their support during the term.
Credit to Gigi DG for Noisemaster and Mutemaster designs.
Tool for creating renders
I used godbolt to help with writing the json files from scratch. i.e. figuring out where the square and triangle coordinates should go.
https://godbolt.org/z/EM7nv4oG9
This link shouldn’t expire, but in case it does, I’ve added the source I used in
godbolt/.











