Inverted Normals in Raytracer I am having the following issue. I am working on a ray tracer for school and I am trying to render a sphere where the radiance of a intersection point is the dot product of the ray direction and the normal at the point of intersection. This works fine if return the inverted normal ( i.e. a vector going from the intersection point to the center of the sphere but not the other way around as it should be ) and I can't figure out what I messed up. Anyone have a intuitive clue on what I could have messed up? Can't really post code here as it's a school task but feel free to ask for further information and I am trying to provide as best as I can. (left: inverted normals, right: right normals)
The issue is, that you considered that the rays coming from the camera to be the light carrying rays. Instead, the rays bounce off the surface, and return to the light source (which you have decided to position at the camera). This means that your light direction is not $\pmb{d}$ but rather $-\pmb{d}$, then $\cos\theta = - \pmb{d} \cdot \pmb{n}$, provided that both vectors are normalized.

Also, you really want to try to retirn the correct normal, as it is, your current code will return the wrong normal if the camera is inside the sphere. So your normal should be:
n = dot(n,d)&lt;0 ? n : -n;, where n is the normal returned by your surface, and d is the ray direction for the ray that intersected the surface.