# Solid angle in a cube

Consider this picture. I need to integrate a function of spatial position and direction for the entire volume of the cube. So for example at point (x1,y1,z1) I need to integrate for the distance s and all the surface area of the cube.
Normally I would just integrate with a volume element dAds* were dA can be dxdy* or dxdz* or dydz*, depending on the surface of the cube.
However the solid angle about s is projected on the wall.
So should I multiply the volume element with the cosine of the angle between the normal of each surface with s?

Consider a box $$B=[a_1,b_1]\times[a_2,b_2]\times[a_3,b_3]\ ,$$ and assume that the "origin" $p=(p_1,p_2,p_3)$ is in the interior of $B$. In order to compute the volume integral $\int_B f(x)\>{\rm d}(x)$ you can go ahead as planned and compute six integrals over pyramids $P_k$ having a face of $B$ as base.
Consider as an example the integral corresponding to the face $x_1=b_1$ of $B$. This face is parametrized by $$(u,v)\in[a_2,b_2]\times[a_3,b_3]=:F\ .$$ A parametric representation of the corresponding pyramid $P$ is then given by $$x=(1-t)p+t\bigl(b_1, u,v\bigr)\qquad\bigl(0\leq t\leq 1,\ (u,v)\in F\bigr)\ .\tag{1}$$ The Jacobian determinant of $(1)$ computes to $J=t^2(b_1-p_1)$. We therefore obtain $$\int_P f(x)\>{\rm d}(x)=(b_1-p_1)\int_F\>\int_0^1 t^2\>f\bigl((1-t)p+t(b_1,u,v)\bigr)\>dt\>{\rm d}(u,v)\ .$$