Package org.terasology.rendering.assets.material

Examples of org.terasology.rendering.assets.material.Material


    public void renderOverlay() {

    }

    private void renderHand(float bobOffset, float handMovementAnimationOffset) {
        Material shader = Assets.getMaterial("engine:prog.block");
        shader.activateFeature(ShaderProgramFeature.FEATURE_USE_MATRIX_STACK);

        shader.enable();
        shader.setFloat("sunlight", worldRenderer.getSunlightValue(), true);
        shader.setFloat("blockLight", worldRenderer.getBlockLightValue(), true);
        glBindTexture(GL11.GL_TEXTURE_2D, handTex.getId());

        glPushMatrix();
        glTranslatef(0.8f, -0.8f + bobOffset - handMovementAnimationOffset * 0.5f, -1.0f - handMovementAnimationOffset * 0.5f);
        glRotatef(-45f - handMovementAnimationOffset * 64.0f, 1.0f, 0.0f, 0.0f);
        glRotatef(35f, 0.0f, 1.0f, 0.0f);
        glTranslatef(0f, 0.25f, 0f);
        glScalef(0.3f, 0.6f, 0.3f);

        handMesh.render();

        glPopMatrix();

        shader.deactivateFeature(ShaderProgramFeature.FEATURE_USE_MATRIX_STACK);
    }
View Full Code Here


        shader.deactivateFeature(ShaderProgramFeature.FEATURE_USE_MATRIX_STACK);
    }

    private void renderIcon(TextureRegion iconTexture, float bobOffset, float handMovementAnimationOffset) {
        Material shader = Assets.getMaterial("engine:prog.block");
        shader.activateFeature(ShaderProgramFeature.FEATURE_USE_MATRIX_STACK);

        shader.enable();

        shader.setBoolean("textured", false, true);

        shader.setFloat("sunlight", worldRenderer.getSunlightValue(), true);
        shader.setFloat("blockLight", worldRenderer.getBlockLightValue(), true);

        glPushMatrix();

        float textureScale = Math.max(iconTexture.getWidth(), iconTexture.getHeight()) / 16f;

        glTranslatef(1.0f, -0.7f + bobOffset - handMovementAnimationOffset * 0.5f, (-1.5f - handMovementAnimationOffset * 0.5f) * (float) Math.pow(textureScale, 0.5));
        glRotatef(-handMovementAnimationOffset * 64.0f, 1.0f, 0.0f, 0.0f);
        glRotatef(-20f, 1.0f, 0.0f, 0.0f);
        glRotatef(-80f, 0.0f, 1.0f, 0.0f);
        glRotatef(45f, 0.0f, 0.0f, 1.0f);
        float scale = 0.75f * (float) Math.pow(textureScale, 0.5);
        glScalef(scale, scale, scale);

        if (iconTexture instanceof Asset<?>) {
            Mesh itemMesh = IconMeshFactory.getIconMesh(iconTexture);
            itemMesh.render();
        }

        glPopMatrix();

        shader.deactivateFeature(ShaderProgramFeature.FEATURE_USE_MATRIX_STACK);
    }
View Full Code Here

    private void renderBlock(BlockFamily blockFamily, float bobOffset, float handMovementAnimationOffset) {
        Block activeBlock = blockFamily.getArchetypeBlock();
        Vector3f playerPos = localPlayer.getPosition();

        // Adjust the brightness of the block according to the current position of the player
        Material shader = Assets.getMaterial("engine:prog.block");
        shader.activateFeature(ShaderProgramFeature.FEATURE_USE_MATRIX_STACK);

        shader.enable();

        glPushMatrix();

        glTranslatef(1.0f, -0.7f + bobOffset - handMovementAnimationOffset * 0.5f, -1.5f - handMovementAnimationOffset * 0.5f);
        glRotatef(-25f - handMovementAnimationOffset * 64.0f, 1.0f, 0.0f, 0.0f);
        glRotatef(35f, 0.0f, 1.0f, 0.0f);
        glTranslatef(0f, 0.1f, 0f);
        glScalef(0.75f, 0.75f, 0.75f);

        float blockLight = worldRenderer.getBlockLightValue();
        float sunlight = worldRenderer.getSunlightValue();

        //  Blocks with a luminance > 0.0 shouldn't be affected by block light
        if (blockFamily.getArchetypeBlock().getLuminance() > 0.0) {
            blockLight = 1.0f;
        }

        activeBlock.renderWithLightValue(sunlight, blockLight);

        glPopMatrix();

        shader.deactivateFeature(ShaderProgramFeature.FEATURE_USE_MATRIX_STACK);
    }
View Full Code Here

        GL11.glLoadMatrix(model);
    }

    protected void renderParticle(Particle particle, float light) {
        Material mat = Assets.getMaterial("engine:prog.particle");

        mat.setFloat4("colorOffset", particle.color.x, particle.color.y, particle.color.z, particle.color.w, true);
        mat.setFloat2("texOffset", particle.texOffset.x, particle.texOffset.y, true);
        mat.setFloat2("texScale", particle.texSize.x, particle.texSize.y, true);
        mat.setFloat("light", light, true);

        glCallList(displayList);
    }
