Package org.terasology.rendering.assets.material

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


         * LIGHT GEOMETRY (STENCIL) PASS
         */
        PerformanceMonitor.startActivity("Render Light Geometry");

        DefaultRenderingProcess.getInstance().beginRenderLightGeometryStencilPass();
        Material program = Assets.getMaterial("engine:prog.simple");
        program.enable();
        program.setCamera(camera);
        EntityManager entityManager = CoreRegistry.get(EntityManager.class);
        for (EntityRef entity : entityManager.getEntitiesWith(LightComponent.class, LocationComponent.class)) {
            LocationComponent locationComponent = entity.getComponent(LocationComponent.class);
            LightComponent lightComponent = entity.getComponent(LightComponent.class);

View Full Code Here


    public void renderWorldReflection(Camera camera) {
        PerformanceMonitor.startActivity("Render World (Reflection)");
        camera.lookThroughNormalized();
        skysphere.render(camera);

        Material chunkShader = Assets.getMaterial("engine:prog.chunk");
        chunkShader.activateFeature(ShaderProgramFeature.FEATURE_USE_FORWARD_LIGHTING);

        if (config.getRendering().isReflectiveWater()) {
            camera.lookThrough();

            glEnable(GL_LIGHT0);

            while (renderQueueChunksOpaqueReflection.size() > 0) {
                renderChunk(renderQueueChunksOpaqueReflection.poll(), ChunkMesh.RenderPhase.OPAQUE, camera, ChunkRenderMode.REFLECTION);
            }
        }

        chunkShader.deactivateFeature(ShaderProgramFeature.FEATURE_USE_FORWARD_LIGHTING);
        PerformanceMonitor.endActivity();
    }
View Full Code Here

        PerformanceMonitor.endActivity();
    }

    private void renderChunk(RenderableChunk chunk, ChunkMesh.RenderPhase phase, Camera camera, ChunkRenderMode mode) {
        if (chunk.getMesh() != null) {
            Material shader = null;

            final Vector3f cameraPosition = camera.getPosition();
            final Vector3f chunkPositionRelToCamera =
                    new Vector3f(chunk.getPosition().x * ChunkConstants.SIZE_X - cameraPosition.x,
                            chunk.getPosition().y * ChunkConstants.SIZE_Y - cameraPosition.y,
                            chunk.getPosition().z * ChunkConstants.SIZE_Z - cameraPosition.z);

            if (mode == ChunkRenderMode.DEFAULT || mode == ChunkRenderMode.REFLECTION) {
                shader = Assets.getMaterial("engine:prog.chunk");
                shader.enable();

                if (phase == ChunkMesh.RenderPhase.REFRACTIVE) {
                    shader.activateFeature(ShaderProgramFeature.FEATURE_REFRACTIVE_PASS);
                } else if (phase == ChunkMesh.RenderPhase.ALPHA_REJECT) {
                    shader.activateFeature(ShaderProgramFeature.FEATURE_ALPHA_REJECT);
                }

                shader.setFloat3("chunkPositionWorld", chunk.getPosition().x * ChunkConstants.SIZE_X,
                        chunk.getPosition().y * ChunkConstants.SIZE_Y, chunk.getPosition().z * ChunkConstants.SIZE_Z);
                shader.setFloat("animated", chunk.isAnimated() ? 1.0f : 0.0f);

                if (mode == ChunkRenderMode.REFLECTION) {
                    shader.setFloat("clip", camera.getClipHeight());
                } else {
                    shader.setFloat("clip", 0.0f);
                }

            } else if (mode == ChunkRenderMode.SHADOW_MAP) {
                shader = Assets.getMaterial("engine:prog.shadowMap");
                shader.enable();
            } else if (mode == ChunkRenderMode.Z_PRE_PASS) {
                CoreRegistry.get(ShaderManager.class).disableShader();
            }

            GL11.glPushMatrix();

            GL11.glTranslatef(chunkPositionRelToCamera.x, chunkPositionRelToCamera.y, chunkPositionRelToCamera.z);

            for (int i = 0; i < VERTICAL_SEGMENTS; i++) {
                if (!chunk.getMesh()[i].isEmpty()) {
                    if (config.getRendering().getDebug().isRenderChunkBoundingBoxes()) {
                        AABBRenderer aabbRenderer = new AABBRenderer(chunk.getSubMeshAABB(i));
                        aabbRenderer.renderLocally(1f);
                        statRenderedTriangles += 12;
                    }

                    if (shader != null) {
                        shader.enable();
                    }

                    chunk.getMesh()[i].render(phase);
                    statRenderedTriangles += chunk.getMesh()[i].triangleCount();
                }
            }

            if (mode == ChunkRenderMode.DEFAULT || mode == ChunkRenderMode.REFLECTION) {
                // eclipse is paranoid about this - it thinks that shader could be null here
                if (shader != null) {
                    if (phase == ChunkMesh.RenderPhase.REFRACTIVE) {
                        shader.deactivateFeature(ShaderProgramFeature.FEATURE_REFRACTIVE_PASS);
                    } else if (phase == ChunkMesh.RenderPhase.ALPHA_REJECT) {
                        shader.deactivateFeature(ShaderProgramFeature.FEATURE_ALPHA_REJECT);
                    }
                }
            }

            GL11.glPopMatrix();
View Full Code Here

        removeMesh(entity);
        addMesh(entity);
    }

    private void removeMesh(EntityRef entity) {
        Material mat = opaqueEntities.remove(entity);
        if (mat != null) {
            opaqueMesh.remove(mat, entity);
            opaqueMeshSorter.remove(entity);
        } else {
            mat = translucentEntities.remove(entity);
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.