Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Memblock Matrix Test

Author
Message
MikeS
Retired Moderator
23
Years of Service
User Offline
Joined: 2nd Dec 2002
Location: United States
Posted: 23rd Nov 2004 09:11
Just finished my first memblock matrix function and had some fun. So here are my results as I tested it against hte regular matrix system.



Conclusion:
Culling large objects helps, but doesn't make a huge difference (I believe this is default anyway). Medium sized textures on matrices don't hit the programs performance minimally.

My Specs:
Ran in DBP Windowed 1024,768,32
1.8 ghz | Radeon 9800 | 1536 ram | Windows XP SP2

I'd like to see other peoples results as well(Preferably in the same matrix dimensions). I'm also going to spend the next few days writing an LOD system and see how far I can optimize this baby. While doing this though, I have a few general questions...

1.) The Advanced terrain, Multi-scape, and other such programs have such nicely multi-textured landscapes. How do I go about doing this?
I tried messing around with 'set blend mapping on' and 'set detail image on' commands, but they really didn't do much to my object.
I believe Fredrrix has a topic about this on the page too, but hopefully we'll each figure this out.

2.) Outputting .x files with save mesh loses all reminants of a texture. Is there anyway to export an .x file with the texture co-ordinates using DBP? (Or must I write my own exporter?)

More questions later, but post your memblock matrix results here. The word was(or so I heard) memblock matrices were faster until they got bigger, but it seems my results are against this.



A book? I hate book. Book is stupid.
(Formerly known as Yellow)
Phaelax
DBPro Master
23
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 23rd Nov 2004 10:13
100x100 segments isn't considered big. I don't get any performance hits until I use around 200x200 tiles on my memblock matrices.
Do you have code for us to test, or are we suppose to use our own memblock code?

"eureka" - Archimedes
MikeS
Retired Moderator
23
Years of Service
User Offline
Joined: 2nd Dec 2002
Location: United States
Posted: 24th Nov 2004 07:21
Just use your own, or grab a snippet from the codebase (In this case, it'd still be your own. ).
http://forum.thegamecreators.com/?m=forum_view&t=32691&b=6

My main concern is getting the multi-texture effect, if anyone can help I'd be very grateful.

The basic routine:


Here's the basic routine. All you see is me writing the data, but the important part is the last two floats in each of the 6 sets. This is where the uv data is set, but I'm not sure if this has anything to do with multi-texturing. Not sure if that helps much, but I'd be very grateful to any help in the right direction.



A book? I hate book. Book is stupid.
(Formerly known as Yellow)
Nicholas Thompson
21
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Bognor Regis, UK
Posted: 24th Nov 2004 07:31
I dont think you can multi texture in DB.. BUT you can apply a shader with a different texture. I got a nice effect earlier by playing with the "set light shader on" when applied to a Mesh (My weapon of choice for terrain generation).

MikeS
Retired Moderator
23
Years of Service
User Offline
Joined: 2nd Dec 2002
Location: United States
Posted: 24th Nov 2004 07:46
Hmm, well. There must be a way to at least fake multi-texturing. I know Hamish uses layers, and he get some good stuff.
perhaps I'll have to get a little dirtier with my code.

I'll look into the shaders next though. Thanks for the suggustion.



A book? I hate book. Book is stupid.
(Formerly known as Yellow)
Lost in Thought
22
Years of Service
User Offline
Joined: 4th Feb 2004
Location: U.S.A. : Douglas, Georgia
Posted: 24th Nov 2004 09:49 Edited at: 24th Nov 2004 09:50
Talk to APEX his .csm importer multitexures. He based his method on the .dbo format I believe.

MikeS
Retired Moderator
23
Years of Service
User Offline
Joined: 2nd Dec 2002
Location: United States
Posted: 24th Nov 2004 09:52
Thanks Lost in Thought. I'll be sure to talk to him.



A book? I hate book. Book is stupid.
(Formerly known as Yellow)
Shadow Robert
23
Years of Service
User Offline
Joined: 22nd Sep 2002
Location: Hertfordshire, England
Posted: 24th Nov 2004 10:16 Edited at: 24th Nov 2004 10:21
Mike how did you get it to work?



everytime i try to make an object in DBP from the Memblock it never seems to appear; it is frustrating, because I figured doing this in dbp would be quicker than C# but it is appearing not to be

As for Multi-Texturing, you'll have to add an extra set of Texture Co-ordinates. DBP supports upto 8, but this has to be changed using the FVF Code.


MikeS
Retired Moderator
23
Years of Service
User Offline
Joined: 2nd Dec 2002
Location: United States
Posted: 24th Nov 2004 11:02
Quote: "As for Multi-Texturing, you'll have to add an extra set of Texture Co-ordinates. DBP supports upto 8, but this has to be changed using the FVF Code."


Ahhh, that makes perfect sense. Thanks for that.

----------------------

Raven, here's the snippet. I might as well post it anyway, since memblocks aren't secrets these days.

(Press space to get rid of matrix once generated)


The only problem with the snippet is that a little bit the last farthest right x segment and the farthest forward z segment still draw out additional lines. I'll fix that up tomorrow before I explore multi-texturing.

Basically how it works is in 3 steps.

1.) Create a matrix and randomize it.(Smooth it if you like)
2.) Plot cubes on each x,z segment.
3.) Retrieve the location of each object, get its height, and then draw a plane. The vertices are then positioned based on the height of the object.

