My RenderMan Study

Back



First, I observed 'Lens Flare' effect of Photoshop, and by utilizing a pixel-coordinates, I indicated on a table how flares change their positions with the movement of the lens center. And, using this data, I wrote the shader, *KTlensflareV.sl*. This is a volume shader, and calculates the positions of flares automatically.

Fig.1 Fig.2
Fig.1 is the 'Lens Flare' image of Photoshop. Fig.2 is the image of KTlensflareV.sl. Here is the RIB.



What settles the positions of flares is the center of a lens. I call it *SunP* in KTlensflareV.sl. By changing this parameter, the center of a lens can be moved. This parameter is a vector, also its coordinates is defined in '"camera" space'. In addtion, the intensity of lens light and lens sparkle can be controlled by the parameters *Highlight_intensity* and *light_intensity*. And in Fig.3 and Fig.4, we can see the effect of the sparkle parameter, *lightscale*.

Fig.3
Fig.4
*lightscale* in Fig.3 is set at "10", in Fig.4 is "20".

Here is the code,
lighttheta=noise(lightscale*lighttheta);
lighttheta=clamp(lighttheta,light_min,light_max);
lighttheta=(lighttheta-light_min)/(light_max-light_min);
lighttheta=lighttheta*pow(lightdis+1,-(light_roughness));
lighttheta*=light_intensity;
Ci=Oi*mix(Ci,lightcolor,lighttheta);



KTlensflareV.sl can calculate 13 flares. Naturally, this shader has the parameters for opasity(as the float a of mix()), color, size (as the radius of a flare), and type for all of the 13 flares.
The flare type in Fig.5 is 'clamp', in Fig.6 is 'sine', in Fig.7 is 'step', and in Fig.8 is 'specular'.

Fig.5
Fig.6
Fig.7
Fig.8

Here is the example code,
max_ring_sL1_1=0.98;
r=judge_sLP1_1/ring_sL1_1;
dis=r;
r=clamp(r,0,max_ring_sL1_1);
r/=max_ring_sL1_1;

if (type_s1_1=="clamp") {
r=r-smoothstep(max_ring_sL1_1,1,dis);
}
if (type_s1_1=="sine") {
r=sin(r*(PI/2));
r=r-smoothstep(max_ring_sL1_1,1,dis);
}
if (type_s1_1=="step") {
r=1-smoothstep(max_ring_sL1_1,1,dis);
}
if (type_s1_1=="specular") {
r=pow(1+dis,s_roughness);
}

r*=max_mix_sL1_1;
ci_s1_1=mix(Ci,cs_s1_1,r);



Also, the size parameter (as mentioned above, the radius of a flare) can be regarded and set as a size (or unit) of 'ScreenWindow' in RIB. This is because KTlensflareV.sl has the parameter *fov* which needs to be set at the value of "fov" in RIB.
Here is the code,
r_unit=tan(radians(fov/2));
judgeS=distance(SWP,SWSunP)/r_unit;
judgeLP1=distance(SWP,SWLensP1)/r_unit;
judgeLP2=distance(SWP,SWLensP2)/r_unit;
judgeLP3=distance(SWP,SWLensP3)/r_unit;
judgeLP4=distance(SWP,SWLensP4)/r_unit;
judgeLP5=distance(SWP,SWLensP5)/r_unit;
judgeLP6=distance(SWP,SWLensP6)/r_unit;
After this,
if (judgeS<*the size parameter of a flare*) {
/*(as mentioned above, give opacity, color, and type.)*/
}
......
*fov* as well as "fov" in RIB In Fig.9 - Fig.11 is set at "60", also 'flameaspect' is 2.
The size paramete of a flare In Fig.9 and Fig.10 is set at "0.5", In Fig.11 is "1".
'ScreenWindow' in RIB In Fig.9 and Fig.11 is '-2 2 -1 1' (i.e. the size is 4*2), In Fig.10 is half (i.e. 2*1).
Fig.9
Fig.10
Fig.11




Last but not least, KTlensflareV.sl supports 'fog' effect when the string parameter *fog* is "on". By the way, 'fog.sl' should be the following, I think...
fog_d=1-exp(-length(I)/distance);
Ci=Oi*mix(Ci,background,fog_d);