Xojo Conferences
MBSSep2018MunichDE
XDCMay2019MiamiUSA

Doing your own vertex lighting (Was: OBJ and 3DS support for vertex colors) (Real Studio games Mailinglist archive)

Back to the thread list
Previous thread: Re: Transforming Vertices and Normals (Was: Doing your own vertex lighting)
Next thread: 2005r3b2


OBJ and 3DS support for vertex colors   -   Lo Saeteurn
  Doing your own vertex lighting (Was: OBJ and 3DS support for vertex colors)   -   Frank Condello
    Re: Doing your own vertex lighting (Was: OBJ and 3DS support for vertex colors)   -   Lo Saeteurn
    Re: Doing your own vertex lighting (Was: OBJ and 3DS support for vertex colors)   -   Frank Condello
    Re: Doing your own vertex lighting (Was: OBJ and 3DS support for vertex colors)   -   Jeff Quan

Doing your own vertex lighting (Was: OBJ and 3DS support for vertex colors)
Date: 21.08.05 06:35 (Sun, 21 Aug 2005 01:35:08 -0400)
From: Frank Condello
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>

Re: Doing your own vertex lighting (Was: OBJ and 3DS support for vertex colors)
Date: 21.08.05 06:54 (Sat, 20 Aug 2005 22:54:36 -0700)
From: Lo Saeteurn
> 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).

Thanks. I'll take a look.

>> 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.

Yes, subdivision is an option.

>>> 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.

I've seen it done in Renegade successfully. Even shifting it by a
visible margin (from side view) seems to do the trick. The problem
may arise when using a lot of these overlays. I have noticed the Z-
fighting errors from a high angle and far distance, but having a near
visible margin seems to eliminate it.

Since Quesa is open source, isn't there a way to force multiple passes?

_______________________________________________
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>

Re: Doing your own vertex lighting (Was: OBJ and 3DS support for vertex colors)
Date: 21.08.05 07:44 (Sun, 21 Aug 2005 02:44:11 -0400)
From: Frank Condello
> I've seen it done in Renegade successfully. Even shifting it by a
> visible margin (from side view) seems to do the trick. The problem
> may arise when using a lot of these overlays. I have noticed the Z-
> fighting errors from a high angle and far distance, but having a
> near visible margin seems to eliminate it.

Well that's the problem - it's an illusion that can easily break. You
can get away with this sort of thing in specific situations but auto-
generating the same effect for an entire map will be extremely
difficult (and again, once Quesa starts sorting those surfaces you'll
see major slowdowns).

> Since Quesa is open source, isn't there a way to force multiple
> passes?

It's certainly possible, but doing it right would require quite a bit
of work and API extensions. I suppose this could be "hacked" on, but
even then you really gotta know your way around the renderer, which
can get convoluted at times.

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>

Re: Doing your own vertex lighting (Was: OBJ and 3DS support for vertex colors)
Date: 21.08.05 21:38 (Sun, 21 Aug 2005 13:38:02 -0700)
From: Jeff Quan

On Aug 20, 2005, at 11:44 PM, Frank Condello wrote:

>> I've seen it done in Renegade successfully. Even shifting it by a
>> visible margin (from side view) seems to do the trick. The problem
>> may arise when using a lot of these overlays. I have noticed the
>> Z-fighting errors from a high angle and far distance, but having a
>> near visible margin seems to eliminate it.
>
> Well that's the problem - it's an illusion that can easily break. You
> can get away with this sort of thing in specific situations but
> auto-generating the same effect for an entire map will be extremely
> difficult (and again, once Quesa starts sorting those surfaces you'll
> see major slowdowns).

Renegades is mostly successful due to the hand-creation of lightmaps
combined with some forced-perspective tricks to minimize depth sorting
errors. I'd rather have multipass than to try to algorithmically do
that in Quesa to avoid having a hit with transparent meshes.

=Jeff Quan
<email address removed>

_______________________________________________
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>