Texture coordinates scale issue with AlphaMap


I am trying to see if I can use a different approach for farmlands…

So I created a Quad mesh and applied a dirt texture to it and created a halo-like AlphaMap in gimp


and so far everything looks fine:

here is the relevent code:

            CenterQuad quad = new CenterQuad(size.x, size.z, true);
            Geometry land = new Geometry(null, quad);

            Material mat = new Material(assets, Materials.LIGHTING);
            Texture diffuse = assets.loadTexture("Textures/Dirt/28.png");
            mat.setTexture("DiffuseMap", diffuse);

            alpha = assets.loadTexture("Textures/farmland-alpha.png");
            mat.setTexture("AlphaMap", alpha);



then I decided to scale texture coordinates and set dirt texture to wrap repeat like this:

quad.scaleTextureCoordinates(new Vector2f(size.x / 4, size.z / 4));

and this is how it looks, which is not what I want

if I remove the AlphaMap it looks fine but of course without the transparency over the land borders.

Is there a simple trick I can do to fix this?

Thanks in advance

I think the issue is related to the way that the Lighting.frag file also uses the tex coords to scale the AlphaMap:

So I think if you made your own custom fork of the shader for farm plots, you should be able to fix the issue by using the scaled texCoords for your repeating dirt texture, and then pass in another non-scaled texCoord for the alphaMap.

1 Like

I give up this approach, and returned to using the terrain splatting! By looping through farmlands and painting some dirt texture underneath.

This would be done at runtime as farmlands are game entities, new lands can be added or an existing land size can change.

With the addition of farmlands so far I have used 7 layers out of 12 terrain texture layers. Though for farmlands, instead of adding a new layer on top, I could just clear from grass layer, and dirt underneath it would then have appeared :stuck_out_tongue:
but using a new layer has the benefit that I can use a different texture, also updating the layer should be much simple as I do not need to re-paint grass once the land is removed for some reason!