Vector graphics - how to make the lines 'glow'?
Blitz3D Forums/Blitz3D Programming/Vector graphics - how to make the lines 'glow'?
| ||
I'm currently dabbling with the source code to a game coded by someone else, namely 'Vecteroids' (2D game) by Jim Pishlo. I'm curious if it's possible to make the vector lines 'glow' and look as smooth as possible as they would on an original vector monitor. Naturally the monitors we are using on our PCs (ie raster) operate very differently to a true vector monitor, but even so, with todays' 2D/3D graphics cards and programming techniques there must be a way to simulate the smooth, bright and *glowing* lines that you'd normally see on a vector monitor. Please note: I'm a relative beginner at this. I could have posted this in the beginners' area but I thought more people would see it here. :) Thanks |
| ||
A vector monitor? I don't think such a thing exists, except for the ones to trace waveforms, which are simply a light-beam moving over phosphor.. which is exactly what a CRT is, except at much higher resolution.. |
| ||
Okay then, an XY monitor to be precise. :) They do exist, just not for use with PCs (I do though have one right behind me ....... in my Asteroids cab :-) |
| ||
The effect would probably be easier to recreate using B3D and drawing the lines with polyons. The 'glow' could be drawn into the texture. Also the texture could be rendered in 'additive' mode. |
| ||
Like this :) Personally I would use a single surface system instead of sprites and use Tris instead of whole quads. This is just a quick one I knocked up for you. [EDIT]Or Use this texture for the line : [/EDIT] |
| ||
Indiepath.T - thanks very much for that, looks really nice. :-) Is it possible to make it look even 'brighter'? Also, given the ignorance of this here beginner, how would I go about using the texture you provided for the line? Many thanks |
| ||
Save the Texture as line.png and put it into the same directory as the code. This is about as bright as you're gonna get without using some kind of filter. It would look cool with a bloom filter :) Use the following code to utilise the texture :- |
| ||
Now that's looking very nice. Thanks very much for all your help so far. :-) Of course, now you've mentioned that it would look even better with a bloom filter, so I just HAVE to ask the inevitable question - how would a bloom filter be added? :) And would it make the lines look brighter/more intense? |
| ||
Here is the bloom code - thanks to Bouncer. and here is the code to use it >>>>>>>>>>> BEWARE this will slow everything down. Neat Eh? |
| ||
Wow, that IS nice. Lovely stuff - thanks. :-) As you say, it does slow things down (understandably so) - if incorporated into a game like Asteroids, would there likely be any problems running it on your 'below average' PC ('below average' being perhaps 1GHz) but perhaps coupled with, say, an older video card (older being a year old perhaps). |
| ||
I would include it in the game and give the user the option to turn it on or off. |
| ||
Alos, bear in mind that brightness is kinda relative to the rest of the screen. Don't ever use pure white (255 255 255) as a colour on screen. (Unless I suppose if you have a nuclear-explosion white-out!)Have a dark background, keep colours light but not bright so that lights will really show! |
| ||
Hey I can feel a remake of the old battlezone coming on... |
| ||
Indiepath.T - agreed, an option to turn it on and off does sound like the best solution. Have you see the Vectoroids source code? I ask as I'm curious how easy (or hard) it would be to incorporate not only the 'bloom' function but also the very nice smooth lines and brightness in the way that you showed me. Remember that I'm a relative beginner - is it likely to be beyond me? Malice - I heed your warning, however, as Asteroids is purely bright white vectors on a black background then presumably it will look 'right' if implemented as per the above code examples? |
| ||
IronGiant - Can't say I have seen the source. It should be possible to convert it to use similar code to the stuff I have posted. If the program uses the 2D line command you could convert it using the following snippet. (from Fredborg)Function Line3D(mesh,x0#,y0#,z0#,x1#,y1#,z1#) If mesh = 0 mesh = CreateMesh() surf = CreateSurface(mesh) EntityFX mesh,1+16 Else lastsurf = CountSurfaces(mesh) surf = GetSurface(mesh,lastsurf) If CountVertices(surf)>30000 surf = CreateSurface(mesh) EndIf End If v0 = AddVertex(surf,x0,y0,z0) v1 = AddVertex(surf,x1,y1,z1) v2 = AddVertex(surf,(x0+x1)*0.5,(y0+y1)*0.5,(z0+z1)*0.5) AddTriangle surf,v0,v1,v2 Return mesh End Function |
| ||
Malice - I heed your warning, however, as Asteroids is purely bright white vectors on a black background then presumably it will look 'right' if implemented as per the above code examples? I hope so! In theory yes, but I think that your problem mainly comes into that of hardware. Newer monitors (especially flat-screen types) have a much sharper definition now, so the luminance/refractive stuff that you'd get from a CRT screen is greatly reduced. So instead of having a bright 'light', you would get the actual, sharp, defined line. I'd certain recommend the Faded Texture, the bloom stuff, if you can (bit techy for me!) and good luck! |
| ||
Indiepath.T - It does indeed appear to be using the Line command, at least in this portion of the code: Function render_object(obj.vector_obj) Color 255,255,255 If obj\visible Then an# = obj\angle For i = 1 To obj\vector_count - 1 ox# = obj\x oy# = obj\y x1# = ox + Sin((obj\vectors[i-1]\angle) + an) * ((obj\vectors[i-1]\radius)) y1# = oy + Cos((obj\vectors[i-1]\angle) + an) * ((obj\vectors[i-1]\radius)) x2# = ox + Sin((obj\vectors[i]\angle) + an) * ((obj\vectors[i]\radius)) y2# = oy + Cos((obj\vectors[i]\angle) + an) * ((obj\vectors[i]\radius)) Line x1,y1,x2,y2 Next End If End Function BTW, how do I make inserted code (ie inserted into a message here) appear as scrollable green text on a black background)? |
| ||
[ code ] [ /code ] (remove spaces) |
| ||
Malice - thanks, yes, I see what you mean. No doubt some experimentation will be called for. :-) |
| ||
Then it SHOULD be pretty easy to convert to 3d. BUT without seeing the rest of the code I could be wrong. Email me the code it you like. I'd like to have a go some time. |
| ||
Thanks Cygnus. Indiepath.T - YHM. |