use of org.terasology.rendering.assets.material.Material in project Terasology by MovingBlocks.
the class ShaderManagerLwjgl method recompileAllShaders.
@Override
public void recompileAllShaders() {
AssetManager assetManager = CoreRegistry.get(AssetManager.class);
assetManager.getLoadedAssets(Shader.class).forEach(Shader::recompile);
assetManager.getLoadedAssets(Material.class).forEach(Material::recompile);
activeMaterial = null;
}
use of org.terasology.rendering.assets.material.Material in project Terasology by MovingBlocks.
the class ShaderManagerLwjgl method addShaderProgram.
// TODO: discuss having a `public removeShaderProgram`, to dispose shader programs no longer in use by any node
public GLSLMaterial addShaderProgram(String title) {
String uri = "engine:" + title;
Optional<? extends Shader> shader = Assets.getShader(uri);
checkState(shader.isPresent(), "Failed to resolve %s", uri);
shader.get().recompile();
GLSLMaterial material = (GLSLMaterial) Assets.generateAsset(new ResourceUrn("engine:prog." + title), new MaterialData(shader.get()), Material.class);
progamaticShaders.add(material);
return material;
}
use of org.terasology.rendering.assets.material.Material in project Terasology by MovingBlocks.
the class Skysphere method render.
@Override
public void render(Camera camera) {
glDepthMask(false);
if (camera.isReflected()) {
glCullFace(GL_BACK);
} else {
glCullFace(GL_FRONT);
}
Material shader = Assets.getMaterial("engine:prog.sky").get();
shader.enable();
// Draw the skysphere
drawSkysphere(camera.getzFar());
if (camera.isReflected()) {
glCullFace(GL_FRONT);
} else {
glCullFace(GL_BACK);
}
glDepthMask(true);
}
use of org.terasology.rendering.assets.material.Material in project Terasology by MovingBlocks.
the class SpriteParticleRenderer method renderAlphaBlend.
@Override
public void renderAlphaBlend() {
Material material = Assets.getMaterial(PARTICLE_MATERIAL_URI).get();
material.enable();
Vector3f camPos = worldRenderer.getActiveCamera().getPosition();
particleSystemManager.getParticleEmittersByDataComponent(ParticleDataSpriteComponent.class).forEach(p -> drawParticles(material, p, camPos));
}
use of org.terasology.rendering.assets.material.Material in project Terasology by MovingBlocks.
the class Block method renderWithLightValue.
public void renderWithLightValue(float sunlight, float blockLight) {
if (meshGenerator == null) {
return;
}
Material mat = Assets.getMaterial("engine:prog.block").orElseThrow(() -> new RuntimeException("Missing engine material"));
mat.activateFeature(ShaderProgramFeature.FEATURE_USE_MATRIX_STACK);
mat.enable();
mat.setFloat("sunlight", sunlight);
mat.setFloat("blockLight", blockLight);
Mesh mesh = meshGenerator.getStandaloneMesh();
if (mesh != null) {
mesh.render();
}
mat.deactivateFeature(ShaderProgramFeature.FEATURE_USE_MATRIX_STACK);
}
Aggregations