use of com.badlogic.gdx.graphics.g3d.attributes.BlendingAttribute in project libgdx by libgdx.
the class ParticleShader method bindMaterial.
protected void bindMaterial(final Renderable renderable) {
if (currentMaterial == renderable.material)
return;
int cullFace = config.defaultCullFace == -1 ? GL20.GL_BACK : config.defaultCullFace;
int depthFunc = config.defaultDepthFunc == -1 ? GL20.GL_LEQUAL : config.defaultDepthFunc;
float depthRangeNear = 0f;
float depthRangeFar = 1f;
boolean depthMask = true;
currentMaterial = renderable.material;
for (final Attribute attr : currentMaterial) {
final long t = attr.type;
if (BlendingAttribute.is(t)) {
context.setBlending(true, ((BlendingAttribute) attr).sourceFunction, ((BlendingAttribute) attr).destFunction);
} else if ((t & DepthTestAttribute.Type) == DepthTestAttribute.Type) {
DepthTestAttribute dta = (DepthTestAttribute) attr;
depthFunc = dta.depthFunc;
depthRangeNear = dta.depthRangeNear;
depthRangeFar = dta.depthRangeFar;
depthMask = dta.depthMask;
} else if (!config.ignoreUnimplemented)
throw new GdxRuntimeException("Unknown material attribute: " + attr.toString());
}
context.setCullFace(cullFace);
context.setDepthTest(depthFunc, depthRangeNear, depthRangeFar);
context.setDepthMask(depthMask);
}
use of com.badlogic.gdx.graphics.g3d.attributes.BlendingAttribute in project libgdx by libgdx.
the class PointSpriteParticleBatch method allocRenderable.
protected void allocRenderable() {
renderable = new Renderable();
renderable.meshPart.primitiveType = GL20.GL_POINTS;
renderable.meshPart.offset = 0;
renderable.material = new Material(new BlendingAttribute(GL20.GL_ONE, GL20.GL_ONE_MINUS_SRC_ALPHA, 1f), new DepthTestAttribute(GL20.GL_LEQUAL, false), TextureAttribute.createDiffuse((Texture) null));
}
use of com.badlogic.gdx.graphics.g3d.attributes.BlendingAttribute in project libgdx by libgdx.
the class SkeletonTest method onLoaded.
@Override
protected void onLoaded() {
if (currentlyLoading == null || currentlyLoading.isEmpty())
return;
instances.clear();
animationControllers.clear();
final ModelInstance instance = new ModelInstance(assets.get(currentlyLoading, Model.class));
for (Material m : instance.materials) m.set(new BlendingAttribute(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA, 0.8f));
instances.add(instance);
if (instance.animations.size > 0)
animationControllers.put(instance, new AnimationController(instance));
currentlyLoading = null;
}
use of com.badlogic.gdx.graphics.g3d.attributes.BlendingAttribute in project libgdx by libgdx.
the class MaterialTest method create.
@Override
public void create() {
texture = new Texture(Gdx.files.internal("data/badlogic.jpg"), true);
// Create material attributes. Each material can contain x-number of attributes.
textureAttribute = new TextureAttribute(TextureAttribute.Diffuse, texture);
colorAttribute = new ColorAttribute(ColorAttribute.Diffuse, Color.ORANGE);
blendingAttribute = new BlendingAttribute(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
ModelBuilder builder = new ModelBuilder();
model = builder.createBox(1, 1, 1, new Material(), Usage.Position | Usage.Normal | Usage.TextureCoordinates);
model.manageDisposable(texture);
modelInstance = new ModelInstance(model);
modelInstance.transform.rotate(Vector3.X, 45);
material = modelInstance.materials.get(0);
builder.begin();
MeshPartBuilder mpb = builder.part("back", GL20.GL_TRIANGLES, Usage.Position | Usage.TextureCoordinates, new Material(textureAttribute));
mpb.rect(-2, -2, -2, 2, -2, -2, 2, 2, -2, -2, 2, -2, 0, 0, 1);
backModel = builder.end();
background = new ModelInstance(backModel);
modelBatch = new ModelBatch();
camera = new PerspectiveCamera(45, 4, 4);
camera.position.set(0, 0, 3);
camera.direction.set(0, 0, -1);
camera.update();
Gdx.input.setInputProcessor(this);
}
use of com.badlogic.gdx.graphics.g3d.attributes.BlendingAttribute in project bdx by GoranM.
the class BDXShaderProvider method render.
public void render(Renderable renderable, Attributes combinedAttributes) {
if (renderable.material.has(BlendingAttribute.Type)) {
BlendingAttribute ba = (BlendingAttribute) renderable.material.get(BlendingAttribute.Type);
Gdx.gl.glBlendFuncSeparate(ba.sourceFunction, ba.destFunction, GL20.GL_ONE, GL20.GL_ONE_MINUS_SRC_ALPHA);
}
IntAttribute shadeless = (IntAttribute) renderable.material.get(Scene.BDXIntAttribute.Shadeless);
if (shadeless == null)
set(u_shadeless, 0);
else
set(u_shadeless, shadeless.value);
ColorAttribute tint = (ColorAttribute) renderable.material.get(Scene.BDXColorAttribute.Tint);
if (tint == null)
set(u_tintColor, new Color());
else
set(u_tintColor, tint.color);
ColorAttribute emit = (ColorAttribute) renderable.material.get(Scene.BDXColorAttribute.Emit);
if (emit == null)
set(u_emitColor, new Color());
else
set(u_emitColor, emit.color);
if (shaderProvider.scene != null) {
ColorAttribute fog = (ColorAttribute) renderable.environment.get(ColorAttribute.Fog);
if (fog == null)
set(u_fogRange, 0f, 0f);
else
set(u_fogRange, shaderProvider.scene.fogRange().x, shaderProvider.scene.fogRange().y);
set(u_camRange, shaderProvider.scene.camera.near(), shaderProvider.scene.camera.far());
}
super.render(renderable, combinedAttributes);
}
Aggregations