Example usage for org.lwjgl.opengl GL13 glActiveTexture

List of usage examples for org.lwjgl.opengl GL13 glActiveTexture

Introduction

In this page you can find the example usage for org.lwjgl.opengl GL13 glActiveTexture.

Prototype

public static void glActiveTexture(@NativeType("GLenum") int texture) 

Source Link

Document

Selects which texture unit subsequent texture state calls will affect.

Usage

From source file:org.terasology.rendering.shader.ShaderParametersSky.java

License:Apache License

@Override
public void applyParameters(Material program) {
    super.applyParameters(program);

    int texId = 0;
    GL13.glActiveTexture(GL13.GL_TEXTURE0 + texId);
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, Assets.getTexture("engine:sky90").getId());
    program.setInt("texSky90", texId++, true);
    GL13.glActiveTexture(GL13.GL_TEXTURE0 + texId);
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, Assets.getTexture("engine:sky180").getId());
    program.setInt("texSky180", texId++, true);

    WorldRenderer worldRenderer = CoreRegistry.get(WorldRenderer.class);
    WorldProvider worldProvider = CoreRegistry.get(WorldProvider.class);

    if (worldProvider != null && worldRenderer != null) {
        program.setFloat("colorExp", worldRenderer.getSkysphere().getColorExp(), true);

        Vector3f sunDirection = worldRenderer.getSkysphere().getSunDirection(false);
        Vector3d zenithColor = getAllWeatherZenith(sunDirection.y, worldRenderer.getSkysphere().getTurbidity());

        program.setFloat("sunAngle", worldRenderer.getSkysphere().getSunPosAngle(), true);
        program.setFloat("turbidity", (Float) worldRenderer.getSkysphere().getTurbidity(), true);
        program.setFloat3("zenith", (float) zenithColor.x, (float) zenithColor.y, (float) zenithColor.z, true);
    }//from  w w  w . jav a 2s.c om

    program.setFloat4("skySettings", sunExponent, moonExponent, skyDaylightBrightness, skyNightBrightness,
            true);
}

From source file:org.terasology.rendering.shader.ShaderParametersSobel.java

License:Apache License

@Override
public void applyParameters(Material program) {
    super.applyParameters(program);

    DefaultRenderingProcess.FBO scene = DefaultRenderingProcess.getInstance().getFBO("sceneOpaque");

    if (scene != null) {
        GL13.glActiveTexture(GL13.GL_TEXTURE0);
        scene.bindDepthTexture();/*from  w  w w.j a  v a  2 s  .c  o  m*/
        program.setInt("texDepth", 0);

        program.setFloat("texelWidth", 1.0f / scene.width);
        program.setFloat("texelHeight", 1.0f / scene.height);
    }

    program.setFloat("pixelOffsetX", pixelOffsetX);
    program.setFloat("pixelOffsetY", pixelOffsetY);
}

From source file:org.terasology.rendering.shader.ShaderParametersSSAO.java

License:Apache License

@Override
public void applyParameters(Material program) {
    super.applyParameters(program);

    DefaultRenderingProcess.FBO scene = DefaultRenderingProcess.getInstance().getFBO("sceneOpaque");

    int texId = 0;

    if (scene != null) {
        GL13.glActiveTexture(GL13.GL_TEXTURE0);
        scene.bindDepthTexture();/*from ww w .  j  a  v  a 2s  .  co m*/
        program.setInt("texDepth", texId++, true);
        GL13.glActiveTexture(GL13.GL_TEXTURE1);
        scene.bindNormalsTexture();
        program.setInt("texNormals", texId++, true);
    }

    Texture ssaoNoiseTexture = updateNoiseTexture();

    GL13.glActiveTexture(GL13.GL_TEXTURE2);
    glBindTexture(GL11.GL_TEXTURE_2D, ssaoNoiseTexture.getId());
    program.setInt("texNoise", texId++, true);

    program.setFloat4("ssaoSettings", ssaoStrength, ssaoRad, 0.0f, 0.0f, true);

    if (CoreRegistry.get(WorldRenderer.class) != null) {
        Camera activeCamera = CoreRegistry.get(WorldRenderer.class).getActiveCamera();
        if (activeCamera != null) {
            program.setMatrix4("invProjMatrix", activeCamera.getInverseProjectionMatrix(), true);
            program.setMatrix4("projMatrix", activeCamera.getProjectionMatrix(), true);
        }
    }
}

From source file:org.terasology.rendering.shader.ShaderParametersToneMapping.java

License:Apache License

@Override
public void applyParameters(Material program) {
    super.applyParameters(program);

    DisplayResolutionDependentFBOs displayResolutionDependentFBOs = CoreRegistry
            .get(DisplayResolutionDependentFBOs.class); // TODO: switch from CoreRegistry to Context.
    ScreenGrabber screenGrabber = CoreRegistry.get(ScreenGrabber.class);

    // TODO: move into a tone mapping node
    GL13.glActiveTexture(GL13.GL_TEXTURE0);
    displayResolutionDependentFBOs.bindFboColorTexture(InitialPostProcessingNode.INITIAL_POST_FBO);
    program.setInt("texScene", 0, true);

    program.setFloat("exposure", screenGrabber.getExposure() * exposureBias, true);
    program.setFloat("whitePoint", whitePoint, true);
}

From source file:org.terasology.rendering.shader.ShaderParametersVolumetricLightingRayMarching.java

License:Apache License

@Override
public void applyParameters(Material program) {
    super.applyParameters(program);

    int texId = 0;

    DefaultRenderingProcess.FBO sceneOpaque = DefaultRenderingProcess.getInstance().getFBO("sceneOpaque");

    if (CoreRegistry.get(Config.class).getRendering().isVolumetricLighting()) {

        if (sceneOpaque != null) {
            GL13.glActiveTexture(GL13.GL_TEXTURE0 + texId);
            sceneOpaque.bindDepthTexture();
            program.setInt("texSceneOpaqueDepth", texId++, true);
        }/*from w  w w. j av a  2s. c o m*/

        DefaultRenderingProcess.FBO volumetricLighting = DefaultRenderingProcess.getInstance()
                .getFBO("volumetricLighting");

        program.setFloat2("texelSize", 1.0f / volumetricLighting.width, 1.0f / volumetricLighting.height, true);

        GL13.glActiveTexture(GL13.GL_TEXTURE0 + texId);
        DefaultRenderingProcess.getInstance().bindFboDepthTexture("sceneShadowMap");
        program.setInt("texSceneShadowMap", texId++, true);

        Camera activeCamera = CoreRegistry.get(WorldRenderer.class).getActiveCamera();
        Camera lightCamera = CoreRegistry.get(WorldRenderer.class).getLightCamera();
        if (lightCamera != null && activeCamera != null) {
            program.setMatrix4("invViewProjMatrix", activeCamera.getInverseViewProjectionMatrix(), true);

            program.setMatrix4("lightViewMatrix", lightCamera.getViewMatrix(), true);
            program.setMatrix4("lightProjMatrix", lightCamera.getProjectionMatrix(), true);
            program.setMatrix4("lightViewProjMatrix", lightCamera.getViewProjectionMatrix(), true);

            Vector3f activeCameraToLightSpace = new Vector3f();
            activeCameraToLightSpace.sub(activeCamera.getPosition(), lightCamera.getPosition());
            program.setFloat3("activeCameraToLightSpace", activeCameraToLightSpace.x,
                    activeCameraToLightSpace.y, activeCameraToLightSpace.z, true);
        }

        program.setFloat4("volumetricLightingSettings", volLightingDensity, volLightingDecay, volLightingPhi,
                volLightingScattering, true);

        if (CoreRegistry.get(Config.class).getRendering().isCloudShadows()) {
            Texture clouds = Assets.getTexture("engine:perlinNoiseTileable");
            GL13.glActiveTexture(GL13.GL_TEXTURE0 + texId);
            glBindTexture(GL11.GL_TEXTURE_2D, clouds.getId());
            program.setInt("texSceneClouds", texId++, true);
        }
    }
}

From source file:org.terasology.rendering.shader.ShaderProgram.java

License:Apache License

public void enable() {
    ShaderProgram activeProgram = ShaderManager.getInstance().getActiveShaderProgram();

    if (activeProgram != this) {
        GL13.glActiveTexture(GL13.GL_TEXTURE0);
        GL20.glUseProgram(shaderProgram);

        // Make sure the shader manager knows that this program is currently active
        ShaderManager.getInstance().setActiveShaderProgram(this);

        // Set the shader parameters if available
        if (parameters != null) {
            parameters.applyParameters(this);
        }/*from w  w  w . j ava  2s.  co  m*/
    }
}

From source file:org.terasology.rendering.ShaderManager.java

License:Apache License

public void bindTexture(int slot, Texture texture) {
    if (activeMaterial != null && !activeMaterial.isDisposed()) {
        GL13.glActiveTexture(GL13.GL_TEXTURE0 + slot);
        // TODO: Need to be cubemap aware, only need to clear bind when switching from cubemap to 2D and vice versa,
        // TODO: Don't bind if already bound to the same
        GL11.glBindTexture(GL11.GL_TEXTURE_2D, texture.getId());
        GL13.glActiveTexture(GL13.GL_TEXTURE0);
    }/* w w w .  j  a va  2 s  .c  om*/
}

From source file:org.terasology.rendering.ShaderManagerLwjgl.java

License:Apache License

@Override
public void bindTexture(int slot, Texture texture) {
    if (activeMaterial != null && !activeMaterial.isDisposed()) {
        GL13.glActiveTexture(GL13.GL_TEXTURE0 + slot);
        // TODO: Need to be cubemap aware, only need to clear bind when switching from cubemap to 2D and vice versa,
        // TODO: Don't bind if already bound to the same
        GL11.glBindTexture(GL11.GL_TEXTURE_2D, texture.getId());
        GL13.glActiveTexture(GL13.GL_TEXTURE0);
    }/*  www  .  ja va 2s.com*/
}

From source file:processing.lwjgl.PGL.java

License:Open Source License

public void activeTexture(int unit) {
    GL13.glActiveTexture(unit);
}

From source file:processing.lwjgl.PLWJGL.java

License:Open Source License

protected void activeTextureImpl(int texture) {
    GL13.glActiveTexture(texture);
}