use of org.terasology.engine.world.block.tiles.WorldAtlas in project Terasology by MovingBlocks.
the class HeadlessEnvironment method setupBlockManager.
@Override
protected void setupBlockManager(AssetManager assetManager) {
WorldAtlas worldAtlas = new NullWorldAtlas();
BlockManagerImpl blockManager = new BlockManagerImpl(worldAtlas, assetManager);
context.put(BlockManager.class, blockManager);
TypeHandlerLibrary typeHandlerLibrary = context.get(TypeHandlerLibrary.class);
typeHandlerLibrary.addTypeHandler(BlockFamily.class, new BlockFamilyTypeHandler(blockManager));
typeHandlerLibrary.addTypeHandler(Block.class, new BlockTypeHandler(blockManager));
}
use of org.terasology.engine.world.block.tiles.WorldAtlas in project Terasology by MovingBlocks.
the class RegisterBlocks method step.
@Override
public boolean step() {
NetworkSystem networkSystem = context.get(NetworkSystem.class);
WorldAtlas atlas = new WorldAtlasImpl(context.get(Config.class).getRendering().getMaxTextureAtlasResolution());
context.put(WorldAtlas.class, atlas);
ModuleEnvironment environment = context.get(ModuleManager.class).getEnvironment();
context.put(BlockFamilyLibrary.class, new BlockFamilyLibrary(environment, context));
BlockManagerImpl blockManager;
if (networkSystem.getMode().isAuthority()) {
blockManager = new BlockManagerImpl(atlas, context.get(AssetManager.class), true);
blockManager.subscribe(context.get(NetworkSystem.class));
} else {
blockManager = new BlockManagerImpl(atlas, context.get(AssetManager.class), false);
}
context.put(BlockManager.class, blockManager);
context.get(TypeHandlerLibrary.class).addTypeHandler(Block.class, new BlockTypeHandler(blockManager));
context.get(TypeHandlerLibrary.class).addTypeHandler(BlockFamily.class, new BlockFamilyTypeHandler(blockManager));
blockManager.initialise(gameManifest.getRegisteredBlockFamilies(), gameManifest.getBlockIdMap());
return true;
}
use of org.terasology.engine.world.block.tiles.WorldAtlas in project Terasology by MovingBlocks.
the class GLSLShader method createShaderBuilder.
private StringBuilder createShaderBuilder() {
String preProcessorPreamble = "";
// TODO: Implement a system for this - this has gotten way out of hand.
WorldAtlas worldAtlas = CoreRegistry.get(WorldAtlas.class);
if (worldAtlas != null) {
preProcessorPreamble += "#define TEXTURE_OFFSET " + worldAtlas.getRelativeTileSize() + "\n";
} else {
preProcessorPreamble += "#define TEXTURE_OFFSET 0.06125\n";
}
RenderingConfig renderConfig = config.getRendering();
preProcessorPreamble += "#define BLOCK_LIGHT_POW " + WorldRenderer.BLOCK_LIGHT_POW + "\n";
preProcessorPreamble += "#define BLOCK_LIGHT_SUN_POW " + WorldRenderer.BLOCK_LIGHT_SUN_POW + "\n";
preProcessorPreamble += "#define BLOCK_INTENSITY_FACTOR " + WorldRenderer.BLOCK_INTENSITY_FACTOR + "\n";
preProcessorPreamble += "#define SHADOW_MAP_RESOLUTION " + (float) renderConfig.getShadowMapResolution() + "\n";
preProcessorPreamble += "#define SSAO_KERNEL_ELEMENTS " + ssaoKernelElements + "\n";
preProcessorPreamble += "#define SSAO_NOISE_SIZE " + ssaoNoiseSize + "\n";
// TODO: This shouldn't be hardcoded
preProcessorPreamble += "#define TEXTURE_OFFSET_EFFECTS " + 0.0625f + "\n";
StringBuilder builder = new StringBuilder().append(preProcessorPreamble);
if (renderConfig.isVolumetricFog()) {
builder.append("#define VOLUMETRIC_FOG \n");
}
if (renderConfig.isAnimateGrass()) {
builder.append("#define ANIMATED_GRASS \n");
}
if (renderConfig.isAnimateWater()) {
builder.append("#define ANIMATED_WATER \n");
}
if (renderConfig.getBlurIntensity() == 0) {
builder.append("#define NO_BLUR \n");
}
if (renderConfig.isFlickeringLight()) {
builder.append("#define FLICKERING_LIGHT \n");
}
if (renderConfig.isVignette()) {
builder.append("#define VIGNETTE \n");
}
if (renderConfig.isBloom()) {
builder.append("#define BLOOM \n");
}
if (renderConfig.isMotionBlur()) {
builder.append("#define MOTION_BLUR \n");
}
if (renderConfig.isSsao()) {
builder.append("#define SSAO \n");
}
if (renderConfig.isFilmGrain()) {
builder.append("#define FILM_GRAIN \n");
}
if (renderConfig.isOutline()) {
builder.append("#define OUTLINE \n");
}
if (renderConfig.isLightShafts()) {
builder.append("#define LIGHT_SHAFTS \n");
}
if (renderConfig.isDynamicShadows()) {
builder.append("#define DYNAMIC_SHADOWS \n");
}
if (renderConfig.isNormalMapping()) {
builder.append("#define NORMAL_MAPPING \n");
}
if (renderConfig.isParallaxMapping()) {
builder.append("#define PARALLAX_MAPPING \n");
}
if (renderConfig.isDynamicShadowsPcfFiltering()) {
builder.append("#define DYNAMIC_SHADOWS_PCF \n");
}
if (renderConfig.isCloudShadows()) {
builder.append("#define CLOUD_SHADOWS \n");
}
if (renderConfig.isLocalReflections()) {
builder.append("#define LOCAL_REFLECTIONS \n");
}
if (renderConfig.isInscattering()) {
builder.append("#define INSCATTERING \n");
}
// TODO A 3D wizard should take a look at this. Configurable for the moment to make better comparisons possible.
if (renderConfig.isClampLighting()) {
builder.append("#define CLAMP_LIGHTING \n");
}
for (ChunkVertexFlag vertexFlag : ChunkVertexFlag.values()) {
builder.append("#define ").append(vertexFlag.getDefineName()).append(" int(").append(vertexFlag.getValue()).append(") \n");
}
return builder;
}
Aggregations