Example #1
0
  // Render the texture
  public void clear(final Renderer r) {

    updateProjection();

    // Render only vertices, nothing else
    setRenderVertexOnly(true);

    // render
    textureRenderer.clear(texture, Renderer.BUFFER_COLOR_AND_DEPTH);

    // restore states
    setRenderVertexOnly(false);

    // set the texture coordinate matrix
    texture.setTextureMatrix(projectionMatrix);
  }
Example #2
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();
  }
Example #3
0
  private void createTexture() {

    texture = new SharedTexture2D();
    texture.setWrap(Texture.WrapMode.BorderClamp);
    texture.setMinificationFilter(Texture.MinificationFilter.BilinearNoMipMaps);
    texture.setMagnificationFilter(Texture.MagnificationFilter.Bilinear);
    texture.setHasBorder(true);
    if (borderWhite) {
      texture.setBorderColor(ColorRGBA.WHITE);
    } else {
      texture.setBorderColor(ColorRGBA.BLACK_NO_ALPHA);
    }

    texture.setEnvironmentalMapMode(Texture.EnvironmentalMapMode.EyeLinear);
    texture.setTextureStoreFormat(TextureStoreFormat.Depth32);
    texture.setDepthCompareMode(DepthTextureCompareMode.RtoTexture);
    texture.setDepthCompareFunc(func);
    texture.setDepthMode(DepthTextureMode.Intensity);
    texture.setTextureKey(TextureKey.getRTTKey(Texture.MinificationFilter.BilinearNoMipMaps));
  }