Search in sources :

Example 1 with WorldAtlas

use of org.terasology.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);
    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(TypeSerializationLibrary.class).add(Block.class, new BlockTypeHandler(blockManager));
    context.get(TypeSerializationLibrary.class).add(BlockFamily.class, new BlockFamilyTypeHandler(blockManager));
    blockManager.initialise(gameManifest.getRegisteredBlockFamilies(), gameManifest.getBlockIdMap());
    return true;
}
Also used : WorldAtlasImpl(org.terasology.world.block.tiles.WorldAtlasImpl) Config(org.terasology.config.Config) NetworkSystem(org.terasology.network.NetworkSystem) TypeSerializationLibrary(org.terasology.persistence.typeHandling.TypeSerializationLibrary) BlockTypeHandler(org.terasology.persistence.typeHandling.extensionTypes.BlockTypeHandler) WorldAtlas(org.terasology.world.block.tiles.WorldAtlas) BlockManagerImpl(org.terasology.world.block.internal.BlockManagerImpl) BlockFamilyTypeHandler(org.terasology.persistence.typeHandling.extensionTypes.BlockFamilyTypeHandler)

Example 2 with WorldAtlas

use of org.terasology.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);
    TypeSerializationLibrary typeSerializationLibrary = context.get(TypeSerializationLibrary.class);
    typeSerializationLibrary.add(BlockFamily.class, new BlockFamilyTypeHandler(blockManager));
    typeSerializationLibrary.add(Block.class, new BlockTypeHandler(blockManager));
}
Also used : NullWorldAtlas(org.terasology.world.block.tiles.NullWorldAtlas) TypeSerializationLibrary(org.terasology.persistence.typeHandling.TypeSerializationLibrary) BlockTypeHandler(org.terasology.persistence.typeHandling.extensionTypes.BlockTypeHandler) WorldAtlas(org.terasology.world.block.tiles.WorldAtlas) NullWorldAtlas(org.terasology.world.block.tiles.NullWorldAtlas) BlockManagerImpl(org.terasology.world.block.internal.BlockManagerImpl) BlockFamilyTypeHandler(org.terasology.persistence.typeHandling.extensionTypes.BlockFamilyTypeHandler)

Example 3 with WorldAtlas

use of org.terasology.world.block.tiles.WorldAtlas in project Terasology by MovingBlocks.

the class GLSLShader method createShaderBuilder.

private StringBuilder createShaderBuilder() {
    String preProcessorPreamble = "#version 120\n";
    // 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 " + SSAO_KERNEL_ELEMENTS + "\n";
    preProcessorPreamble += "#define SSAO_NOISE_SIZE " + SSAO_NOISE_SIZE + "\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");
    }
    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.rendering.primitives.ChunkVertexFlag) WorldAtlas(org.terasology.world.block.tiles.WorldAtlas) RenderingConfig(org.terasology.config.RenderingConfig)

Aggregations

WorldAtlas (org.terasology.world.block.tiles.WorldAtlas)3 TypeSerializationLibrary (org.terasology.persistence.typeHandling.TypeSerializationLibrary)2 BlockFamilyTypeHandler (org.terasology.persistence.typeHandling.extensionTypes.BlockFamilyTypeHandler)2 BlockTypeHandler (org.terasology.persistence.typeHandling.extensionTypes.BlockTypeHandler)2 BlockManagerImpl (org.terasology.world.block.internal.BlockManagerImpl)2 Config (org.terasology.config.Config)1 RenderingConfig (org.terasology.config.RenderingConfig)1 NetworkSystem (org.terasology.network.NetworkSystem)1 ChunkVertexFlag (org.terasology.rendering.primitives.ChunkVertexFlag)1 NullWorldAtlas (org.terasology.world.block.tiles.NullWorldAtlas)1 WorldAtlasImpl (org.terasology.world.block.tiles.WorldAtlasImpl)1