### Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

### Topics - Marchioly

Pages: [1]
1
##### Support / Texture Blending on a heightmap/surfacemap
« on: March 04, 2016, 05:34:33 pm »
I am loading a heightmap, and texturing it based upon the data stored in the map format. I would like to apply texture blending to this.

I use the following for preparing the triangles/UV coordinates

Code: [Select]
` /** * The terrain heights are calculated now. Now we have to build an * Object3D from them. */ Object3D ground = new Object3D(width * height * 2); for (int x = 0; x < width - 1; x++) { for (int z = 0; z < height - 1; z++) { int x1 = x * 10; int x2 = (x + 1) * 10; int z1 = z * 10; int z2 = (z + 1) * 10; float southwestY = heights[x][z]; float southeastY = heights[x + 1][z]; float northwestY = heights[x][z + 1]; float northeastY = heights[x + 1][z + 1]; /* * Triangles start being drawn at the smallest 'x' Cartesian coordinate in jpct. * You then go clockwise to fill in the rest of the points. * *0,1-1,1      * |  /| * | / | * |/  | *0,0-1,0 * * Above is a cheat sheet for the coordinates. * * * TODO: Implement it such  we can select the triangle hypotenuse  for the tile based * on surrounding textures. This should improve blending when that finally gets implemented. */ // 0,1 // |\ // | \ // |  \ // |___\ // 0,0, 1,0 ground.addTriangle( new SimpleVector(x1, southwestY, z1), 0,0, new SimpleVector(x2, southeastY, z1),0,1, new SimpleVector(x1, northwestY, z2), 1,0, fetchTexture(surfaces[x][z])); // //0,1____1,1 //   \  | //    \ | //     \| //     1,0, ground.addTriangle( new SimpleVector(x1, northwestY, z2), 1, 0, new SimpleVector(x2, southeastY, z1), 0, 1, new SimpleVector(x2, northeastY, z2),1, 1, fetchTexture(surfaces[x][z])); // TODO // ____ //     /| //    / | //   /  | // /__ | } }`
Does anyone have any tips or advice they could give me for making this look nicer?

Pages: [1]