Actually simpler than I thought once I got the flat plane going.

Only other problem I can think of, is that turning culling on will hide too many polygons on smaller memblock matrices which is weird.



A book? I hate book. Book is stupid.
(Formerly known as Yellow)
Shadow Robert
23
Years of Service
User Offline
Joined: 22nd Sep 2002
Location: Hertfordshire, England
Posted: 24th Nov 2004 11:13
Hey what do you know, that WAS the problem

Cheers, turned culling off and bam! it shows. Looks snazzy too.



When I have time, I guess I'll have to sort out a Vertex ReOrdering so that it always points a face outwards. That'll take too much time right now though; just have to rely on DBP to save doube-sided faces.

I think I'll redo this in C# when I have time, it is far more straight forward..


MikeS
Retired Moderator
23
Years of Service
User Offline
Joined: 2nd Dec 2002
Location: United States
Posted: 24th Nov 2004 11:27
Glad to help.

----------------------
Just going to put some links here before I lose them, for I'm off to bed.

http://forum.thegamecreators.com/?m=forum_view&t=31926&b=1
http://forum.thegamecreators.com/?m=forum_view&t=33079&b=1
http://forum.thegamecreators.com/?m=forum_view&t=33175&b=13
*Makes mental note to talk to Apex*



A book? I hate book. Book is stupid.
(Formerly known as Yellow)
Van B
Moderator
23
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 24th Nov 2004 16:36
Multitexturing is usually done with memblocks using alpha coloured vertices. All the verts on your terrain can be coloured, then you could even disable lighting (performance boost), but more importantly you add the 24 bit alpha part onto the RGB value to fade the edges out. When I last did this, I used the heightmap data, and an alpha reference image. The alpha reference image is just a bitmap the same size as your terrain, a greyscale mask if you like, just shows the area to create the second layer on.

I made a base terrain, then made a detail texture terrain too, with alpha faded vertices. Skipping polygons that would be unnecessary is quite easy, but be careful with the memblock size, you have to set that to the polygon count of your mesh first, so it can get a little tricky to work out.


Van-B


It's c**p being the only coder in the village.
Nicholas Thompson
21
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Bognor Regis, UK
Posted: 24th Nov 2004 16:43
So are you saying you put two faces in "one place" and faded the alpha of the edges?

@Raven:
Quote: "As for Multi-Texturing, you'll have to add an extra set of Texture Co-ordinates. DBP supports upto 8, but this has to be changed using the FVF Code."


What extra FVF info is there?

In my 3D Terrain Generator, I use FVF as 274 (x,y,z,nx,ny,nz,u,v). In those options I see only 1 set of UV, surely if there was an option for 8 texture layers, u'd need 8 uv coords?

