Search in sources :

Example 1 with Texture2D

use of io.xol.chunkstories.api.rendering.textures.Texture2D in project chunkstories-core by Hugobros3.

the class DefaultItemRenderer method renderItemInWorld.

@Override
public void renderItemInWorld(RenderingInterface renderingInterface, ItemPile pile, World world, Location location, Matrix4f handTransformation) {
    Matrix4f handTransformation2 = new Matrix4f(handTransformation);
    handTransformation2.rotate((float) (Math.PI / 2f), new Vector3f(0.0f, 0.0f, 1.0f));
    handTransformation2.rotate((float) (Math.PI / 2f), new Vector3f(0.0f, 1.0f, 0.0f));
    handTransformation2.translate(new Vector3f(-0.0f, 0.0f, 0.2f));
    // handTransformation2.translate(new Vector3f(-0.00f, -0.15f, 0.0f));
    handTransformation2.scale(new Vector3f(1.0f, 0.20f * pile.getItem().getDefinition().getSlotsWidth(), 0.20f * pile.getItem().getDefinition().getSlotsHeight()));
    renderingInterface.setObjectMatrix(handTransformation2);
    textures.getTexture(pile.getTextureName()).setLinearFiltering(false);
    Texture2D texture = textures.getTexture(pile.getTextureName());
    if (texture == null)
        texture = textures.getTexture("items/icons/notex.png");
    texture.setLinearFiltering(false);
    renderingInterface.bindAlbedoTexture(texture);
    draw3DPlane(renderingInterface);
}
Also used : Matrix4f(org.joml.Matrix4f) Texture2D(io.xol.chunkstories.api.rendering.textures.Texture2D) Vector3f(org.joml.Vector3f)

Example 2 with Texture2D

use of io.xol.chunkstories.api.rendering.textures.Texture2D in project chunkstories-core by Hugobros3.

the class DefaultItemRenderer method renderItemInInventory.

@Override
public void renderItemInInventory(RenderingInterface renderingInterface, ItemPile pile, float screenPositionX, float screenPositionY, int scaling) {
    int slotSize = 24 * 2;
    // System.out.println(((ClientContent) this.itemType.store().parent()).textures());
    if (textures == null)
        return;
    textures.getTexture(pile.getTextureName()).setLinearFiltering(false);
    Texture2D texture = textures.getTexture(pile.getTextureName());
    if (texture == null)
        texture = textures.getTexture("items/icons/notex.png");
    int width = slotSize * pile.getItem().getDefinition().getSlotsWidth();
    int height = slotSize * pile.getItem().getDefinition().getSlotsHeight();
    renderingInterface.getGuiRenderer().drawBoxWindowsSpaceWithSize(screenPositionX, screenPositionY, width, height, 0, 1, 1, 0, texture, true, true, null);
}
Also used : Texture2D(io.xol.chunkstories.api.rendering.textures.Texture2D)

Example 3 with Texture2D

use of io.xol.chunkstories.api.rendering.textures.Texture2D in project chunkstories-core by Hugobros3.

the class BreakingBlockDecal method render.

public void render(RenderingInterface renderingInterface) {
    Shader decalsShader = renderingInterface.useShader("decal_cracking");
    renderingInterface.getCamera().setupShader(decalsShader);
    renderingInterface.setCullingMode(CullingMode.DISABLED);
    renderingInterface.setBlendMode(BlendMode.MIX);
    renderingInterface.getRenderTargetManager().setDepthMask(false);
    int phases = 6;
    int phase = (int) (phases * miningProgress.progress);
    decalsShader.setUniform1f("textureScale", 1f / 6);
    decalsShader.setUniform1f("textureStart", 1f / 6 * phase);
    // decalType.getTexture();
    Texture2D diffuseTexture = renderingInterface.textures().getTexture("./textures/voxel_cracking.png");
    diffuseTexture.setTextureWrapping(true);
    diffuseTexture.setLinearFiltering(false);
    renderingInterface.bindAlbedoTexture(diffuseTexture);
    renderingInterface.bindAttribute("vertexIn", vertexBuffer.asAttributeSource(VertexFormat.FLOAT, 3, 4 * (3 + 2), 0));
    renderingInterface.bindAttribute("texCoordIn", vertexBuffer.asAttributeSource(VertexFormat.FLOAT, 2, 4 * (3 + 2), 4 * 3));
    renderingInterface.draw(Primitive.TRIANGLE, 0, size);
    renderingInterface.getRenderTargetManager().setDepthMask(true);
}
Also used : Texture2D(io.xol.chunkstories.api.rendering.textures.Texture2D) Shader(io.xol.chunkstories.api.rendering.shader.Shader)

Example 4 with Texture2D

use of io.xol.chunkstories.api.rendering.textures.Texture2D in project chunkstories-core by Hugobros3.

the class GBuffersOpaquePass method render.

