Esempio n. 1
0
 private Float64Vector[][] fromNormalMap(NormalMap source) {
   Float64Vector[][] normals = new Float64Vector[16][16];
   Coordinate chunkOrigin = location.zoomIn(Coordinate.OFFSET_BLOCK_CHUNK);
   for (int x = 0; x < 16; x++) {
     for (int y = 0; y < 16; y++) {
       normals[x][y] =
           source.getNormal(chunkOrigin.plus(new Coordinate(x, y, Coordinate.LEVEL_BLOCK)));
     }
   }
   return normals;
 }
 private static double computeDiffuseShading(
     ChunkSnapshot chunkSnapshot, int x, int z, NormalMap nm) {
   Float64Vector n =
       nm.getNormal(
           Coordinate.fromSnapshot(chunkSnapshot)
               .zoomIn(Coordinate.OFFSET_BLOCK_CHUNK)
               .plus(new Coordinate(x, z, Coordinate.LEVEL_BLOCK)));
   Float64Vector light = Float64Vector.valueOf(-1, -1, -1);
   if (n == null) {
     return -1;
   }
   double shading = n.times(light).divide((n.norm().times(light.norm()))).doubleValue();
   return ((shading + 1) * 0.4) + 0.15;
 }