• This Website Is Not For Sale
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Strange line on the road

Discussion in 'Bob's Track Builder' started by Barbje_Keller, May 3, 2010.

  1. Hy, I have strange effect with my texture on the road. Lines - between different textures... :frown:

    In BTB, this don't seen. :mad: I try everything but not have result without it
    I'm sure that don't leave any line on textures pictures, this is effect from BTB... Any body can help me!?!
  2. Kris Vickers

    Kris Vickers
    Hardware Staff

    There will be very slight transparency on the outer edge of your texture.
    What your best off doing is
    1. create a new layer (in your dds file)
    2. fill it with the most common colour (a sandy colour)
    3. put that layer underneath your track texture
    4. merge the 2 layer
    5. put it back into BTB and see the difference

    I had the same thing.
  3. But in DDS file not support layers or background, I think that is BTB bug... I find this bug in another my project too, (with different textures...) Dam :(
  4. It might mean - check the textures again in Photoshop (or anything you use) - if there are any thin transparent areas/lines. So, convert from dds back to psd or check your original pictures?
    I know that when I crop pictures which are on single layers (and the whole picture is not flatten), Photoshop leaves a single pixel line of transparency at the borders. Look there - at the borders.
  5. it is not a BTB bug, is more likely an anti-aliasing problem or a texture sampling problem.

    a direct x effect usually specifies a set of parameters for each texture
    which defines how a texture is to be handled, these are called sampling parameters, all together forming a sampler".
    you'll see them in fx files looking like this:
    sampler2D diffuseMap = sampler_state
    	Texture		= (diffuseTexture);
    	AddressU	= WRAP;
    	AddressV	= WRAP;       
    	MinFilter	= ANISOTROPIC;
    	MagFilter	= ANISOTROPIC;
    	MipFilter	= ANISOTROPIC;
    	MIPMAPLODBIAS	= -2.0f;
    	MAXANISOTROPY	= 2.0f;
    you can find a full description of all the parameters in direct x documentation but in this case what you should care about is AddressU and AddressV; these two parameters are, simply put, controlling what happens at the "edge" of the texture.

    in an ideal situation, with a 256x256 texture the UVs in range 0.0-1.0 will cover the texture from pixel 0 to 255 so borders should never be an issue; in real world however, due to mipmaps and due to anti-aliasing the things get literally fuzzy when UVs are reaching the edges, ie. 0.0 and 1.0.
    in these cases the hardware has several options on how to read from texture, usually tiled textures are warped as it happens in the effects you are using now for RBR.

    WRAP means the texture is repeated at the edge which is fine only when the texture is symmetric , your textures however are not symmetric so tilling the left edge near the right edge will create a mess just like the "lines" in your screen shots.
    what you can do is use different sampling and for that you can change the
    	AddressU	= WRAP;
    	AddressV	= WRAP; 
    	AddressU	= Border;
    	AddressV	= Border; 
    	AddressU	= Mirror;
    	AddressV	= Mirror; 
    in your fx files. this solution is simple but involves quite alot of manual editing of material files.

    another solution is to offset the UVs so the border would never be reached; in programs like max you can do that by simply dragging the UV verts in the UVMapping editor but you can do something with similar effect in BTB too by scaling and offsetting in material editor.
    what you need first is to figure out how big is a "texture pixel"(texel), ie. with a 256x256 you'll get 1/256 = 0.004(approx) so if you want to offset 2 texels, one on each side of the texture, you first need to scale down:
    X Scale = (1 - 0.004 - 0.004) = -0.992
    to eliminate the borders
    and then shift back(negative offset):
    X offset = -0.004.
    to recenter the UV over texture.

    this method basically shrinks the UVs but you'll notice one texel is not enough in most of the cases, you'll probably need at least 4, in which case you also need to alter your textures, ie. make the 3-4 rows at the edge identical.

    note. original RBR tracks are using a similar method, the UVs are shrunk by more or less one texel but that fails because the multi-sampling used in anti-aliasing theses days screws that basically forcing the hardware to read and blend regions of texture which were never intended to be accessed, and as a result tiles are "bleeding" over each over at the edge creating the famous lines on road "bug".(original RBR effects are also using POINT sampling instead of LINEAR or ANISOTROPIC filtering which also change things a bit but it also creates the "blocky" and low res. look of ground textures)

    ideally, decals should be used for those skid marks you're doing there but decals are also tricky and will create a whole new set of problems and artifacts.
  6. Wow... How you do know that... :) I've never had a problem like that, but I will remember then. Thanks!
  7. Oh, yes, I remember - I was producing some landscape texture for the wall - with transparency at the top - after export I had thin dark line there... So, I did some small offset and it solved the problem. Some thin lines like these can be seen also when using SObjects from GB XPack (trees/forests).
  8. You are not right. If witness the more closely. See that line is not empty. Without any transparency. They repeat the opposite edge of the texture - about 1px
  9. Then try jharro's methods - there must be some solution. Good luck! :)
  10. Kris Vickers

    Kris Vickers
    Hardware Staff

    What compression is the DDS saved as? DXT1, DXT3 or DXT5?
  11. It happens when you resize a layer in ps or gimp or what ever graphics program you use.
    I just duplicate the layer, then merge, duplicate again and merge, etc. Just repeat the process till the transparent edge is gone.
  12. DXT3 , before I used DXT1 - result the same (but view is more "lambent" with this setup)
  13. I have the same thing with croping to new (smaller) size - if there is e.g. a background layer with solid color and transparent tree layer over it, when I crop from huge photo to say 512x125, the background layer has transparent edges (Photoshop).
    More - I used to work with DDS Converter 2 to make .dds's - if there are both an alpha channel and transparent edges on the bgr solid layer, DDS Converter even does not allow to convert. I think similar thing says the DDS plugin in Photoshop (to many channels).
  14. Kris Vickers

    Kris Vickers
    Hardware Staff

    You say your DDS doesn`t have transparency, but DXT3 (and DXT5) supports it, so maybe worth looking into