Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!


1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


Texturing issue


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
6 replies to this topic

#1 DarkRonin   Members   -  Reputation: 636

Like
0Likes
Like

Posted 12 May 2014 - 06:23 PM

Hi Guys,

 

I am having troubles with texturing a 2D Quad.

 

If I texture a square shaped quad all looks ok. But if I make the quad a rhomboid shape the texture doesn't stretch properly.

 

I fully understand that what is happening 'is' correct, as it is mapping correctly with its given UV's. But, I am wondering if there is a way to stretch the image rather than map this way (see below).

 

mapping.png

 

I'd rather not go down the path of any 3D as my game is strictly 2D based. I'd just like to be able to make odd shaped quads and have them map as intended.

 

Thanks in advance :)



Sponsor:

#2 C0lumbo   Crossbones+   -  Reputation: 2772

Like
2Likes
Like

Posted 12 May 2014 - 11:05 PM

This problem is a real pain. Here's a couple of articles that address it. Basically you need to be able to mess around with the q coordinate.

 

http://www.reedbeta.com/blog/2012/05/26/quadrilateral-interpolation-part-1/

https://home.xyzw.us/~cass/qcoord/



#3 DarkRonin   Members   -  Reputation: 636

Like
0Likes
Like

Posted 12 May 2014 - 11:23 PM

Thanks for the links. Checking them out now.

 

What is the q co-ordinate? First time I have heard of it.



#4 Hodgman   Moderators   -  Reputation: 36418

Like
0Likes
Like

Posted 21 May 2014 - 01:50 AM

Instead of 2D uv/st/xy values, you can supply 4D uvwq/strq/xyzw values. The 4th value here is the "q coordinate"



#5 DarkRonin   Members   -  Reputation: 636

Like
0Likes
Like

Posted 21 May 2014 - 02:17 AM

Thanks Hodgman.

Before this thread I had never heard of wq in texture mapping.

I tried to follow the links above but the first is OpenGL based and the second uses a Shader Model 4 shader as the solution.

I am looking for a way I can do this in DX9, preferably fixed function, shader if it is nessesary.

#6 unbird   Crossbones+   -  Reputation: 6508

Like
1Likes
Like

Posted 21 May 2014 - 02:39 AM

This is a recurring problem. I once found a solution myself using a bit a convoluted approach here. More elegantly one can use homogenous 2D coords, derived here by (of course) Alvaro. IIRC this is the same approach Blinn showed in his Notation3 book.

PS: This works with FFP, too.

Attached Thumbnails

  • Quad2D.jpg
  • Quad2DFakePerspective.jpg

Edited by unbird, 21 May 2014 - 02:45 AM.


#7 mhagain   Crossbones+   -  Reputation: 8996

Like
0Likes
Like

Posted 21 May 2014 - 02:49 AM

I'm not aware of any way to do this with fixed-function D3D9.

 

Correction: you may be able to do it, and it probably does work, by using a vertex declaration in combination with fixed pipeline code, or even with D3DFVF_TEXCOORDSIZE4 if you're still using FVF codes, but it's so long since I've done any real fixed-pipeline work that I'd advise you just go for shaders.

 

The GL or SM4 code should be easy for you to translate to SM3 HLSL: the calculations will be the same so you're just dealing with syntax differences.


It appears that the gentleman thought C++ was extremely difficult and he was overjoyed that the machine was absorbing it; he understood that good C++ is difficult but the best C++ is well-nigh unintelligible.





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS