Terrain +

  1. I suppose that the texture orientation in terrain is wrong. I added texture with a text as “grass” in jme3test.terrain and it was showed “mirrored”.




  2. I can’t find com.jme3.bullet.control.PhysicsRigidBodyControl in “jme3 - jMonkeyEngine3.jar” archive which was used in jme3test. (I downloaded jMonkeyPlatform yesterday and all updates)



    PS (Sorry for my English)

Its com.jme3.bullet.control.RigidBodyControl, the javadoc of jME is available through Help->Javadoc->jMonkeyEngine3

I’ve noticed this also, when I make a grayscale height map and compare it against something I’ve sketched up on graph paper. It feels like the image you posted, flipped around, as in the orientation your render describes.



almost seems as if the U and V cords have been flipped.

to normen:

Thanks a lot. Now It’s work.



to lwsquad:

I didn’t know that. It’s really bad. I thought I can sort it out by flipping coords in material GLSL file.

First post here, had to make a note about this :wink:



I’ve been probing around with the engine a bit in the past few days and making huge progress on a game I’m making, and the above thing occurred to me too. Strangely, for me even the heightmap seems to have been flipped on the Z-Axis, can anyone check that? If I compare the heigthmap and the textures, this appears to be the error, both solvable by inverting Z.

it could very well be flipped. I will take a look and see where it is doing that flip and fix it

Hi all!



My first post here also. :slight_smile:



I found this bug when I was testing all the features of JME. It looks like textures are not flipped, but the whole alphamap is flipped and textures with it. Both alphamap and heightmap is affected (tested). Images are flipped, looks like Z-axis values are inverted.



Bug must be in the loading of images. I made a code which loads alphamap to BufferedImage and checks RGB color from alphamap image corresponding to worldtranslation of the player. In this way I was able to get correct texture (based on red/green/blue) where player is located. Maybe there is a simplier way to get correct texture, but I didn’t found it. But in my own way I did got a correct texture, so both alphamap and my image which I was used for RGB check must be flipped. Sample code below where alphaMapImage is also flipped. So, I assume that loadTexture is good place to start…



[java]

Texture alphaMapTexture = assetManager.loadTexture(“Textures/alphamap.png”);

BufferedImage alphaMapImage = ImageToAwt.convert(alphaMapTexture.getImage(), false, true, 0);

[/java]

ok, I committed a fix to ImageBasedHeightmap. Now the load() method will load the heightmap image as expected. I also created another load(bool,bool) method that takes in two parameters: flipX and flipY for more flexibility and some backwards compatability.

I will work on the flipped texture coordinates tomorrow

to Sploreg:

Thank you.

Is it only for HeightMap?

What about textures?

Yes that is for the heightmap only, the texture flipping I believe is the texture coordinates on the geometry, but I’m not sure as I haven’t looked into it yet. It should be fixed tomorrow :slight_smile:

I flipped the texture coordinates of the terrain. The latest is in SVN. Check it out and let me know if it fixed it for you.

Note that you will need to manually flip your existing heightmaps and texture alpha map so your older scenes won’t be backwards.

Just updated from SVN and got odd results.



I writed text to alphamap image with color blue and text is now readable, so flipping in that direction is fixed in screen. But it’s still rotated in 180 degrees, I think so. If I’m correct, I should be in top of the alphamap covered terrain when my WorldTranslation Z-value is negative, but instead I’m in bottom part of the alphamap. Just look at the image below, test screenshot in top.







There is still problem with flipping while loading assets. I made another test with BufferedImage. Resulted test.png file is flipped different way than visible textures created by alphamap. Original alphamap.png is in the left hand side and image file wrote by code below is in the right hand side.



[java]

try {

Texture alphaMapTexture = assetManager.loadTexture(“Textures/alphamap.png”);

BufferedImage alphaMapImage = ImageToAwt.convert(alphaMapTexture.getImage(), false, true, 0);

File file = new File(“C:/test.png”);

ImageIO.write(alphaMapImage, “png”, file);

} catch (Exception ex) {}

[/java]



I assume that the alphamap is flipped now twice, first time when loaded and second time before using it.

I looked at the asset manager, and the TextureKey it creates defaults to flipY=true. So that is causing the issue here.

You can specify your own texture key while loading by doing this:

[java]TextureKey tk = new TextureKey(“Textures/myImage.png”, false);

Texture alphaMapTexture = assetManager.loadTexture(tk);[/java]



Since it is the asset manager doing this, I will revert my change to the terrain where it is also flipping the coordinates.



As for your camera location… terrain is y-up, so x-z is the horizontal plane the the terrain in. You will want to test with the camera position in the positive Y-axis, and looking down the Y-axis in the negative direction. Also, you will have to orient your camera with the correct “up” vector.

to Sploreg:

Good work. Thank you very much. Looks like that was the root cause.

Height map and alpha map test, looks good :slight_smile:



I had time to test and changed my code to work with TextureKey.



AlphaMap is correct when flipY parameter is false.

Textures are correct when flipY parameter is false.

HeightMap is correct when there are no flipY parameter or it’s true.



AlphaMap image saved with my code snippet (in earlier post) is also correct, without flipY parameter. So now one can access the image from AssetManager also directly.





Now everything looks like they should be, but I found another problem. Using TextureKey will break something in textures. Textures has correct orientation, but I got horrible noise in textures while moving. When using image path directly there is no noise, but when using TextureKey object there is noise, regardless of flipY value.



You can repeat it easily using this texture for example and test it with and without TextureKey. You will notice that noise I found immediately when you move.

Do you have a screenshot of what noise you are seeing @damsteri ?

damsteri said:
Now everything looks like they should be, but I found another problem. Using TextureKey will break something in textures. Textures has correct orientation, but I got horrible noise in textures while moving. When using image path directly there is no noise, but when using TextureKey object there is noise, regardless of flipY value.

You might have to call TextureKey.setGenerateMips(true) on your texture keys

@Sploreg



Here is my screenshot. Noise can be seen in screenshot. It looks like random noise with texture colors, changing every time you move. If you zoom very close, you can see some texture correctly.







I can reproduce this easily. I used jme3 from SVN and Hello Terrain sample code with adding TextureKey. Just replaced texture paths with TextureKeys. Changed all three textures. Most visible noise can be seen with grass.jpg , but also other textures are affected mildly.





@Momoko_Fan



TextureKey.setGenerateMips(true) is working, and noise disappears. No problems after that. But now you have to first create TextureKeys with no-flipping, then setGenerateMips(true) for every TextureKeys, just to get textures to screen without flipping. So maybe we can get more usable solution to this (in future)? Currently in that way it’s working.



PS. If this noise is graphics adapter related issue, I’m using two 5970s in Crossfire with Catalyst 10.12.