|
entity - entity handle fx - effect flags, added together: 0: none (default) 1: full-bright - ignore scene lighting 2: use vertex colours instead of the brush colour 4: flat shaded 8: disable fog 16: disable backface culling - draw both sides of every triangle 32: force alpha blending - required for per-vertex alpha |
|
Sets miscellaneous rendering effects for an entity. Flags add together, so a value of 3 (1+2) gives an entity that is both full-bright and vertex-coloured. Flag 1 takes the entity out of the lighting calculation entirely, drawing it at full strength - the flag for skyboxes, HUD props, glowing pickups and anything that must stay readable in a dark room. Flag 2 tells the renderer to use the colours you set with VertexColor rather than the brush or entity colour, which is how you bake per-vertex tinting into effect meshes; add flag 32 as well if those vertex colours carry alpha, since per-vertex transparency only appears once alpha blending is forced on. Flag 4 gives faceted, flat-shaded lighting - useful for a deliberately low-poly, retro look. Flag 8 exempts the entity from camera fog, which is what you want for a skybox (fogging the sky makes the horizon look wrong) and for HUD elements drawn in 3D. Flag 16 switches off backface culling so both sides of each triangle are drawn: the flag for single-plane geometry like leaves, fences, banners and grass cards, which would otherwise vanish when seen from behind. It roughly doubles the fill cost for that entity, so use it only where it is needed. The setting replaces whatever was there before rather than adding to it, so pass the full combination each time. It applies to the entity as a whole; for effects on individual surfaces use BrushFX with PaintSurface. See also: BrushFX, VertexColor, EntityBlend, EntityColor, PaintSurface. |
; EntityFX Example
; ----------------
Graphics3D 640,480,0,2
SetBuffer BackBuffer()
camera=CreateCamera()
; Fog tints distant objects, so the disable-fog flag is easy to spot
CameraFogMode camera,1
CameraFogRange camera,1,15
CameraFogColor camera,100,100,140
CameraClsColor camera,100,100,140
light=CreateLight()
RotateEntity light,45,45,0
; A green orb pickup to apply effects to
orb=CreateSphere(16)
PositionEntity orb,0,0,10
EntityColor orb,0,255,0
mode=0
While Not KeyDown(1)
; Space cycles through the fx modes
If KeyHit(57) Then mode=(mode+1) Mod 7
; Each mode is a single flag: 0,1,2,4,8,16,32 (flags may also be added together)
If mode=0 Then fx=0 Else fx=1 Shl (mode-1)
fx_name$="nothing (default)"
If fx=1 Then fx_name="full-bright"
If fx=2 Then fx_name="use vertex colors"
If fx=4 Then fx_name="flatshaded"
If fx=8 Then fx_name="disable fog"
If fx=16 Then fx_name="disable backface culling"
If fx=32 Then fx_name="force alpha-blending"
; Apply the current effect to the orb
EntityFX orb,fx
TurnEntity orb,0,1,0
; Arrow keys move the camera
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,"Space: next fx mode Arrows: camera Esc: exit"
Text 0,20,"EntityFX orb,"+fx+" ("+fx_name+")"
Flip
Wend
End