realbasic-games
[Top] [All Lists]

Doing your own vertex lighting (Was: OBJ and 3DS support for vertex colo

To: REALbasic Games <realbasic-games at lists dot realsoftware dot com>
Subject: Doing your own vertex lighting (Was: OBJ and 3DS support for vertex colors)
From: Frank Condello <developer at chaoticbox dot com>
Date: Sun, 21 Aug 2005 01:35:08 -0400
Delivered-to: realbasic-games at lists dot realsoftware dot com
References: <8DF2BB08-78E5-4A06-B484-895B5868CC47 at miensoftware dot com> <98D5C6A8-4D28-4AAC-9D45-664AA46DD36E at chaoticbox dot com> <D962D06D-00DB-4899-A24F-5553090F959B at miensoftware dot com> <CAE9040D-2C53-47E2-81EC-3B54FA9F6C50 at chaoticbox dot com> <C67E7CE8-E64B-4C39-A825-14CD0A88C271 at miensoftware dot com> <75099C14-B525-45F5-B96A-6FF18C435514 at chaoticbox dot com> <D1B36A2F-97EE-4B71-BC3B-BD3A5548541A at miensoftware dot com> <049C1457-8F68-4A08-A591-E874CF0EC7B7 at chaoticbox dot com> <034341D7-ECC5-4072-8B76-7E9F1DC660DD at miensoftware dot com> <668F9E8B-AD29-4B01-B08E-67F41622722E at miensoftware dot com> <C9ED2AF5-4F2C-4D9C-BC0C-D19340F96E96 at chaoticbox dot com> <58EAA4E1-3CA9-492C-960C-ABC9888DF34E at miensoftware dot com>
On 21-Aug-05, at 12:53 AM, Lo Saeteurn wrote:

Well, it doesn't light properly if the object has been rotated.
...
What am I doing wrong?

Not sure you'll be able to do this using Quaternion.Transform - IIRC, that rotates around the origin and is generally only useful when dealing with unit direction vectors. The "proper" way to do this is to run the rotated geometry (or a copy of it) through an appropriate matrix transform in software (i.e. rotate the vertexes/triangles, then recalculate the normals). You might be able to take some shortcuts but I can't think of anything at the moment. The 3DMF Workshop source has some software transform routines you might be able to adapt (Generic3DModel.RotateX/Y/Z in particular).

Not sure what you mean by a "mesh-based" lightmap (a highly tessellated version of the original mesh?)

A mesh generated by the rays hitting a surface. Or, instead, attach the new points onto the mesh that the ray hits so that the shadows are sharper and more accurate.

The latter is really your only viable option in Quesa. Better yet, just subdivide the model prior to lighting.

Either way it's pretty much impossible to render per-pixel lightmaps through Quesa, as it only allows one texture per triangle (and one set of UV's for that matter).

That's what I mean. Since Quesa cannot support multiple UVs, the 2nd texture must be on a separate mesh that is slightly shifted over the original.

It will be nearly impossible to do this for models of any complexity. Even if you can generate a mesh that's cleanly shifted above the original geometry (which isn't as simple as it may seem) shifting it too far will ruin the effect, and not shifting it enough will cause z- fighting errors. Add to that that Quesa will treat the lightmap surface as transparent and it'll likely render too slow to be of any good. The only reliable way to render lightmaps is using a multitexture pass, or a second blended pass with depth writes disabled. Neither of these techniques are available with Quesa.

Frank.
–––––––––––––––––––––––––––––––––
Open Source RB Goodies and Shareware
<http://developer.chaoticbox.com/>
<http://www.chaoticbox.com/>
–––––––––––––––––––––––––––––––––

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

<Prev in Thread] Current Thread [Next in Thread>