Lighting Normals Problem

Blitz3D Forums/Blitz3D Programming/Lighting Normals Problem

Stevie G(Posted 2005) [#1]
Just messing around with something here ...

I'm not 100% sure how the updatenormals function works but as you can see here it's no doing as I want. The attached image is a basic track mesh made from various track tile meshes. I use addmesh to make one big mesh then use updatenormals. Note that there are no shared vertices on each tile.

As you can see the lighting is dodgy at the seems. I've tried various programs from the code archives with no joy. What I want is a function that will sort out the lighting on the edges.

Can anyone help without the use of a modeling program?




Yan(Posted 2005) [#2]
Have you tried this?...

http://www.blitzbasic.com/codearcs/codearcs.php?code=1377


Stevie G(Posted 2005) [#3]
Yip, the trouble with it is that it welds the whole mesh .. not just the seems so the rest of the mesh looks 10 times worse. Cheers anywho!


Shambler(Posted 2005) [#4]
You say you tried some of the archive code but did you try Swifts calcnormals function?

http://www.blitzbasic.com/codearcs/codearcs.php?code=975


Stevie G(Posted 2005) [#5]
Yeah, that doesn't work either. It pretty much produces the same results as the native command.

I'm using Vertexcolor btw.


big10p(Posted 2005) [#6]
Couple questions:

You say "Note that there are no shared vertices on each tile". So each tile mesh is made up of a set of unwelded tris, yes? Can I ask why? :) UpdateNormals can't smooth normals unless shared verts are used.

If each of the tile meshes normals are correct before you're AddMesh'ing them together, why are you using UpdateNormals at all? You do know AddMesh doesn't weld any vertices, right?

Last thing - you may have seen this already - but this may help with 'debugging' your normals, at least :)
http://www.blitzbasic.com/codearcs/codearcs.php?code=1085


Stevie G(Posted 2005) [#7]
Hmmm maybe I'm not 100% sure what welded, unwelded means.

For example the vertices are arranges in a left/right straight tile as below. Note that polys use vertices 0,1,3 / 3,2,0 & 4,5,8 / 7,6,4 etc... Vertices 2&4 / 3&5 etc. share the same position.

The reason I'm doing this is I'm using vertex colours and don't want certain parts to bleed colours into others etc..

Make more sense?

I've tried updating the normals for each tile and not updating normals for the new mesh but this is worse than the picture.

0							1

2							3
4							5

6							7
8							9

10							11
12							13

14							15
16							17

18							19
20							21

22							23
24							25

26							27
28							29

30							31



Banshee(Posted 2005) [#8]
Here's a thought which should solve it but probably involves a bit of a head "foray" for you if you've not done mesh creation before.

Why not construct a single mesh out of the tiles by using the mesh/surface/vertice command set. That way you will end up with one smooth mesh.

Another option might be to disable lighting on the object and use a texture layer to alpha on a light map created with the good old plot command.


Braincell(Posted 2005) [#9]
You have to fix this in a modeler package. Weld the vertices where you want the transitions to be smooth, then use smoothing groups. You'll have to know how to fix the parameter(s) of smoothing groups to get the right effect. You can separate the two meshes or have them together and use smoothing groups, the results shouldnt be too different, although if the meshes are separate you might get slightly different lighting at the edges of the other mesh. If you created the mesh with code, you'll simply have to change the code so that the same vertice is used by for example 4 surrounding squares (if you have a square grid). You should know what welding means anyhow.


Stevie G(Posted 2005) [#10]
@ Becky. I've never used any modeling programs before so building meshes in code is what I always do. Building the whole track without tiles defeats the purpose. I did consider using a lightmap so this may be the way to go.

@ Lenn. I'm sure I could write a routine to remove duplicate vertices and amend the triangles which use these.

Thanks folks.