What are the options for 338? I understand there is diffuse RGB values..

I am very interested in this as mutli texturing a terrain would be of GREAT use to me and would make my terrain generator example that I hope to turn into a tutorial on Terrain Generation using a Mesh.

Cheers guys, this is an interesting thread!

Van B
Moderator
23
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 24th Nov 2004 17:37
Actually, I have some code lying around that tries to make an optimised mesh, I'll have a look. My idea was to use 4 textures on a single image, then make it all into 1 mesh. That failed because of transparency issues - however I haven't looked back at it with the latest patch, so I might be able to get it working better.


Van-B


It's c**p being the only coder in the village.
Nicholas Thompson
21
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Bognor Regis, UK
Posted: 24th Nov 2004 17:43
I considered making an optimised mesh a while ago.. A sort of LOD type thing. You shouldn't need 1,000,000 polys if the terrain is miles away, so I tried to consider methods for LOD.. never got anywhere.

I also considered a non-grid method for makign a terrain. I wanted to find an algorithm that somehow picked triangles to make a kind of spiderweb style mesh. The advantage of this is you simply add more points where you want the detail This would also make deformable terrains very easy. Again - never had enough idea's to do it..

Shadow Robert
23
Years of Service
User Offline
Joined: 22nd Sep 2002
Location: Hertfordshire, England
Posted: 24th Nov 2004 20:06
DarkBASIC Professional Automatically sets 8 Texture Layers...

