/** * Part of the deferred lighting technique, this method applies lighting through screen-space * calculations to the previously flat-lit world rendering stored in the primary FBO. // TODO: * rename sceneOpaque* FBOs to primaryA/B * * <p>See http://en.wikipedia.org/wiki/Deferred_shading as a starting point. */ public void applyLightBufferPass() { int texId = 0; GL13.glActiveTexture(GL13.GL_TEXTURE0 + texId); buffers.sceneOpaque.bindTexture(); materials.lightBufferPass.setInt("texSceneOpaque", texId++); GL13.glActiveTexture(GL13.GL_TEXTURE0 + texId); buffers.sceneOpaque.bindDepthTexture(); materials.lightBufferPass.setInt("texSceneOpaqueDepth", texId++); GL13.glActiveTexture(GL13.GL_TEXTURE0 + texId); buffers.sceneOpaque.bindNormalsTexture(); materials.lightBufferPass.setInt("texSceneOpaqueNormals", texId++); GL13.glActiveTexture(GL13.GL_TEXTURE0 + texId); buffers.sceneOpaque.bindLightBufferTexture(); materials.lightBufferPass.setInt("texSceneOpaqueLightBuffer", texId, true); buffers.sceneOpaquePingPong.bind(); graphicState.setRenderBufferMask(buffers.sceneOpaquePingPong, true, true, true); setViewportTo(buffers.sceneOpaquePingPong.dimensions()); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // TODO: verify this is necessary renderFullscreenQuad(); graphicState.bindDisplay(); // TODO: verify this is necessary setViewportToWholeDisplay(); // TODO: verify this is necessary renderingProcess.swapSceneOpaqueFBOs(); buffers.sceneOpaque.attachDepthBufferTo(buffers.sceneReflectiveRefractive); }
public void start(ResourceLocation texture) { this.useProgram(); GL13.glActiveTexture(GL13.GL_TEXTURE0 + MASK_TEXID); GL11.glEnable(GL11.GL_TEXTURE_2D); RenderUtils.loadTexture(texture); GL13.glActiveTexture(GL13.GL_TEXTURE0); }
private void bindTextures(Terrain terrain) { TerrainTexturePack pack = terrain.getTexturePack(); GL13.glActiveTexture(GL13.GL_TEXTURE0); GL11.glBindTexture(GL11.GL_TEXTURE_2D, pack.getBackgroundTexture().getTextureID()); GL13.glActiveTexture(GL13.GL_TEXTURE1); GL11.glBindTexture(GL11.GL_TEXTURE_2D, pack.getRedTexture().getTextureID()); GL13.glActiveTexture(GL13.GL_TEXTURE2); GL11.glBindTexture(GL11.GL_TEXTURE_2D, pack.getGreenTexture().getTextureID()); GL13.glActiveTexture(GL13.GL_TEXTURE3); GL11.glBindTexture(GL11.GL_TEXTURE_2D, pack.getBlueTexture().getTextureID()); GL13.glActiveTexture(GL13.GL_TEXTURE4); GL11.glBindTexture(GL11.GL_TEXTURE_2D, terrain.getBlendMap().getTextureID()); }
public void renderAnimationFrame( Transform transform, int frame, Texture tex, boolean horizontalFlip) { GL20.glUseProgram(animSpriteShaderProgram.getProgramId()); spriteVAO.bind(); // GL30.glBindVertexArray(flatPlane.getVaoId()); Matrix4f finalMatrix = rs.getCamera() .getProjectionMatrix() .multiply(rs.getCamera().getWorldMatrix().multiply(transform.toMatrix())); // Diffuse Texture GL13.glActiveTexture(GL13.GL_TEXTURE0); GL11.glBindTexture(GL30.GL_TEXTURE_2D_ARRAY, tex.getTextureId()); GL20.glUniformMatrix4fv( animSpriteShaderProgram.getUniform("mvpMatrix").getLocation(), false, finalMatrix.toBuffer()); GL20.glUniform1i(animSpriteShaderProgram.getUniform("diffuseTextureAtlas").getLocation(), 0); GL20.glUniform1i(animSpriteShaderProgram.getUniform("currentFrame").getLocation(), frame); GL20.glUniform1i( animSpriteShaderProgram.getUniform("horizontalFlip").getLocation(), (horizontalFlip) ? GL11.GL_TRUE : GL11.GL_FALSE); GL11.glDrawArrays(GL11.GL_TRIANGLE_STRIP, 0, SPRITE_NUM_VERTICES); }
public int loadCubeMap(String[] textures) { int textureID = GL11.glGenTextures(); GL13.glActiveTexture(GL13.GL_TEXTURE0); GL11.glBindTexture(GL13.GL_TEXTURE_CUBE_MAP, textureID); for (int i = 0; i < textures.length; i++) { TextureData data = decodeTextureFile("res/Textures/" + textures[i] + ".png"); GL11.glTexImage2D( GL13.GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, GL11.GL_RGBA, data.getWidth(), data.getHeight(), 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, data.getBuffer()); } GL11.glTexParameteri(GL13.GL_TEXTURE_CUBE_MAP, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR); GL11.glTexParameteri(GL13.GL_TEXTURE_CUBE_MAP, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR); GL11.glTexParameteri(GL13.GL_TEXTURE_CUBE_MAP, GL11.GL_TEXTURE_WRAP_S, GL12.GL_CLAMP_TO_EDGE); GL11.glTexParameteri(GL13.GL_TEXTURE_CUBE_MAP, GL11.GL_TEXTURE_WRAP_T, GL12.GL_CLAMP_TO_EDGE); this.textures.add(textureID); return textureID; }
public static void func_77475_a(int p_77475_0_, float p_77475_1_, float p_77475_2_) { if (field_77477_c) { ARBMultitexture.glMultiTexCoord2fARB(p_77475_0_, p_77475_1_, p_77475_2_); } else { GL13.glMultiTexCoord2f(p_77475_0_, p_77475_1_, p_77475_2_); } }
public static void func_77472_b(int p_77472_0_) { if (field_77477_c) { ARBMultitexture.glClientActiveTextureARB(p_77472_0_); } else { GL13.glClientActiveTexture(p_77472_0_); } }
public void renderSprite(Transform transform, Texture texture, boolean hFlip, boolean vFlip) { GL20.glUseProgram(spriteShaderProgram.getProgramId()); spriteVAO.bind(); GL13.glActiveTexture(GL13.GL_TEXTURE0); GL11.glBindTexture(GL11.GL_TEXTURE_2D, texture.getTextureId()); Matrix4f finalMatrix = rs.getCamera() .getProjectionMatrix() .multiply(rs.getCamera().getWorldMatrix().multiply(transform.toMatrix())); GL20.glUniformMatrix4fv( spriteShaderProgram.getUniform("mvpMatrix").getLocation(), false, finalMatrix.toBuffer()); GL20.glUniform1i( spriteShaderProgram.getUniform("horizontalFlip").getLocation(), (hFlip) ? GL11.GL_TRUE : GL11.GL_FALSE); GL20.glUniform1i( spriteShaderProgram.getUniform("verticalFlip").getLocation(), (vFlip) ? GL11.GL_TRUE : GL11.GL_FALSE); GL20.glUniform1i(spriteShaderProgram.getUniform("sprite").getLocation(), 0); GL11.glDrawArrays(GL11.GL_TRIANGLE_STRIP, 0, SPRITE_NUM_VERTICES); }
public void applyParameters(ShaderProgram program) { LocalPlayer localPlayer = CoreRegistry.get(LocalPlayer.class); GL13.glActiveTexture(GL13.GL_TEXTURE0); glBindTexture(GL11.GL_TEXTURE_2D, terrainTex.getId()); if (localPlayer != null) program.setInt("carryingTorch", localPlayer.isCarryingTorch() ? 1 : 0); }
@Override public void applyParameters(ShaderProgram program) { super.applyParameters(program); DefaultRenderingProcess.FBO sceneOpaque = DefaultRenderingProcess.getInstance().getFBO("sceneOpaque"); int texId = 0; GL13.glActiveTexture(GL13.GL_TEXTURE0 + texId); sceneOpaque.bindTexture(); program.setInt("texSceneOpaque", texId++); GL13.glActiveTexture(GL13.GL_TEXTURE0 + texId); sceneOpaque.bindDepthTexture(); program.setInt("texSceneOpaqueDepth", texId++); GL13.glActiveTexture(GL13.GL_TEXTURE0 + texId); sceneOpaque.bindNormalsTexture(); program.setInt("texSceneOpaqueNormals", texId++); DefaultRenderingProcess.FBO sceneTransparent = DefaultRenderingProcess.getInstance().getFBO("sceneTransparent"); GL13.glActiveTexture(GL13.GL_TEXTURE0 + texId); sceneTransparent.bindTexture(); program.setInt("texSceneTransparent", texId++); GL13.glActiveTexture(GL13.GL_TEXTURE0 + texId); sceneTransparent.bindDepthTexture(); program.setInt("texSceneTransparentDepth", texId++); GL13.glActiveTexture(GL13.GL_TEXTURE0 + texId); sceneTransparent.bindNormalsTexture(); program.setInt("texSceneTransparentNormals", texId++); if (CoreRegistry.get(Config.class).getRendering().isSsao()) { DefaultRenderingProcess.FBO ssao = DefaultRenderingProcess.getInstance().getFBO("ssaoBlurred1"); GL13.glActiveTexture(GL13.GL_TEXTURE0 + texId); ssao.bindTexture(); program.setInt("texSsao", texId++); } if (CoreRegistry.get(Config.class).getRendering().isOutline()) { DefaultRenderingProcess.FBO sobel = DefaultRenderingProcess.getInstance().getFBO("sobel"); GL13.glActiveTexture(GL13.GL_TEXTURE0 + texId); sobel.bindTexture(); program.setInt("texEdges", texId++); program.setFloat("outlineDepthThreshold", (Float) outlineDepthThreshold.getValue()); program.setFloat("outlineThickness", (Float) outlineThickness.getValue()); } program.setFloat("shoreStart", (Float) shoreStart.getValue()); program.setFloat("shoreEnd", (Float) shoreEnd.getValue()); }
@Override public void applyParameters(Material program) { super.applyParameters(program); int texId = 0; GL13.glActiveTexture(GL13.GL_TEXTURE0 + texId); LwjglRenderingProcess.getInstance().bindFboTexture("sceneFinal"); program.setInt("texSceneFinal", texId++, true); }
void unbind() { GL11.glPopAttrib(); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glPopMatrix(); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glPopMatrix(); if (lightmapEnabled) { GL13.glActiveTexture(GL13.GL_TEXTURE1); GL11.glEnable(GL11.GL_TEXTURE_2D); GL13.glActiveTexture(GL13.GL_TEXTURE0); } GL11.glEnable(GL11.GL_BLEND); GLAPI.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); EXTFramebufferObject.glBindFramebufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, 0); }
private void renderVbo(int id) { if (lock.tryLock()) { try { if (vertexBuffers[id] <= 0 || disposed) { return; } glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_TEXTURE_COORD_ARRAY); glEnableClientState(GL_COLOR_ARRAY); glEnableClientState(GL_NORMAL_ARRAY); GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, idxBuffers[id]); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vertexBuffers[id]); glVertexPointer(SIZE_VERTEX, GL11.GL_FLOAT, STRIDE, OFFSET_VERTEX); GL13.glClientActiveTexture(GL13.GL_TEXTURE0); glTexCoordPointer(SIZE_TEX0, GL11.GL_FLOAT, STRIDE, OFFSET_TEX_0); GL13.glClientActiveTexture(GL13.GL_TEXTURE1); glTexCoordPointer(SIZE_TEX1, GL11.GL_FLOAT, STRIDE, OFFSET_TEX_1); glColorPointer(SIZE_COLOR * 4, GL11.GL_UNSIGNED_BYTE, STRIDE, OFFSET_COLOR); glNormalPointer(GL11.GL_FLOAT, STRIDE, OFFSET_NORMAL); GL11.glDrawElements(GL11.GL_TRIANGLES, vertexCount[id], GL11.GL_UNSIGNED_INT, 0); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0); GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, 0); glDisableClientState(GL_NORMAL_ARRAY); glDisableClientState(GL_COLOR_ARRAY); glDisableClientState(GL_TEXTURE_COORD_ARRAY); glDisableClientState(GL_VERTEX_ARRAY); } finally { lock.unlock(); } } }
private void prepareTexturedModel(TexturedModel model) { RawModel rawModel = model.getRawModel(); GL30.glBindVertexArray(rawModel.getVaoID()); GL20.glEnableVertexAttribArray(0); GL20.glEnableVertexAttribArray(1); GL20.glEnableVertexAttribArray(2); ModelTexture texture = model.getTexture(); shader.loadNumberOfRows(texture.getNumberOfRows()); if (texture.isHasTransparency()) { MasterRenderer.disableCulling(); } shader.loadShineVariables(texture.getShineDamper(), texture.getReflectivity()); GL13.glActiveTexture(GL13.GL_TEXTURE0); GL11.glBindTexture(GL11.GL_TEXTURE_2D, model.getTexture().getID()); shader.loadUseSpecularMap(texture.hasSpecularMap()); if (texture.hasSpecularMap()) { GL13.glActiveTexture(GL13.GL_TEXTURE1); GL11.glBindTexture(GL11.GL_TEXTURE_2D, texture.getSpecularMap()); } }
public void render(Camera camera) { shader.start(); shader.loadViewMatrix(camera); GL30.glBindVertexArray(cube.getVaoID()); GL20.glEnableVertexAttribArray(0); GL13.glActiveTexture(GL13.GL_TEXTURE0); GL11.glBindTexture(GL13.GL_TEXTURE_CUBE_MAP, texture); GL11.glDrawArrays(GL11.GL_TRIANGLES, 0, cube.getVertexCount()); GL20.glDisableVertexAttribArray(0); GL30.glBindVertexArray(0); shader.stop(); }
void bind() { EXTFramebufferObject.glBindFramebufferEXT( EXTFramebufferObject.GL_FRAMEBUFFER_EXT, frameBuffer); GL11.glPushAttrib(glAttributes); GL11.glViewport(x0, y0, width, height); GL11.glEnable(GL11.GL_SCISSOR_TEST); GL11.glScissor(x0, y0, width, height); lightmapEnabled = false; if (gl13Supported) { GL13.glActiveTexture(GL13.GL_TEXTURE1); lightmapEnabled = GL11.glIsEnabled(GL11.GL_TEXTURE_2D); if (lightmapEnabled) { GL11.glDisable(GL11.GL_TEXTURE_2D); } GL13.glActiveTexture(GL13.GL_TEXTURE0); } GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glDisable(GL11.GL_DEPTH_TEST); GLAPI.glColor4f(1.0f, 1.0f, 1.0f, 1.0f); GL11.glDisable(GL11.GL_LIGHTING); GL11.glEnable(GL11.GL_ALPHA_TEST); GLAPI.glAlphaFunc(GL11.GL_GREATER, 0.01f); if (useGL13) { GL11.glDisable(GL13.GL_MULTISAMPLE); } GLAPI.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); GL11.glClear(GL11.GL_COLOR_BUFFER_BIT); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glPushMatrix(); GL11.glLoadIdentity(); GL11.glOrtho(-1.0f, 1.0f, -1.0f, 1.0f, -1.0f, 1.0f); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glPushMatrix(); GL11.glLoadIdentity(); }
public void render(Camera camera) { shader.start(); shader.loadViewMatrix(camera); GL30.glBindVertexArray(sun.getRawModel().getVaoID()); GL20.glEnableVertexAttribArray(0); GL20.glEnableVertexAttribArray(1); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); shader.loadBlendFactor(); GL13.glActiveTexture(GL13.GL_TEXTURE0); GL11.glBindTexture(GL11.GL_TEXTURE_2D, texture); GL13.glActiveTexture(GL13.GL_TEXTURE1); GL11.glBindTexture(GL11.GL_TEXTURE_2D, redSunTexture); billboardRotation(camera); GL11.glDrawElements( GL11.GL_TRIANGLES, sun.getRawModel().getVertexCount(), GL11.GL_UNSIGNED_INT, 0); GL11.glDisable(GL11.GL_BLEND); GL20.glDisableVertexAttribArray(0); GL20.glDisableVertexAttribArray(1); GL30.glBindVertexArray(0); shader.stop(); }
private void prepareTexturedModel(TexturedModel model) { RawModel rawModel = model.getModel(); GL30.glBindVertexArray(rawModel.getVaoID()); GL20.glEnableVertexAttribArray(0); // vertices array GL20.glEnableVertexAttribArray(1); // textures array GL20.glEnableVertexAttribArray(2); // normals array { // Load Texture and shine ModelTexture texture = model.getTexture(); shader.loadShineVariables(texture.getShineDamper(), texture.getReflectivity()); GL13.glActiveTexture(GL13.GL_TEXTURE0); GL11.glBindTexture(GL11.GL_TEXTURE_2D, model.getTexture().getTextureID()); } }
public void glCompressedTexImage2D( int target, int level, int internalformat, int width, int height, int border, int imageSize, Buffer data) { if (data instanceof ByteBuffer) { GL13.glCompressedTexImage2D( target, level, internalformat, width, height, border, (ByteBuffer) data); } else { throw new GdxRuntimeException( "Can't use " + data.getClass().getName() + " with this method. Use ByteBuffer instead."); } }
/** * Renders entieis to the shadow map. Each model is first bound and then all of the entities using * that model are rendered to the shadow map. * * @param entities - the entities to be rendered to the shadow map. */ protected void render(Map<TexturedModel, List<Entity>> entities) { for (TexturedModel model : entities.keySet()) { RawModel rawModel = model.getRawModel(); bindModel(rawModel); GL13.glActiveTexture(GL13.GL_TEXTURE0); GL11.glBindTexture(GL11.GL_TEXTURE_2D, model.getTexture().getID()); if (model.getTexture().hasTransparency()) MasterRenderer.disableCulling(); for (Entity entity : entities.get(model)) { prepareInstance(entity); GL11.glDrawElements(GL11.GL_TRIANGLES, rawModel.getVertexCount(), GL11.GL_UNSIGNED_INT, 0); } if (model.getTexture().hasTransparency()) MasterRenderer.enableCulling(); } GL20.glDisableVertexAttribArray(0); GL20.glDisableVertexAttribArray(1); GL30.glBindVertexArray(0); }
private void applyOculusDistortion(FBO inputBuffer) { materials.ocDistortion.enable(); int texId = 0; GL13.glActiveTexture(GL13.GL_TEXTURE0 + texId); inputBuffer.bindTexture(); materials.ocDistortion.setInt("texInputBuffer", texId, true); if (renderingProcess.isNotTakingScreenshot()) { updateOcShaderParametersForVP( 0, 0, fullScale.width() / 2, fullScale.height(), WorldRenderer.WorldRenderingStage.LEFT_EYE); renderFullscreenQuad(0, 0, Display.getWidth(), Display.getHeight()); updateOcShaderParametersForVP( fullScale.width() / 2 + 1, 0, fullScale.width() / 2, fullScale.height(), WorldRenderer.WorldRenderingStage.RIGHT_EYE); renderFullscreenQuad(0, 0, Display.getWidth(), Display.getHeight()); } else { // what follows -should- work also when there is no screenshot being taken, but somehow it // doesn't, hence the block above updateOcShaderParametersForVP( 0, 0, fullScale.width() / 2, fullScale.height(), WorldRenderer.WorldRenderingStage.LEFT_EYE); renderFullscreenQuad(0, 0, fullScale.width(), fullScale.height()); updateOcShaderParametersForVP( fullScale.width() / 2 + 1, 0, fullScale.width() / 2, fullScale.height(), WorldRenderer.WorldRenderingStage.RIGHT_EYE); renderFullscreenQuad(0, 0, fullScale.width(), fullScale.height()); } }
public void renderBuffer(OpenGLBuffer buffer, ITextureObject texture) { GL13.glActiveTexture(GL13.GL_TEXTURE0 + 0); texture.bind(); glEnableClientState(GL_VERTEX_ARRAY); glEnableVertexAttribArray(0); glEnableVertexAttribArray(1); glEnableVertexAttribArray(2); glBindBuffer(GL_ARRAY_BUFFER, buffer.getVboID()); glVertexAttribPointer(0, 3, GL_FLOAT, false, Vertex.SIZE_IN_FLOATS * 4, 0); glVertexAttribPointer(1, 2, GL_FLOAT, false, Vertex.SIZE_IN_FLOATS * 4, 12); glVertexAttribPointer(2, 3, GL_FLOAT, false, Vertex.SIZE_IN_FLOATS * 4, 20); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, buffer.getIboID()); glDrawElements(GL_TRIANGLES, buffer.getIndicesCount(), GL_UNSIGNED_INT, 0); glDisableVertexAttribArray(2); glDisableVertexAttribArray(1); glDisableVertexAttribArray(0); }
public void render(List<GuiTexture> guis) { shader.start(); GL30.glBindVertexArray(quad.getVaoID()); GL20.glEnableVertexAttribArray(0); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glDisable(GL11.GL_DEPTH_TEST); for (GuiTexture gui : guis) { GL13.glActiveTexture(GL13.GL_TEXTURE0); GL11.glBindTexture(GL11.GL_TEXTURE_2D, gui.getTexture()); Matrix4f matrix = Maths.createTransformationMatrix(gui.getPosition(), gui.getScale()); shader.loadTransformation(matrix); GL11.glDrawArrays(GL11.GL_TRIANGLE_STRIP, 0, quad.getVertexCount()); } GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glDisable(GL11.GL_BLEND); GL20.glDisableVertexAttribArray(0); GL30.glBindVertexArray(0); shader.stop(); }
private void generateHighPass() { materials.highPass.enable(); materials.highPass.setFloat("highPassThreshold", bloomHighPassThreshold, true); int texId = 0; GL13.glActiveTexture(GL13.GL_TEXTURE0 + texId); buffers.sceneOpaque.bindTexture(); materials.highPass.setInt("tex", texId); // GL13.glActiveTexture(GL13.GL_TEXTURE0 + texId); // buffers.sceneOpaque.bindDepthTexture(); // program.setInt("texDepth", texId++); buffers.sceneHighPass.bind(); setViewportTo(buffers.sceneHighPass.dimensions()); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); renderFullscreenQuad(); graphicState.bindDisplay(); setViewportToWholeDisplay(); }
public void glSampleCoverage(float value, boolean invert) { GL13.glSampleCoverage(value, invert); }
public void maskTexCoord(double u, double v) { GL13.glMultiTexCoord2d(GL13.GL_TEXTURE0 + MASK_TEXID, u, v); }
public void glActiveTexture(int texture) { GL13.glActiveTexture(texture); }
public void end() { GL13.glActiveTexture(GL13.GL_TEXTURE0 + MASK_TEXID); GL11.glDisable(GL11.GL_TEXTURE_2D); GL13.glActiveTexture(GL13.GL_TEXTURE0); GL20.glUseProgram(0); }