Help Me VertexTextCoords!!!!
Blitz3D Forums/Blitz3D Programming/Help Me VertexTextCoords!!!!
| ||
Hi, I have someone clarifies the possible use of VertexTextcoords ... An easy example to understand their potential uses. A greeting. |
| ||
It has been a while since i went into this, but it is something like: if you have a square (2 triangles) x--x | / | x--x The vertices (x) that make up the 2 tris need uv coordinates. For a straight mapping: 0,0 -- 0,1 1,0 -- 1,1 For a left rotated mapping: 0,1 -- 1,1 0,0 -- 1,0 etc.. the numbers are obviously (U,V) using fractional values like .5,.5 or double values will scale the texture. (but in reverse to what you expect. For example 2.0 will REPEAT twice, so texture will render half the size not be twice the size. - well, depending on which way you look at it :D) Play with it and see, it is not that difficult to work out. :) Last edited 2011 |
| ||
=), well now the question is the last parameter refers to the texture I can climb right? 0 to 3 |
| ||
The coordinate set parameter decides which texture coordinate channel to use. This is often used when using; for example lightmaps where the textures have different UVs to the main channel. I dunno about 0-3 though, i only thought there were 2 coord sets (0 & 1). Last edited 2011 |
| ||
hi this post isn't related with your question here, but there is a code in wich you can play with u,v and see what d4nman expalins. http://blitzbasic.com/Community/posts.php?topic=93660 Juan |
| ||
You can have 4 textures on a brush, but only 2 UV Sets for them. Usually used this way: Set 0: diffuse mapping, the actual texture Set 1: lightmap I never use mre than 2 textures. You could add a Detail Grain Texture on layer 3, so a blur texture will remain "sharp" when watched closely. Note that additional textures may slow rendering down a little bit. |
| ||
=( Although I do not hear how this works, I'm doing tests, all I see is that when using vertextextcoords the texture is much smaller.Graphics3D 800,600,32,False SetBuffer BackBuffer() Local Camara = CreateCamera() Local Cubo = CreateCube() Local Sol = CreateLight() Local Textu = LoadTexture("bump.jpg") EntityTexture Cubo,Textu PositionEntity Cubo,0,0,4 Local SP = CountSurfaces(Cubo) Local V = 0 Local S Local Super For S = 1 To SP Super = GetSurface(Cubo,S) Next For V = 0 To CountVertices(Super) VertexTexCoords Super,V,.5,.5 Next Repeat TurnEntity Cubo,0,1,0 RenderWorld Text 0,0, SP + " " + CountVertices(Super) Flip Until KeyHit(1) End |
| ||
hi you are defining u,v 0.5 for all the vertex, i think that you aren't seeing a texture at all. see the cube information: vertex coords, uv coords and triangles, execute the following code: Graphics3D 800,600 cube = CreateCube() For i=1 To CountSurfaces(cube) surf=GetSurface(cube,i) DebugLog "surface: "+i+" : "+surf DebugLog "has the following vertex position and uv's" For vert=0 To CountVertices(surf)-1 DebugLog "vertice: "+vert DebugLog "3d Position: "+VertexX(surf,vert)+", "+VertexY(surf,vert) + ", " + VertexZ(surf,vert) DebugLog "UV coords "+VertexU(surf,vert)+", "+VertexV(surf,vert) DebugLog "" Next DebugLog "Triangles made by the following set's of vertices:" For tris=0 To CountTriangles(surf)-1 DebugLog "triangle: "+tris+" "+TriangleVertex(surf, tris, 0)+" "+TriangleVertex(surf, tris, 1)+" "+TriangleVertex(surf, tris, 2) Next Next WaitKey() visualize the first triangle (made by vertex 0,1,2 ) is facing us: ..V0 V1 ..------ ..\.....| ...\....| ... \...| .... \..| ......\.| .......\| ..V3 V2 Imagine you have a piece of paper (the texture) and you skin the triangle with it. There are many ways you can do it. Supose you don't rotate the paper. So you start with 0,0 (width, height) and casually, the x,y of the triangle is equal to the x,y of your piece of paper. In this situation, your paper extends form start to end matching perfectly your trinangle (obviously you have a square piece of paper and a half of the square has no triangle to cover) vertex 0, has 0,0 uv coordinates so you are saying: place the x start of the texture and the y start of the texture here at 0,0. in the image texture it extends from 0 unitl it ends on 255, 511 or whatever depending on the size of the bitmap. In the u,v space 0 means start point and 1 means end point. The default textrue coords (for a cube) dictates that the texture will skin the cube matching exactly one face of it. You can change every 1 in the u,v for 2 or 0.5 to scale texture up/down a slight modification of your code sould be: the modification is that this code only modifies the "not 0" u or v for the double or half value. Juan Last edited 2011 |