More UV issues.. help
Blitz3D Forums/Blitz3D Programming/More UV issues.. help
| ||
I am tinkering with single surface tiled terrain. I am able to get things to look great if i use each tile image as its own brush.. problem is that the suface count goes up with each tile type used.. so now ive put all the tile images on one large image.. and im using one brush. then assigning UVs to each quad so that the proper tile will be presented on the mesh.. but I got this working but, slivers are appearing between tiles. heres the code im using to create the quads please ignore some of the vars as thay are unimportant to this problem.. H1-H4 is vertex height (not causing this problem).. it appears to be a pixel of image next to the tile being put down, like the uvs are spread to wide, but i know that cant be. any advice is greatly appreciated. h1#=H_map(x,z) ;top right height h2#=H_map(x-1,z) ;top left height h3#=H_map(x-1,z+1) ;bot left height h4#=H_map(x,z+1) cnt=CountVertices( surfaceid ) ; Get count of vertices M_VDATA(1,X,Z)=AddVertex(SurfaceID,X-1.0,h2,Z) M_VDATA(2,X,Z)=AddVertex(SurfaceID,X,h1,Z) M_VDATA(3,X,Z)=AddVertex(SurfaceID,X,h4,1.0+Z) M_VDATA(4,X,Z)=AddVertex(SurfaceID,X-1.0,h3,1.0+Z)AddTriangle(SurfaceID,M_VDATA(1,X,Z),M_VDATA(3,X,Z),M_VDATA(2,X,Z)) AddTriangle(Surfaceid,M_VDATA(1,X,Z),M_VDATA(4,X,Z),M_VDATA(3,X,Z)) paintgrid surfaceid,x,z,map(1,x,z)-16 Next Next UpdateNormals meshid End Function ok now here is the problem area.. this is called for each quad to paint it the image is a 1024x1024 with 16 tiles across and 16 tiles down, each tile is 64x64 pixels.. Function PaintGrid(SURFACEID,X,Z,TileIndex) Column=TileIndex Mod 16 Row=1+(TileIndex-Column)/16 spd#=0.0625 VertexTexCoords(SurfaceID,M_VDATA(1,X,Z),(spd#*column)+spd,(row*spd)) VertexTexCoords(SurfaceID,M_VDATA(2,X,Z),(spd#*column),(row*spd)) VertexTexCoords(SurfaceID,M_VDATA(3,X,Z),(spd#*column),(row*spd)+spd) VertexTexCoords(SurfaceID,M_VDATA(4,X,Z),(spd#*column)+SPD,(row*spd)+SPD) End Function and here is an image of the artifact im fighting. |
| ||
bump |
| ||
The artefacts come from mipmapping. You can probably get around it by moving the uv's slightly inwards. Ie: 0.0 -> 0.05 1.0 -> 0.95 or in your code: movein# = 0.05 VertexTexCoords(SurfaceID,M_VDATA(1,X,Z),(spd#*column)+spd-movein,(row*spd)+movein) VertexTexCoords(SurfaceID,M_VDATA(2,X,Z),(spd#*column)+movein,(row*spd)+movein) VertexTexCoords(SurfaceID,M_VDATA(3,X,Z),(spd#*column)+movein,(row*spd)+spd-movein) VertexTexCoords(SurfaceID,M_VDATA(4,X,Z),(spd#*column)+SPD-movein,(row*spd)+SPD-movein)That should take care of most of it! |
| ||
wow, thanks. that worked.. but tiles are pointing the wrong way now.. lol Thanks. :) |
| ||
Oh, just use a smaller movein value :) |
| ||
I found that a nice result gan be achieved, by adding a "bufferborder" of 2 pixels around each tile; increasing width and height by 4. Then make the "movein-value" the width or height of two pixels, to get the position and size of the original tile. |
| ||
nice.. seems a waste to have to do that.. but it works great. |
| ||
ok guys maybe you can help me again . :) i did the above and created a new 1088x1088 texture.. each of the original tiles is placed on it in the same orders as the old texture, only allowing 2 pixels on every side of it. meaning each tile is now 64+2+2+2+2 or 68x68 wich is the 64x64 and 2pixel wide border. now the math should be the same correct? 1088/68 = 0.0625 then you said to assign move in at the 4 pixels? wich would be 4/1088 = 0.0036764705882352941176470588235294 ive tried with a few variations.. but apparently i jsut dont get the math i thought it was simple enough but my calcs arent working. heres the code again Function PaintGrid(SURFACEID,cnt,X,Z,TileIndex) Column#=(TileIndex Mod 16) Row#=1+(TileIndex-Column)/16 spd#=0.0625 movein# = 0.0036764705882352941176470588235294 VertexTexCoords(SurfaceID,M_VDATA(1,X,Z),(spd#*column)+spd-movein,(row*spd)+movein) VertexTexCoords(SurfaceID,M_VDATA(2,X,Z),(spd#*column)+movein,(row*spd)+movein) VertexTexCoords(SurfaceID,M_VDATA(3,X,Z),(spd#*column)+movein,(row*spd)+spd-movein) VertexTexCoords(SurfaceID,M_VDATA(4,X,Z),(spd#*column)+SPD-movein,(row*spd)+SPD-movein) End Function i get it to work ok just moving in the uvs without the 2 pixel buffer, but would liek to get it 100% perfect if i can.. thank you both very much for your help so far |
| ||
I have not looked at your uv-calculation yet, so I don't know if there is a problem. (I always calculate the UV's by using the width and height of 1 pixel. So: pixelwidth#=1.0/texturewidth pixelheight#=1.0/textureheight To calculate a UV-position, You multiply these with the xy-position of a pixel in the texture. simple and fast.) But! You can not have a texturesize of 1088*1088! It must be 512,1024 or 2048! This because of limitations of GFX-cards. Blitz will create a 2048*2048 texture if You Try to create a 1088*1088! Its a bummer, but using this border will prevent the "bleeding" of colours of adjacent tiles. If You don't want to waste this space on Your texture You have to make the tiles smaller, or use the method of Fredborg |
| ||
ah thanks for that info. currently I am using Fredborgs method it works great except that to get it to look right i had to cleartexturefilters to disable mipmapping.. the jaggies in the scene are severe now. |