Procedural Splat Texture Generator

Two part question, sorry if it seems dumb but I am new:



I have being trying my own procedural splat texturing for terrain loaded from an image file height map. It works except that it scales the splat texture I am loading (originally 256 x 256) so that it covers the entire terrain (visible if I set the alpha file to 100% for all parts of the image). Is there a way to define the size and tiling of the splat texture without affecting the height dependent texturing scale?



URL sand = Hello3D.class.getClassLoader().getResource(“mygame/resources/terrain/sand.png”);

URL rock = Hello3D.class.getClassLoader().getResource(“mygame/resources/terrain/rocks.png”);

URL rockAlpha = Hello3D.class.getClassLoader().getResource(“mygame/resources/terrain/rocksAlpha2.png”);

URL cliff1 = Hello3D.class.getClassLoader().getResource(“mygame/resources/terrain/cliff1.png”);

URL cliff2 = Hello3D.class.getClassLoader().getResource(“mygame/resources/terrain/cliff2.png”);



ProceduralSplatTextureGenerator pst = new ProceduralSplatTextureGenerator(heightMap);

pst.addTexture(new ImageIcon(sand), -128, 0, 128);

pst.addTexture(new ImageIcon(sand), 0, 128, 255);

pst.addTexture(new ImageIcon(sand), 128, 255, 384);



pst.addSplatTexture(new ImageIcon(rockAlpha), new ImageIcon(rock));

pst.createTexture(512);



TextureState ts = display.getRenderer().createTextureState();

ts.setEnabled(true);

Texture t1 = TextureManager.loadTexture(pst.getImageIcon().getImage(), Texture.MinificationFilter.Trilinear,

Texture.MagnificationFilter.Bilinear, true);

ts.setTexture(t1, 0);



Texture t2 = TextureManager.loadTexture(Hello3D.class.getClassLoader().getResource(

“mygame/resources/terrain/sand.png”), Texture.MinificationFilter.Trilinear, Texture.MagnificationFilter.Bilinear);



ts.setTexture(t2, 1);

t2.setWrap(Texture.WrapMode.Repeat);



t1.setApply(Texture.ApplyMode.Combine);

t1.setCombineFuncRGB(Texture.CombinerFunctionRGB.Modulate);

t1.setCombineSrc0RGB(Texture.CombinerSource.CurrentTexture);

t1.setCombineOp0RGB(Texture.CombinerOperandRGB.SourceColor);

t1.setCombineSrc1RGB(Texture.CombinerSource.PrimaryColor);

t1.setCombineOp1RGB(Texture.CombinerOperandRGB.SourceColor);



t2.setApply(Texture.ApplyMode.Combine);

t2.setCombineFuncRGB(Texture.CombinerFunctionRGB.AddSigned);

t2.setCombineSrc0RGB(Texture.CombinerSource.CurrentTexture);

t2.setCombineOp0RGB(Texture.CombinerOperandRGB.SourceColor);

t2.setCombineSrc1RGB(Texture.CombinerSource.Previous);

t2.setCombineOp1RGB(Texture.CombinerOperandRGB.SourceColor);

rootNode.setRenderState(ts);





Secondly, I have looked at the files, “TestTerrainProceduralSplatting” and “TestIsland”. Both use a different approach (the first uses the proceduralsplattexturegenerator and the second uses some multi pass rendering method - which I didn’t fully understand being new n’all). Which is generally regarded as the best approach?

In reference to last post, I realised that the procedural texture is scaled up from its defined size (512) to fit the entire terrain and within that texture it overlaps the individual height dependant/splat textures based on the height/alpha respectively but doesn’t tile or repeat them. This means that the textures are massively stretched when the procedural texture is resized. Is there anyway to get the procedural texture to tile individual the individual textures it is made up of so that you get a nice high resolution texture on the final terrain?

I hope that made sense, again sorry if it’s a stupid question but I’m new to any form of game programming let alone JME.