CopyEntity/Mesh & Vertex Lighting problem

Blitz3D Forums/Blitz3D Programming/CopyEntity/Mesh & Vertex Lighting problem

Danny(Posted 2006) [#1]
Hi All,

I'm doing this vertex lighting thing and I'm very happy with the results. The shading & shadows on static entities (the set/terrain) look really nice, but I just found out that lighting/shading dynamic objects (tables, chairs, crates) is a different story.

Problem is that dynamic objects are instances made with COPYENTITY. And the obvious problem is that if I alter the vertex colors on ONE mesh, ALL the instances get the same (lighting) effect.
So in stead, I need to use COPYMESH to create unique instances- that can receive individual lighting. But using CopyMESH over CopyEntity has the obvious drawbacks on 100's of entities: More memory, more surfaces => performance hit.

I'm pretty sure I'm falling in an obvious 'vertex lighting' trap here that some of you must have encountered before... Any tips, work arounds, 'magic red buttons' or other advice appreciated.

cheers
Danny


Dreamora(Posted 2006) [#2]
There is no way around it.

If you really need hundred of copies, you should consider chunking them by using CopyMesh and then using Addmesh to form a single mesh with all the copies. That way lighting is correct and you only have 1 surface. (don't do that with widely spread stuff as Blitz3D occlusion is mesh based)
You still have more vertices but on static vertices, B3D pushes through far more than 500k to 1 million even on lower end system (GF4 MX)


Danny(Posted 2006) [#3]
I know that one possible solution would be to ""light"" dynamic objects by adjusting their EntityCOLOR. I can apply this seperately to different instances. So that an object in total darkess gets entitycolor 0,0,0 whilst one in full light would be set EntityColor 255,255,255. This works pretty well and much faster since I only have to check it's light 'once' in stead of for every vertex.

But I can imagine there might be a better solution since there's some 'grey area' with CopyEntity(); ie. You CAN apply individual textures, Even though all instances share the 1 same surface, etc.

d.


Danny(Posted 2006) [#4]
Ok, thanks Dreamora for confirming that :/

I guess I'll stick with the 'entity color' method, since it's fast enough for real time..

cheers