Search Home Members Contacts
About Us
Products
Downloads
Community
Support
Pages: [1]
  Print  
Author Topic: Textured quad UV problem !!!  (Read 3587 times)
harikumar001
Customers
Community Member
*****
Posts: 65


« on: April 23, 2011, 04:11:52 AM »

Hi guys,

I am working on an image processing application that takes a texture as input an generates a perspective transformed output based on a quadrilateral the size and shape of which the user decides. I also need to tile the perspective output to correctly fit a rectangle of a preset size.

eg: http://i19.photobucket.com/albums/b193/Coincoin/perspective-correction.png

I could get the image transformed in perspective using some image processing libraries, but cannot get the tiling part done. Did a lot of research. I used a big tiled image as input but get memory errors as the size increases.

So I thought I will use TV3D to generate the tiled perspective image. To test it, I created a quad using add vertex (2 triangles) and set the UV values appropriately. But the output shows a mismatch along the line that separates the two triangles. What can be done regarding this?
Any ideas?

Here is the image showing the issue:

http://www.4shared.com/photo/CUhFc7aO/Quad.html

Regards

Code:
Code:
Quad = Scene.CreateMeshBuilder("Quad");
Quad.SetPrimitiveType(CONST_TV_PRIMITIVETYPE.TV_TRIANGLELIST);
Quad.AddVertex(0, 100, 0, 0, 0, 1, 0, 0);
Quad.AddVertex(150, 120, 0, 0, 0, 1, 1, 0);
Quad.AddVertex(0, 0, 0, 0, 0, 1, 0, 1);
Quad.AddVertex(0, 0, 0, 0, 0, 1, 0, 1);
Quad.AddVertex(150, 120, 0, 0, 0, 1, 1, 0);           
Quad.AddVertex(100, 0, 0, 0, 0, 1, 1, 1);
Quad.SetTexture(IDDiffuse);
« Last Edit: April 23, 2011, 04:15:12 AM by harikumar001 » Logged
Lenn
Customers
Community Member
*****
Posts: 876

+/-


« Reply #1 on: April 27, 2011, 04:07:11 AM »

hariku,
this is simply 3D rendering works. The UV per-pixel on a point of a triangle is calculated as a linear average between the three points on that triangle. In order to do what you want you would need a mesh with a lot more triangles. The more, the better the approximation will be, so maybe try something like a grid 1000x1000, and then move the vertices based on distance from corner (when moving corner).

There would also be a way to do this with a shader on a 2-triangle quad, but if you dont know how to do it, it would take too long to explain.
Logged

TV3D 6.5 Community Docs - Read, use and please contribute!
SylvainTV
Administrator
Community Member
*****
Posts: 4971


WWW
« Reply #2 on: May 01, 2011, 03:20:29 PM »

Perspective correction for texturing is done when you render 3D things only.
The actual operation for correction is dividing by w which is linked to the depth of the pixel on the screen. If you render only 2D triangles you will have this kind of problem.

BTW this problem was handled on IRC and he is now using a method using OpenCV for perspective.
Logged

Regards

Sylvain Dupont
TrueVision3D Developer
sylvain@truevision3d.com

TV3D IRC at http://chat.truevision3d.com or on server irc.truevision3d.com #Truevision3D. Come talk with us !
Pages: [1]
  Print  
 
Jump to:  

Powered by SMF 1.1.3 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks