Example usage for org.lwjgl.opengl GL13 GL_TEXTURE0

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

Introduction

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

Prototype

int GL_TEXTURE0

To view the source code for org.lwjgl.opengl GL13 GL_TEXTURE0.

Click Source Link

Document

Accepted by the texture parameter of ActiveTexture and MultiTexCoord.

Usage

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

License:Apache License

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

    Texture terrainTex = Assets.getTexture("engine:terrain");

    if (terrainTex == null) {
        return;//from  w  ww.  j a  v a  2 s  .co m
    }

    GL13.glActiveTexture(GL13.GL_TEXTURE0);
    glBindTexture(GL11.GL_TEXTURE_2D, terrainTex.getId());

    program.setFloat3("colorOffset", 1.0f, 1.0f, 1.0f, true);
    program.setBoolean("textured", true, true);
    program.setFloat("alpha", 1.0f, true);
}

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

License:Apache License

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

    Texture terrain = Assets.getTexture("engine:terrain");
    Texture terrainNormal = Assets.getTexture("engine:terrainNormal");
    Texture terrainHeight = Assets.getTexture("engine:terrainHeight");

    Texture water = Assets.getTexture("engine:waterStill");
    Texture lava = Assets.getTexture("engine:lavaStill");
    Texture waterNormal = Assets.getTexture("engine:waterNormal");
    Texture waterNormalAlt = Assets.getTexture("engine:waterNormalAlt");
    Texture effects = Assets.getTexture("engine:effects");

    if (terrain == null || water == null || lava == null || waterNormal == null || effects == null) {
        return;//from  w w w. jav a  2 s  .c  o m
    }

    int texId = 0;
    GL13.glActiveTexture(GL13.GL_TEXTURE0 + texId);
    glBindTexture(GL11.GL_TEXTURE_2D, terrain.getId());
    program.setInt("textureAtlas", texId++, true);
    GL13.glActiveTexture(GL13.GL_TEXTURE0 + texId);
    glBindTexture(GL11.GL_TEXTURE_2D, water.getId());
    program.setInt("textureWater", texId++, true);
    GL13.glActiveTexture(GL13.GL_TEXTURE0 + texId);
    glBindTexture(GL11.GL_TEXTURE_2D, lava.getId());
    program.setInt("textureLava", texId++, true);
    GL13.glActiveTexture(GL13.GL_TEXTURE0 + texId);
    glBindTexture(GL11.GL_TEXTURE_2D, waterNormal.getId());
    program.setInt("textureWaterNormal", texId++, true);
    GL13.glActiveTexture(GL13.GL_TEXTURE0 + texId);
    glBindTexture(GL11.GL_TEXTURE_2D, waterNormalAlt.getId());
    program.setInt("textureWaterNormalAlt", texId++, true);
    GL13.glActiveTexture(GL13.GL_TEXTURE0 + texId);
    glBindTexture(GL11.GL_TEXTURE_2D, effects.getId());
    program.setInt("textureEffects", texId++, true);
    GL13.glActiveTexture(GL13.GL_TEXTURE0 + texId);
    DefaultRenderingProcess.getInstance().bindFboTexture("sceneReflected");
    program.setInt("textureWaterReflection", texId++, true);
    GL13.glActiveTexture(GL13.GL_TEXTURE0 + texId);
    DefaultRenderingProcess.getInstance().bindFboTexture("sceneOpaque");
    program.setInt("texSceneOpaque", texId++, true);

    if (CoreRegistry.get(Config.class).getRendering().isNormalMapping()) {
        GL13.glActiveTexture(GL13.GL_TEXTURE0 + texId);
        glBindTexture(GL11.GL_TEXTURE_2D, terrainNormal.getId());
        program.setInt("textureAtlasNormal", texId++, true);

        if (CoreRegistry.get(Config.class).getRendering().isParallaxMapping()) {
            GL13.glActiveTexture(GL13.GL_TEXTURE0 + texId);
            glBindTexture(GL11.GL_TEXTURE_2D, terrainHeight.getId());
            program.setInt("textureAtlasHeight", texId++, true);
        }
    }

    Vector4f lightingSettingsFrag = new Vector4f();
    lightingSettingsFrag.z = waterSpecExp;
    program.setFloat4("lightingSettingsFrag", lightingSettingsFrag, true);

    Vector4f waterSettingsFrag = new Vector4f();
    waterSettingsFrag.x = waterNormalBias;
    waterSettingsFrag.y = waterRefraction;
    waterSettingsFrag.z = waterFresnelBias;
    waterSettingsFrag.w = waterFresnelPow;
    program.setFloat4("waterSettingsFrag", waterSettingsFrag, true);

    Vector4f alternativeWaterSettingsFrag = new Vector4f();
    alternativeWaterSettingsFrag.x = waterTint;
    program.setFloat4("alternativeWaterSettingsFrag", alternativeWaterSettingsFrag, true);

    if (CoreRegistry.get(Config.class).getRendering().isAnimateWater()) {
        program.setFloat("waveIntensFalloff", waveIntensFalloff, true);
        program.setFloat("waveSizeFalloff", waveSizeFalloff, true);
        program.setFloat("waveSize", waveSize, true);
        program.setFloat("waveSpeedFalloff", waveSpeedFalloff, true);
        program.setFloat("waveSpeed", waveSpeed, true);
        program.setFloat("waveIntens", waveIntens, true);
        program.setFloat("waterOffsetY", waterOffsetY, true);
        program.setFloat("waveOverallScale", waveOverallScale, true);
    }

    if (CoreRegistry.get(Config.class).getRendering().isParallaxMapping()
            && CoreRegistry.get(Config.class).getRendering().isNormalMapping()) {
        program.setFloat4("parallaxProperties", parallaxBias, parallaxScale, 0.0f, 0.0f, true);
    }
}

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

License:Apache License

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

    int texId = 0;

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

    if (sceneOpaque != null) {
        GL13.glActiveTexture(GL13.GL_TEXTURE0 + texId);
        sceneOpaque.bindTexture();//from   w  w  w .ja v  a2 s .c o m
        program.setInt("texSceneOpaque", texId++, true);

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

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

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

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

    if (sceneReflectiveRefractive != null) {
        GL13.glActiveTexture(GL13.GL_TEXTURE0 + texId);
        sceneReflectiveRefractive.bindTexture();
        program.setInt("texSceneReflectiveRefractive", texId++, true);
    }

    if (CoreRegistry.get(Config.class).getRendering().isLocalReflections()) {
        if (sceneReflectiveRefractive != null) {
            GL13.glActiveTexture(GL13.GL_TEXTURE0 + texId);
            sceneReflectiveRefractive.bindNormalsTexture();
            program.setInt("texSceneReflectiveRefractiveNormals", texId++, true);
        }

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

    if (CoreRegistry.get(Config.class).getRendering().isSsao()) {
        GL13.glActiveTexture(GL13.GL_TEXTURE0 + texId);
        DefaultRenderingProcess.getInstance().bindFboTexture("ssaoBlurred");
        program.setInt("texSsao", texId++, true);
    }

    if (CoreRegistry.get(Config.class).getRendering().isOutline()) {
        GL13.glActiveTexture(GL13.GL_TEXTURE0 + texId);
        DefaultRenderingProcess.getInstance().bindFboTexture("sobel");
        program.setInt("texEdges", texId++, true);

        program.setFloat("outlineDepthThreshold", outlineDepthThreshold, true);
        program.setFloat("outlineThickness", outlineThickness, true);
    }

    if (CoreRegistry.get(Config.class).getRendering().isInscattering()) {
        GL13.glActiveTexture(GL13.GL_TEXTURE0 + texId);
        DefaultRenderingProcess.getInstance().bindFboTexture("sceneSkyBand1");
        program.setInt("texSceneSkyBand", texId++, true);

        Vector4f skyInscatteringSettingsFrag = new Vector4f();
        skyInscatteringSettingsFrag.y = skyInscatteringStrength;
        skyInscatteringSettingsFrag.z = skyInscatteringLength;
        skyInscatteringSettingsFrag.w = skyInscatteringThreshold;
        program.setFloat4("skyInscatteringSettingsFrag", skyInscatteringSettingsFrag, true);
    }
}

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

License:Apache License

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

    Config config = CoreRegistry.get(Config.class);

    int texId = 0;

    switch (config.getRendering().getDebug().getStage()) {
    case SHADOW_MAP:
        GL13.glActiveTexture(GL13.GL_TEXTURE0 + texId);
        DefaultRenderingProcess.getInstance().bindFboDepthTexture("sceneShadowMap");
        program.setInt("texDebug", texId++, true);
        break;/*from w ww  .ja  v  a 2s.  c  o m*/
    case OPAQUE_COLOR:
        GL13.glActiveTexture(GL13.GL_TEXTURE0 + texId);
        DefaultRenderingProcess.getInstance().bindFboTexture("sceneOpaque");
        program.setInt("texDebug", texId++, true);
        break;
    case OPAQUE_NORMALS:
    case OPAQUE_SUNLIGHT:
        GL13.glActiveTexture(GL13.GL_TEXTURE0 + texId);
        DefaultRenderingProcess.getInstance().bindFboNormalsTexture("sceneOpaque");
        program.setInt("texDebug", texId++, true);
        break;
    case OPAQUE_DEPTH:
        GL13.glActiveTexture(GL13.GL_TEXTURE0 + texId);
        DefaultRenderingProcess.getInstance().bindFboDepthTexture("sceneOpaque");
        program.setInt("texDebug", texId++, true);
        break;
    case OPAQUE_LIGHT_BUFFER:
        GL13.glActiveTexture(GL13.GL_TEXTURE0 + texId);
        DefaultRenderingProcess.getInstance().bindFboLightBufferTexture("sceneOpaque");
        program.setInt("texDebug", texId++, true);
        break;
    case TRANSPARENT_COLOR:
        GL13.glActiveTexture(GL13.GL_TEXTURE0 + texId);
        DefaultRenderingProcess.getInstance().bindFboTexture("sceneReflectiveRefractive");
        program.setInt("texDebug", texId++, true);
        break;
    case SSAO:
        GL13.glActiveTexture(GL13.GL_TEXTURE0 + texId);
        DefaultRenderingProcess.getInstance().bindFboTexture("ssaoBlurred");
        program.setInt("texDebug", texId++, true);
        break;
    case SOBEL:
        GL13.glActiveTexture(GL13.GL_TEXTURE0 + texId);
        DefaultRenderingProcess.getInstance().bindFboTexture("sobel");
        program.setInt("texDebug", texId++, true);
        break;
    case BAKED_OCCLUSION:
        GL13.glActiveTexture(GL13.GL_TEXTURE0 + texId);
        DefaultRenderingProcess.getInstance().bindFboTexture("sceneOpaque");
        program.setInt("texDebug", texId++, true);
        break;
    case RECONSTRUCTED_POSITION:
        Camera activeCamera = CoreRegistry.get(WorldRenderer.class).getActiveCamera();
        if (activeCamera != null) {
            program.setMatrix4("invProjMatrix", activeCamera.getInverseProjectionMatrix(), true);
        }

        GL13.glActiveTexture(GL13.GL_TEXTURE0 + texId);
        DefaultRenderingProcess.getInstance().bindFboDepthTexture("sceneOpaque");
        program.setInt("texDebug", texId++, true);
        break;
    case BLOOM:
        GL13.glActiveTexture(GL13.GL_TEXTURE0 + texId);
        DefaultRenderingProcess.getInstance().bindFboTexture("sceneBloom2");
        program.setInt("texDebug", texId++, true);
        break;
    case HIGH_PASS:
        GL13.glActiveTexture(GL13.GL_TEXTURE0 + texId);
        DefaultRenderingProcess.getInstance().bindFboTexture("sceneHighPass");
        program.setInt("texDebug", texId++, true);
        break;
    case SKY_BAND:
        GL13.glActiveTexture(GL13.GL_TEXTURE0 + texId);
        DefaultRenderingProcess.getInstance().bindFboTexture("sceneSkyBand1");
        program.setInt("texDebug", texId++, true);
        break;
    case LIGHT_SHAFTS:
        GL13.glActiveTexture(GL13.GL_TEXTURE0 + texId);
        DefaultRenderingProcess.getInstance().bindFboTexture("lightShafts");
        program.setInt("texDebug", texId++, true);
        break;
    default:
        break;
    }

    program.setInt("debugRenderingStage",
            CoreRegistry.get(Config.class).getRendering().getDebug().getStage().getIndex());
}

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

License:Apache License

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

    GL13.glActiveTexture(GL13.GL_TEXTURE0);
    glBindTexture(GL11.GL_TEXTURE_2D, 0);
}

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

License:Apache License

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

    GL13.glActiveTexture(GL13.GL_TEXTURE0);
    glBindTexture(GL11.GL_TEXTURE_2D, Assets.getTexture("engine:slime").getId());
}

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

License:Apache License

@Override
public void applyParameters(ShaderProgram program) {
    LocalPlayer localPlayer = CoreRegistry.get(LocalPlayer.class);

    GL13.glActiveTexture(GL13.GL_TEXTURE0);
    glBindTexture(GL11.GL_TEXTURE_2D, texture.getId());

    if (localPlayer != null)
        program.setInt("carryingTorch", localPlayer.isCarryingTorch() ? 1 : 0);

    program.setFloat3("colorOffset", 1.0f, 1.0f, 1.0f);
    program.setInt("textured", 1);
}

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

License:Apache License

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

    GL13.glActiveTexture(GL13.GL_TEXTURE0);
    DefaultRenderingProcess.getInstance().bindFboTexture("scenePrePost");

    program.setInt("texScene", 0, true);
    program.setFloat("exposure", DefaultRenderingProcess.getInstance().getExposure() * exposureBias, true);
    program.setFloat("whitePoint", whitePoint, true);
}

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

License:Apache License

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

    // TODO: often used objects: perhaps to be obtained in BaseMaterial?
    DisplayResolutionDependentFBOs displayResolutionDependentFBOs = CoreRegistry
            .get(DisplayResolutionDependentFBOs.class); // TODO: switch from CoreRegistry to Context.
    Camera activeCamera = CoreRegistry.get(WorldRenderer.class).getActiveCamera();
    WorldProvider worldProvider = CoreRegistry.get(WorldProvider.class);

    // TODO: move what follows into material and/or node
    Vector3f tint = worldProvider.getBlock(activeCamera.getPosition()).getTint();
    program.setFloat3("inLiquidTint", tint.x, tint.y, tint.z, true);

    int texId = 0;
    GL13.glActiveTexture(GL13.GL_TEXTURE0 + texId);
    displayResolutionDependentFBOs.bindFboColorTexture(DefaultDynamicFBOs.READ_ONLY_GBUFFER.getName());
    program.setInt("texScene", texId++, true);

    // TODO: monitor config parameter by subscribing to it
    if (CoreRegistry.get(Config.class).getRendering().isBloom()) {
        GL13.glActiveTexture(GL13.GL_TEXTURE0 + texId);
        displayResolutionDependentFBOs.bindFboColorTexture(BloomBlurNode.ONE_8TH_SCALE_FBO);
        program.setInt("texBloom", texId++, true);

        program.setFloat("bloomFactor", bloomFactor, true);
    }//from  w  w w.  j  a  va  2 s . c o m

    program.setFloat2("aberrationOffset", aberrationOffsetX, aberrationOffsetY, true);

    // TODO: monitor config parameter by subscribing to it
    if (CoreRegistry.get(Config.class).getRendering().isLightShafts()) {
        GL13.glActiveTexture(GL13.GL_TEXTURE0 + texId);
        displayResolutionDependentFBOs.bindFboColorTexture(LightShaftsNode.LIGHT_SHAFTS_FBO);
        program.setInt("texLightShafts", texId++, true);
    }

    // TODO: obtain once, monitor using Texture.subscribeToDisposal(Runnable)
    Optional<? extends Texture> vignetteTexture = Assets.getTexture("engine:vignette");

    if (vignetteTexture.isPresent()) {
        GL13.glActiveTexture(GL13.GL_TEXTURE0 + texId);
        glBindTexture(GL11.GL_TEXTURE_2D, vignetteTexture.get().getId());
        program.setInt("texVignette", texId++, true);
    }
}

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

License:Apache License

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

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

    int texId = 0;
    if (sceneOpaque != null) {
        GL13.glActiveTexture(GL13.GL_TEXTURE0 + texId);
        sceneOpaque.bindDepthTexture();//from   w  ww .j  a v  a 2  s . co  m
        program.setInt("texSceneOpaqueDepth", texId++, true);

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

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

    if (CoreRegistry.get(Config.class).getRendering().isDynamicShadows()) {
        GL13.glActiveTexture(GL13.GL_TEXTURE0 + texId);
        DefaultRenderingProcess.getInstance().bindFboDepthTexture("sceneShadowMap");
        program.setInt("texSceneShadowMap", texId++, true);

        Camera lightCamera = CoreRegistry.get(WorldRenderer.class).getLightCamera();
        Camera activeCamera = CoreRegistry.get(WorldRenderer.class).getActiveCamera();

        if (lightCamera != null && activeCamera != null) {
            program.setMatrix4("lightViewProjMatrix", lightCamera.getViewProjectionMatrix(), true);
            program.setMatrix4("invViewProjMatrix", activeCamera.getInverseViewProjectionMatrix(), true);

            Vector3f activeCameraToLightSpace = new Vector3f();
            activeCameraToLightSpace.sub(activeCamera.getPosition(), lightCamera.getPosition());
            program.setFloat3("activeCameraToLightSpace", activeCameraToLightSpace.x,
                    activeCameraToLightSpace.y, activeCameraToLightSpace.z, 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);
        }
    }
}