Search in sources :

Example 6 with ExtShaderProgram

use of gaiasky.util.gdx.shader.ExtShaderProgram in project gaiasky by langurmonkey.

the class PointCloudRenderSystem method renderStud.

@Override
public void renderStud(Array<IRenderable> renderables, ICamera camera, double t) {
    if (renderables.size > 0) {
        ExtShaderProgram shaderProgram = getShaderProgram();
        shaderProgram.begin();
        // Pre-render
        preRenderObjects(shaderProgram, camera);
        // Render
        renderables.forEach((r) -> renderObject(shaderProgram, r));
        // Post-render
        postRenderObjects(shaderProgram, camera);
        shaderProgram.end();
    }
}
Also used : ExtShaderProgram(gaiasky.util.gdx.shader.ExtShaderProgram)

Example 7 with ExtShaderProgram

use of gaiasky.util.gdx.shader.ExtShaderProgram in project gaiasky by langurmonkey.

the class PointRenderSystem method renderStud.

@Override
public void renderStud(Array<IRenderable> renderables, ICamera camera, double t) {
    this.camera = camera;
    ExtShaderProgram shaderProgram = getShaderProgram();
    shaderProgram.begin();
    shaderProgram.setUniformMatrix("u_projView", camera.getCamera().combined);
    addEffectsUniforms(shaderProgram, camera);
    renderables.forEach(r -> {
        IPointRenderable renderable = (IPointRenderable) r;
        renderable.render(this, camera, getAlpha(renderable));
        renderable.blend();
        renderable.depth();
        for (int md = 0; md < meshIdx; md++) {
            MeshData meshd = meshes.get(md);
            meshd.mesh.setVertices(meshd.vertices, 0, meshd.vertexIdx);
            meshd.mesh.render(shaderProgram, glType);
            meshd.clear();
        }
    });
    shaderProgram.end();
    // Reset indices
    meshIdx = 1;
    curr = meshes.get(0);
}
Also used : ExtShaderProgram(gaiasky.util.gdx.shader.ExtShaderProgram) IPointRenderable(gaiasky.render.IPointRenderable)

Example 8 with ExtShaderProgram

use of gaiasky.util.gdx.shader.ExtShaderProgram in project gaiasky by langurmonkey.

the class BillboardSpriteRenderSystem method renderStud.

@Override
public void renderStud(Array<IRenderable> renderables, ICamera camera, double t) {
    if ((ctIndex < 0 || alphas[ctIndex] != 0)) {
        renderables.sort(comp);
        ExtShaderProgram shaderProgram = getShaderProgram();
        shaderProgram.begin();
        // Global uniforms
        shaderProgram.setUniformMatrix("u_projView", camera.getCamera().combined);
        shaderProgram.setUniformf("u_time", (float) t);
        // Rel, grav, z-buffer
        addEffectsUniforms(shaderProgram, camera);
        // Render each sprite
        renderables.forEach(r -> {
            IQuadRenderable s = (IQuadRenderable) r;
            s.render(shaderProgram, getAlpha(s), mesh, camera);
        });
        shaderProgram.end();
    }
}
Also used : IQuadRenderable(gaiasky.render.IQuadRenderable) ExtShaderProgram(gaiasky.util.gdx.shader.ExtShaderProgram)

Example 9 with ExtShaderProgram

use of gaiasky.util.gdx.shader.ExtShaderProgram in project gaiasky by langurmonkey.

the class BillboardStarRenderSystem method renderStud.

@Override
public void renderStud(Array<IRenderable> renderables, ICamera camera, double t) {
    if ((ctIndex < 0 || alphas[ctIndex] != 0)) {
        renderables.sort(comp);
        ExtShaderProgram shaderProgram = getShaderProgram();
        shaderProgram.begin();
        if (texture0 != null) {
            texture0.bind(0);
            shaderProgram.setUniformi("u_texture0", 0);
        }
        // General uniforms
        shaderProgram.setUniformMatrix("u_projView", camera.getCamera().combined);
        // Rel, grav, z-buffer
        addEffectsUniforms(shaderProgram, camera);
        // Global uniforms
        shaderProgram.setUniformf("u_time", (float) t);
        renderables.forEach(r -> {
            IQuadRenderable s = (IQuadRenderable) r;
            s.render(shaderProgram, getAlpha(s), mesh, camera);
        });
        shaderProgram.end();
    }
}
Also used : IQuadRenderable(gaiasky.render.IQuadRenderable) ExtShaderProgram(gaiasky.util.gdx.shader.ExtShaderProgram)

Example 10 with ExtShaderProgram

use of gaiasky.util.gdx.shader.ExtShaderProgram in project gaiasky by langurmonkey.

the class LineQuadRenderSystem method renderStud.

@Override
public void renderStud(Array<IRenderable> renderables, ICamera camera, double t) {
    this.camera = camera;
    // Reset
    meshIdx = 1;
    currExt = (MeshDataExt) meshes.get(0);
    curr = currExt;
    renderables.forEach(r -> {
        ILineRenderable renderable = (ILineRenderable) r;
        renderable.render(this, camera, getAlpha(renderable));
    });
    // Sort phase
    provisionalLines.sort(sorter);
    for (double[] l : provisionalLines) addLinePostproc(l[0], l[1], l[2], l[3], l[4], l[5], l[6], l[7], l[8], l[9], l[10], l[11], l[13]);
    for (Line l : provLines) addLinePostproc(l);
    ExtShaderProgram shaderProgram = getShaderProgram();
    shaderProgram.begin();
    shaderProgram.setUniformMatrix("u_projView", camera.getCamera().combined);
    // Rel, grav, z-buffer
    addEffectsUniforms(shaderProgram, camera);
    for (int i = 0; i < meshIdx; i++) {
        MeshDataExt md = (MeshDataExt) meshes.get(i);
        md.mesh.setVertices(md.vertices, 0, md.vertexIdx);
        md.mesh.setIndices(md.indices, 0, md.indexIdx);
        md.mesh.render(shaderProgram, GL20.GL_TRIANGLES);
        md.clear();
    }
    shaderProgram.end();
    // Reset mesh index and current
    int n = provisionalLines.size;
    for (int i = 0; i < n; i++) doublePool.free(provisionalLines.get(i));
    provisionalLines.clear();
    provLines.clear();
}
Also used : ILineRenderable(gaiasky.render.ILineRenderable) ExtShaderProgram(gaiasky.util.gdx.shader.ExtShaderProgram)

Aggregations

ExtShaderProgram (gaiasky.util.gdx.shader.ExtShaderProgram)12 Orbit (gaiasky.scenegraph.Orbit)3 IQuadRenderable (gaiasky.render.IQuadRenderable)2 OrbitComponent (gaiasky.scenegraph.component.OrbitComponent)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 PointCloudData (gaiasky.data.util.PointCloudData)1 IAnnotationsRenderable (gaiasky.render.IAnnotationsRenderable)1 ILineRenderable (gaiasky.render.ILineRenderable)1 IPointRenderable (gaiasky.render.IPointRenderable)1 IRenderable (gaiasky.render.IRenderable)1 OrbitalElementsGroup (gaiasky.scenegraph.OrbitalElementsGroup)1 SceneGraphNode (gaiasky.scenegraph.SceneGraphNode)1 CatalogInfo (gaiasky.util.CatalogInfo)1 Vector3d (gaiasky.util.math.Vector3d)1