lighting problem!

Blitz3D Forums/Blitz3D Beginners Area/lighting problem!

gingerprince(Posted 2003) [#1]
When running the following code the light seems to flick

on and off the sides of the box in an unrealistic fashion.

How can it be remedied? Only happens with point(2) &

spot(3) light settings.

CODE:-

Graphics3D 800,600

SetBuffer BackBuffer ()

camera = CreateCamera ()

light1=CreateLight (3) ;POINT LIGHTING

CameraViewport camera,0,0,GraphicsWidth (),GraphicsHeight ()

mybox = LoadMesh ( "boxtest1.b3d" )

mybox_texture = LoadTexture ( "boxtest1texture.bmp")

EntityTexture mybox,mybox_texture

MoveEntity mybox,0,0,12 ;MOVE BOX IN VIEW

MoveEntity light1,5,5,5 ;MOVE LIGHT TO POSITION

PointEntity light1,mybox ;POINT LIGHT AT BOX

While Not KeyHit (1)

TurnEntity mybox,.3,.2,.1

UpdateWorld

RenderWorld

Flip

Wend


jhocking(Posted 2003) [#2]
It's nice that you posted the code but I'm guessing the problem is mostly due to your model. In particular note that dynamic lighting is vertex based (it is Gouraud shading.) Thus the lighting on huge polygons (and a box is often just a few huge polygons) can flicker because the lighting is only affecting very few vertices on the corners. If the flickering is looking really bad and you want more realistic lighting across the box's surface try tessalating it (ie. splitting up the polygons into smaller polygons) to increase the density of vertices.


gingerprince(Posted 2003) [#3]
cheers.It all makes sense.

Is vertex dynamic lighting the only form of lighting?

GP


jhocking(Posted 2003) [#4]
For dynamic light yes. For static lighting however you can use lightmaps (ie. lighting/shading baked into textures) and set the mesh to "fullbright" so that dynamic lights in your game don't affect it.


gingerprince(Posted 2003) [#5]
Does that mean that for example a textured mesh,say a wooden box,if stationary within a scene can be lit by a lightmap? And then save the dynamic lighting for high polygon models (like a game character) where lighting effects would work ok?

gp


jhocking(Posted 2003) [#6]
Yes, that's exactly what I mean. Typically lightmaps are applied to the scenery/level (because typically the scenery/level is static.) Some level editing/modeling tools can generate lightmaps (Maplet, Cartography Shop, Quill, 3D Studio Max, etc.) or you can use a separate lightmapping tool like Lightbulb to lightmap models created elsewhere.


gingerprince(Posted 2003) [#7]
thanks...