Archived

This topic is now archived and is closed to further replies.

cone3d

Polygons to patches

Recommended Posts

Hi all. I''ve got a little question. Let''s say I have a little polygon (with 3 or more vertices). How do I divide it into little square patches (so that I could calculate radiosity)? All the help would be appreciated
---
cone3d
http://cone3d.gamedev.net
My software never has any bugs - it just generates random features

Share this post


Link to post
Share on other sites
What kind of patches ?

Do you want to geometrically subdivide your mesh or you want a radiosity lightmap ?

In the first case, it''s not that easy, since it involves geometric boolean operations, which are somewhat unstable by definition (rounding errors).

There are 2 possibilities: you can take an (infinite) quad patch (mathematically defined) and do a boolean intersection operation between the patch and your planar polygon. The result is a quad patch trimmed to the outer contours of your polygon.

Second possibility is to recursively subdivide your polygon mesh at some predefined gridlines. This can be tweaked to be pretty stable, but it''s rather hard to code and might increase your facecount far above the optimal level achieved with the first method. You might need to reapply a geometric optimization pass afterwards.

All in all, I would strongly suggest to use radiosity maps instead.

Share this post


Link to post
Share on other sites
Radiosity is what I''m trying to achieve here. I understand all that I need to write a radiosity preprocessor except how to subdivide a polygon into patches and later create a lihtmap out of them.


---
cone3d
http://cone3d.gamedev.net
My software never has any bugs - it just generates random features

Share this post


Link to post
Share on other sites
Well, the problem here is the term ''patches''.

There are several different ways displaying radiosity in a scene (and several more calculating it). The essence is, that you need to sample your polygons at a sub-vertex level of any sort. Means, that you need more light control points than just the original vertices, so that lighting discontinuities can be correctly rendered. The area influenced by such extended light control points is called a patch.

There are 2 mainstream methods to do that:

*) patch subdivision. Simply subdivide your polygon into lots of smaller ones. That''s what I explained in the previous post. Now calculate your radiosity values for each newly created vertex and use normal gouraud interpolation to display the result in realtime. You can go pretty far with this method, using adaptive subdivision, etc. The nice thing about it is, that you won''t need any lightmaps in your game afterwards, so you can use all your texture units to do some interesting other stuff (eg. bumpmaps). The downside is the *massive* amount of faces it will generate, so it is normally no good idea for use in consumer level 3D graphics.

*) lightmaps. Totally unrelated to patch subdivision above, but the results are visually approx. the same (although subdivision gives slightly better results). Your polygons aren''t subdivided in any way, but you need lots of texture memory for your lightmaps.

Essentially, this is what you do: you apply a texture to every planar polygon in your scene. Now, try to look at your scene, those textures applied, but without interpolation. You will see lots of blocky texels, just as in the old software renderer days. Guess what, those blocky texels are your patches What you do in your radiosity algorithm, is calculate the exact position of each applied texture patch (texel) by computing it''s 4 corner coordinates on the polygon plane. Then you use that information to gather radiosity through whatever else algorithm you use (eg. hemicube). Assign the resulting radiosity value to the texture texel value. Now, in realtime, you just display the radiosity lightmaps as normally interpolated modulated lightmaps, and supply the same texture coords than you used when calculating your patches in the first place.

Share this post


Link to post
Share on other sites