View Full Code Here

        glCallList(displayList);
    }

    protected void renderParticle(Particle particle, Block block, Biome biome, float light) {
        Material mat = Assets.getMaterial("engine:prog.particle");

        Vector4f colorMod = block.calcColorOffsetFor(BlockPart.FRONT, biome);
        mat.setFloat4("colorOffset", particle.color.x * colorMod.x, particle.color.y * colorMod.y, particle.color.z * colorMod.z, particle.color.w * colorMod.w, true);

        mat.setFloat2("texOffset", particle.texOffset.x, particle.texOffset.y, true);
        mat.setFloat2("texScale", particle.texSize.x, particle.texSize.y, true);
        mat.setFloat("light", light, true);

        glCallList(displayList);
    }
View Full Code Here

        }
        PerformanceMonitor.endActivity();
    }

    private void renderFinalSceneToRT(StereoRenderState stereoRenderState) {
        Material material;

        if (config.getRendering().getDebug().isEnabled()) {
            material = Assets.getMaterial("engine:prog.debug");
        } else {
            material = Assets.getMaterial("engine:prog.post");
        }

        material.enable();

        bindFbo("sceneFinal");

        if (stereoRenderState == StereoRenderState.MONO || stereoRenderState == StereoRenderState.OCULUS_LEFT_EYE) {
            glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
View Full Code Here

        program.setFloat2("ocScaleIn", (2 / w), (2 / h) / as, true);
    }

    private void renderFinalScene() {

        Material material;

        if (config.getRendering().isOculusVrSupport()) {
            material = Assets.getMaterial("engine:prog.ocDistortion");
            material.enable();

            updateOcShaderParametersForVP(material, 0, 0, rtFullWidth / 2, rtFullHeight, StereoRenderState.OCULUS_LEFT_EYE);
        } else {
            if (config.getRendering().getDebug().isEnabled()) {
                material = Assets.getMaterial("engine:prog.debug");
            } else {
                material = Assets.getMaterial("engine:prog.post");
            }

            material.enable();
        }

        renderFullscreenQuad(0, 0, org.lwjgl.opengl.Display.getWidth(), org.lwjgl.opengl.Display.getHeight());

        if (config.getRendering().isOculusVrSupport()) {
View Full Code Here

        flipPingPongFbo("sceneOpaque");
        attachDepthBufferToFbo("sceneOpaque", "sceneReflectiveRefractive");
    }

    private void applyLightBufferPass(String target) {
        Material program = Assets.getMaterial("engine:prog.lightBufferPass");
        program.enable();

        DefaultRenderingProcess.FBO targetFbo = getFBO(target);

        int texId = 0;
        if (targetFbo != null) {
            GL13.glActiveTexture(GL13.GL_TEXTURE0 + texId);
            targetFbo.bindTexture();
            program.setInt("texSceneOpaque", texId++);

            GL13.glActiveTexture(GL13.GL_TEXTURE0 + texId);
            targetFbo.bindDepthTexture();
            program.setInt("texSceneOpaqueDepth", texId++);

            GL13.glActiveTexture(GL13.GL_TEXTURE0 + texId);
            targetFbo.bindNormalsTexture();
            program.setInt("texSceneOpaqueNormals", texId++);

            GL13.glActiveTexture(GL13.GL_TEXTURE0 + texId);
            targetFbo.bindLightBufferTexture();
            program.setInt("texSceneOpaqueLightBuffer", texId++, true);
        }

        bindFbo(target + "PingPong");
        setRenderBufferMask(true, true, true);
View Full Code Here

        }

        skyBand.bind();
        setRenderBufferMask(true, false, false);

        Material material = Assets.getMaterial("engine:prog.blur");

        material.enable();
        material.setFloat("radius", 8.0f, true);
        material.setFloat2("texelSize", 1.0f / skyBand.width, 1.0f / skyBand.height, true);

        if (id == 0) {
            bindFboTexture("sceneOpaque");
        } else {
            bindFboTexture("sceneSkyBand" + (id - 1));
View Full Code Here

        lightshaft.unbind();
        glViewport(0, 0, rtFullWidth, rtFullHeight);
    }

    private void generateSSAO() {
        Material ssaoShader = Assets.getMaterial("engine:prog.ssao");
        ssaoShader.enable();

        FBO ssao = getFBO("ssao");

        if (ssao == null) {
            return;
        }

        ssaoShader.setFloat2("texelSize", 1.0f / ssao.width, 1.0f / ssao.height, true);
        ssaoShader.setFloat2("noiseTexelSize", 1.0f / 4.0f, 1.0f / 4.0f, true);

        ssao.bind();

        glViewport(0, 0, ssao.width, ssao.height);
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
View Full Code Here

TOP

Related Classes of org.terasology.rendering.assets.material.Material

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.