/** * Make a duplicate of this cube Map. That means that it's another instant * od TextureCubeMap, but the underlying buffers are duplicates of the * original ones. see {@link ByteBuffer#duplicate()} * * Use this if you need to read from the map from multiple threads, it * should garanty the thread safety. Note that if you want to write to the * cube map you have to make sure that the different thread do not write to * the same area of the buffer. The position, limit and mark are not an * issue. * * @param sourceMap * @return */ public static TextureCubeMap duplicateCubeMap(TextureCubeMap sourceMap) { Image srcImg = sourceMap.getImage(); Image cubeImage = new Image(srcImg.getFormat(), srcImg.getWidth(), srcImg.getHeight(), null, srcImg.getColorSpace()); for (ByteBuffer d : srcImg.getData()) { cubeImage.addData(d.duplicate()); } cubeImage.setMipMapSizes(srcImg.getMipMapSizes()); TextureCubeMap cubeMap = new TextureCubeMap(cubeImage); cubeMap.setAnisotropicFilter(sourceMap.getAnisotropicFilter()); cubeMap.setMagFilter(sourceMap.getMagFilter()); cubeMap.setMinFilter(sourceMap.getMinFilter()); cubeMap.setWrap(sourceMap.getWrap(Texture.WrapAxis.S)); return cubeMap; }
public TextureCubeMap(int width, int height, Image.Format format){ this(createEmptyLayeredImage(width, height, 6, format)); }
public Texture createSimpleClone() { return createSimpleClone(new TextureCubeMap()); }
/** * initialize the Irradiancemap * @param size the size of the map * @param imageFormat the format of the image * @return the initialized Irradiance map */ public static TextureCubeMap createIrradianceMap(int size, Image.Format imageFormat) { TextureCubeMap irrMap = new TextureCubeMap(size, size, imageFormat); irrMap.setMagFilter(Texture.MagFilter.Bilinear); irrMap.setMinFilter(Texture.MinFilter.BilinearNoMipMaps); irrMap.getImage().setColorSpace(ColorSpace.Linear); return irrMap; }
TextureCubeMap cubeMap = new TextureCubeMap(cubeImage); cubeMap.setAnisotropicFilter(0); cubeMap.setMagFilter(Texture.MagFilter.Bilinear); cubeMap.setMinFilter(Texture.MinFilter.BilinearNoMipMaps); cubeMap.setWrap(Texture.WrapMode.EdgeClamp);
TextureCubeMap offTex = new TextureCubeMap(512, 512, Format.RGBA8); offTex.setMinFilter(Texture.MinFilter.Trilinear); offTex.setMagFilter(Texture.MagFilter.Bilinear);
texture = new TextureCubeMap(image);
/** * Add a color texture to use for this framebuffer. * If MRT is enabled, then each subsequently added texture can be * rendered to through a shader that writes to the array <code>gl_FragData</code>. * If MRT is not enabled, then the index set with {@link FrameBuffer#setTargetIndex(int) } * is rendered to by the shader. * * @param tex The cube-map texture to add. * @param face The face of the cube-map to render to. */ public void addColorTexture(TextureCubeMap tex, TextureCubeMap.Face face) { if (id != -1) throw new UnsupportedOperationException("FrameBuffer already initialized."); Image img = tex.getImage(); checkSetTexture(tex, false); RenderBuffer colorBuf = new RenderBuffer(); colorBuf.slot = colorBufs.size(); colorBuf.tex = tex; colorBuf.format = img.getFormat(); colorBuf.face = face.ordinal(); colorBufs.add(colorBuf); }
data.add(BufferUtils.clone(sourceData)); texture = new TextureCubeMap(new Image(image.getFormat(), image.getWidth(), image.getHeight(), 6, data, ColorSpace.Linear)); result = texture; } else { ImageUtils.mix(result.getImage(), texture.getImage());
public static Node getCubeMapCrossDebugViewWithMipMaps(TextureCubeMap cubeMap, AssetManager assetManager) { Node n = new Node("CubeMapDebug" + cubeMap.getName()); int size = cubeMap.getImage().getWidth(); int nbMips = cubeMap.getImage().getMipMapSizes().length; Picture[] pics = new Picture[6*nbMips]; int guiOffset = 0; for (int mipLevel = 0; mipLevel < nbMips; mipLevel++) { size = Math.max(1, cubeMap.getImage().getWidth() >> mipLevel); int dataSize = cubeMap.getImage().getMipMapSizes()[mipLevel]; byte[] dataArray = new byte[dataSize]; for (int i = 0; i < 6; i++) { ByteBuffer bb = cubeMap.getImage().getData(i); Texture2D tex = new Texture2D(new Image(cubeMap.getImage().getFormat(), size, size, data, cubeMap.getImage().getColorSpace())); Quad q = new Quad(cubeMap.getImage().getWidth() * 4 + nbMips, guiOffset + size); Geometry g = new Geometry("bg", q); Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
public TextureCubeMap(Image img){ super(); setImage(img); }
@Override public boolean equals(Object other) { if (!(other instanceof TextureCubeMap)) { return false; } TextureCubeMap that = (TextureCubeMap) other; if (this.getWrap(WrapAxis.S) != that.getWrap(WrapAxis.S)) return false; if (this.getWrap(WrapAxis.T) != that.getWrap(WrapAxis.T)) return false; if (this.getWrap(WrapAxis.R) != that.getWrap(WrapAxis.R)) return false; return super.equals(other); }
TextureCubeMap cubeMap = new TextureCubeMap(cubeImage); cubeMap.setAnisotropicFilter(0); cubeMap.setMagFilter(Texture.MagFilter.Bilinear); cubeMap.setMinFilter(Texture.MinFilter.BilinearNoMipMaps); cubeMap.setWrap(Texture.WrapMode.EdgeClamp);
/** * initialize the pem map * @param size the size of the map * @param imageFormat the format of the image * @return the initialized prefiltered env map */ public static TextureCubeMap createPrefilteredEnvMap(int size, Image.Format imageFormat) { TextureCubeMap pem = new TextureCubeMap(size, size, imageFormat); pem.setMagFilter(Texture.MagFilter.Bilinear); pem.setMinFilter(Texture.MinFilter.Trilinear); pem.getImage().setColorSpace(ColorSpace.Linear); int nbMipMap = Math.min(6, (int) (Math.log(size) / Math.log(2))); CubeMapWrapper targetWrapper = new CubeMapWrapper(pem); targetWrapper.initMipMaps(nbMipMap); return pem; } }
texture = new TextureCubeMap(); texture.setImage(img);
/** * Creates a CubeMapWrapper for the given cube map * Note that the cube map must be initialized, and the mipmaps sizes should * be set if relevant for them to be readable/writable * @param cubeMap the cubemap to wrap. */ public CubeMapWrapper(TextureCubeMap cubeMap) { image = cubeMap.getImage(); if (image.hasMipmaps()) { int nbMipMaps = image.getMipMapSizes().length; sizes = new int[nbMipMaps]; mipMapRaster = new MipMapImageRaster(image, 0); for (int i = 0; i < nbMipMaps; i++) { sizes[i] = Math.max(1, image.getWidth() >> i); } } else { sizes = new int[1]; sizes[0] = image.getWidth(); } raster = new DefaultImageRaster(image, 0,0 , false); }
public TextureCubeMap(Image img){ super(); setImage(img); }
@Override public boolean equals(Object other) { if (!(other instanceof TextureCubeMap)) { return false; } TextureCubeMap that = (TextureCubeMap) other; if (this.getWrap(WrapAxis.S) != that.getWrap(WrapAxis.S)) return false; if (this.getWrap(WrapAxis.T) != that.getWrap(WrapAxis.T)) return false; if (this.getWrap(WrapAxis.R) != that.getWrap(WrapAxis.R)) return false; return super.equals(other); }
/** * Make a duplicate of this cube Map. That means that it's another instant * od TextureCubeMap, but the underlying buffers are duplicates of the * original ones. see {@link ByteBuffer#duplicate()} * * Use this if you need to read from the map from multiple threads, it * should garanty the thread safety. Note that if you want to write to the * cube map you have to make sure that the different thread do not write to * the same area of the buffer. The position, limit and mark are not an * issue. * * @param sourceMap * @return */ public static TextureCubeMap duplicateCubeMap(TextureCubeMap sourceMap) { Image srcImg = sourceMap.getImage(); Image cubeImage = new Image(srcImg.getFormat(), srcImg.getWidth(), srcImg.getHeight(), null, srcImg.getColorSpace()); for (ByteBuffer d : srcImg.getData()) { cubeImage.addData(d.duplicate()); } cubeImage.setMipMapSizes(srcImg.getMipMapSizes()); TextureCubeMap cubeMap = new TextureCubeMap(cubeImage); cubeMap.setAnisotropicFilter(sourceMap.getAnisotropicFilter()); cubeMap.setMagFilter(sourceMap.getMagFilter()); cubeMap.setMinFilter(sourceMap.getMinFilter()); cubeMap.setWrap(sourceMap.getWrap(Texture.WrapAxis.S)); return cubeMap; }