use of gaiasky.util.gdx.shader.attribute.BlendingAttribute in project gaiasky by langurmonkey.
the class StubModel method setTransparency.
public void setTransparency(float alpha) {
if (instance != null) {
int n = instance.materials.size;
for (int i = 0; i < n; i++) {
Material mat = instance.materials.get(i);
BlendingAttribute ba = null;
if (mat.has(BlendingAttribute.Type)) {
ba = (BlendingAttribute) mat.get(BlendingAttribute.Type);
} else {
ba = new BlendingAttribute(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
mat.set(ba);
}
ba.opacity = alpha;
}
}
}
use of gaiasky.util.gdx.shader.attribute.BlendingAttribute in project gaiasky by langurmonkey.
the class Star method initModel.
private void initModel(final AssetManager manager) {
Texture tex = manager.get(Settings.settings.data.dataFile("tex/base/star.jpg"), Texture.class);
Texture lut = manager.get(Settings.settings.data.dataFile("tex/base/lut.jpg"), Texture.class);
tex.setFilter(TextureFilter.Linear, TextureFilter.Linear);
Map<String, Object> params = new TreeMap<>();
params.put("quality", 120L);
params.put("diameter", 1d);
params.put("flip", false);
Pair<IntModel, Map<String, Material>> pair = ModelCache.cache.getModel("sphere", params, Bits.indexes(Usage.Position, Usage.Normal, Usage.TextureCoordinates), GL20.GL_TRIANGLES);
IntModel model = pair.getFirst();
Material mat = pair.getSecond().get("base");
mat.clear();
mat.set(new TextureAttribute(TextureAttribute.Diffuse, tex));
mat.set(new TextureAttribute(TextureAttribute.Normal, lut));
// Only to activate view vector (camera position)
mat.set(new ColorAttribute(ColorAttribute.Specular));
mat.set(new BlendingAttribute(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA));
Matrix4 modelTransform = new Matrix4();
mc = new ModelComponent(false);
mc.initialize(null);
mc.env = new Environment();
mc.env.set(new ColorAttribute(ColorAttribute.AmbientLight, 1f, 1f, 1f, 1f));
mc.env.set(new FloatAttribute(FloatAttribute.Time, 0f));
mc.instance = new IntModelInstance(model, modelTransform);
// Relativistic effects
if (Settings.settings.runtime.relativisticAberration)
mc.rec.setUpRelativisticEffectsMaterial(mc.instance.materials);
mc.setModelInitialized(true);
}
use of gaiasky.util.gdx.shader.attribute.BlendingAttribute in project gaiasky by langurmonkey.
the class StarCluster method initModel.
public void initModel() {
if (clusterTex == null) {
clusterTex = new Texture(Settings.settings.data.dataFileHandle("data/tex/base/cluster-tex.png"), true);
clusterTex.setFilter(TextureFilter.MipMapLinearNearest, TextureFilter.Linear);
}
if (model == null) {
Material mat = new Material(new BlendingAttribute(GL20.GL_ONE, GL20.GL_ONE), new ColorAttribute(ColorAttribute.Diffuse, cc[0], cc[1], cc[2], cc[3]));
IntModelBuilder modelBuilder = ModelCache.cache.mb;
modelBuilder.begin();
// create part
IntMeshPartBuilder bPartBuilder = modelBuilder.part("sph", GL20.GL_LINES, Bits.indexes(Usage.Position), mat);
bPartBuilder.icosphere(1, 3, false, true);
model = (modelBuilder.end());
modelTransform = new Matrix4();
}
mc = new ModelComponent(false);
mc.initialize(null);
DirectionalLight dLight = new DirectionalLight();
dLight.set(1, 1, 1, 1, 1, 1);
mc.env = new Environment();
mc.env.add(dLight);
mc.env.set(new ColorAttribute(ColorAttribute.AmbientLight, 1.0f, 1.0f, 1.0f, 1f));
mc.env.set(new FloatAttribute(FloatAttribute.Shininess, 0.2f));
mc.instance = new IntModelInstance(model, modelTransform);
// Relativistic effects
if (Settings.settings.runtime.relativisticAberration)
mc.rec.setUpRelativisticEffectsMaterial(mc.instance.materials);
// Gravitational waves
if (Settings.settings.runtime.gravitationalWaves)
mc.rec.setUpGravitationalWavesMaterial(mc.instance.materials);
}
use of gaiasky.util.gdx.shader.attribute.BlendingAttribute in project gaiasky by langurmonkey.
the class StarGroup method initModel.
private void initModel(final AssetManager manager) {
Texture tex = manager.get(Settings.settings.data.dataFile("tex/base/star.jpg"), Texture.class);
Texture lut = manager.get(Settings.settings.data.dataFile("tex/base/lut.jpg"), Texture.class);
tex.setFilter(TextureFilter.Linear, TextureFilter.Linear);
Map<String, Object> params = new TreeMap<>();
params.put("quality", 120L);
params.put("diameter", 1d);
params.put("flip", false);
Pair<IntModel, Map<String, Material>> pair = ModelCache.cache.getModel("sphere", params, Bits.indexes(Usage.Position, Usage.Normal, Usage.Tangent, Usage.BiNormal, Usage.TextureCoordinates), GL20.GL_TRIANGLES);
IntModel model = pair.getFirst();
Material mat = pair.getSecond().get("base");
mat.clear();
mat.set(new TextureAttribute(TextureAttribute.Diffuse, tex));
mat.set(new TextureAttribute(TextureAttribute.Normal, lut));
// Only to activate view vector (camera position)
mat.set(new ColorAttribute(ColorAttribute.Specular));
mat.set(new BlendingAttribute(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA));
Matrix4 modelTransform = new Matrix4();
mc = new ModelComponent(false);
mc.initialize(null);
mc.env = new Environment();
mc.env.set(new ColorAttribute(ColorAttribute.AmbientLight, 1f, 1f, 1f, 1f));
mc.env.set(new FloatAttribute(FloatAttribute.Time, 0f));
mc.instance = new IntModelInstance(model, modelTransform);
// Relativistic effects
if (Settings.settings.runtime.relativisticAberration)
mc.rec.setUpRelativisticEffectsMaterial(mc.instance.materials);
mc.setModelInitialized(true);
}
use of gaiasky.util.gdx.shader.attribute.BlendingAttribute in project gaiasky by langurmonkey.
the class DepthIntShader method render.
@Override
public void render(IntRenderable renderable, Attributes combinedAttributes) {
if (combinedAttributes.has(BlendingAttribute.Type)) {
final BlendingAttribute blending = (BlendingAttribute) combinedAttributes.get(BlendingAttribute.Type);
combinedAttributes.remove(BlendingAttribute.Type);
final boolean hasAlphaTest = combinedAttributes.has(FloatAttribute.AlphaTest);
if (!hasAlphaTest)
combinedAttributes.set(alphaTestAttribute);
if (blending.opacity >= ((FloatAttribute) combinedAttributes.get(FloatAttribute.AlphaTest)).value)
super.render(renderable, combinedAttributes);
if (!hasAlphaTest)
combinedAttributes.remove(FloatAttribute.AlphaTest);
combinedAttributes.set(blending);
} else
super.render(renderable, combinedAttributes);
}
Aggregations