Alpha flag = geometry holes?
Blitz3D Forums/Blitz3D Beginners Area/Alpha flag = geometry holes?
| ||
I'm probably doing something dumb but if I give my terrain the Alpha flag: EntityFX terrain, 32 OR load my texture (DXT3 or png) with the alpha flag: LoadTexture( "tiles.dds", 1+8+16+32 ) I get this where the terrain geometry is munted (sort of holes through things): ![]() Any ideas? (I generate the terrain programmatically so may be something I've done.) |
| ||
Can you post the pertinent code where you generate them programmatically? |
| ||
Do you think it is related to that then? Hmm ok I'll try to extract some code when I get home tonight - it's pretty crazy code though :P |
| ||
quote: OR load my texture (DXT3 or png) with the alpha flag: LoadTexture( "tiles.dds", 1+8+16+32 ) Alpha flag for a texture is 2, so add this. Also, you may not have to force alpha using EntityFX 32 as long as the texture is already using the Alpha flag. |
| ||
Oops yes jfk I copied and pasted incorrectly. My test was in fact using flags 1+2+8+16+32. I disabled my terrain "sides" construction but the problem is still occurring so here is the code simplified, which constructs a grid of 1x1 squares. Each corner can be of varying height. Textures(2) = LoadTexture( "tiles.png", 1+2+8+16+32 ) Global t = CreateMesh() brush = CreateBrush() BrushTexture brush, Textures(2), 0, 0 s1 = CreateSurface( t, brush ) size = G\MapSize For z = 0 To size For x = 0 To size AddSquare( t, s1, x, z ) Next Next UpdateNormals t FreeBrush brush Function AddSquare( t, s1, x%, z% ) Local y1# = MapData(x,z,1) Local y2# = MapData(x,z,2) Local y3# = MapData(x,z,3) Local y4# = MapData(x,z,4) ;UV calculations in here z = 0-z v1 = AddVertex( s1, x, 0+y1#, z, UVStartX, UVStartY ) ;top-left v2 = AddVertex( s1, x+1, 0+y2#, z, UVStartX + UVWidth, UVStartY ) ;top-right v3 = AddVertex( s1, x+1, 0+y3#, z-1, UVStartX + UVWidth, UVStartY + UVWidth ) ;bot-right v4 = AddVertex( s1, x, 0+y4#, z-1, UVStartX, UVStartY + UVWidth ) ;bot-left t0 = AddTriangle( s1, v1,v2,v3 ) t1 = AddTriangle( s1, v1,v3,v4 ) End function Also here's another picture showing it a bit better, with three tiles elevated (they're different heights and the perspective makes them look a bit smooshed). Pic #1 is in "true form" with no alpha flag. Pic #2 is with alpha flag 2 turned on my PNG texture. Pic #3 I tried saving my PNG without transparency but still loading it with alpha flag! O_o; Is that right... ![]() |
| ||
Hmm just read a post by jfk in another thread: "use DDS DXT3 alpha masked textures with the mask flag to get best results and intact z-order" I think I may be getting confused between alpha and masking, I'll check it out. But still, the affect of turning on alpha flag on my texture seems odd. |
| ||
whenever you use alpha, the triangles of a mesh are "unsorted", this leads to the well known z-order artefacts. As long as you don't need semitransparent parts you should use Masks instead, the have no z-order problems. When using DDS with alpha information for masks, they are still simple masks, only DirectX will utilize the alpha info to draw an interpolated outline. BTW when you load a texture with the alpha flag and the texture doesn't contain specific alpha information, then the darkness of the pixels are used to set the transparency level. |