creating lightsources

BlitzMax Forums/BlitzMax Programming/creating lightsources

flying willy(Posted 2005) [#1]
Hi,

Since blitzmax uses 3D hardware it would be nice to have proper lights with proper attenuation.

Either through image overlays or vert cols, I would like to discuss this issue with you as my game requires lighting.

Max 2D is half baked as you have powerful visual control with lighting which wasn't available on 2D hardware. Lets make the most of it with a proper lighting system.

What do you suggest?


Wiebo(Posted 2005) [#2]
The first thing that pops into my mind is to use the additive blending with image overlays... If, for instance, you have a topdown look, you could draw the floor, add lights, draw walls, add lights, etc... That could look very cool.
For sideviews the thing becomes a bit more complicated, but vertex color could be the answer. If you break your scenery into small enough bits you could create a decent lighting system. I wouldn't know how to access the vertices of loaded images though...


flying willy(Posted 2005) [#3]
Yep I'm thinking drawing overlays. Fill rate monster though isn't it?

The game is a sideways scrolling platformer. What I would like to do is have most of it dark, and be illuminated by lighting.

There is no modulate 2x blend mode in opengl? This is sorely missed because I need this right now!

Perhaps there is a way to enable this (modulate2x) ?


Wiebo(Posted 2005) [#4]
I don't know any openGL, so I can't help you with the modulate2x stuff. Yes, fill-rate will be the determing factor in this, so smart level design is needed, or vertex colors may be the better option. I am in the process of creating a tile editor as well... I'll surely will keep you posted on my findings. Hassle me on IRC ( yes, I know who you are )


flying willy(Posted 2005) [#5]
For lighting, what would be the best blend mode?


TeaVirus(Posted 2005) [#6]
I'm using the overlay method for a top-down style game and am using two overlays to simulate modulate2x. The first is drawn with SHADEBLEND and the second is drawn with LIGHTBLEND. It's actually much faster than I thought it would be.


flying willy(Posted 2005) [#7]
I reakon I'll give that a go.


Wiebo(Posted 2005) [#8]
show us a pic of it in action.. i'd love to see it


TeaVirus(Posted 2005) [#9]


Here's a pic of something I threw together in my editor. Tileset gratuitously stolen from the Alien Breed project to use as temporary placeholders. =)


flying willy(Posted 2005) [#10]
So which parts are shaded with what? Looks nice but does this mean I have to draw all my tiles really dark?


Wiebo(Posted 2005) [#11]
Very nice, Tea Virus ( wha? )


TeaVirus(Posted 2005) [#12]
Your tiles can be drawn at whatever you consider a "normal" brightness. Take a look at the screenshots in the Alien Breed remake post to see what these normally look like. The pixels are darkened by the shadeblend image or brightened by the lightblend image based on the lighting data at that location. This is based on distance from any lights within range, falloff, and whether or not there is line of sight.


TeaVirus(Posted 2005) [#13]
Tea Virus ( wha? )


I'm a fan of the Resident Evil games... =)


Tom(Posted 2005) [#14]
Code borrowed from a flipcode article (thanks to a guy named Jeckle)

Be sure to check the paths to the textures!

Global ScreenWidth:Int=1024
Global ScreenHeight:Int=768
Global ScreenDepth:Int=32



Global tex0scale:Float=1.0 ' Modulate value, must be 1.0, 2.0 or 4.0
Global tex1scale:Float=1.0 ' same
Global useTex:Int[]=[1,1]

bglCreateContext ScreenWidth,ScreenHeight,ScreenDepth,0,BGL_BACKBUFFER | BGL_DEPTHBUFFER' | BGL_FULLSCREEN

' Needed to use Extensions
glewInit()

' Check extension support
If Not ExtensionSupported("GL_ARB_texture_env_combine") RuntimeError("GL_ARB_texture_env_combine Not supported!")


' some textures
Global tex1=bglTexFromPixmap( LoadPixmap( "E:\blitzmax\samples\birdie\misc\lightImage\media\light.png" ) )
Global tex2=bglTexFromPixmap( LoadPixmap( "E:\blitzmax\samples\birdie\misc\filmclip\media\B-Max.png" ) )

glActiveTextureARB(GL_TEXTURE0_ARB)
glBindTexture(GL_TEXTURE_2D, tex1)
glActiveTextureARB(GL_TEXTURE1_ARB)
glBindTexture(GL_TEXTURE_2D, tex2)


InitGl()

While Not KeyHit( KEY_ESCAPE )

	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)

	glColor3f(1.0,1.0,1.0)
	glActiveTextureARB(GL_TEXTURE0_ARB)
	glDisable(GL_TEXTURE_2D)
	glActiveTextureARB(GL_TEXTURE1_ARB)
	glDisable(GL_TEXTURE_2D)
	
	'glDisable(GL_LIGHTING)
	bglDrawText("Keys 1 & 2 toggle textures on & off",10,22)
	bglDrawText("Cursors left/right, up/down adjusts modulate value for both textures",10,44)
	bglDrawText("Texture 1 Modulate: "+tex0scale,10,68)
	bglDrawText("Texture 1 Modulate: "+tex1scale,10,80)
	'glEnable(GL_LIGHTING)

	DrawScene()
	FlushMem
	bglSwapBuffers
Wend
End



Function InitGl()
	glClearColor(0.5, 0.5, 0.5, 0.0)
	glClearDepth 1.0

	glEnable(GL_DEPTH_TEST)	
	glDepthFunc(GL_LESS)

	glFrontFace(GL_CW)
	glShadeModel(GL_SMOOTH)	
	glViewport(0,0,ScreenWidth,ScreenHeight)
	glEnable(GL_CULL_FACE)

	' Light
	Local lmodel_ambient#[]=[ 0.8,0.8,0.8,1.0]
	glLightModelfv(GL_LIGHT_MODEL_AMBIENT,lmodel_ambient)
	
	glLoadIdentity()
	glEnable(GL_LIGHTING)
	glEnable(GL_LIGHT0)

	Global light_position#[] = [0.0, 0.5, 5.0, 0.0]
	glLightfv(GL_LIGHT0, GL_POSITION, light_position)
	
	Global light_AMB#[] = [1.0,1.0,1.0,1.0]	
	Global light_DIF#[] = [1.0,1.0,1.0,1.0]	
	
	glLightfv(GL_LIGHT0, GL_AMBIENT, light_AMB)
	glLightfv(GL_LIGHT0, GL_DIFFUSE, light_DIF)
	
End Function



Function DrawScene()
	glMatrixMode(GL_PROJECTION)
	glLoadIdentity()
	Local aspect:Float = Float(screenwidth)/Float(screenheight)
	gluPerspective(45.0,aspect,1.0,30.0)
	
	' Toggle texture on & off
	If KeyHit(KEY_1) useTex[0]=Not useTex[0]
	If KeyHit(KEY_2) useTex[1]=Not useTex[1]

	If useTex[0]
		glActiveTextureARB(GL_TEXTURE0_ARB)
		SetTexParams()
		glEnable(GL_TEXTURE_2D)
	Else
		glActiveTextureARB(GL_TEXTURE0_ARB)
		glDisable(GL_TEXTURE_2D)
	End If

	If useTex[1]
		glActiveTextureARB(GL_TEXTURE1_ARB)
		SetTexParams()
		glEnable(GL_TEXTURE_2D)
	Else
		glActiveTextureARB(GL_TEXTURE1_ARB)
		glDisable(GL_TEXTURE_2D)
	End If
	
	If KeyHit(KEY_LEFT) tex0scale:-1.0
	If KeyHit(KEY_RIGHT)	tex0scale:+1.0

	If KeyHit(KEY_DOWN) tex1scale:-1.0
	If KeyHit(KEY_UP)	tex1scale:+1.0
	
	Modulate2x()

	glMatrixMode(GL_MODELVIEW)
	glLoadIdentity

	glTranslatef 0.0,0.0,-4.5
	glRotatef -(300-MouseY()) *.4, 1.0,0.0,0.0
	glRotatef -(400-MouseX()) *.4, 0.0,1.0,0.0	

	Local s:Float=1.0
	glBegin GL_QUADS
		glMultiTexCoord2fARB(GL_TEXTURE0_ARB,0.0, 0.0)
		glMultiTexCoord2fARB(GL_TEXTURE1_ARB,0.0, 0.0)
		glNormal3f(0.0, 0.0, -1.0)
		glVertex3f -s, s, 0.0          ' Top Left

		glMultiTexCoord2fARB(GL_TEXTURE0_ARB,1.0, 0.0)
		glMultiTexCoord2fARB(GL_TEXTURE1_ARB,1.0, 0.0)
		glNormal3f(0.0, 0.0, -1.0)
		glVertex3f  s, s, 0.0        ' Top Right

		glMultiTexCoord2fARB(GL_TEXTURE0_ARB,1.0, 1.0)
		glMultiTexCoord2fARB(GL_TEXTURE1_ARB,1.0, 1.0)
		glNormal3f(0.0, 0.0, -1.0)
		glVertex3f  s,-s, 0.0         ' Bottom Right

		glMultiTexCoord2fARB(GL_TEXTURE0_ARB,0.0, 1.0)
		glMultiTexCoord2fARB(GL_TEXTURE1_ARB,0.0, 1.0)
		glNormal3f(0.0, 0.0, -1.0)
		glVertex3f -s,-s, 0.0          ' Bottom Left
	glEnd

		
End Function


Function ExtensionSupported(ext$) ' cheers Terabit!
	Local RetStr:String=String.FromCString$(Byte Ptr(glGetString( GL_EXTENSIONS )))
	If Instr(retstr$,ext$)<>0 Return True
	Return False
End Function



Function SetTexParams()
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR)
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT)
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT)
End Function
	
	
	
Function Modulate2x()
'Program texture environment zero
glActiveTexture(GL_TEXTURE0_ARB)
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT)
glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_MODULATE)
glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_EXT, GL_MODULATE)
glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_TEXTURE)
glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_PREVIOUS_EXT)
glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE2_RGB_EXT, GL_CONSTANT_EXT)
glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND0_RGB_EXT, GL_SRC_COLOR)
glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND1_RGB_EXT, GL_SRC_COLOR)
glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND2_RGB_EXT, GL_SRC_ALPHA)
glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_EXT, GL_TEXTURE)
glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE1_ALPHA_EXT, GL_PREVIOUS_EXT)
glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA_EXT, GL_SRC_ALPHA)
glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND1_ALPHA_EXT, GL_SRC_ALPHA)
glTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE_EXT, tex0scale)
glTexEnvf(GL_TEXTURE_ENV, GL_ALPHA_SCALE, 1.0)

