Not logged in, Join Here! or Log In Below:  
 
News Articles Search    
 

 Home / 3D Theory & Graphics / Texture projection Account Manager
 
Archive Notice: This thread is old and no longer active. It is here for reference purposes. This thread was created on an older version of the flipcode forums, before the site closed in 2005. Please keep that in mind as you view this thread, as many of the topics and opinions may be outdated.
 
Eddy Akman

May 26, 1999, 05:35 AM

I just can't seem to get my head around it:

I have a mesh which I render in the ordinary way. But I also have this 'camera' which projects a 2d bitmap, just like in real life. But how do I project that bitmap (texture) onto theat mesh? It's like pointing a overhead sheet projector onto a random object like a human. The image will perfectly 'wrap' around it.. but how can this be done?

 
Phantom

May 26, 1999, 06:45 AM

Eddy Akman wrote:
>> I just can't seem to get my head around it:
>> I have a mesh which I render in the ordinary way.
>> But I also have this 'camera' which projects a 2d
>> bitmap, just like in real life. But how do I
>> project that bitmap (texture) onto theat mesh?
>> It's like pointing a overhead sheet projector onto
>> a random object like a human. The image will
>> perfectly 'wrap' around it.. but how can this be done?

Try this: The 2D bitmap can be seen as a 'volume',
starting at the projector, with a pyramid shape.
Every object that is (partially) in this volume
should be 'lit' with the projected texture. So, you
have to clip every polygon against this volume, and
every polygon (portion) that is inside the volume is
then drawn twice: Once in the ordinary way, the
second time with a part of the projected texture.
Problem is, how to find the U/V coordinates in the
projected texture for the illuminated polygon.
You can calculate this U/V like this:
For each vertex of the clipped polygon, calculate
the distance to all four boundary planes of the
pyramid volume. Divide the distance to the 'left'
plane by the distance to the right plane plus the
distance to the left plane. This gives you a value
between 0 and 1. Then multiply this value by the
size of the projected texture. Now you have U. Do
the same for V, except this time you use the top
and bottom plane of the pyramid.

That should do the job (it works fine in Focus,
anyway). There seem to be some nasty problems with
the 3D->2D conversion of the texture that you
find this way: The usual perspective correction
seems to warp the texture slightly. The VooDoo has
a special way of projecting these textures, but
I don't know how it's done, and why it's neccessary.
Maybe someone else? Focus simply uses a affine
mapping, and that works pretty good for projected
light spots. If you are going to project a real
image, it won't look so good, I'm afraid...

Greets,
Phantom.

 
Colas

May 27, 1999, 03:02 AM

A idea :

when you project your vertices on the screen , simply use the x,y coordinates as
the u,v of your mapping coordinates

too simple ?
of course you should scale the u,v coordinates ...

 
Eddy Akman

May 27, 1999, 08:08 AM

I found a solution.

 
Led

May 27, 1999, 10:34 AM



Eddy Akman wrote:
>>I found a solution.

Would you mind sharing it..?
Otherwise it doesn't make any sense stating so :]

 
Led aka L.e.Denninger

June 02, 1999, 07:57 AM

>> ..Blablah..
>>There seem to be some nasty problems with
>>the 3D->2D conversion of the texture that you
>>find this way: The usual perspective correction
>>seems to warp the texture slightly. The VooDoo has
>>a special way of projecting these textures, but
>>I don't know how it's done, and why it's neccessary.
>>Maybe someone else?
>>Greets,
>>Phantom.

Tadaah, someone else knows :)
For projected textures (like videobeamers, light/shadow-volumes etc.) the perspective correction is a li'll bit different.
Normally one would use (1.0/w), (u/w) and (v/w) for persp. correction, but with projected textures the W-value is different than for nonprojected ones.
the W-value to be used for projected textures is in fact (q/w),
where
q = homogeneous distance from projection-source,
w = homogeneous distance from the cameraposition || eyeposition - whichever term you prefer :)

The Voodoo-card (And as far as I know all other 3d-cards too) has special thingies that make it possible to use this without affecting depthbuffering; check the glide-Sdk for more info.

