# [0,1]^2 mapping to arbitrary light source

###
#2
Anonymous Poster_Anonymous Poster_*
Guests - Reputation:

Posted 28 August 2001 - 05:25 AM

###
#3
Members - Reputation: **122**

Posted 28 August 2001 - 05:40 AM

Now I want to create a uniform mapping from the unit square (2D domain) to my light source (3D domain) which consists of triangles (for instance a triangulated sphere).

I need the mapping to generate sample points on my light source for lighting calculations.

Edited by - TM on August 28, 2001 12:41:41 PM

Edited by - TM on August 28, 2001 12:43:40 PM

###
#4
Members - Reputation: **169**

Posted 28 August 2001 - 06:10 AM

-- I''m not sure I understand this - Seems backwards to me. Don''t you need to generate points on the surface, or are you using a volume light and trying to generate shadows?

Well, I''ll assume the former first, that you''re trying to generate values for the interior points. This is very similar to interpolative shading. Seeing that you know what ranges and domains are, I''m sure you''re somewhat versed in math. Go look up Gouraud or Phong Interpolative Shading Techniques. I''ll give you a quick run down of the two here.

Polygons are only defined at their vertices. That is, they''re defined by a descrete, non-continuous collection of points. Basically, both Phong and Gouraud shading give you lighting values for interior points of a polygon.

In order to use these techniques, you must have 1) the 1, 2, or 3d coordinates of the vertices, and similarly dimensioned surface normals at those points. Surface normals are the vectors that are perpendicular the actual surface the vertices are approximating. If you''re modeling, say, a gem, each polygon represents the surface exactly, in which case the surface normals are the normals of the polygon, but if you''re modeling, say, a sphere with flat polygons, the surface normals should be the normals of the sphere, and not the normals of the polygons.

Anyway, for Gouraud shading, calculate the scalar lighting values at each of the vertices, and interpolate this value between each vertex. This will give you the values at the vertices, and the values of the bounding lines on the outside of the poly. Now just interpolate between these lines scanline by scanline, left to right.

Phong shading''s only difference is that, instead of interpolating the lighting value, you interpolate the actual normals, which means interpolating vectors instead of scalars and recomputing the lighting equation for each pixel instead of just the vertices.

Does that sound something like what you''re trying to do?

Remember - that mapping you''re doing, though tecnically (in mathematical terms) is 2d, it really is being done in 3d - those [0..1]''s are just interpolation mapping values between 3d points.

Thank you for your bandwidth,

-- Succinct

###
#5
Members - Reputation: **122**

Posted 28 August 2001 - 08:37 PM

I need a set of sampling locations on my light source. This source is a volume described by triangles.

Now suppose I use a pseudo-random sequence generator which generates a 2D point in the unit square (like Halton for instance). Now how do I map this 2D point to a 3D point on my light source in a uniform fashion.

So, if I would have a NxN uniform grid in the unit square, this would generate NxN uniformly distributed samples on the source.

For your information, these samples are needed for radiosity calculations.

Is this information sufficient?

###
#6
Members - Reputation: **122**

Posted 29 August 2001 - 03:22 AM

From the description you just gave, your unit square is sounding like a 2d intensity map that you are trying to wrap around a polygonal model, much like a texture map. Is that what you had in mind?

###
#7
Members - Reputation: **122**

Posted 29 August 2001 - 04:04 AM

I use these samples as point light sources, because they can easily be rendered with hardware. It''s comparable to soft shadow computation, where point samples are taken on an area light source.

###
#8
Members - Reputation: **142**

Posted 29 August 2001 - 01:05 PM

Of course, I may be misinterpreting what you''re saying entirely!

###
#9
Members - Reputation: **122**

Posted 29 August 2001 - 10:58 PM

I''m not talking about spherical light sources, but arbitrary shapes ones.

What the hell, maybe there''s no a clean solution to this problem. I guess you''ll always have to assume that the source is a sphere, a square, a box, or other geometry.

###
#10
Anonymous Poster_Anonymous Poster_*
Guests - Reputation:

Posted 30 August 2001 - 02:49 AM

Even if you got a regular arrengement of points off the light source and used them as point lights, you''d still have some icky problems to solve. 1) Hardware only supports so many lights, depending on the card. Usually in the single digits. 2) Unless the rays from the object to the point light sources are nearly the same (point lights very close to each other) your specular highlights are going to look incorrect. In the general case, you''ll end up needing more than 10 or so hardware point lights in order to avoid this. You couldn''t model a decent size flourescent light diffuser panel without hitting that kind of problem.

You might as well generate lightmaps in software, by integrating over the surface of the light source or something, rather than approximating with many point lights.

###
#11
Members - Reputation: **142**

Posted 30 August 2001 - 04:42 AM

But I''m still not entirely sure what you''re trying to do, so I''m functioning off of a guess!

###
#12
Members - Reputation: **169**

Posted 03 October 2001 - 12:05 PM

How could you possibly define this? A uniform jitter of an arbitrary surface? I don't think you have enough information. You could do it if, as the AP stated, if you have an equation for the surface

****

********

**********

***********

***********

***********

***********

**********

*******Z

****Y--|

------\-|

-------\|

=======X=======

What criteria can you define that says to choose Y as a sampling point over Z? The only thing's I can say would be the following points:

1) the closest point on the light to the point

2) the collection of points defining the silhouette edge of the light relative to a projection from the point under consideration to point 1.

Not to mention all of the interior points!

How do you choose which points are more important than others? I don't see how you can for an arbitrary surface - you just plain have to know somethign about it...

Besides, I thought radiosity delt with entire surfaces, not sampled points.

Edited by - Succinct on October 4, 2001 1:10:49 PM