'Program texture environment one
glActiveTexture(GL_TEXTURE1_ARB)
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT)
glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_MODULATE)
glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_EXT, GL_MODULATE)
glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_TEXTURE)
glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_PREVIOUS_EXT)
glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE2_RGB_EXT, GL_CONSTANT_EXT)
glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND0_RGB_EXT, GL_SRC_COLOR)
glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND1_RGB_EXT, GL_SRC_COLOR)
glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND2_RGB_EXT, GL_SRC_ALPHA)
glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_EXT, GL_TEXTURE)
glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE1_ALPHA_EXT, GL_PREVIOUS_EXT)
glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA_EXT, GL_SRC_ALPHA)
glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND1_ALPHA_EXT, GL_SRC_ALPHA)
glTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE_EXT, tex1scale)
glTexEnvf(GL_TEXTURE_ENV, GL_ALPHA_SCALE, 1.0)
End Function 



flying willy(Posted 2005) [#15]
SWEET work.

can you add this to modules section so that MOD2X gets added to blend modes? it needs to be in the language.


Dreamora(Posted 2005) [#16]
i get a gray screen ...
P-M 1,5ghz, mobility radeon 9700, winxp sp2


Tom(Posted 2005) [#17]
Oops! Updated it, sorry!

Skunk: I'm not 100% what all the commands do, I'm just showing that it 'can' be done :)


Dreamora(Posted 2005) [#18]
superb works now :)

interesting effect ... the blending as it is done reminds me of stuff some people wanted to do in Blitz3D with using a texture as "blend mask" for another one


altitudems(Posted 2005) [#19]
I'd be happy with a port of gosse corupted's lighting system in nSprite Pro


flying willy(Posted 2005) [#20]
Same here, that sounds like a great little idea :)

I would code what his one does, but it's not that simple because the verts need modifying before the image is drawn.

I suggested that 2D lights be added to the Max2D module for this very reason, however many people (including a couple of dev team members) thought I was a fool for suggesting it.

I believe 2D lights in a 2D module makes every bit as sense as 3D lights in a 3D module.


ImaginaryHuman(Posted 2005) [#21]
So you are basicaly overlaying an image of a light, on top of the scene, to produce lighting?


tonyg(Posted 2005) [#22]
Tea Virus, the screenshot is fantastic.
If you can provide any more information on how you created it (a tutorial?) would be most welcome.


flying willy(Posted 2005) [#23]
I think vert lights would be less expensive.


TeaVirus(Posted 2005) [#24]
Vert lights would definitely be less expensive but won't look as good. The thing that would help here is mod2x which according to Tom's nice example above is definitely possible and will hopefully be integrated into Max2D. Disclaimer: I REALLY suck at explaining things like this but here goes:

- Create an array that will define what portions of your map are "solid". This will define the areas that block light to create shadows. This array should be higher resolution than your tile grid for your map but the larger it is the more data you have to move each frame. I’m using an array that is 4x the size of my map so since the tiles are 32x32 each “lighted pixel” will be 8x8.

- Create two tImage objects. One for the lightblend overlay and one for the shadeblend overlay. For my images sizes, I use the screen resolution plus one tile overlap for scrolling divided by 4.

- Create lights on your map with at least these attributes: Static, Red, Green, Blue, Range. I preprocess the map and add to a list in each map location (tile) which lights are visible from that location based on each light’s range. Lights that are set as "static" are pre-calculated at this point and don't slow down the game rendering.

- Create a 3 dimensional array [w,h,3] of the same size you created for the first step. This will hold the color data for the static lights. Loop through your entire map and for each “pixel” or location in the static light array add the R,G,B values for each light within range. For each light you will need to calculate falloff and line of site to the pixel based on the contents of the array in the first step.

Everything up to now is preprocessing. Now for what you do every screen refresh or so:

- When drawing a screen full of tiles from the map data, pop all of the non-static lights visible from each location drawn into a temp list. These are the dynamic lights you will need to render this frame.

- Loop through a screen sized portion of the static light data array and add the static light data for each pixel to a temp array. At the same time, calculate the light data for the dynamic lights and add it to each pixel.

- I run a 2 pass blur filter over the light data in the temp array to smooth things out and hide the low res nature of the overlays.

- At this point, you will have an array that is the size of each of the overlay images. Loop through the temp array and write the color data to each overlay image. Color values below 127 are multiplied by 2 and written to the shadeblend image and anything above is multiplied by 2 and written to the lightblend image.

- Set ScaleImage to ScreenWidth()+1 tile overlap/overlay width, ScreenHeight()+1 tile overlap/overlay height so the overlays will be scaled up to screen size. Draw the shadeblend overlay and then the lightblend overlay to the screen.

This may sound slow but if done in an optimized manner is plenty fast for a 2D game. On my 1ghz P3 laptop with Radeon Mobility I so far can maintian around 60FPS depending on the number and size of dynamic lights. Anyway, sorry for the long post...


ImaginaryHuman(Posted 2005) [#25]
Wow, sounds cool. Thanks for explaining and sharing! I am just wondering to myself.. I don't know about the speed involved, but what about using an OpenGL stencil buffer to mask off the areas that area solid, and then just render pre-drawn light images (ie increasingly concentric circles of brightness) to the backbuffer. It will be automatically stencilled and you can draw it in LIGHTBLEND or SHADEBLEND mode to combine it with the background - and can use SetColor to select a tint color? Depending on how many lights you have on-screen and how far reaching they are, this would probably be pretty quick and easy? Only thing is it wouldn't support shadow casting. Your technique is very intriguing and I'm sure it works well, but maybe the graphics processor should be doing more of the color-combining work?

I'm not sure how you would do decent shadows with this alternative technique thought - shadows depend on the lights. I guess you could just draw `shadow objects` in appropriate places that you think would normally be shady, areas which of course will be illuminated as well by any nearby lights.


flying willy(Posted 2005) [#26]
nice tips! as for me I don't need any lightsourcing, just brighter/darker radial colours so vert cols really do just fit the bill. I'm curious which module I should look at to have a crack myself...


ImaginaryHuman(Posted 2005) [#27]
You mean, setting each vertex to a given color and allowing the OpenGL engine to interpolate the color accross the image quad to act as a kind of lighting?


flying willy(Posted 2005) [#28]
Thats exactly how vertex lighting works with point lights. You have a radius, brightness etc...

I don't need a 3D engine, just high level access to the quad.

Basically, SetVertexColor v,r,g,b

We know where the verts are as they will be on each corner of the quad.

Right now we can use SetColor but it in actual fact, sets all 4 vert cols at once. So maybe I'll look at writing a command based off that...


TeaVirus(Posted 2005) [#29]
Might look good if you subdivide the quads enough. For a full screen that would probably be alot of triangles.


altitudems(Posted 2005) [#30]
@mephitis mephitis
I'm a complete novice, but in order to change each vert's color couldn't you just use the following inside glBegin()/glEnd() ?:
glColor3f(r, g, b) 'Set The Color
glVertex2D(x, y) 'Pick vert
(oops I just realized that this only creates new verts with set color! Oh well )


ImaginaryHuman(Posted 2005) [#31]
Yes you basically redefine the color before you define each vertex.

The only problem I see with this approach is that interpolation is linear and probably would create a square-ness to the lighting effect? Or does it interpolate based on `distance from the vertex` at any angle radially, rather than laterally/longitudinally?


altitudems(Posted 2005) [#32]
It's at any angle, so it doesn't look square, here take a look:




flying willy(Posted 2005) [#33]
Looks nice - how did you achieve it?


ImaginaryHuman(Posted 2005) [#34]
So to do this, in each of those quarter regions, you defined 4 quads where the center of those (where they all touch) is the light color and further towards the corners is darker? How do you handle the corners that are diagonal from the center and further away - do you have to diminish the intensity there based on how much further away it is, to get things spherical?

Also, how did you render the quads so that you would achieve the lighting effect shown? Some kind of blend mode or with alpha channels or something? To combine with the masked sprites - are they drawn after or before?


flying willy(Posted 2005) [#35]
nope...

you calculate the distance between each corner to the light source and multiply it by the light intensity plus a fudge# variable.

no-one bothers with the centre of the object tbh...


ImaginaryHuman(Posted 2005) [#36]
Okay and how do you draw it with a tint so that, in the example shown, the background is unaffected but the objects are?


flying willy(Posted 2005) [#37]
You only affect the verts you want. Obviously the BG has it's own verts (however in that shot I think the BG is just a cls color)


...edit...

For those that don't know:

I should clarify: each 2D image in blitzmax is actually 2 triangles joined up. If you join up 2 triangles the right way, you form a square.

The square is texture mapped using 3D hardware to show the resulting image... However at each corner of the square is a vertex (or control point) which you can change.

The position, rotation and color of the control point (vertex) can be changed for a variety of effects. If you move them all apart, the image scales. If you rotate them around the middle, the image rotates... and so on.

So it stands to reason if you manually color verts, the object color will change from that point, gradually to the colors of the other points. So we need to do it all manually point by point...

Since we only affect the next 4 points using SetVertexColor vertnum,r,g,b then it only applies to the next image being drawn (like set rotation etc)...


Dreamora(Posted 2005) [#38]
hmm are quads slower than tris that blitz uses 2 tris instead of 1 quad to form the 2d image representation?


teamonkey(Posted 2005) [#39]
Max2D uses quads, not tris. Whether your graphics card treets the quad as two triangles or not is up to the driver.

The theory is correct though. The square has four corners (vertices) and it's possible to colour each vertex individually. The colour is blended between the vertices.

Incidentally, is it not possible just to use OpenGL's standard lights?


flying willy(Posted 2005) [#40]
Dreamora: if you were to code a custom engine you would still find triangles slower than quads, as the triangles would need to be huge (expensive fill rate) in order to fit a texture inside it.

I don't think opengl standard lights will work for two reasons:

firstly, the co-ordinate system may be different to max2D, and secondly there seems to be fullbright lighting in effect now, which could interfere with it.

Lighting is a really important part of 2D which is now here to stay.

For people to claim lights have no part in 2D, then I ask them to have the same reaction when 3D introduced lights.

The question isn't if we should have lights. The question is why aren't lights already available?

I have worked in art for many years previously, and I assure you, lighting is paramount in 2D and 3D. There's no argument against...

Therefore the omission of lighting in 2D is a large oversight.


teamonkey(Posted 2005) [#41]
firstly, the co-ordinate system may be different to max2D

It's not.

and secondly there seems to be fullbright lighting in effect now, which could interfere with it.

GL lighting isn't enabled, which is why everything's full brightness. Switch lighting on, dim the ambient light, add a few spot lights...

I know that it requires some OpenGL knowledge, but it should be at least possible and you can easily hide it inside some easy-to-use functions.


ImaginaryHuman(Posted 2005) [#42]
Yes, no reason why you couldn't use OpenGL lights. An image quad is just a polygon like any other in 3D space.

Also, isn't it kind of time consuming to change the vertex colors of all the vertex's for all objects, rather than just do a render of a light-image with a particular blend mode or stencilling??


flying willy(Posted 2005) [#43]
Also, isn't it kind of time consuming to change the vertex colors of all the vertex's for all objects, rather than just do a render of a light-image with a particular blend mode or stencilling??


Not quite. Each frame, Blitzmax is creating brand new polygons each and every frame, instead of re-using existing meshes with lighting.

Also, adding a single light adds a performance hit. Lights are never free anyway...

That said, I would be willing to use OpenGL lights if someone could teach me how it's achieved... :)


altitudems(Posted 2005) [#44]
I don't think that hardware lights are the way to go for tile based games. Your pretty much limited on the number of lights you can have (8 usualy), every poly will be effected when lighting is enabled, and calculating each vertex color yourself allows for real flexability. A simple SetVertexColor command, or overlayed image based lighting, would be perfect, most of the time.
Or if someone wants to port this:
http://www.gamedev.net/reference/articles/article2032.asp

That would be cool too!

@mephitis mephitis
If you want to know how openGL lighting works there is a great tutorial right here:
http://www.sjbaker.org/steve/omniv/opengl_lighting.html


teamonkey(Posted 2005) [#45]
Your pretty much limited on the number of lights you can have (8 usualy)

Remember that's a minimum of 8 lights per vertex. You can move lights during the draw cycle, switch them on or off etc.

That's a lovely article on gamedev. If you look at the author's web site it's got a few good screenshots: http://www.orangytang.net/VScript/stypeScreenshotThumbs.php
It's only good for dynamic lighting with shadows though. Light maps would be better for static lighting with shadows.

[EDIT] Here's a little demo I knocked up that uses some basic OpenGL lighting.



ImaginaryHuman(Posted 2005) [#46]
How does one go about cut-and-pasting that program over to Blitz (on a mac)?


dmoc(Posted 2005) [#47]
Trying teamonkey's demo I get the following error. Any idea what the prob is? Also what are the numbers referring to? Finally can the ide display line numbers?

"C:/filestore/dev/bmax/various/lights-demo.debug"
Unhandled Exception: Attempt to access field or method of Null object
DrawImage [C:\bmax\mod\brl.mod\max2d.mod/max2d.bmx;260;2]
lights-demo [C:\filestore\dev\bmax\various/lights-demo.bmx;52;4]


tonyg(Posted 2005) [#48]
Do you have ball.png in the same directory that you saved the bmx file?
260 is the line in max2d.bmx (the 2D module)
52 is the line in the lights-demo.bmx file
No line numbers in the beta-IDE.


dmoc(Posted 2005) [#49]
tonyg, thanks