com.badlogic.gdx.graphics.g3d.utils.TextureDescriptor Java Examples

The following examples show how to use com.badlogic.gdx.graphics.g3d.utils.TextureDescriptor. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PBRMaterialLoader.java    From gdx-gltf with Apache License 2.0 6 votes vote down vote up
private PBRTextureAttribute getTexureMap(long type, GLTFTextureInfo glMap) {
	TextureDescriptor<Texture> textureDescriptor = textureResolver.getTexture(glMap);
	
	PBRTextureAttribute attribute = new PBRTextureAttribute(type, textureDescriptor);
	attribute.uvIndex = glMap.texCoord;
	
	if(glMap.extensions != null){
		{
			KHRTextureTransform ext = glMap.extensions.get(KHRTextureTransform.class, KHRTextureTransform.EXT);
			if(ext != null){
				attribute.offsetU = ext.offset[0];
				attribute.offsetV = ext.offset[1];
				attribute.scaleU = ext.scale[0];
				attribute.scaleV = ext.scale[1];
				attribute.rotationUV = ext.rotation;
				if(ext.texCoord != null){
					attribute.uvIndex = ext.texCoord;
				}
			}
		}
	}
	
	return attribute;
}
 
Example #2
Source File: DirectionalShadowLight.java    From gdx-gltf with Apache License 2.0 5 votes vote down vote up
public DirectionalShadowLight(int shadowMapWidth, int shadowMapHeight, float shadowViewportWidth,
		float shadowViewportHeight, float shadowNear, float shadowFar) {
	fbo = new FrameBuffer(Format.RGBA8888, shadowMapWidth, shadowMapHeight, true);
	cam = new OrthographicCamera(shadowViewportWidth, shadowViewportHeight);
	cam.near = shadowNear;
	cam.far = shadowFar;
	textureDesc = new TextureDescriptor();
	textureDesc.minFilter = textureDesc.magFilter = Texture.TextureFilter.Nearest;
	textureDesc.uWrap = textureDesc.vWrap = Texture.TextureWrap.ClampToEdge;
}
 
Example #3
Source File: TextureResolver.java    From gdx-gltf with Apache License 2.0 5 votes vote down vote up
public TextureDescriptor<Texture> getTexture(GLTFTextureInfo glMap) {
	GLTFTexture glTexture = glTextures.get(glMap.index);
	
	TextureDescriptor<Texture> textureDescriptor = new TextureDescriptor<Texture>();

	boolean useMipMaps;
	if(glTexture.sampler != null){
		GLTFSampler glSampler = glSamplers.get(glTexture.sampler);
		GLTFTypes.mapTextureSampler(textureDescriptor, glSampler);
		useMipMaps = GLTFTypes.isMipMapFilter(glSampler);
	}else{
		// default sampler options.
		// https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#texture
		textureDescriptor.minFilter = TextureFilter.Linear;
		textureDescriptor.magFilter = TextureFilter.Linear;
		textureDescriptor.uWrap = TextureWrap.Repeat;
		textureDescriptor.vWrap = TextureWrap.Repeat;
		useMipMaps = false;
	}
	
	ObjectMap<Integer, Texture> textureMap = useMipMaps ? texturesMipmap : texturesSimple;
	
	Texture texture = textureMap.get(glTexture.source);
	if(texture == null){
		throw new GdxRuntimeException("texture not loaded");
	}
	textureDescriptor.texture = texture;
	return textureDescriptor;
}
 
Example #4
Source File: PBRTextureAttribute.java    From gdx-gltf with Apache License 2.0 4 votes vote down vote up
public PBRTextureAttribute(long type, TextureDescriptor<Texture> textureDescription) {
	super(type, textureDescription);
}
 
Example #5
Source File: PBRCubemapAttribute.java    From gdx-gltf with Apache License 2.0 4 votes vote down vote up
public PBRCubemapAttribute(long type, TextureDescriptor<Cubemap> textureDescription) {
	super(type, textureDescription);
}
 
Example #6
Source File: DirectionalShadowLight.java    From gdx-gltf with Apache License 2.0 4 votes vote down vote up
@Override
public TextureDescriptor getDepthMap () {
	textureDesc.texture = fbo.getColorBufferTexture();
	return textureDesc;
}
 
Example #7
Source File: GLTFTypes.java    From gdx-gltf with Apache License 2.0 4 votes vote down vote up
public static void mapTextureSampler(TextureDescriptor<Texture> textureDescriptor, GLTFSampler glSampler) {
	textureDescriptor.minFilter = GLTFTypes.mapTextureMinFilter(glSampler.minFilter);
	textureDescriptor.magFilter = GLTFTypes.mapTextureMagFilter(glSampler.magFilter);
	textureDescriptor.uWrap = GLTFTypes.mapTextureWrap(glSampler.wrapS);
	textureDescriptor.vWrap = GLTFTypes.mapTextureWrap(glSampler.wrapT);
}