protected void createTextures() { reflectionTexture = new Texture2D(renderWidth, renderHeight, Format.RGBA8); refractionTexture = new Texture2D(renderWidth, renderHeight, Format.RGBA8); reflectionTexture.setMinFilter(Texture.MinFilter.Trilinear); reflectionTexture.setMagFilter(Texture.MagFilter.Bilinear); refractionTexture.setMinFilter(Texture.MinFilter.Trilinear); refractionTexture.setMagFilter(Texture.MagFilter.Bilinear); depthTexture = new Texture2D(renderWidth, renderHeight, Format.Depth); }
/** * Creates a new two-dimensional texture using the given image. * @param img The image to use. */ public Texture2D(Image img){ super(); setImage(img); if (img.getData(0) == null) { setMagFilter(MagFilter.Nearest); setMinFilter(MinFilter.NearestNoMipMaps); } }
private Texture2D createAtlasTextureInternal(final int width, final int height) throws Exception { ByteBuffer initialData = BufferUtils.createByteBuffer(width*height*4); for (int i=0; i<width*height*4; i++) { initialData.put((byte) 0x00); } initialData.rewind(); Texture2D texture = new Texture2D(new com.jme3.texture.Image(Format.RGBA8, width, height, initialData, ColorSpace.sRGB)); texture.setMinFilter(MinFilter.NearestNoMipMaps); texture.setMagFilter(MagFilter.Nearest); return texture; }
@Override public int createNonAtlasTexture(final Image image) { ImageImpl imageImpl = (ImageImpl) image; Texture2D texture = new Texture2D(imageImpl.image); texture.setMinFilter(MinFilter.NearestNoMipMaps); texture.setMagFilter(MagFilter.Nearest); return addTexture(texture); }
/** * Sets the shadow compare mode. See {@link CompareMode} for more info. * * @param compareMode the desired compare mode (not null) */ final public 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); }
/** * Sets the shadow compare mode. See {@link CompareMode} for more info. * * @param compareMode the desired compare mode (not null) */ final public 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); }
/** * Sets the filtering mode for shadow edges. See {@link EdgeFilteringMode} * for more info. * * @param filterMode the desired filter mode (not null) */ final public void setEdgeFilteringMode(EdgeFilteringMode filterMode) { if (filterMode == null) { throw new NullPointerException(); } 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); } } } }
/** * Sets the filtering mode for shadow edges. See {@link EdgeFilteringMode} * for more info. * * @param filterMode the desired filter mode (not null) */ final public void setEdgeFilteringMode(EdgeFilteringMode filterMode) { if (filterMode == null) { throw new NullPointerException(); } 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); } } } }
/** * Sets the filtering mode for shadow edges see {@link FilterMode} for more * info * * @param filterMode */ final public void setFilterMode(FilterMode filterMode) { if (filterMode == null) { throw new NullPointerException(); } if (this.filterMode == filterMode) { return; } this.filterMode = filterMode; postshadowMat.setInt("FilterMode", filterMode.ordinal()); postshadowMat.setFloat("PCFEdge", edgesThickness); if (compareMode == CompareMode.Hardware) { for (Texture2D shadowMap : shadowMaps) { if (filterMode == FilterMode.Bilinear) { shadowMap.setMagFilter(MagFilter.Bilinear); shadowMap.setMinFilter(MinFilter.BilinearNoMipMaps); } else { shadowMap.setMagFilter(MagFilter.Nearest); shadowMap.setMinFilter(MinFilter.NearestNoMipMaps); } } } applyFilterMode = true; }
/** * Creates a new atlas texture for the given map name. * @param mapName * @return the atlas texture */ public Texture getAtlasTexture(String mapName) { if (images == null) { return null; } byte[] image = images.get(mapName); if (image != null) { //TODO check if color space shouldn't be sRGB Texture2D tex = new Texture2D(new Image(format, atlasWidth, atlasHeight, BufferUtils.createByteBuffer(image), null, ColorSpace.Linear)); tex.setMagFilter(Texture.MagFilter.Bilinear); tex.setMinFilter(Texture.MinFilter.BilinearNearestMipMap); tex.setWrap(Texture.WrapMode.EdgeClamp); return tex; } return null; }
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(); }
public Texture2D readSampler(int samplerIndex, Texture2D texture) throws IOException { if (samplers == null) { throw new AssetLoadException("No samplers defined"); } JsonObject sampler = samplers.get(samplerIndex).getAsJsonObject(); Texture.MagFilter magFilter = getMagFilter(getAsInteger(sampler, "magFilter")); Texture.MinFilter minFilter = getMinFilter(getAsInteger(sampler, "minFilter")); Texture.WrapMode wrapS = getWrapMode(getAsInteger(sampler, "wrapS")); Texture.WrapMode wrapT = getWrapMode(getAsInteger(sampler, "wrapT")); if (magFilter != null) { texture.setMagFilter(magFilter); } if (minFilter != null) { texture.setMinFilter(minFilter); } texture.setWrap(Texture.WrapAxis.S, wrapS); texture.setWrap(Texture.WrapAxis.T, wrapT); texture = customContentManager.readExtensionAndExtras("texture.sampler", sampler, texture); return texture; }
dualEyeTex.setMinFilter(Texture.MinFilter.BilinearNoMipMaps); dualEyeTex.setMagFilter(Texture.MagFilter.Bilinear);
offTex.setMinFilter(Texture.MinFilter.BilinearNoMipMaps); offTex.setMagFilter(Texture.MagFilter.Bilinear);
private ViewPort setupViewBuffers(Camera cam, String viewName) { if (environment != null) { if (environment.getApplication() != null) { // create offscreen framebuffer FrameBuffer offBufferLeft = new FrameBuffer(cam.getWidth(), cam.getHeight(), 1); //offBufferLeft.setSrgb(true); //setup framebuffer's texture Texture2D offTex = new Texture2D(cam.getWidth(), cam.getHeight(), Image.Format.RGBA8); offTex.setMinFilter(Texture2D.MinFilter.BilinearNoMipMaps); offTex.setMagFilter(Texture2D.MagFilter.Bilinear); //setup framebuffer to use texture offBufferLeft.setDepthBuffer(Image.Format.Depth); offBufferLeft.setColorTexture(offTex); ViewPort viewPort = environment.getApplication().getRenderManager().createPreView(viewName, cam); viewPort.setClearFlags(true, true, true); viewPort.setBackgroundColor(ColorRGBA.Black); Iterator<Spatial> spatialIter = environment.getApplication().getViewPort().getScenes().iterator(); while (spatialIter.hasNext()) { viewPort.attachScene(spatialIter.next()); } //set viewport to render to offscreen framebuffer viewPort.setOutputFrameBuffer(offBufferLeft); return viewPort; } else { throw new IllegalStateException("This VR environment is not attached to any application."); } } else { throw new IllegalStateException("This VR view manager is not attached to any VR environment."); } }
offTex.setMinFilter(Texture.MinFilter.BilinearNoMipMaps); offTex.setMagFilter(Texture.MagFilter.Bilinear);
public void reshape(ViewPort vp, int w, int h){ if (mainSceneFB != null){ renderer.deleteFrameBuffer(mainSceneFB); } mainSceneFB = new FrameBuffer(w, h, 1); mainScene = new Texture2D(w, h, bufFormat); mainSceneFB.setDepthBuffer(Format.Depth); mainSceneFB.setColorTexture(mainScene); mainScene.setMagFilter(fbMagFilter); mainScene.setMinFilter(fbMinFilter); if (msFB != null){ renderer.deleteFrameBuffer(msFB); } tone.setTexture("Texture", mainScene); Collection<Caps> caps = renderer.getCaps(); if (numSamples > 1 && caps.contains(Caps.FrameBufferMultisample)){ msFB = new FrameBuffer(w, h, numSamples); msFB.setDepthBuffer(Format.Depth); msFB.setColorBuffer(bufFormat); vp.setOutputFrameBuffer(msFB); }else{ if (numSamples > 1) logger.warning("FBO multisampling not supported on this GPU, request ignored."); vp.setOutputFrameBuffer(mainSceneFB); } createLumShaders(); }
@Override protected Texture toJmeObject() { Image image = null; TextureKey key = null; if (media != null) { image = (Image) media.getJmeObject(); key = media.getTextureKey(); } if (image == null) { image = PlaceholderAssets.getPlaceholderImage(assetManager); } Texture2D tex = new Texture2D(image); if (key != null) { tex.setKey(key); tex.setName(key.getName()); tex.setAnisotropicFilter(key.getAnisotropy()); } tex.setMinFilter(MinFilter.Trilinear); tex.setMagFilter(MagFilter.Bilinear); if (wrapModeU == 0) { tex.setWrap(WrapAxis.S, WrapMode.Repeat); } if (wrapModeV == 0) { tex.setWrap(WrapAxis.T, WrapMode.Repeat); } return tex; }
offTex.setMinFilter(Texture.MinFilter.Trilinear); offTex.setMagFilter(Texture.MagFilter.Bilinear);
tex.setMinFilter(MinFilter.Trilinear); tex.setMagFilter(MagFilter.Bilinear);