Getting UVs from Polygon

Hi everybody,

I’m using the Triangle-Contribution to create a polygon-mesh. Now I would like to map a Texture to it, and there I’m a bit stuck. I don’t get how to convert from object-space to texture space. I know the differences, but the math is giving me a little headache. I appreciate any hint.

thanks

triangle_Polygon.zip (10.9 KB)

I can’t get it to work, it’s pink AF.
Rereading it, the math is that vertex coords lie in -1[…]1, tex coords in 0[…]1, also dx tex start from upper left, and propagates to opposite corner.

If you want to map a 2*2 grid of Scale 1 (vertices at +/-0.5) you’ll simply take those vertices and map them into a 0[…]1 interval. So the top left corner (vertex coords: -0.5,0.5) will have 0.0,0.0 tex coords. The vertex at -0.5,0.0 will have 0.0,0.5. The bottom left vertex at 0.5,-0.5 will have 1.0,1.0; so you see it’s a 0.0[…]1.0.

This would work in dx9; don’t know in 11, but it shouldn’t be too different.

Crazy… which nodes don’t work?

Triangle

Edit: It’s a pack!

Reedit: Add a iid and a uv_coords between indexedgeometrybuffer and constant.fx
and in InputElement put also normals (format as the position) between position and texturecoord

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.