In previous topic " How can I obtain the sky vectors for a image based sky?", I was able to get the sky vectors with Greg’s help. However, I am wondering how to calculate the direct sunlight contribution. My initial thought was to extract the sun pixels from the sky HDR (as shown in Fig. 1) and map them into sky glow. However, when I used mksource to generate sources for direct calculation, no sources were generated.
The mksource command creates sources from bright areas in a captured sky. It is not meant to be applied to a generated sky, which has only the sun, and it is already labeled as a source.
I don’t know what is in your “sky2025-01-02_1240.rad” file, or what you are really hoping to accomplish. The position of the sun is known and produced in the gensky output.
The file directSky/2025-01-02_1240.hdr is shown in Fig.1.
I want to calculate the direct sunlight contribution jusk like what is done in five-phase method, the difference is that I use rpict to calcuate it rather than rcontrib.
OK, that makes more sense now that I understand this is in fact a mapped sky.
Your calculation should produce a source for the sun at least. I am not sure what is going wrong, though this is rather an extreme input for a tool that was only tested on natural environment captures.
Can you send me your HDR image? I would like to test this, myself. (I can probably regenerate the image if that is too difficult to send.)
I tried mksource using an image I generated, and it did produce a light source, although it seemed to underestimate the intensitt of the sun by a factor of 2 or so.
I noticed a potential bug on 32-bit machines for the -d setting you used, which I fixed and updated on CVS. The new binaries should be created sometime this weekend from that if you want to give that a try to see if it helps.
I am still not sure that your mapping of the sky is correct – where did you get your formula?
My formula for the mapping of sky derived from Paul Debevec’s paper “Image Based Lighting”. However, I have modified it into -Y axis. It seems that it’a a Equi-angular projection.
Well, it’s not actually an equi-angular projection, whose angle is proportional to the distance from the image center. The formula you have is for a light probe, whose angle is twice the arcsin of the distance to the center, I think.
In any case, did you wait for mksource to finish in your initial test? Because my run is still going after 24 hours, on an admittedly slow laptop, but still. I think the -d setting is excessive, and maybe yours just never finished. You may be able to get by with -d 500000 or so, instead. You are trying to see a very small source, admittedly.
I would recomend switching to 180° fisheye captures and the “fisheye.cal” file included with Radiance (below) if you are rendering with the -vta option.
Cheers,
-Greg
{
Calculate coordinates for a 180 degree fisheye lens.
Assume view direction is (0,1,0), view up (0,0,1), (1,0,0) right.
4/30/90
}
fish_Rxz = sqrt(Dx*Dx + Dz*Dz);
fish_Ry = Acos(Dy) / PI;
fish_u = .5 + Dx/fish_Rxz * fish_Ry;
fish_v = .5 + Dz/fish_Rxz * fish_Ry;
The modified formula I used is the same with the formula in fisheye.cal.
{
angmap1.cal
Convert from directions in the world \
(Dx, Dy, Dz) into (u,v) \
}
d = sqrt(Dx*Dx + Dz*Dz);
r = if(d, 2*0.159154943*acos(-Dy)/d,0); // 2*0.159154943=1/pi
u = 0.5 - Dx * r;
v = 0.5 + Dz * r;
I also test the fisheye.cal and found the rendering result is the same with my previous.
Calculating the altitude and amuzith value of the sun
θ = arctan [(581-400)/(408-400)]=87.46923698°
φ = ((581-400)^2+(408-400)^2 )^0.5/400 * (pi/2) * 180/pi = 40.76476°
vectors X = (sinφcosθ, sinφsinθ,cosφ) = (0.028831736, 0.652318028, 0.757396806)
since the center of the image is expected to -Y, X should be rotate 90° round the X axis, then X’ = (-0.028831736, -0.757396806, 0.652318028), the sun vectors should be (-0.028831736, -0.757396806, 0.652318028).
Calculating the luminance of the sun, L = Ev/Ω/179=13135.194/0.00114432/179=64126.27