Texturing issue

Started by
5 comments, last by 21st Century Moose 9 years, 11 months ago

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

Advertisement

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/

Thanks for the links. Checking them out now.

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

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

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.
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.

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.

Direct3D has need of instancing, but we do not. We have plenty of glVertexAttrib calls.

This topic is closed to new replies.

Advertisement