Custom mesh different textures

I read manual about Custom mesh and noticed that there used 1 texture for whole mesh. Searched in the forum with keywords “custom mesh” and seems I can’t for 1 custom mesh use different textures?!



I’m creating game for fun and want my game be destructible (like minecraft).

Search for voxels and then texture atlases, there’s countless threads in these forums for minecraft type games

roger that! Thanks!

Okay, I read threads in this forum and found only one thread about texture atlases and hundreds about minecraft :slight_smile:



Could someone save my time and answer :slight_smile: Is it possible apply many textures to one custom mesh ?

@avekir said:
Okay, I read threads in this forum and found only one thread about texture atlases and hundreds about minecraft :)

Could someone save my time and answer :) Is it possible apply many textures to one custom mesh ?


HS. I found :)
http://hub.jmonkeyengine.org/groups/general-2/forum/topic/can-i-have-one-mesh-with-many-textures-applied-short-post/

seems all that link for box mesh, not for custom :frowning:





Who can provide sample multiple textures for custom mesh? :slight_smile:



Thanks

You have to use a texture atlas. Combine the textures to one in an image editor or use the TextureAtlas class. Then set the texture coords right.

@normen said:
You have to use a texture atlas. Combine the textures to one in an image editor or use the TextureAtlas class. Then set the texture coords right.

Normen hello :)

Yes, I found you comment in this thread: http://hub.jmonkeyengine.org/groups/graphics/forum/topic/im-looking-for-an-example-of-using-one-image-that-has-multiple-textures-to-map-cubes/#post-128439

The texture coordinates for each vertex are ranging from 0.0 to 1.0 where the values describe the x and y location of the image multiplied by its x / y size. The default box texture coordinates display the texture completely on each side.

in my code I use

[java]Vector2f texture_bl = new Vector2f(0, 0);
Vector2f texture_br = new Vector2f(1.0f, 0);
Vector2f texture_tl = new Vector2f(0, 1.0f);
Vector2f texture_tr = new Vector2f(1.0f, 1.0f);[/java]

I tried to change that values, for example texture_bl = new Vector2f(0, 0.2f); - texture become stretched

I don't understand!

OK, understood and implemented texture atlas



but some lines between textures… any idea ?



https://dl.dropbox.com/u/553098/Screenshot_2012-11-02_22-36.png

1 Like

Thats probably mipmap blurring mixing in the white from around the texture. Try having some pixels around the original images with the “last pixel” of the image border.

How have you split up your atlas?



Edit: also note that if you have one texture starting at 0.5 then the previous one ends at 0.49999 or you will easily get bleeding also.



And as normen says, best to give everything a border if you want filtering.

Thanks for answers!

For first time I stole texture from mod for minecraft and now I fixed it… but later I’ll create my texture atlas with border!

It is possible to avoid having to add the borders in this case but I think you’d have to write a custom shader to clamp the values at the borders.