Texture loadedTexture = assetManager.loadTexture(texKey); textures[texUnit].setImage(loadedTexture.getImage()); textures[texUnit].setMinFilter(loadedTexture.getMinFilter()); textures[texUnit].setMagFilter(loadedTexture.getMagFilter()); textures[texUnit].setAnisotropicFilter(loadedTexture.getAnisotropicFilter()); textures[texUnit].setKey(loadedTexture.getKey()); textures[texUnit].setWrap(WrapMode.Repeat); if (texName != null){ textures[texUnit].setName(texName); texName = null; }else{ textures[texUnit].setName(texKey.getName()); textures[texUnit].setImage(PlaceholderAssets.getPlaceholderImage(assetManager)); textures[texUnit].setKey(texKey);
@Override public Texture createSimpleClone(Texture rVal) { rVal.setWrap(WrapAxis.S, wrapS); rVal.setWrap(WrapAxis.T, wrapT); return super.createSimpleClone(rVal); }
/** * <code>setImage</code> sets the image object that defines the texture. * * @param image * the image that defines the texture. */ public void setImage(Image image) { this.image = image; // Test if mipmap generation required. setMinFilter(getMinFilter()); }
/** Retrieve a basic clone of this Texture (ie, clone everything but the * image data, which is shared) * * @return Texture * * @deprecated Use {@link Texture#clone()} instead. */ @Deprecated public Texture createSimpleClone(Texture rVal) { rVal.setMinFilter(minificationFilter); rVal.setMagFilter(magnificationFilter); rVal.setShadowCompareMode(shadowCompareMode); rVal.setAnisotropicFilter(anisotropicFilter); rVal.setImage(image); // NOT CLONED. rVal.setKey(key); rVal.setName(name); return rVal; }
Texture loadedTexture = assetManager.loadTexture(texKey); textures[texUnit].setImage(loadedTexture.getImage()); textures[texUnit].setMinFilter(loadedTexture.getMinFilter()); textures[texUnit].setKey(loadedTexture.getKey()); textures[texUnit].setWrap(WrapMode.Repeat); if (texName != null){ textures[texUnit].setName(texName); texName = null; }else{ textures[texUnit].setName(texKey.getName()); textures[texUnit].setImage(PlaceholderAssets.getPlaceholderImage());
Image img = texture.getImage(); texture = new TextureCubeMap(); texture.setImage(img); break; texture.setMagFilter(Texture.MagFilter.Bilinear); texture.setMinFilter(Texture.MinFilter.BilinearNoMipMaps); texture.setAnisotropicFilter(0); texture.setWrap(Texture.WrapMode.EdgeClamp); skyMat.setTexture("Texture", texture); sky.setMaterial(skyMat);
for (TextureData textureData : textureDatas) { if (textureDatas.size() > 1 && textureData.texture.getImage().getFormat().isCompressed()) { textureData.texture.setImage(ImageUtils.decompress(textureData.texture.getImage())); textureData.textureBlender = TextureBlenderFactory.alterTextureType(textureData.texture.getImage().getFormat(), textureData.textureBlender); LOGGER.warning("The texture " + textureData.texture.getName() + " has assigned non existing UV coordinates group: " + textureData.uvCoordinatesName + "."); } else if (textureData.texture instanceof Texture2D) { if (this.isUVTypesMatch(masterUVCoordinatesType, masterUserUVSetName, textureData.uvCoordinatesType, textureData.uvCoordinatesName) && resultTexture instanceof Texture2D) { this.scale((Texture2D) textureData.texture, resultTexture.getImage().getWidth(), resultTexture.getImage().getHeight()); ImageUtils.merge(resultTexture.getImage(), textureData.texture.getImage()); previousTexture = resultTexture; } else { resultTexture.setWrap(WrapMode.Repeat); resultTexture.setMagFilter(MagFilter.Nearest); resultTexture.setMinFilter(MinFilter.NearestNoMipMaps);
if (loadedTexture != null) { result = loadedTexture; this.applyColorbandAndColorFactors(textureStructure, result.getImage(), blenderContext); result.setName(textureStructure.getName()); result.setWrap(WrapMode.Repeat); result.setMinFilter(MinFilter.Trilinear); break; case NEVER_GENERATE: case GENERATE_WHEN_NEEDED: if ((imaflag & 0x04) != 0) { result.setMinFilter(MinFilter.Trilinear); result.setKey(new GeneratedTextureKey(textureStructure.getName())); LOGGER.log(Level.FINE, "Adding texture {0} to the loaded features with OMA = {1}", new Object[] { result.getName(), textureStructure.getOldMemoryAddress() });
tex.setMinFilter(Texture.MinFilter.Trilinear); tex.setAnisotropicFilter(texKey.getAnisotropy()); tex.setName(texKey.getName()); tex.setImage(img); return tex;
private static Material createCheckerBoardMaterial(AssetManager assetManager) { Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); Texture tex = createCheckerBoardTexture(); // assetManager.loadTexture("Textures/Terrain/BrickWall/BrickWall.dds"); tex.setMagFilter(Texture.MagFilter.Bilinear); tex.setMinFilter(Texture.MinFilter.Trilinear); tex.setWrap(Texture.WrapMode.Repeat); mat.setTexture("ColorMap", tex); return mat; }
protected static String formatMatParamTexture(MatParamTexture param) { StringBuilder ret = new StringBuilder(); Texture tex = (Texture) param.getValue(); TextureKey key; if (tex != null) { key = (TextureKey) tex.getKey(); if (key != null && key.isFlipY()) { ret.append("Flip "); } ret.append(formatWrapMode(tex, Texture.WrapAxis.S)); ret.append(formatWrapMode(tex, Texture.WrapAxis.T)); ret.append(formatWrapMode(tex, Texture.WrapAxis.R)); //Min and Mag filter Texture.MinFilter def = Texture.MinFilter.BilinearNoMipMaps; if (tex.getImage().hasMipmaps() || (key != null && key.isGenerateMips())) { def = Texture.MinFilter.Trilinear; } if (tex.getMinFilter() != def) { ret.append("Min").append(tex.getMinFilter().name()).append(" "); } if (tex.getMagFilter() != Texture.MagFilter.Bilinear) { ret.append("Mag").append(tex.getMagFilter().name()).append(" "); } ret.append("\"").append(key.getName()).append("\""); } return ret.toString(); }
protected Texture loadTexture(String path){ String[] split = path.trim().split("\\p{javaWhitespace}+"); // will crash if path is an empty string path = split[split.length-1]; String name = new File(path).getName(); TextureKey texKey = new TextureKey(folderName + name); texKey.setGenerateMips(true); Texture texture; try { texture = assetManager.loadTexture(texKey); texture.setWrap(WrapMode.Repeat); } catch (AssetNotFoundException ex){ logger.log(Level.WARNING, "Cannot locate {0} for material {1}", new Object[]{texKey, key}); texture = new Texture2D(PlaceholderAssets.getPlaceholderImage(assetManager)); texture.setWrap(WrapMode.Repeat); texture.setKey(key); } return texture; }
@SuppressWarnings("fallthrough") private void setupTextureParams(int unit, Texture tex) { Image image = tex.getImage(); int samples = image != null ? image.getMultiSamples() : 1; int target = convertTextureType(tex.getType(), samples, -1); if (curState.magFilter != tex.getMagFilter()) { bindTextureAndUnit(target, image, unit); gl.glTexParameteri(target, GL.GL_TEXTURE_MAG_FILTER, convertMagFilter(tex.getMagFilter())); curState.magFilter = tex.getMagFilter(); if (curState.minFilter != tex.getMinFilter()) { bindTextureAndUnit(target, image, unit); gl.glTexParameteri(target, GL.GL_TEXTURE_MIN_FILTER, convertMinFilter(tex.getMinFilter(), haveMips)); curState.minFilter = tex.getMinFilter(); int desiredAnisoFilter = tex.getAnisotropicFilter() == 0 ? defaultAnisotropicFilter : tex.getAnisotropicFilter(); switch (tex.getType()) { case ThreeDimensional: case CubeMap: // cubemaps use 3D coords if (gl2 != null && curState.rWrap != tex.getWrap(WrapAxis.R)) { bindTextureAndUnit(target, image, unit); gl2.glTexParameteri(target, GL2.GL_TEXTURE_WRAP_R, convertWrapMode(tex.getWrap(WrapAxis.R))); curState.rWrap = tex.getWrap(WrapAxis.R); if (curState.tWrap != tex.getWrap(WrapAxis.T)) { bindTextureAndUnit(target, image, unit);
@Override public void applyToTexture(final String option, final Texture texture) { final int separatorPosition = option.indexOf("_"); if (separatorPosition >= option.length() - 2) { final String axis = option.substring(separatorPosition + 1); final String mode = option.substring(0, separatorPosition); final Texture.WrapAxis wrapAxis = Texture.WrapAxis.valueOf(axis); texture.setWrap(wrapAxis, Texture.WrapMode.valueOf(mode)); } else { texture.setWrap(Texture.WrapMode.valueOf(option)); } } },
private Image loadImageSafe(AssetManager assetManager, TextureKey texKey) { try { return assetManager.loadTexture(texKey).getImage(); } catch (AssetNotFoundException ex) { return null; } catch (AssetLoadException ex) { logger.log(Level.WARNING, "Error when loading image: " + texKey, ex); return null; } }
@SuppressWarnings("fallthrough") private void setupTextureParams(Texture tex) { Image image = tex.getImage(); int target = convertTextureType(tex.getType(), image != null ? image.getMultiSamples() : 1, -1); int minFilter = convertMinFilter(tex.getMinFilter(), haveMips); int magFilter = convertMagFilter(tex.getMagFilter()); glTexParameteri(target, GL_TEXTURE_MIN_FILTER, minFilter); glTexParameteri(target, GL_TEXTURE_MAG_FILTER, magFilter); if (tex.getAnisotropicFilter() > 1) { if (caps.contains(Caps.TextureFilterAnisotropic)) { glTexParameterf(target, GL_TEXTURE_MAX_ANISOTROPY_EXT, tex.getAnisotropicFilter()); switch (tex.getType()) { case ThreeDimensional: case CubeMap: // cubemaps use 3D coords glTexParameteri(target, GL_TEXTURE_WRAP_R, convertWrapMode(tex.getWrap(WrapAxis.R))); glTexParameteri(target, GL_TEXTURE_WRAP_T, convertWrapMode(tex.getWrap(WrapAxis.T))); glTexParameteri(target, GL_TEXTURE_WRAP_S, convertWrapMode(tex.getWrap(WrapAxis.S))); break; default: throw new UnsupportedOperationException("Unknown texture type: " + tex.getType()); if(tex.isNeedCompareModeUpdate()){
String mode = split[1]; if (mode.equals("wrap")){ textures[texUnit].setWrap(WrapMode.Repeat); }else if (mode.equals("clamp")){ textures[texUnit].setWrap(WrapMode.EdgeClamp); }else if (mode.equals("mirror")){ textures[texUnit].setWrap(WrapMode.MirroredRepeat); }else if (mode.equals("border")){ textures[texUnit].setWrap(WrapMode.BorderClamp); textures[texUnit].setAnisotropicFilter(amount); }else{ logger.log(Level.WARNING, "Unsupported texture_unit directive: {0}", keyword);
if (!tex.getImage().isNPOT()) { if (tex.getMinFilter().usesMipMapLevels()) { throw new RendererException("non-power-of-2 textures with mip-maps " + "are not supported by the video hardware"); switch (tex.getType()) { case CubeMap: case ThreeDimensional: if (tex.getWrap(WrapAxis.R) != Texture.WrapMode.EdgeClamp) { throw new RendererException("repeating non-power-of-2 textures " + "are not supported by the video hardware"); if (tex.getWrap(WrapAxis.S) != Texture.WrapMode.EdgeClamp || tex.getWrap(WrapAxis.T) != Texture.WrapMode.EdgeClamp) { throw new RendererException("repeating non-power-of-2 textures " + "are not supported by the video hardware");
tex.setMinFilter(Texture.MinFilter.Trilinear); Texture texCustomMip = tex.clone(); Image imageCustomMip = texCustomMip.getImage().clone(); MipMapGenerator.generateMipMaps(imageCustomMip); texCustomMip.setImage(imageCustomMip);
Texture tex = rb.getTexture(); if (tex != null && tex.getMinFilter().usesMipMapLevels()) { setTexture(0, rb.getTexture()); int textureType = convertTextureType(tex.getType(), tex.getImage().getMultiSamples(), rb.getFace()); glfbo.glGenerateMipmapEXT(textureType);