DX lights don't calculate light intensity by normals, do they?
Blitz3D Forums/Blitz3D Programming/DX lights don't calculate light intensity by normals, do they?
| ||
I just noticed that a face on a spinning cube will either be fully lit or unlit, but there is no falloff as the face approaches parallel with the light position. Run this Blitz3D code and then look at this OpenGL demo: http://www.leadwerks.com/demo.zip The OpenGL demo uses coded vertex lights, not GL lights. I don't know if GL lights behave like DX lights or not. Graphics3D 800,600,32,2 SetBuffer BackBuffer() l=CreateLight(2) PositionEntity l,100,0,0 cam=CreateCamera() MoveEntity cam,0,0,-20 world=CreatePivot() Dim box(200) For n=0 To 100 box(n)=CreateCube(world) MoveEntity box(n),Rnd(-10,10),Rnd(-10,10),Rnd(-10,10) ScaleMesh box(n),.5,.5,.5 Next While Not KeyHit(1) TurnEntity world,0,1,0 RenderWorld Text 0,0,FPS() Flip Wend End Global fpstime Global lastupdate Global oldfps Function FPS() oldtime=fpstime fpstime=MilliSecs() elapsed=fpstime-oldtime If Not elapsed elapsed=1 time=Int(MilliSecs()/1000) If time>lastupdate lastupdate=time oldfps=1000/elapsed EndIf Return oldfps End Function |
| ||
Halo, after your CreateCube(), put an "UpdateNormals" .. then it will do the normal shading (if that is what it is..) instead of the face lighting. Tracer |
| ||
Blitz's UpdateNormals() command averages the normals of the vertices out, and because the normals are pointed different directions, the faces will get some blending across them. But you'll notice that the vertex lighting still pops in and out. Any vertex is either 100% lit, or 100% unlit. Add an AmbientLight 0,0,0 call to see this better. If you then run the OpenGL example, you'll see that the vertices smoothly illuminate as they turn to face the light source. I always thought Blitz lights looked liked they "popped" in and out. I wonder if that's DX or Blitz, and if OpenGL lights do the same thing. I uploaded 2 exe's: http://www.leadwerks.com/compare.zip |
| ||
most likely Blitz, i've not seen my codings in DX9 or OpenGL do this yet .. but then, it may be DX7 and it's fixed in DX9 :) You can also use entityfx to select the use of the entity's vertex colors, but that's not what you're looking for i think. But you never know.. :) Tracer |
| ||
I've had it do the same. Blitz's lighting is a bit whacky. |
| ||
changing the light to directional seemed to make it a bit smoother after updateing normals, or when i loaded a cube from a modeler with a smooth group of 90. Thats kinda strange, its seems like a directional light should "pop in " more than a point light. Graphics3D 800,600,32,1 SetBuffer BackBuffer() cube=CreateCube() UpdateNormals cube AmbientLight 0,0,0 light=CreateLight(1) PositionEntity light,30,0,-30 camera=CreateCamera() PositionEntity camera,0,0,-3 While Not KeyHit(1) TurnEntity cube,.5,.5,1.1 UpdateWorld RenderWorld Flip Wend End Zmatrix |
| ||
The lights work just fine. Halo just doesn't know how to use them. Adding this command will fix things: LightRange L, 100 The reason the light seems to change instantly, is because the default light radius is 1000, and this means that the light brightens up everything within that radius 100% or more. The falloff is OUTSIDE that range. Being that it brightens everything 100% or more, the angle of the surface to the light ends up having little effect. There is a change in brightness but it's very breif. 10% of 10,000 is still 1000 after all. So with the ligth that bright and that close with that kind of range, only the polygons which are most angled away from the light will fall into the 0..255 range. So they appear to flash on instantly. If you rotated the cubes MUCH slower then you might be able to see a gradual change then. |
| ||
That looks a lot better. |
| ||
Live and learn... live and learn... [gently nodding] |
| ||
A nice side effect of this is that you can make lighting that kinda looks like cel shading where the change in brightness is swift. |
| ||
Yeah lightrange always worked for me :) |