Java Code Examples for com.badlogic.gdx.graphics.g3d.Attributes#get()

The following examples show how to use com.badlogic.gdx.graphics.g3d.Attributes#get() . 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: PBRShader.java    From gdx-gltf with Apache License 2.0 6 votes vote down vote up
private static long getTextureCoordinateMapMask(Attributes attributes){
	// encode texture coordinate unit in a 5 bits integer.
	// 5 texture types with 1 bits per texture type.
	// 0 means no texture or unit 0
	// 1 means unit 1
	// only 2 units are supported.
	long mask = 0L;
	int maskShift = 0;
	for(long textureType : allTextureTypes){
		PBRTextureAttribute attribute = attributes.get(PBRTextureAttribute.class, textureType);
		if(attribute != null){
			mask |= (attribute.uvIndex & 1) << maskShift;
		}
		maskShift++;
	}
	return mask;
}
 
Example 2
Source File: PBRShader.java    From gdx-gltf with Apache License 2.0 6 votes vote down vote up
@Override
protected void bindLights(Renderable renderable, Attributes attributes) {
	
	// XXX update color (to apply intensity) before default binding
	DirectionalLightsAttribute dla = attributes.get(DirectionalLightsAttribute.class, DirectionalLightsAttribute.Type);
	if(dla != null){
		for(DirectionalLight light : dla.lights){
			if(light instanceof DirectionalLightEx){
				((DirectionalLightEx) light).updateColor();
			}
		}
	}
	
	super.bindLights(renderable, attributes);
		
	// XXX
	ColorAttribute ambiantLight = attributes.get(ColorAttribute.class, ColorAttribute.AmbientLight);
	if(ambiantLight != null){
		program.setUniformf(u_ambientLight, ambiantLight.color.r, ambiantLight.color.g, ambiantLight.color.b);
	}
}
 
Example 3
Source File: PBRShader.java    From gdx-gltf with Apache License 2.0 5 votes vote down vote up
@Override
public void set (BaseShader shader, int inputID, Renderable renderable, Attributes combinedAttributes) {
	ColorAttribute attribute = combinedAttributes.get(ColorAttribute.class, PBRColorAttribute.BaseColorFactor);
	Color color = attribute == null ? Color.WHITE : attribute.color;
	shader.set(inputID, color);
}
 
Example 4
Source File: PBRShader.java    From gdx-gltf with Apache License 2.0 5 votes vote down vote up
@Override
public void set (BaseShader shader, int inputID, Renderable renderable, Attributes combinedAttributes) {
	PBRFloatAttribute metallicAttribute = combinedAttributes.get(PBRFloatAttribute.class, PBRFloatAttribute.Metallic);
	PBRFloatAttribute roughnessAttribute = combinedAttributes.get(PBRFloatAttribute.class, PBRFloatAttribute.Roughness);
	float metallic = metallicAttribute == null ? 1f : metallicAttribute.value;
	float roughness = roughnessAttribute == null ? 1f : roughnessAttribute.value;
	shader.set(inputID, v2.set(metallic, roughness));
}
 
Example 5
Source File: PBRShader.java    From gdx-gltf with Apache License 2.0 5 votes vote down vote up
@Override
public void set (BaseShader shader, int inputID, Renderable renderable, Attributes combinedAttributes) {
	PBRTextureAttribute attribute = combinedAttributes.get(PBRTextureAttribute.class, PBRTextureAttribute.BRDFLUTTexture);
	if(attribute != null){
		final int unit = shader.context.textureBinder.bind(attribute.textureDescription);
		shader.set(inputID, unit);
	}
}
 
Example 6
Source File: PBRShader.java    From gdx-gltf with Apache License 2.0 4 votes vote down vote up
@Override
public void set (BaseShader shader, int inputID, Renderable renderable, Attributes combinedAttributes) {
	PBRFloatAttribute normalScaleAttribute = combinedAttributes.get(PBRFloatAttribute.class, PBRFloatAttribute.NormalScale);
	float normalScale = normalScaleAttribute == null ? 1f : normalScaleAttribute.value;
	shader.set(inputID, normalScale);
}
 
Example 7
Source File: PBRShader.java    From gdx-gltf with Apache License 2.0 4 votes vote down vote up
@Override
public void set (BaseShader shader, int inputID, Renderable renderable, Attributes combinedAttributes) {
	PBRFloatAttribute occlusionStrengthAttribute = combinedAttributes.get(PBRFloatAttribute.class, PBRFloatAttribute.OcclusionStrength);
	float occlusionStrength = occlusionStrengthAttribute == null ? 1f : occlusionStrengthAttribute.value;
	shader.set(inputID, occlusionStrength);
}
 
Example 8
Source File: PBRShader.java    From gdx-gltf with Apache License 2.0 4 votes vote down vote up
@Override
public void set (BaseShader shader, int inputID, Renderable renderable, Attributes combinedAttributes) {
	PBRCubemapAttribute diffuseEnvAttribute = combinedAttributes.get(PBRCubemapAttribute.class, PBRCubemapAttribute.DiffuseEnv);
	final int unit = shader.context.textureBinder.bind(diffuseEnvAttribute.textureDescription);
	shader.set(inputID, unit);
}
 
Example 9
Source File: PBRShader.java    From gdx-gltf with Apache License 2.0 4 votes vote down vote up
@Override
public void set (BaseShader shader, int inputID, Renderable renderable, Attributes combinedAttributes) {
	PBRCubemapAttribute specularEnvAttribute = combinedAttributes.get(PBRCubemapAttribute.class, PBRCubemapAttribute.SpecularEnv);
	final int unit = shader.context.textureBinder.bind(specularEnvAttribute.textureDescription);
	shader.set(inputID, unit);
}
 
Example 10
Source File: PBRShader.java    From gdx-gltf with Apache License 2.0 4 votes vote down vote up
@Override
public void set (BaseShader shader, int inputID, Renderable renderable, Attributes combinedAttributes) {
	PBRFloatAttribute attribute = combinedAttributes.get(PBRFloatAttribute.class, PBRFloatAttribute.ShadowBias);
	float value = attribute == null ? 0f : attribute.value;
	shader.set(inputID, value);
}
 
Example 11
Source File: PBRShader.java    From gdx-gltf with Apache License 2.0 4 votes vote down vote up
@Override
public void set (BaseShader shader, int inputID, Renderable renderable, Attributes combinedAttributes) {
	FogAttribute attribute = combinedAttributes.get(FogAttribute.class, FogAttribute.FogEquation);
	Vector3 value = attribute == null ? Vector3.Zero : attribute.value;
	shader.set(inputID, value);
}