Hoping to have confused you just that *little* bit more ;),
Greets,
Led

 
Led aka L.e.Denninger

June 02, 1999, 07:57 AM

>> ..Blablah..
>>There seem to be some nasty problems with
>>the 3D->2D conversion of the texture that you
>>find this way: The usual perspective correction
>>seems to warp the texture slightly. The VooDoo has
>>a special way of projecting these textures, but
>>I don't know how it's done, and why it's neccessary.
>>Maybe someone else?
>>Greets,
>>Phantom.

Tadaah, someone else knows :)
For projected textures (like videobeamers, light/shadow-volumes etc.) the perspective correction is a li'll bit different.
Normally one would use (1.0/w), (u/w) and (v/w) for persp. correction, but with projected textures the W-value is different than for nonprojected ones.
the W-value to be used for projected textures is in fact (q/w),
where
q = homogeneous distance from projection-source,
w = homogeneous distance from the cameraposition || eyeposition - whichever term you prefer :)

The Voodoo-card (And as far as I know all other 3d-cards too) has special thingies that make it possible to use this without affecting depthbuffering; check the glide-Sdk for more info.

Hoping to have confused you just that *little* bit more ;),
Greets,
Led

 
Michael Abrash

June 15, 1999, 02:23 PM



Led wrote:
>>
>>
>>Eddy Akman wrote:
>>>>I found a solution.
>>
>>Would you mind sharing it..?
>>Otherwise it doesn't make any sense stating so :]

Remember what I said at the outset, that knowing something has be done makes it much easier to do ?

 
Led

June 18, 1999, 04:17 AM



Michael Abrash wrote:
>>Remember what I said at the outset, that knowing something has be done makes it much easier to do ?

True.
I just think it's a good thing for everybody to share knowledge / information.
If someone knows the solution for worldpeace - why let everyone else figure it out for themselves..? :]
I guess that 'oldskool' "information-wants-to-be-free" blabla doesn't work anymore for the new generation programmers..?


Greetings earthling,
Led

 
Colas

June 29, 1999, 06:55 AM

Led

I have read your answer to finf the correct u,v,w coordinates for texture projections
but i dont understand why the standard perspective projection is wrong
i dont understand what you call a homogeneous distance (??)

maybee do you have an article/tutorial where you have learn ??
i search the proofs or a example to understand

thank in advance

Colas

 
Led / L.e.Denninger

July 02, 1999, 05:14 AM

Colas wrote:
>>Led
>>I have read your answer to finf the correct u,v,w coordinates for texture projections
>>but i dont understand why the standard perspective projection is wrong
>>maybee do you have an article/tutorial where you have learn ??

Colas, I can only show you the door - you have to walk through it yourself ;]
But seriously - check out the 3DFX / Voodoo SDK, that's where I got it from.
Even better - hang on, I'll try to cut 'n paste it here :

>The GrVertex structure also includes a small array of GrTmuVertex data structures, one for >each TMU present in the system, and each of the array elements contains private oow, sow, and >tow variables. Each TMU and the Pixelfx chip each have their own copy of 1/w, s/w, and t/w. >Normally, they will all be the same. However, projected textures have a different w value >than non-projected textures. Projected textures iterate q/w where w is the homogeneous >distance from the eye and q is the homogeneous distance from the projected source.

If you do not understand the term 'homogeneous distance', you'll have to look into the subject of homogeneous coordinates; a way of describing your vertices with 4 components : X, Y, Z and W.
It's covered in almost every serious 3d-programming book / tutorial.
(Do not read the 'demo-coder' tutorials as those are mostly written by guys who started 3d-coding like 4 months before they wrote that doc (although there are few exceptions)- trust me, I know :))
Instead try to realize the truth - read University-papers, research-stuff, openGl docs etc. :)

>>thank in advance
>>Colas

Hoped to be of any help,
Ciao bebe

Led

 
This thread contains 11 messages.
 
 
Hosting by Solid Eight Studios, maker of PhotoTangler Collage Maker.