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 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*.
|
|
![]() |
![]() |
*lightscale* in Fig.3 is set at "10", in Fig.4 is "20". |
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'. |
|||
![]() |
![]() |
![]() |
![]() |
|
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. |
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; |
|
*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). |
||
![]() |
![]() |
![]() |
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); |