Ejemplo n.º 1
0
  /** Load water textures. */
  protected void setupTextures() {
    textureReflect = new Texture2D();
    textureReflect.setWrap(Texture.WrapMode.EdgeClamp);
    textureReflect.setMagnificationFilter(Texture.MagnificationFilter.Bilinear);
    Matrix4 matrix = new Matrix4();
    matrix.setM00(-1.0);
    matrix.setM30(1.0);
    textureReflect.setTextureMatrix(matrix);
    tRenderer.setupTexture(textureReflect);

    normalmapTexture =
        TextureManager.load(
            normalMapTextureString,
            Texture.MinificationFilter.Trilinear,
            TextureStoreFormat.GuessCompressedFormat,
            true);
    textureState.setTexture(normalmapTexture, 0);
    normalmapTexture.setWrap(Texture.WrapMode.Repeat);

    textureReflectBlur = new Texture2D();
    textureReflectBlur.setWrap(Texture.WrapMode.EdgeClamp);
    textureReflectBlur.setMagnificationFilter(Texture.MagnificationFilter.Bilinear);
    textureReflectBlur.setTextureMatrix(matrix);
    tRenderer.setupTexture(textureReflectBlur);

    textureState.setTexture(textureReflectBlur, 1);

    dudvTexture =
        TextureManager.load(
            dudvMapTextureString,
            Texture.MinificationFilter.Trilinear,
            TextureStoreFormat.GuessNoCompressedFormat,
            true);
    matrix = new Matrix4();
    matrix.setM00(0.8);
    matrix.setM11(0.8);
    dudvTexture.setTextureMatrix(matrix);
    textureState.setTexture(dudvTexture, 2);
    dudvTexture.setWrap(Texture.WrapMode.Repeat);

    if (useRefraction) {
      textureRefract = new Texture2D();
      textureRefract.setWrap(Texture.WrapMode.EdgeClamp);
      textureRefract.setMagnificationFilter(Texture.MagnificationFilter.Bilinear);
      tRenderer.setupTexture(textureRefract);

      textureDepth = new Texture2D();
      textureDepth.setWrap(Texture.WrapMode.EdgeClamp);
      textureDepth.setMagnificationFilter(Texture.MagnificationFilter.NearestNeighbor);
      textureDepth.setTextureStoreFormat(TextureStoreFormat.Depth24);
      tRenderer.setupTexture(textureDepth);

      textureState.setTexture(textureRefract, 3);
      textureState.setTexture(textureDepth, 4);
    }

    if (useProjectedShader) {
      foamTexture =
          TextureManager.load(
              foamMapTextureString,
              Texture.MinificationFilter.Trilinear,
              TextureStoreFormat.GuessCompressedFormat,
              true);
      if (useRefraction) {
        textureState.setTexture(foamTexture, 5);
      } else {
        textureState.setTexture(foamTexture, 3);
      }
      foamTexture.setWrap(Texture.WrapMode.Repeat);
    }

    reloadShader();
  }