Repeat texure problem.[Solved]

Im using procedural splat texture to create the road on my terrain. the road texture has little breaks on it.

however, i cant find a way to set the repeat of the splat texture. and if i dont set the repeat, the breaks become really big.

so heres a pic to show what i want. on the left is the current effect, and on the right is what i want the road to look like.

Have you tried using the texture's matrix (scale part - texture.setScale(Vector3f))?

renanse said:

Have you tried using the texture's matrix (scale part - texture.setScale(Vector3f))?

how would i use that? i tried to scale it with (0.1f, 0.1f, 0.1f). but it scales the entire texture including the grass and rock.

the road part texture is passed in to the procedural splat texture generator as a splat.

Ah, sorry, I wasn't paying attention.  Maybe someone could add a scale factor to the generator class and post a patch…  8)

renanse said:

Ah, sorry, I wasn't paying attention.

I took a look into the problem and found out the following:

Here's what ProceduralSplatTextureGenerator does currently:

  • save all texture/alpha maps in two distinct vectors

  • on creation of the result image, the textures will be painted in their original scale and cropped/tiled as neccessary

So a hastily added scale facility would essentially:

  • scale the texture map before adding it to the vector

  • continue with the steps above

I suggest that you just scale the image file used to produce the road texture instead - that gives you more control over the image quality, reduces your project's download size, and avoids messing with ProceduralSplatTextureGenerator.

Which admittedly needs some work anyway (there's currently no tracking of image creation progress in there, which could cause incomplete data to be passed to TextureManager eventually - also PSTG still seems to use ImageIcons as texture/alpha map input, but that's mainly a matter of aesthetics I guess).

ImageIcons are actually also cached wthin java

theprism said:

ImageIcons are actually also cached wthin java

Sorry, I don't understand what that implies! Could you shed some light?

ive already tried scaling the source image file. but besides making the texture more clear, it doesnt solve the problem at all.

i checked how textures r repeated in geometry batch. it simply multiply the texture's float buffer with a constant. but then how do i retrieve the float buffer of the image icon?

Hevee, wqatch out for ImageIcons, see the java api, Constructing an Imageicon thats uses MediaTracker will put it into a cache.

OK I see your problem now.

You are using the wrong approach for what you want to achieve. PSTG generates a huge single image out of the layers and splat maps you provide. To get a better Image quality with that, ou could scale the generated texture up - but that will only take you so far before getting problems with the resulting texture being too large, especially for bigger terrains.

For any better results you'll have to use a "real" texture splatting approach, of which numerous are available on the forum - and one, made by MrCoder, is even in the jme-tests. See TestIsland for reference. With that, texture matrices, texture coord scaling, and all the rest will work perfectly.

@theprism: OK I think you are saying that having an ImageIcon in the wrong place is not only an "aesthetic" problem but a rather concrete waste of memory. That's certainly true.

thx for the info. i found that last night and already implemented it. :smiley:

then i have the problem with lighting ha~ plz c the other post