EntityAutoFade entity,near#,far#
Parameters
|
entity - entity handle near# - distance in front of the camera at which the entity starts to fade far# - distance in front of the camera at which the entity is fully faded out (invisible) |
Description
|
Enables auto fading for an entity, so its alpha drops off with distance from the camera. Closer than the near distance the entity is drawn at full alpha. Between near and far its alpha scales down smoothly, and beyond far it is not drawn at all. As entities approach the camera they fade in instead of popping into view. This is a cheap way to soften the moment distant objects reach the camera's far range - set the fade band just inside your CameraRange far value and scenery will melt away instead of being clipped. It is also handy for de-cluttering: fade out minor props before they reach the horizon. The fade multiplies with the entity's own EntityAlpha. Auto fade applies per entity - children are not affected. See also: EntityAlpha, CameraRange, CameraFogMode. |
Example
; EntityAutoFade Example ; ---------------------- Graphics3D 640,480,0,2 SetBuffer BackBuffer() camera=CreateCamera() PositionEntity camera,0,1,-5 light=CreateLight() RotateEntity light,45,45,0 ; A long corridor of crates on alternating sides Dim crates(19) For i=0 To 19 crates(i)=CreateCube() x#=-2 If i Mod 2 Then x=2 PositionEntity crates(i),x,0,i*3 EntityColor crates(i),255,150,50 ; Each crate is solid up to 10 units from the camera, then fades ; out until it is invisible at 20 units EntityAutoFade crates(i),10,20 Next While Not KeyDown(1) ; Spin the crates so the scene is alive For i=0 To 19 TurnEntity crates(i),0,1,0 Next ; Arrow keys fly the camera along the corridor If KeyDown(200) Then MoveEntity camera,0,0,0.1 If KeyDown(208) Then MoveEntity camera,0,0,-0.1 If KeyDown(203) Then TurnEntity camera,0,1,0 If KeyDown(205) Then TurnEntity camera,0,-1,0 RenderWorld Text 0,0,"Arrow keys: fly along the corridor Esc: exit" Text 0,20,"EntityAutoFade crate,10,20 - crates fade in as you approach" Flip Wend End
Index