Exemplo n.º 1
0
  public RenderImageJme(String filename, boolean linear, NiftyJmeDisplay display) {
    TextureKey key = new TextureKey(filename, true);

    key.setAnisotropy(0);
    key.setGenerateMips(false);

    texture = (Texture2D) display.getAssetManager().loadTexture(key);
    texture.setMagFilter(linear ? MagFilter.Bilinear : MagFilter.Nearest);
    texture.setMinFilter(linear ? MinFilter.BilinearNoMipMaps : MinFilter.NearestNoMipMaps);
    image = texture.getImage();

    width = image.getWidth();
    height = image.getHeight();
  }
Exemplo n.º 2
0
  /**
   * sets the shadow compare mode see {@link CompareMode} for more info
   *
   * @param compareMode
   */
  public final void setShadowCompareMode(CompareMode compareMode) {
    if (compareMode == null) {
      throw new IllegalArgumentException("Shadow compare mode cannot be null");
    }

    this.shadowCompareMode = compareMode;
    for (Texture2D shadowMap : shadowMaps) {
      if (compareMode == CompareMode.Hardware) {
        shadowMap.setShadowCompareMode(ShadowCompareMode.LessOrEqual);
        if (edgeFilteringMode == EdgeFilteringMode.Bilinear) {
          shadowMap.setMagFilter(MagFilter.Bilinear);
          shadowMap.setMinFilter(MinFilter.BilinearNoMipMaps);
        } else {
          shadowMap.setMagFilter(MagFilter.Nearest);
          shadowMap.setMinFilter(MinFilter.NearestNoMipMaps);
        }
      } else {
        shadowMap.setShadowCompareMode(ShadowCompareMode.Off);
        shadowMap.setMagFilter(MagFilter.Nearest);
        shadowMap.setMinFilter(MinFilter.NearestNoMipMaps);
      }
    }
    postshadowMat.setBoolean("HardwareShadows", compareMode == CompareMode.Hardware);
  }
Exemplo n.º 3
0
  /**
   * Sets the filtering mode for shadow edges see {@link EdgeFilteringMode} for more info
   *
   * @param EdgeFilteringMode
   */
  public final void setEdgeFilteringMode(EdgeFilteringMode filterMode) {
    if (filterMode == null) {
      throw new NullPointerException();
    }

    if (this.edgeFilteringMode == filterMode) {
      return;
    }

    this.edgeFilteringMode = filterMode;
    postshadowMat.setInt("FilterMode", filterMode.getMaterialParamValue());
    postshadowMat.setFloat("PCFEdge", edgesThickness);
    if (shadowCompareMode == CompareMode.Hardware) {
      for (Texture2D shadowMap : shadowMaps) {
        if (filterMode == EdgeFilteringMode.Bilinear) {
          shadowMap.setMagFilter(MagFilter.Bilinear);
          shadowMap.setMinFilter(MinFilter.BilinearNoMipMaps);
        } else {
          shadowMap.setMagFilter(MagFilter.Nearest);
          shadowMap.setMinFilter(MinFilter.NearestNoMipMaps);
        }
      }
    }
  }