Texture Object Object, Layer, Texture `is the syntax

however unless you set the FVF for extra Texture Layers (additional UV Sets) you can only natively use Layer 0, which is the based layer.

FVF_TEX1=0x100,
FVF_TEX2=0x200,
FVF_TEX3=0x300,
FVF_TEX4=0x400,
FVF_TEX5=0x500,
FVF_TEX6=0x600,
FVF_TEX7=0x700,
FVF_TEX8=0x800

You can only use 1 of these, and I would recommend using them with the TextureCoordinates Routine; If you search the forum, you'll find i released a .dba which provided all of the Constants, Functions and such needed for FVF use.
Back then the FVF system wasn't properly integrated so alot of it was a waste of time.

Might be a good idea to fish it out.


Hamish McHaggis
23
Years of Service
User Offline
Joined: 13th Dec 2002
Location: Modgnik Detinu
Posted: 24th Nov 2004 20:26
The method I used in Multiscape was making differently textured meshes as separate limbs in the same object, then alpha fading verts to show through the lower layers. But are you saying that DBPro already has this functionality built in using the same technique? I was under the impression that DBPro didn't yet have "functioning" multitexturing capabilities, and I thought multitexturing actually blended textures then rendered one set of polygons, rather than rendering up to 8 sets.

Isn't it? Wasn't it? Marvellous!
Van B
Moderator
23
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 24th Nov 2004 20:38
Yeah, I thought that too - as far as I can tell, the memblock mesh only supports 2 FVF formats, one with vert colours, one without - no format for setting different layers from what I can tell.


Van-B


It's c**p being the only coder in the village.
Nicholas Thompson
21
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Bognor Regis, UK
Posted: 24th Nov 2004 20:42
So can matrixes (which surely are just meshes with some built in commands in DBP) have 8 texture layers?

I think Raven needs to make an example as he seems to be the expert here.. I'd be very interested to see it!

Hamish McHaggis
23
Years of Service
User Offline
Joined: 13th Dec 2002
Location: Modgnik Detinu
Posted: 24th Nov 2004 20:57 Edited at: 24th Nov 2004 20:58
Quote: "So can matrixes (which surely are just meshes with some built in commands in DBP) have 8 texture layers?"


Matrices are not the same as meshes/objects. They are handled differently from meshes, and are not as flexable. This is why TGC made the new terrain system, which ARE DBPro objects, and you are (supposedly, but not actually) able to do everything with them that you can do with regular objects. Matrices can only have one texture (per tile) if I'm not mistaken? I'm not an expert, I have never really used matrices in a proper scenario.

Isn't it? Wasn't it? Marvellous!
Nicholas Thompson
21
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Bognor Regis, UK
Posted: 24th Nov 2004 22:33
Sure a matrix is just a mesh though? When it comes down to rendering.. I know is DB terms it is a seperate section of the help file alltogether, but judging by its looks.. Is it not just a nooby-proof way of doing terrains without needing to use a mesh and memblocks and stuff?

Van B
Moderator
23
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 24th Nov 2004 23:26
Matrices are really just leftovers from DBC.

A matrice is like an updatable terrain, the mesh would be created internally, but stored in an accessible way so that changes could be made, then with a quick object build you have your matrice. Matrices are about the most limited terrain solution.

Advanced terrains use something like detail mapping, that's all - like an object with a detail map, then each limb is hidden or shown when updating the terrain. Really, you could probably do everything that advanced terrains do, but it's not easy. The terrain splitting up is good for speed because if it was 1 big object, it could'nt cull the unseen detail. This can be replicated by splitting a memblock matrice into chunks and hiding limbs where necessary - OR - simply create each chunk as a seperate object (but offsetting, don't just plonk it where it should go), and DBPro will occlude automatically.

Memblock matrices are the optimum technique, but not everyone has the time to learn them properly.

I'm planning on looking back over my memblocky stuff later, see how the revised transparency settings affect it. If it works out, I'll see if I can go head to head with advanced terrains for looks and speed. My idea is to use 3 textures, like 3 seamless 512x512 textures, e.g. grass, sand, rock - then have a 512x512 texture with 16 individual matrice tiles, like pavement or wood planks for example. Then, that leaves you with smooth transitions between any 3 textures, plus the detail layer (where needed), plus a vertex colouring layer.


Van-B


It's c**p being the only coder in the village.
Nicholas Thompson
21
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Bognor Regis, UK
Posted: 25th Nov 2004 00:55
That sounds cool..

This might sound REALLY stupid but.. Whats the difference between Memblock Matrix and Memblock Mesh? Or are they the same? I cannot see any memblock matrix commands in the help (or are they hidden..)

At my site I have a terrain generator that uses Memblocks and Meshes (as I have previously said ). It is pretty efficient.. I also have a 2D terrain generator that UV Maps tiles predefined in a text file into a tiled mesh. Take a look if its of any use..

How do you plan to use 3 layers of images?

Van B
Moderator
23
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 25th Nov 2004 04:53
There's no difference, memblock matrix is just what some use to describe a memblock mesh that acts as a terrain.

I have a big texture with 4 sections, like sand, grass, rock, whatever - then I set which texture to use at a specific point using a reference bitmap. I seem to have gotten round a weird bug that left visible edges round the terrain, I was offsetting the alpha'd layer, but leaving the Y locations the same as the base mesh seems to fix it - strange.


Van-B


It's c**p being the only coder in the village.
Shadow Robert
23
Years of Service
User Offline
Joined: 22nd Sep 2002
Location: Hertfordshire, England
Posted: 25th Nov 2004 09:36
If you want to see the multi-layer texturing in action, just edit up the code I posted; shouldn't be to hard to edit it and then create a grid (matrix) plane

I would but, though not being hard, it'll be timely. but g'luck


MikeS
Retired Moderator
23
Years of Service
User Offline
Joined: 2nd Dec 2002
Location: United States
Posted: 25th Nov 2004 11:39
Little image of my WIP memblock matrix. Just added vertex coloring, based on the height. Still needs a little bit of balancing, as when I apply a dark texture to the landscape, it's practically black.

[href][/href]

Still reading up on multi-texturing stuff. This is definitly going to take some time.



A book? I hate book. Book is stupid.
(Formerly known as Yellow)
Van B
Moderator
23
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 25th Nov 2004 16:34
Mike,
What colouring are you using on the verts? - just that you should consider RGB(128,128,128) as the default, and also look into disabling lighting when using vertice colours. It is possible to mimic lighting with it anyway, but disabling lighting on your object will make it display 20% faster and make the colouring much more noticable .

Raven,
The code you posted would never ever ever use more than 1 set of UV coords, it's just not possible in the supported memblock mesh formats.


Van-B


It's c**p being the only coder in the village.
Nicholas Thompson
21
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Bognor Regis, UK
Posted: 25th Nov 2004 19:16
so how do you do it then?

Van B
Moderator
23
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 25th Nov 2004 20:57
I'd render the heightmap in a terrain texture generator (like texgen), then load that and read the colour values from each point, and apply that to the vertices. Once you disable lighting, the object colours should match what you have planned pretty well.

There is some strangeness with mesh alphas with transparency mode 4 - it appears to be cutting out the terrain instead of blending it - like giving a solid edge but curvy. It might be usefull for a road, I'll experiment some more - mode 2 seems to work for me so far though. I'm adding all the layers into composite meshes, like broken up like advanced terrain into limbs that can be occluded - but each layer gets added to the same limb.


Van-B


It's c**p being the only coder in the village.
Nicholas Thompson
21
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Bognor Regis, UK
Posted: 25th Nov 2004 21:05 Edited at: 25th Nov 2004 21:05
That is because Mode 4 removes anything with alpha less than a certain value (it was shown in the 5.7 Patch Release info)..

Ah ha here it is..:
Quote: "New Object Transparency Option; SET OBJECT TRANSPARENCY Obj,4 will set the alpha test to not render alpha values less than 0x000000CF. Useful for rendering transparent objects in any order rather than z-sorted
"


I normally used either 2 or 3.. I found out in an old thread what they did..

EDIT:

Btw: VanB, surely if you disable lighting then yeah it;ll look nice from a prefefined angle but wont it look silly if the light or camera angle changed? Or are you working on the assumtion you have a directional light?

Van B
Moderator
23
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 25th Nov 2004 21:17
If the light changed, then it would'nt affect the terrain - but the camera angle won't matter.

With vertice colouring, it's like hard baking the lighting information to the vertices rather than letting DX do it with it's lighting system. If you need your terrain to react to lights, then you can't disable them, but if your main light source is static (like the sun in a skybox) then avoiding lighting can do wonders for performance.


Van-B


It's c**p being the only coder in the village.
Nicholas Thompson
21
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Bognor Regis, UK
Posted: 25th Nov 2004 21:38
Thats true..

If you turn lighting off, how to adjust the brightness? Is it still effected by ambient light? Or do you again have to "hardbake" the brightness into the the vertices (by adjusting the RGB)..

Does anyone else thing that it'd be usefull to have the option to use HSV coloring (or HSB, HSL or whatever naming scheme you use.. I covered it during my degree and the same lecturer couldn't even find a consistant naming scheme!!)

Van B
Moderator
23
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 25th Nov 2004 21:48
Hmmm, I've never checked if ambient lighting affects it or not, I'm guessing it wont.

Usually when using a generated terrain texture, it has shading already, but my plan is to use vanmesh to make special objects that have no lighting, and instead calculate their vertice lights depending on the scene. Generating a mesh is not too slow, it's not really great for live updating, but fine for amendments when loading it in.


Van-B


It's c**p being the only coder in the village.
Nicholas Thompson
21
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Bognor Regis, UK
Posted: 25th Nov 2004 21:56
So your saying you make your mesh up with an assumption the light is directional at angle "nx,ny,nz" and then you shade everything in accordance with that?

Van B
Moderator
23
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 25th Nov 2004 22:43 Edited at: 25th Nov 2004 22:44
Yeah, I'd set the light direction in the terrain map generator, then work out the estimate location of the lights game world location, and put the DBPro light 0 there. If I was calculating the lights on a building mesh, I would use the light source position and check for collision on the line between the vertice, and the light source. That's like a real basic lightmapper, but it looks cool - I do that in vanmesh and it's working out nicely. I'll see if I can post an example screenie later.


Van-B


It's c**p being the only coder in the village.
Nicholas Thompson
21
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Bognor Regis, UK
Posted: 25th Nov 2004 22:56
That'd be cool..

It must massively increase the availabled FPS as everything would be precalculated and not done every frame. Hmm...

Van B
Moderator
23
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 25th Nov 2004 23:19
Yeah, it's a shame that DX lighting is not more clever, well in DBPro it isn't - I mean even just having a lighting system that does'nt ignore walls is tough in DBPro, in fact I don't even think it's possible. Like if you vert lightmap a mesh, even with a very very basic lightmapper, your still doing a better job than DX lighting, because it's actually calculating light, not just a range and normal. One concearn though - it's damn easy to loose track of textures when dealing with memblock meshes, because if your original mesh uses more than 1 texture, it gets really complex - you should try and use a single tileable texture whenever possible, it looks better and you can often get away with it on a lightmapped mesh (it also means UV mapping can be done in a couple of minutes, instead of hours).


Van-B


It's c**p being the only coder in the village.
Nicholas Thompson
21
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Bognor Regis, UK
Posted: 25th Nov 2004 23:55
Another silly question alert.. What exactly is Light Mapping? I was playing about with it the other night and I got a nice effect, but I have no idea what it was actually doing!

Van B
Moderator
23
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 26th Nov 2004 00:22
Lightmapping is like taking the lights in a scene, and creating a mesh and texture to overlay on top of the scene to mimic high detail lighting. It's incredibly processor intensive to calculate shadows for example, so on static objects it's better to use a lightmap when you want shadows.

Most people would'nt think of using a vertice lightmapper, Carto Shop and Giles are pixel lightmappers and are much more common, the problem I have with these though is the added strain on the frame rate with duplicate polygons and a big texture for every building. A vertice lightmapper won't look as good, and it'd have trouble calculating an accurate shadow, your limited by how detailed your mesh is you see, but with pixel lightmappers it creates it's own media and is much more accurate.

Note that there were rumblings from the TGC camp about a built in DBPro lightmapper - I think FPSC is using it already.


Van-B


It's c**p being the only coder in the village.
MikeS
Retired Moderator
23
Years of Service
User Offline
Joined: 2nd Dec 2002
Location: United States
Posted: 26th Nov 2004 00:23 Edited at: 26th Nov 2004 00:26
Van, you were right. Disabling the lighting helped between 16-20% for me.

[href][/href]

Right now, for my coloring I'm using a simple formula. Basically, you tell what the maximum height is for your memblock matrix, in other words, the highest Y value.

Based on that, it colors each vertice based on their height from 0.
So right now I'm trying to work out how to get that value to 255(since that's the highest rgb value) no matter what your highest Y value is. That way the colors will fade nicely, and get lighter as you get higher. Thus, a cheap shadow effect.

Also, as far as I can tell, ambient light played no effect on my terrain when the lighting was disabled.



A book? I hate book. Book is stupid.
(Formerly known as Yellow)
Nicholas Thompson
21
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Bognor Regis, UK
Posted: 26th Nov 2004 01:33 Edited at: 26th Nov 2004 01:34
Algorithm Time:
Min = Minimum Height (from searching)
Max = Maximum Height from searching
H = current node height

Therefore:
Current_color = 255.0 * ((H-min) / max)

I THINK thats correct.. If my brain is working..

Oh yeah, thanks for that explanation VanB!! I'll look into that for some of my apps.. It'd work well on a game I'm workin on right now..

Van B
Moderator
23
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 26th Nov 2004 01:45 Edited at: 26th Nov 2004 01:46
Check the image I attached, shows some primitives, ones on the left (grey) are DX lighting, the light source is in front of the cube, so it should mean the sphere would be in shadow, but it isn't. The ones on the right are a basic vertice lightmap in vanmesh, the lightsource is roughly in the same place.


Van-B


It's c**p being the only coder in the village.
Nicholas Thompson
21
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Bognor Regis, UK
Posted: 26th Nov 2004 01:51
So in vanmesh, you say it ray casts from the source of the light and detects where it hits something? Hence the sphere being in shadow?

How do you know where you have hit a plain or something? Or do you draw a line between light source and each vertice and if its a clear line it should get some lighting?

Van B
Moderator
23
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 26th Nov 2004 02:37 Edited at: 26th Nov 2004 02:43
Mike,
It's looking cool, nice and smooth .

There is a cheats way to get slope shading, I did it with OIE - all I did was check the heights and their differences depending on the light direction. Like, if the light is comming from the northwest, I'd check the relevant heights and the difference between them can be used as a multiplier. This is all I did with OIE:

for z=1 to 64
for x=1 to 64
y1#=height(x,z)
y2#=height(x-1,z-1)
ls#=((y1#-y2#)/100.00)+0.50
if ls#<0.0 then ls#=0.0
if ls#>1.0 then ls#=1.0
`Edited to make more sense! matcol(x,z)=rgb(255.0*ls#,255.0*ls#,255.0*ls#)
if y1#<0.0 then matcol(x,z)=rgb(0,0,rnd(32)) ` underwater
next x
next z

If you mix that with your height colouring it'll look smooth as silk.

EDIT:
Changed the colouring, now it's just white lights, but it'd be easy to change that.


Van-B


It's c**p being the only coder in the village.
Van B
Moderator
23
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 26th Nov 2004 02:40
Nick,
Yeah, you only really need to know if a 3D line interects with the mesh - getting the vertice locations from a mesh is fairly easy, then you just need the light position and a distance function to work out the light strength.


Van-B


It's c**p being the only coder in the village.
Nicholas Thompson
21
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Bognor Regis, UK
Posted: 26th Nov 2004 04:58 Edited at: 26th Nov 2004 05:01
A question here..

In the game I want to make, I'd like to try this disabling of light.. Now, My game dynamically creates an arena based on some terrain generation with raised edges.

How would I work out the lightmap for this?

Say I set my directional light to -2,-1,0. How would I use that? (assuming I need to)?

EDIT:
Rite, I was plying around.. I have lightmapping "working" with a predefined PNG (white fade to black).. It seems lightmapping is tied in with UV mapping.. Anyway around this?

Van B
Moderator
23
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 26th Nov 2004 05:16 Edited at: 26th Nov 2004 05:16
Ahh, that's one of the downsides to a pixel lightmapper, you gotta have it as a seperate ghosted object, I think it's best to negative (dark) ghost and use it more for shadowing.

Kudo's on the lightmapper, be sure to show us some screenies.

Talking of screenies... Here's one of an alpha vert colour terrain, uses smooth alphas and transparency mode 4 to make curvy sections of road, I can edit the road with an airbrush in PSP . I smell a mini project.


Van-B


It's c**p being the only coder in the village.
Nicholas Thompson
21
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Bognor Regis, UK
Posted: 26th Nov 2004 05:18 Edited at: 26th Nov 2004 05:23
Ah so your method you talk about for light mapping doubled the poly count for the object?

Edit:

This is my "game" so far.. I'm now reading up on car physics. I want to make it a realistic car fighting type game with a turret on the car. It'll be set in the arena that is either gonna be dynamic or have an option for a height map.

I suppose its gonna be a like a fighting version of "Generally" (if you haven't played it, google for it!! ITS SO FUN!!!)

Van B
Moderator
23
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 26th Nov 2004 05:28
Pixel lightmapping needs a seperate mesh, vertice lightmapping affects the mesh itself.

I think I know what you mean about your racing game, my bro has been harassing me for something similar. Check out the screenie I posted .


Van-B


It's c**p being the only coder in the village.
Nicholas Thompson
21
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Bognor Regis, UK
Posted: 26th Nov 2004 05:30
Hmm.. Well after messing about with the imaging I have currently gone back to directional lighting.

Maybe vertice light mapping would be more appropriate seeing as my mesh is currently 64x64 (and therefore 64*64*2=8,192 polys (*2 because 2 triangles per grid square)).

Login to post a reply

Server time is: 2026-06-11 09:35:08
Your offset time is: 2026-06-11 09:35:08