Search in sources :

Example 1 with WorldAtlas

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));
}
Also used : TypeHandlerLibrary(org.terasology.persistence.typeHandling.TypeHandlerLibrary) NullWorldAtlas(org.terasology.engine.world.block.tiles.NullWorldAtlas) BlockTypeHandler(org.terasology.engine.persistence.typeHandling.extensionTypes.BlockTypeHandler) NullWorldAtlas(org.terasology.engine.world.block.tiles.NullWorldAtlas) WorldAtlas(org.terasology.engine.world.block.tiles.WorldAtlas) BlockManagerImpl(org.terasology.engine.world.block.internal.BlockManagerImpl) BlockFamilyTypeHandler(org.terasology.engine.persistence.typeHandling.extensionTypes.BlockFamilyTypeHandler)

Example 2 with WorldAtlas

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;
}
Also used : WorldAtlasImpl(org.terasology.engine.world.block.tiles.WorldAtlasImpl) Config(org.terasology.engine.config.Config) ModuleEnvironment(org.terasology.gestalt.module.ModuleEnvironment) TypeHandlerLibrary(org.terasology.persistence.typeHandling.TypeHandlerLibrary) NetworkSystem(org.terasology.engine.network.NetworkSystem) BlockFamilyLibrary(org.terasology.engine.world.block.family.BlockFamilyLibrary) ModuleManager(org.terasology.engine.core.module.ModuleManager) BlockTypeHandler(org.terasology.engine.persistence.typeHandling.extensionTypes.BlockTypeHandler) WorldAtlas(org.terasology.engine.world.block.tiles.WorldAtlas) BlockManagerImpl(org.terasology.engine.world.block.internal.BlockManagerImpl) BlockFamilyTypeHandler(org.terasology.engine.persistence.typeHandling.extensionTypes.BlockFamilyTypeHandler)

Example 3 with WorldAtlas

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;
}
Also used : ChunkVertexFlag(org.terasology.engine.rendering.primitives.ChunkVertexFlag) WorldAtlas(org.terasology.engine.world.block.tiles.WorldAtlas) RenderingConfig(org.terasology.engine.config.RenderingConfig)

Aggregations

WorldAtlas (org.terasology.engine.world.block.tiles.WorldAtlas)3 BlockFamilyTypeHandler (org.terasology.engine.persistence.typeHandling.extensionTypes.BlockFamilyTypeHandler)2 BlockTypeHandler (org.terasology.engine.persistence.typeHandling.extensionTypes.BlockTypeHandler)2 BlockManagerImpl (org.terasology.engine.world.block.internal.BlockManagerImpl)2 TypeHandlerLibrary (org.terasology.persistence.typeHandling.TypeHandlerLibrary)2 Config (org.terasology.engine.config.Config)1 RenderingConfig (org.terasology.engine.config.RenderingConfig)1 ModuleManager (org.terasology.engine.core.module.ModuleManager)1 NetworkSystem (org.terasology.engine.network.NetworkSystem)1 ChunkVertexFlag (org.terasology.engine.rendering.primitives.ChunkVertexFlag)1 BlockFamilyLibrary (org.terasology.engine.world.block.family.BlockFamilyLibrary)1 NullWorldAtlas (org.terasology.engine.world.block.tiles.NullWorldAtlas)1 WorldAtlasImpl (org.terasology.engine.world.block.tiles.WorldAtlasImpl)1 ModuleEnvironment (org.terasology.gestalt.module.ModuleEnvironment)1