Surfaces and textures

Blitz3D Forums/Blitz3D Programming/Surfaces and textures

_PJ_(Posted 2009) [#1]
Can someone please let me know if i understand this all correctly...

A mesh is typically 'built' of vertices (points) that are considered the vertices of triangles (being the simples polygons) this structure of triangles form the outer faces of the 3D mesh, though there may be more than one triangle in a flat face to make, for example, a rectangular face as one face of a cube:
___
| /|
|/ |
¬¬¬¬


A 'Surface' is a collection of some or all of these triangles. By splitting the mesh into differing surfaces, separate areas can be given separate textures and therefore the mesh as a whole can have a much better quality texture since the resolution of pixels of the texture wont have to be 'stretched out' over the entire 'surface area' of the whole meshs' triangles.

To apply a texture, the a surface can be considered 'unfolded' from the geometry of the mesh, so all the triangles of the surface lie on a plane. Althouugh this may leave 'gaps' in the plan view, these are simply ignoerd. Also, the surface triangles are arranged to fit within a square.

The texture, a square, 2D image, can then be mapped directly onto the surface. Any areas of the texture image that correspond to the 'gaps' in the surface as mentioned above, will simply not be drawn.

When the texture is applied, and viewed on the mesh, the surface that was textured displays the texture wrapped around the mesh geometry as intended.

Texture coordinates differ from standard image coordinates in two ways:

-- Image coordinates are generally referred to as X and Y for the horizontal and Vertical. Texture Coordinates are named U and V denoting horizonal and vertical but to distinguish from the 2D field. U and V refer to a 3D property.

-- Image coordinates reflect the actual size of the image, whilst texture coordinates are ratios. U and V only go from 0 to 1

--Texture Coordinates can be attributed a 3rd coordinate value, W (or Z) which relates to the position of a texel* when applied in 3D space.


Jiffy(Posted 2009) [#2]
You're overcomplicating this.

Triangles are made of vertices, both of which which must belong to a surface. There is a hardware limit on that number, which I forget- but it's pretty big.
A surface may have multi-textures- the limit of which is determined by the hardware. Software can fake this, but it will slow things down.
Any vertice is give an xyz placement, and uv(w) value.

All concepts of mapping, unfolding and such are, in a rough sense- interpretations of data. Higher res textures mean higher res models- unless you map the display area badly, and 'stretch' a 'big' tri to a 'small' uv texture area. Also, some cards don't like textures bigger than the selected display size.

tri areas automatically determine orientation based on uv position, thereby rotating or 'flipping' as needed.
UV do go from 0 to 1, but negatives and oversized can be used to do wrapping/tiling.

I think the texel thing is an application-specific use when using the a-buffer(?) or whatever. I think 'normally it is ignored, and commonly 'may' pick a texture or surface. I'm not sure, but I don't think there's a standard.

The major issue with slowdown usually is more a matter of surfaces than polycount. This is fun to get around, because using alpha complicates z-ordering things so that grouping surfaces can get messy. You know what? ignore this bit. Just use alpha sparingly or cleverly, or expect some tweakiness.

I'm sure this won't answer all your q's, but maybe it'll help.


_PJ_(Posted 2009) [#3]
Thanks, it does help some, but I still find it a bit confusing.
I'm glad you cleared up the vertex XYZ and UV(W) thing that really helps.

I understand the implications of negative UV, but that's beyond what I am looking at for now, same as with multiple textures.

What I am unsure of, and where I am ultimately heading with this, is how does one know which 'piece' of texture applies to which particular triangle?

It's all very well suggesting vertices have the texture coords, but how do a vertex's coords relate to a coordinate on a 2D texture image and how can one know the relative orientation of the texture to that vertex?
Assuming that triangular 'sections' of the texture are applied to the triangles formed from the vertices.


Jiffy(Posted 2009) [#4]
The vertices actual 3d coords (x,y,z) have absolutely nothing to do with the 2d texture image (uv).
Any 3dspace triangle plays 'connect the dots' with a particular 3 points on a 2d page. Doesn't matter the facing, angle or rotation- the image on that triangle is a cutout of the selected points '1', '2', '3' of that 'connect-the dot' page. And the x,y for each 1,2,3 pair are determined entirely by uv's assigned each of the vertices 1,2,3.
4___3
 | /|
 |/d|
2¬¬¬¬1 (mesh)
 _______
|      |
|1___2 |
| |p/  |
| |/   |
|3     | (texture)
|______|



_PJ_(Posted 2009) [#5]
Got it, thanks so much, Jiffy that really helps :)


Jiffy(Posted 2009) [#6]
np.


neoshaman(Posted 2009) [#7]
W doesnot count use to store extra info vertice wise.

UV is not related to XYZ, it is just an user define projection of the vertice onto the texture map.

Each 2D triangle "user projected" (because you choose the coordinate of his vertices) define on the texture an area that will be display by the triangle in the 3D space.

That mean that the triangle projected on the texture may certainly not have the same dimension/proportion than the triangle in 3D space.

This difference create distorsion of the texture displayed in 3D space as pixel try to cover the triangle, ending stretched.

Artist try to have uniform repartition of pixel but you always have some stretch, you can only minimize the effect (because you can't perfectly develope a 3D model on a flat surface without loss).

That mean that orientation of the image from the texture in 3D really depend on how you put your projected triangle on the image space (UV)

But best is to look how actually we do it :)

Look these video and you will see how we actually create a UV for a 3D model by projecting Triangle on the texture map!

http://cg.tutsplus.com/tutorials/3d-art/model-uv-and-texture-a-complete-manga-character-in-blender-day-3/