Landscape Texture is smeared when using Clamp

In the Texture Editor, setting “Y-axis Tiling Method” to “Clamp” causes the x0_y1 Tile to render as a smeared image. The x0_y0 Tile is able to use Clamp without this issue.

In the attached image, Tile x0_y0 is on the left and x0_y1 on the right.

The reason we would like to use Clamp instead of Wrap is that we think pixels from the opposite side are wrapping around due to trilinear filtering. You can see this artifact below as a thin red line at the boundary between the two tiles. In the source imagery, there are red pixels on the opposite side to exaggerate the wrapping around effect.

Hello jcossigny,

If you would post a screenshot of your material screenshot I can eliminate some of the guesswork on how you are implementing the clamp.

Thanks,

Hi

I have attached screenshots of the Material Editor, the Texture Sample and the Texture Editor settings.

Thanks

JP

Hello jcossigny,

If you take a look at the Mapping Scale in your LandscapeCoordinates, it is set to over 2000. That is saying the one to one scale that you have on your landscape is now stretched out 2000 units. Set it back to 1 or zero. Fixes the stretching.

Hi,

I did as requested but it just shrinks the smearing. Attached are two images showing the result of setting the scale to 1 (zero shows similar behavior).

Note: we have one single large satellite image that is draped over the landscape tile. We are using the World Composition to create a large area with each tile having exactly 1 image across its entirety. This is why we need to use 2016 in the Mapping Scale.

Ok, I have a bit more information to gather in order to narrow this down.

1.) Are you using world composition?
2.) Can you link me a copy of your DxDiag?
3.) Can you make a blank copy with the tiles in it and send me a copy?

I would like to test this on my end to eliminate much of the guesswork.

Thank you,

Yes we are using World Composition.
I am working with our IT department to figure out how to share files with you.

Thanks
JP

Hey,

Just got those files. I will be testing them shortly.

Hey JP,

With help, I was able to diagnose your problem. The big red line through your landscape was a little difficult to decipher but I figured it out.

I am linking you the screenshots of your scene. Basically, turn off the clamp and go back to wrap. I lined up your landscapes and found the right scale. I can’t tell where the pixels are stretching.

The hardest part is finding the scale that is necessary and make sure that everything is lined up the way it should be.

.

Hi ,

With the mode set back to Wrap again and the UV scaling set to 2016 we still see a thin red line in the join between the two level tiles. Note that these were the original settings we used before investigating Clamp.
Did you have to do something else to make the thin red line disappear? For example, are you adjusting the position of the Landscape Actor?
If you zoom in very close to the seam do you see any red pixels?

With Wrap enabled, if you look at the source image in the Texture Editor and zoom to the maximum you can see the red pixels along the bottom edge. When this image is used over such a large landscape they therefore become visible.

JP

Hey,

I did zoom in and I was able to see the thin red line.

I changed the scaling a bit but only slightly. So on your material Elev_x_0_y0 i changed the landscape scale to 2015.8
On y1 i changed it to 2015.9.

If you added that red value to highlight it then increasing and decreasing the scaling will cause a bit of tiling issue. However this is the result. You are still able to see the red line but only if you are very far zoomed in and only if you are looking for it. I’ll post some screenshots.

So as you can see even from a semi decent zoom distance you can barely notice the seam. I’m not quite sure what your intents are for this but if you are needing to be at a distance further than this you won’t notice it.

Please let me know if this is acceptable.

Hi ,

Thanks for you help so far.
Unfortunately, we do need the ability to zoom in. With this example it is barely visible but since we are using satellite imagery, we could have a source texture with say bright blue ocean on one side and dark ground at the other end. You would then see a clear blue line at the seam.

This was the main motivation for us looking at Clamp. When clamp is on, you no longer see the pixel “bleed” at the bottom edge in the Texture Editor which should in theory fix the issue.

However, the problem then becomes that the textures are smeared. I was able to use the Visual Studio Graphics Analyzer and determine that the UV’s for the landscape tile are outside of the range of 0 to 1. It appears they have the integer number of the corresponding Tile added to them. For example, Tile x2_y2 would have UV coordinates from 2 onward. Is this intentional or a possible bug?

Thanks again.
JP

Hey JP,

Is it possible to get those maps without the thin red line. I think I may have come up with a solution but I can’t know for sure without being able to see through it.

Thanks,

Hi ,

The red line exists to highlight the issue so removing it is probably not an option. In our use case, it is imperative that the imagery lines up with the elevation data to a high degree of accuracy.

I have been looking into the Shader code and I think I found where the UV’s are generated:

float3  GetMaterialBaseColorRaw(FMaterialPixelParameters Parameters)
{
	float  Local0 = dot(Parameters.TexCoords[0].xy,  float2 (-0.00000000,1.00000000));
	float  Local1 = dot(Parameters.TexCoords[0].xy,  float2 (1.00000000,0.00000000));
	float2  Local2 = (0.00049603 *  float2 (Local1,Local0));
	float2  Local3 = (Local2 +  float2 (0.00000000,0.00000000));
	float4  Local4 = ProcessMaterialColorTextureLookup(Texture2DSample(Material_Texture2D_0,Material_Texture2D_0Sampler,Local3));
	float3  Local5 = (Local4.rgb * Material_VectorExpressions[3].rgb);
	return Local5;;
}

Using the Visual Studio Graphics Analyzer, I was able to determine that a TexCoords XY in Tile x0_y2 might be say (0, 6000). It then multiplies this by 1/2016 which is the 0.00049603 above. This results in UV coordinates of (0, 2.976). Since the V is above 1.0 you get smearing.

Would it make sense to subtract the starting top left coordinate of the Tile’s heightfield texture first as this would bring the values within the 0 to 1 range after the division by 2016?

In the example given above, the input coordinates would therefore have (0, 4032) subtracted from them since Tile y2 ranges from 4032+. This would result in a final UV coordinate of (0, 0.976).

JP

Hey JP,

You can try. Right now the issue is lining up the seams. Scale and maybe shaving off a few pixels could fix this. Thankfully the smearing is gone but it is extremely difficult for me to try and do that on my end through the red. Best I can do is get it within a pixel or two where the red is barely showing.

Ah, so you were essentially adding an add and generating more information than you wanted when tiling.

Cool. Glad you found a solution.

Hi ,

I think I found a solution: looking at the shader code you can see that there is already an “add” in there that happens to be currently set to (0,0). However, this value can be adjusted per Tile material to bring the UV’s within the 0-1 range so that clamp can be used.

To do this I simply entered the appropriate value in the “Mapping Pan U” and “Mapping Pan V” fields of the LandscapeCoords material expression.

For example: in the material for Tile x2_y1 you would set the Pan values to U = -2.0 and V = -1.0. Note that these are negative values that effectively bring the UV’s back down to the 0-1 range so that clamp can be used.

Using this method fixes the red line issue with no smearing :slight_smile:

Cheers
JP