@Override
public void render(RenderingInterface renderingInterface) {
    if (fbo != null) {
        GameWindow gameWindow = pipeline.getRenderingInterface().getWindow();
        renderingInterface.getRenderTargetManager().setConfiguration(fbo);
        renderingInterface.getRenderTargetManager().clearBoundRenderTargetAll();
        // Set fixed-function parameters
        renderingInterface.setDepthTestMode(DepthTestMode.LESS_OR_EQUAL);
        renderingInterface.setBlendMode(BlendMode.DISABLED);
        renderingInterface.setCullingMode(CullingMode.COUNTERCLOCKWISE);
        Shader opaqueBlocksShader = renderingInterface.useShader("blocks_opaque");
        Texture2D blocksAlbedoTexture = gameWindow.getClient().getContent().voxels().textures().getDiffuseAtlasTexture();
        Texture2D blocksNormalTexture = gameWindow.getClient().getContent().voxels().textures().getNormalAtlasTexture();
        Texture2D blocksMaterialTexture = gameWindow.getClient().getContent().voxels().textures().getMaterialAtlasTexture();
        renderingInterface.bindAlbedoTexture(blocksAlbedoTexture);
        renderingInterface.bindNormalTexture(blocksNormalTexture);
        renderingInterface.bindMaterialTexture(blocksMaterialTexture);
        renderingInterface.bindTexture2D("lightColors", renderingInterface.textures().getTexture("./textures/environement/light.png"));
        renderingInterface.bindTexture2D("vegetationColorTexture", worldRenderer.getWorld().getGenerator().getEnvironment().getGrassTexture(renderingInterface));
        // renderingInterface.bindTexture2D("vegetationColorTexture", getGrassTexture());
        // Set texturing arguments
        blocksAlbedoTexture.setTextureWrapping(false);
        blocksAlbedoTexture.setLinearFiltering(false);
        blocksAlbedoTexture.setMipMapping(false);
        blocksAlbedoTexture.setMipmapLevelsRange(0, 4);
        blocksNormalTexture.setTextureWrapping(false);
        blocksNormalTexture.setLinearFiltering(false);
        blocksNormalTexture.setMipMapping(false);
        blocksNormalTexture.setMipmapLevelsRange(0, 4);
        blocksMaterialTexture.setTextureWrapping(false);
        blocksMaterialTexture.setLinearFiltering(false);
        blocksMaterialTexture.setMipMapping(false);
        blocksMaterialTexture.setMipmapLevelsRange(0, 4);
        // World stuff
        opaqueBlocksShader.setUniform1f("mapSize", world.getSizeInChunks() * 32);
        opaqueBlocksShader.setUniform1f("overcastFactor", world.getWeather());
        opaqueBlocksShader.setUniform1f("wetness", world.getGenerator().getEnvironment().getWorldWetness(renderingInterface.getCamera().getCameraPosition()));
        opaqueBlocksShader.setUniform1f("time", worldRenderer.getAnimationTimer());
        opaqueBlocksShader.setUniform1f("animationTimer", worldRenderer.getAnimationTimer());
        opaqueBlocksShader.setUniform2f("screenSize", gameWindow.getWidth(), gameWindow.getHeight());
        renderingInterface.getCamera().setupShader(opaqueBlocksShader);
        renderingInterface.setObjectMatrix(new Matrix4f());
        worldRenderer.getChunksRenderer().renderChunks(renderingInterface);
        worldRenderer.getChunksRenderer().renderChunksExtras(renderingInterface);
        worldRenderer.getEntitiesRenderer().renderEntities(renderingInterface);
        worldRenderer.getParticlesRenderer().renderParticles(renderingInterface);
    }
}
Also used : GameWindow(io.xol.chunkstories.api.rendering.GameWindow) Texture2D(io.xol.chunkstories.api.rendering.textures.Texture2D) Matrix4f(org.joml.Matrix4f) Shader(io.xol.chunkstories.api.rendering.shader.Shader)

Example 5 with Texture2D

use of io.xol.chunkstories.api.rendering.textures.Texture2D in project chunkstories-api by Hugobros3.

the class BaseButton method render.

@Override
public void render(RenderingInterface renderer) {
    float width = getWidth();
    String localizedText = layer.getGameWindow().getClient().getContent().localization().localize(text);
    Texture2D buttonTexture = renderer.textures().getTexture("./textures/gui/scalableButton2.png");
    if (isFocused() || isMouseOver())
        buttonTexture = renderer.textures().getTexture("./textures/gui/scalableButtonOver2.png");
    buttonTexture.setLinearFiltering(false);
    renderer.getGuiRenderer().drawCorneredBoxTiled(xPosition, yPosition, width, getHeight(), 4 * scale(), buttonTexture, 32, scale());
    // new Vector4f(76/255f, 76/255f, 76/255f, 1));
    renderer.getFontRenderer().drawString(font, xPosition + 4 * scale(), yPosition, localizedText, fontScaler * scale(), new Vector4f(0, 0, 0, 1));
}
Also used : Texture2D(io.xol.chunkstories.api.rendering.textures.Texture2D) Vector4f(org.joml.Vector4f)

Aggregations

Texture2D (io.xol.chunkstories.api.rendering.textures.Texture2D)27 Shader (io.xol.chunkstories.api.rendering.shader.Shader)9 Vector4f (org.joml.Vector4f)6 Matrix4f (org.joml.Matrix4f)5 Vector3f (org.joml.Vector3f)5 Location (io.xol.chunkstories.api.Location)3 GameWindow (io.xol.chunkstories.api.rendering.GameWindow)3 Voxel (io.xol.chunkstories.api.voxel.Voxel)3 ByteBuffer (java.nio.ByteBuffer)3 ItemVoxel (io.xol.chunkstories.api.item.ItemVoxel)2 CollisionBox (io.xol.chunkstories.api.physics.CollisionBox)2 Player (io.xol.chunkstories.api.player.Player)2 Font (io.xol.chunkstories.api.rendering.text.FontRenderer.Font)2 CellData (io.xol.chunkstories.api.world.cell.CellData)2 DummyCell (io.xol.chunkstories.api.world.cell.DummyCell)2 MemFreeByteBuffer (io.xol.chunkstories.client.util.MemFreeByteBuffer)2 HeightmapImplementation (io.xol.chunkstories.world.summary.HeightmapImplementation)2 Vector2d (org.joml.Vector2d)2 Vector3dc (org.joml.Vector3dc)2 Entity (io.xol.chunkstories.api.entity.Entity)1