Author
Topic: The question about setTexture (Read 2042 times)

Hello Egon, I pack some texture images into one large picture, I want to set model texture by each texture image coordinates (I can get the coordinates) , but I don't know how to do this ? I only found setTexture(String) and setTexture(TextureInfo) , I try setTexture(TextureInfo) method but not work ok for me. Please help me, thank a lot

Thanks Egon,My means I have some 3d models ,i,e 3 models 1.ser 2.ser 3.ser , and each model have a textue , i,e 1.png 2.png and 3.png , now I use texturePacker tool pack 1 2 3 .png to a single picture x.png , and I want to set each model use this single texture , How can I do this ?

Use the PolygonManager to get the current coordinates for each point, transform them to the match the new coordinates in your texture atlas, create a new TextureInfo with these coordinates and set it via the PolygonManager.You just have to keep in mind that bilinear filtering might cause bleeding into adjacent textures at the edges. If this is an issue in your case depends on the mapping of the model.

Your great ! I got it , as you say that bilinear filtering might cause bleeding into adjacent textures at the edges,The road texture by repeat mode, and there looks somethings like a black line at the edges , How to resove this issue?

Thanks , I shrink the uv ( 0 changed to 0.001 and 1 changed to 0.009) , it seems edge is ok , but I think this is not a good solution, when one model use one texture everything is ok ,but when one model use part of texture it's not ok , what's the diffrent between this case?

I found when Object3D use transparent mode , there is a black border around the model. If use a texture , setClamping(true) can resovle this issue , but when use part of texture , it's no effect .

No, of course not. Clamping affects all coordinates <0 and > 1. Inside a texture, it has no effect. As said: All the problems that arise from combining multiple textures into one have to be solved in the art pipeline.

Thanks Egon, Could you give me a simple way to solve this problem? I'm sorry for I realy no idea (Modify either the texture coordinates at the edges or the texture atlas, I 'm not clear how to do this, could you give me a simple example ?)

I don't know. Maybe adding an alpha channel to the texture or whatever. I'm not sure where that black border comes from in your case. The behaviour that causes these issues is simply that the bilinear filter applied to the texels takes texture coordinates into account that lie outside of the actual uv coordinates of the model. This happens on single textures too (as it has too, because otherwise you wouldn't be able to get seemless textuering) but as long as it happens on the egdes, you can fight it with clamping and such.I usually don't combine textures into one because in most cases, the advantages don't outweigh the drawbacks IMHO.

No. All that this changes is that it doesn't have to switch between textures. And while this is a little performance improvement, i highly doubt that it would be noticable unless you are using a lot of different textures in an unoptimizable rendering order (i.e. transparent objects). For opaque objects, jPCT will sort by state anyway, so texture changes are reduced to a minimum.