Jump to content
  • Advertisement
Sign in to follow this  
lonewolff

Texturing issue

This topic is 1492 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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 :)

Share this post


Link to post
Share on other sites
Advertisement

Thanks for the links. Checking them out now.

 

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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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. Edited by unbird

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!