Skip to content

Instantly share code, notes, and snippets.

@mTvare6
Created July 9, 2026 04:53
Show Gist options
  • Select an option

  • Save mTvare6/769f9105b5d18e678c5dfa6e0b84277a to your computer and use it in GitHub Desktop.

Select an option

Save mTvare6/769f9105b5d18e678c5dfa6e0b84277a to your computer and use it in GitHub Desktop.
pclub-graphics-hire-test.tex
\documentclass[a4paper,11pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{geometry}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{listings}
\usepackage{xcolor}
\usepackage{enumitem}
\usepackage{fancyhdr}
\usepackage{tabularx}
\usepackage{framed}
\geometry{top=1.5cm, bottom=2cm, left=2cm, right=2cm}
\pagestyle{fancy}
\fancyhf{}
\lhead{\small \textbf{Graphics Recruitment Test}}
\rhead{\small Total Marks: 50}
\cfoot{\thepage}
\newcommand{\answerbox}[1]{
\begin{center}
\fbox{\begin{minipage}{0.98\linewidth}
\hfill\vspace{#1}
\end{minipage}}
\end{center}
}
\definecolor{codegreen}{rgb}{0,0.6,0}
\definecolor{codegray}{rgb}{0.5,0.5,0.5}
\definecolor{codepurple}{rgb}{0.58,0,0.82}
\definecolor{backcolour}{rgb}{0.95,0.95,0.92}
\definecolor{rustorange}{rgb}{0.8, 0.4, 0.0}
\lstdefinelanguage{Rust}{
keywords={fn, let, mut, if, else, while, for, return, impl, struct, enum, match, use, pub, mod, crate, super, self, Self, true, false},
keywordstyle=\color{rustorange}\bfseries,
ndkeywords={u8, u16, u32, u64, i8, i16, i32, i64, f32, f64, bool, char, str, String, Vec, Option, Some, None, Result, Ok, Err},
ndkeywordstyle=\color{codepurple}\bfseries,
comment=[l]{//},
morecomment=[s]{/*}{*/},
commentstyle=\color{codegreen}\ttfamily,
stringstyle=\color{codegreen},
morestring=[b]",
basicstyle=\ttfamily\footnotesize,
breaklines=true,
backgroundcolor=\color{backcolour},
numbers=left,
numberstyle=\tiny\color{codegray},
stepnumber=1,
numbersep=5pt,
tabsize=4
}
\lstdefinestyle{mystyle}{
backgroundcolor=\color{backcolour},
commentstyle=\color{codegreen},
keywordstyle=\color{magenta},
numberstyle=\tiny\color{codegray},
stringstyle=\color{codepurple},
basicstyle=\ttfamily\footnotesize,
breakatwhitespace=false,
breaklines=true,
captionpos=b,
keepspaces=true,
numbers=left,
numbersep=5pt,
showspaces=false,
showstringspaces=false,
showtabs=false,
tabsize=2
}
\lstset{style=mystyle}
\begin{document}
\begin{center}
{\LARGE \textbf{Graphics Spring Camp}} \\[0.2cm]
{\large Selection Test \hfill \textbf{Max Marks: 50}}
\end{center}
\noindent
\fbox{
\begin{minipage}{\dimexpr\textwidth-2\fboxsep-2\fboxrule\relax}
\vspace{0.2cm}
\noindent
% Adjusted columns to fix wrapping and margins:
% Col 1: 0.17\textwidth (Wider for "Priority")
% Col 2: 0.30\textwidth (Slightly narrower)
% Col 3: 0.15\textwidth (Standard)
% Col 4: 0.30\textwidth (Slightly narrower)
\begin{tabular}{@{}p{0.17\textwidth} p{0.30\textwidth} p{0.15\textwidth} p{0.30\textwidth}@{}}
\textbf{Name:} & \hrulefill & \textbf{Roll No:} & \hrulefill\hspace{0.5cm} \\[1.5em]
\textbf{Priority (1-3):} & \hrulefill & \textbf{Start/End:} & \underline{\hspace{1.8cm}} / \underline{\hspace{1.8cm}} \\
\end{tabular}
\vspace{0.1cm}
\end{minipage}
}
\vspace{0.5cm}
% --- CONTENT START ---
\section*{Passage 1: Ray-Sphere Intersection Geometry}
We define a Ray as $P(t) = O + tD$, where $O$ is the origin and $D$ is the direction.
We define a Sphere with Center $C$ and Radius $r$ as the set of points where $\|P - C\|^2 = r^2$.
To find the intersection, we substitute the Ray equation into the Sphere equation. This gives us a quadratic equation for $t$.
\begin{enumerate}
\item \textbf{[2 Marks] Geometric Miss Condition:}
Without relying on calculating the discriminant ($b^2 - 4ac$), describe the condition for "No Intersection" purely in terms of the geometry of vectors $O, D, C$ and scalar $r$. (Conceptually, when does the ray miss?)
\answerbox{2cm}
\item \textbf{[5 Marks] Solving for $t$:}
The standard quadratic formula is $t = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}$.
In the live session, we implemented the code to find the value of $t$.
\textbf{Derive the formula} or show the logical steps to find the intersection point $t$ below. \textit{Use this box for rough work; you will be graded on your derivation.}
\answerbox{6cm}
\item \textbf{[2 Marks] The Choice of Root:}
The quadratic formula produces two solutions: $t_1$ (using $-\sqrt{\dots}$) and $t_2$ (using $+\sqrt{\dots}$). In our code, we specifically looked for the root with the \textbf{minus} sign first. Why do we prefer $t = -b - \sqrt{\dots}$?
\answerbox{1.5cm}
\end{enumerate}
\section*{Passage 2: Constructive Solid Geometry \& SDFs}
Modern rendering often uses \textbf{Signed Distance Fields (SDFs)}. An SDF is a function \texttt{float map(vec3 p)} that returns the distance from point $p$ to the closest surface.
\begin{itemize}
\item If $map(p) > 0$: You are outside the object.
\item If $map(p) < 0$: You are \textbf{inside} the object.
\end{itemize}
\begin{lstlisting}[language=C]
float sdSphere(vec3 p, float r) { return length(p) - r; }
\end{lstlisting}
\begin{enumerate}[resume]
\item \textbf{[3 Marks] Intersection Logic:}
To combine two shapes (Shape A with distance $d_1$, Shape B with distance $d_2$), we use min/max functions.
\texttt{min(d1, d2)} creates the \textbf{Union}.
Which function creates the \textbf{Intersection}? \textbf{Explain why} that specific logic results in the intersection of the two shapes.
\answerbox{3cm}
\item \textbf{[2 Marks] Subtraction Logic:}
If you wanted to cut Shape B out of Shape A (Subtraction), which formula would you use?
\begin{itemize}
\item[a)] $d_1 - d_2$
\item[b)] $\max(d_1, -d_2)$
\item[c)] $\min(d_1, -d_2)$
\end{itemize}
\item \textbf{[2 Marks] Inflation (Isosurfaces):}
If we calculate a new distance field $d_{new} = d_{cube} - 0.1$, describe exactly how the visual shape of the cube changes, particularly at the sharp corners.
\answerbox{1.5cm}
\end{enumerate}
\section*{Passage 3: The Rendering Equation}
The fundamental integral that governs how light behaves is:
$$ L_o(p, \omega_o) = L_e(p, \omega_o) + \int_{\Omega} f_r(p, \omega_i, \omega_o) \, L_i(p, \omega_i) \, (\omega_i \cdot n) \, d\omega_i $$
\begin{enumerate}[resume]
\item \textbf{[2 Marks] The Cosine Term:}
What physical phenomenon does the term $(\omega_i \cdot n)$ account for?
\answerbox{1.5cm}
\item \textbf{[2 Marks] The F Term:}
What does the term $f_r$ (the BRDF) represent in this equation?
\answerbox{1.5cm}
\item \textbf{[2 Marks] The L Term:}
What does $L_i(p, \omega_i)$ represent?
\answerbox{1.5cm}
\item \textbf{[2 Marks] Color Mixing:}
A ray hits a pure \textbf{Red} wall ($1.0, 0.0, 0.0$) and then bounces to hit a pure \textbf{Blue} wall ($0.0, 0.0, 1.0$). What is the resulting color of that ray?
\begin{itemize}
\item[a)] Purple ($0.5, 0.0, 0.5$)
\item[b)] Black ($0.0, 0.0, 0.0$)
\item[c)] White ($1.0, 1.0, 1.0$)
\end{itemize}
\end{enumerate}
\section*{Passage 4: Implementation Details}
\begin{enumerate}[resume]
\item \textbf{[2 Marks] Fuzz Factor:}
We implemented metal reflection as: \texttt{ray\_dir = reflected + fuzz * random\_vector}.
If we want to simulate \textbf{Chalk} (matte), what is the ideal value for \texttt{fuzz}?
\answerbox{1cm}
\item \textbf{[3 Marks] Shadows:}
We did not write any specific code like \texttt{if (is\_blocked) return black}. How did shadows appear in our final render?
\answerbox{2cm}
\item \textbf{[3 Marks] Recursion Limit:}
We set \texttt{\#define MAX\_DEPTH 10}. If we changed this to \texttt{1}, we would essentially see the Sky Gradient where there is nothing. But what would we see where the \textbf{Glass/Mirror} spheres are?
\answerbox{2cm}
\item \textbf{[2 Marks] Missing Keyword:}
In GLSL, we defined \texttt{bool hit\_sphere(Ray r, out Hit rec)}. Why does the image break if we remove the \texttt{out} keyword?
\answerbox{1.5cm}
\item \textbf{[2 Marks] Aspect Ratio:}
If we strictly mapped coordinates from 0 to 1 without correcting for Aspect Ratio, what happens to the spheres on a wide monitor?
\answerbox{1.5cm}
\item \textbf{[2 Marks] The Epsilon:}
In \texttt{world\_hit}, we ignored hits closer than $0.001$. Why not just use $0.0$?
\answerbox{1.5cm}
\item \textbf{[3 Marks] Reflection Math:}
Write the vector formula to calculate the reflection vector $R$, given incoming vector $I$ and normal $N$.
\answerbox{2cm}
\item \textbf{[2 Marks] Gamma Correction:}
We applied \texttt{col = sqrt(col);} at the end. Why is this necessary for monitors?
\answerbox{1.5cm}
\end{enumerate}
\section*{Passage 5: Rust Comprehension}
\begin{enumerate}[resume]
\item \textbf{[4 Marks] Iterator Invalidation:}
The rule in Rust is: \textit{You cannot modify a collection while iterating over it.}
Explain why the following code is memory unsafe and why the compiler prevents it:
\begin{lstlisting}[language=Rust]
let mut list = vec![1, 2, 3, 4];
for num in &list {
if *num == 2 {
list.push(5); // Compiler Error
}
}
\end{lstlisting}
\answerbox{2.5cm}
\item \textbf{[3 Marks] Move Semantics vs Copy:}
In Rust, complex types (like Strings) "Move" ownership, meaning the old variable becomes invalid. However, primitive types (like integers) "Copy".
Given this code:
\begin{lstlisting}[language=Rust]
fn main() {
let mut a = 2;
let mut T = [1, a, 3]; // We put 'a' into an array
println!("{}", a); // We try to print 'a'
}
\end{lstlisting}
Does this code compile? If so, what does it print? If not, why?
\answerbox{2cm}
\end{enumerate}
\end{document}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment