lights

Blitz3D Forums/Blitz3D Beginners Area/lights

Ben(t)(Posted 2008) [#1]
so i want to use just the l8 lights that dx7 can supply, and i have code on how to make them fade away so that no more than 8 are active at a time, but here is my question. how do i deactivate a light on just one entity?


Stevie G(Posted 2008) [#2]
EntityFx Entity, 1


Matty(Posted 2008) [#3]
Unless he wishes for only some lights and not others to affect an entity (of which I have no idea how to achieve with blitz hardware lights).


GfK(Posted 2008) [#4]
Unless he wishes for only some lights and not others to affect an entity (of which I have no idea how to achieve with blitz hardware lights).
The only way you could do that is with multi pass rendering.


Ben(t)(Posted 2008) [#5]
would that slow down my game all that much? The multi rendering


Mortiis(Posted 2008) [#6]
Yes, why do you need that effect? Maybe we can figure out another way to mimic the effect you want.


Ben(t)(Posted 2008) [#7]
I want my characters to change thier lighting if they were to go under a bridge for example, but I have a onverhead light that is light type 1 basically a sunlight. i want it to not shine on units if they are not visible to its light


GfK(Posted 2008) [#8]
would that slow down my game all that much? The multi rendering
No it won't slow it down at all. You're only rendering the same number of polygons - you're just doing it in two passes instead of one.


puki(Posted 2008) [#9]
If you have a spare light then you can use a black light under the bridge or you can use black mesh-lighting: http://www.blitzbasic.com/codearcs/codearcs.php?code=2020


Mortiis(Posted 2008) [#10]
are you the real puki? :D it's been a very long time.


Ben(t)(Posted 2008) [#11]
that works really well, thanks!


Ben(t)(Posted 2008) [#12]
is there a limit to how many fake lights i can use at once?


puki(Posted 2008) [#13]
I just applied a million fake light calls on that little sucker. Blitz didn't seem to care. However, I am not sure whether or not it can keep up with blending that much.

I have further called 10 million fake lights. Again, Blitz3D did not complain.

Play around with it.

Use a loop with LightMesh ent, rand(255), rand(255), rand(255), rand(-50,50), rand(-50,50), rand(-50,50)

That will throw random colour lights from random directions.


Ben(t)(Posted 2008) [#14]
i have this function for my lighting right now and the lights are either on or off, can anyone suggest some way to make the lights have a smoother transition rather than being on or off?


Function lights(entity)
LightMesh entity,-255,-255,-255
For l.light=Each light
PointEntity l\entity,entity
If EntityDistance(entity,l\entity)<=l\range#*2 And EntityVisible(l\entity,entity) Then
TFormPoint 0,0,0,l\entity,entity ; bypass the limits of LightMesh's fake light coordinates
LightMesh entity,l\r#,l\g#,l\b#,l\range#,TFormedX(),TFormedY(),TFormedZ(); re-apply fake lighting
EndIf
Next
End Function


puki(Posted 2008) [#15]
Alter the LightColor.


GfK(Posted 2008) [#16]
I have further called 10 million fake lights. Again, Blitz3D did not complain.
Why should it? You're only changing the vertex colours. You can do that til you drop down dead of boredom and Blitz will continue happily.


Ben(t)(Posted 2008) [#17]
what about tformpoint? does that use a lot of processing?


Matty(Posted 2008) [#18]
tformpoint and the other tform commands are very fast, they are just transforming between coordinate systems which is some simple matrix mathematics.


Ben(t)(Posted 2008) [#19]
what about entity visible?


Matty(Posted 2008) [#20]
EntityVisible is a slower command, as it is pretty much a line pick, and depends upon the complexity of the geometry involved.


Ben(t)(Posted 2008) [#21]
is there a faster comand that does the same thing


Ben(t)(Posted 2008) [#22]
odd, for some reason tformpoint slows down my computer but entityvisible does not.


Ben(t)(Posted 2008) [#23]
actually i think its the way i utilize the code, here

Function lights(entity)
LightMesh entity,-255,-255,-255
LightMesh entity,64,64,64
For l.light=Each light
If EntityVisible(l\entity,entity)=True Then ;l\visible#=1

l\r#=l\r#+10
l\b#=l\b#+10
l\g#=l\g#+10

Else
l\r#=l\r#-10
l\b#=l\b#-10
l\g#=l\g#-10
EndIf

If l\r#<0 Then l\r#=0
If l\g#<0 Then l\g#=0
If l\b#<0 Then l\b#=0

If l\r#>l\fr# Then l\r#=l\fr#
If l\g#>l\fg# Then l\g#=l\fg#
If l\b#>l\fb# Then l\b#=l\fb#

If l\r#>0 Or l\b#>0 Or l\g#>0 Then
TFormPoint 0,0,0,l\entity,entity
x#=TFormedX()
y#=TFormedY()
z#=TFormedZ()
LightMesh entity,l\r#,l\g#,l\b#,l\range#/10,x#,y#,z#
EndIf

Next
End Function


Matty(Posted 2008) [#24]
It will be the lightmesh command not the tformpoint that slows things down. The lightmesh command has to, internally, set the vertex colors of each vertex of the mesh. The tformpoint command simply takes a vector and transforms it from one space into another - it is not slow.


Ben(t)(Posted 2008) [#25]
any way to speed it up?


Matty(Posted 2008) [#26]
Use hardware lights, other than that I'm not sure. Although as you are already aware you are limited to 8 hardware lights.